| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| | |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcIndicatorItemTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcProductReportWordBuilder; |
| | | import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcReportService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcLineService; |
| | | import cn.iocoder.yudao.module.mes.service.qc.iqc.MesQcIqcLineService; |
| | |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | return success(reportService.getQcReportData(qcId, qcType, resultId)); |
| | | } |
| | | |
| | | @GetMapping("/export-product-word") |
| | | @Operation(summary = "导出产品检验单 Word(纸质检验单版式:无技术指标列,判定结论/质检专用章留空手填,打印用 Word 打开)") |
| | | @Parameters({ |
| | | @Parameter(name = "qcId", description = "质检单ID", required = true, example = "1"), |
| | | @Parameter(name = "qcType", description = "质检类型", required = true, example = "1"), |
| | | @Parameter(name = "resultId", description = "检验结果(样品)编号,可不传;多样品时用于选择", example = "1") |
| | | }) |
| | | @PreAuthorize("@ss.hasAnyPermissions('mes:qc-iqc:query', 'mes:qc-ipqc:query', 'mes:qc-oqc:query', 'mes:qc-rqc:query')") |
| | | public void exportProductWord( |
| | | @RequestParam("qcId") Long qcId, |
| | | @RequestParam("qcType") Integer qcType, |
| | | @RequestParam(value = "resultId", required = false) Long resultId, |
| | | HttpServletResponse response) throws IOException { |
| | | MesQcQcReportRespVO report = reportService.getQcReportData(qcId, qcType, resultId); |
| | | byte[] docx = MesQcProductReportWordBuilder.build(report); |
| | | String productName = StrUtil.isNotBlank(report.getItemName()) ? report.getItemName() : "产品"; |
| | | String filename = productName + "产品质量检验单" |
| | | + (StrUtil.isNotBlank(report.getDocCode()) ? "-" + report.getDocCode() : "") + ".docx"; |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); |
| | | response.addHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename)); |
| | | response.getOutputStream().write(docx); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | /** |