From 0243c8742350c4d422ba352c5f1c08cfb05f93b9 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 28 Aug 2024 10:31:40 +0800 Subject: [PATCH] =?UTF-8?q?2024-08-28=20=E6=A3=80=E9=AA=8C=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/modules/pms/data/QcReportData.java | 9 + .../modules/pms/mapper/QcReportMapper.java | 3 +- .../pms/service/Impl/QcReportServiceImpl.java | 42 +-- .../report/data/QcReportOtherData.java | 250 ++++++++++++++++++ .../resources/mapper/pms/QcReportMapper.xml | 8 +- 5 files changed, 295 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/xujie/sys/modules/report/data/QcReportOtherData.java diff --git a/src/main/java/com/xujie/sys/modules/pms/data/QcReportData.java b/src/main/java/com/xujie/sys/modules/pms/data/QcReportData.java index b36ae65c..66c714c7 100644 --- a/src/main/java/com/xujie/sys/modules/pms/data/QcReportData.java +++ b/src/main/java/com/xujie/sys/modules/pms/data/QcReportData.java @@ -92,6 +92,9 @@ public class QcReportData extends QueryPage { @ExcelProperty(index = 12, value = "计量单位") private String umId; + @ExcelIgnore + private String umName; + @ExcelProperty(index = 21, value = "质检备注") private String inspectionRemark; @@ -264,4 +267,10 @@ public class QcReportData extends QueryPage { @ExcelProperty(index = 38, value = "项目检验结论") private String itemResultDesc; + + /** + * 特殊要求 + */ + @ExcelIgnore + private String specialRequirements; } diff --git a/src/main/java/com/xujie/sys/modules/pms/mapper/QcReportMapper.java b/src/main/java/com/xujie/sys/modules/pms/mapper/QcReportMapper.java index b512ed7a..82192fd5 100644 --- a/src/main/java/com/xujie/sys/modules/pms/mapper/QcReportMapper.java +++ b/src/main/java/com/xujie/sys/modules/pms/mapper/QcReportMapper.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xujie.sys.modules.pms.data.QcDetailReport; import com.xujie.sys.modules.pms.data.QcReportData; import com.xujie.sys.modules.report.data.OperatorData; +import com.xujie.sys.modules.report.data.QcReportOtherData; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -32,7 +33,7 @@ public interface QcReportMapper { IPage getIPQCDetailReportCount(Page qcDetailReportPage, @Param("query") QcDetailReport data); - List downloadIPQCDetailRecord(QcDetailReport data); + List downloadIPQCDetailRecord(QcDetailReport data); IPage getFAIDetailReport(Page qcDetailReportPage, @Param("query") QcDetailReport data); diff --git a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java index 8c13125a..947eeda7 100644 --- a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java @@ -12,6 +12,7 @@ import com.xujie.sys.modules.pms.mapper.QcReportMapper; import com.xujie.sys.modules.pms.service.QcReportService; import com.xujie.sys.modules.report.constant.ExcelConstant; import com.xujie.sys.modules.report.data.OperatorData; +import com.xujie.sys.modules.report.data.QcReportOtherData; import com.xujie.sys.modules.report.listener.QcDetailReportListener; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; @@ -118,19 +119,19 @@ public class QcReportServiceImpl implements QcReportService { if ("iqc".equals(data.getDownloadType())) { IPage list = this.qcReportMapper.getIQCDetailReportCount(new Page(data.getPage(), data.getLimit()), data); totalRowCount = (int)list.getTotal(); + int pageSize = ExcelConstant.PER_WRITE_ROW_COUNT; + int writeCount = totalRowCount % pageSize == 0 ? (totalRowCount / pageSize) : (totalRowCount / pageSize + 1); + // 创建 ExcelWriter + EasyExcel.write(out, QcDetailReport.class).sheet(String.valueOf(sheet)).doWrite(getIQCData(writeCount, pageSize, data, result)); // 批量写入数据 } else if ("ipqc".equals(data.getDownloadType())) { IPage list = this.qcReportMapper.getIPQCDetailReportCount(new Page(data.getPage(), data.getLimit()), data); totalRowCount = (int)list.getTotal(); + int pageSize = ExcelConstant.PER_WRITE_ROW_COUNT; + int writeCount = totalRowCount % pageSize == 0 ? (totalRowCount / pageSize) : (totalRowCount / pageSize + 1); + // 创建 ExcelWriter + EasyExcel.write(out, QcReportOtherData.class).sheet(String.valueOf(sheet)).doWrite(getIPQCData(writeCount, pageSize, data, result)); // 批量写入数据 } - int pageSize = ExcelConstant.PER_WRITE_ROW_COUNT; - int writeCount = totalRowCount % pageSize == 0 ? (totalRowCount / pageSize) : (totalRowCount / pageSize + 1); - - // 创建 ExcelWriter - EasyExcel.write(out, QcDetailReport.class) - .sheet(String.valueOf(sheet)) - .doWrite(getAllData(writeCount, pageSize, data, result)); // 批量写入数据 - // 下载EXCEL response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); @@ -143,16 +144,11 @@ public class QcReportServiceImpl implements QcReportService { } } - private List getAllData(int writeCount, int pageSize, QcDetailReport data, Map result) { + private List getIQCData(int writeCount, int pageSize, QcDetailReport data, Map result) { List allData = new ArrayList<>(); for (int i = 0; i < writeCount; i++) { PageHelper.startPage(i + 1, pageSize); - List detailReports = new ArrayList<>(); - if ("iqc".equals(data.getDownloadType())) { - detailReports = this.qcReportMapper.downloadIQCDetailRecord(data); - } else if ("ipqc".equals(data.getDownloadType())) { - detailReports = this.qcReportMapper.downloadIPQCDetailRecord(data); - } + List detailReports = this.qcReportMapper.downloadIQCDetailRecord(data); if (!detailReports.isEmpty()) { for (QcDetailReport detailReport : detailReports) { detailReport.setOperatorName(result.get(detailReport.getSite() + "_" + detailReport.getBuNo() + "_" + detailReport.getInspectionNo() + "_" + "coordination")); @@ -164,6 +160,22 @@ public class QcReportServiceImpl implements QcReportService { return allData; } + private List getIPQCData(int writeCount, int pageSize, QcDetailReport data, Map result) { + List allData = new ArrayList<>(); + for (int i = 0; i < writeCount; i++) { + PageHelper.startPage(i + 1, pageSize); + List detailReports = this.qcReportMapper.downloadIPQCDetailRecord(data); + if (!detailReports.isEmpty()) { + for (QcReportOtherData detailReport : detailReports) { + detailReport.setOperatorName(result.get(detailReport.getSite() + "_" + detailReport.getBuNo() + "_" + detailReport.getInspectionNo() + "_" + "coordination")); + detailReport.setResponsiblePersonName(result.get(detailReport.getSite() + "_" + detailReport.getBuNo() + "_" + detailReport.getInspectionNo() + "_" + "responsible")); + } + allData.addAll(detailReports); + } + } + return allData; + } + private Map getOperatorNameMap() { String type1 = "coordination"; String type2 = "responsible"; diff --git a/src/main/java/com/xujie/sys/modules/report/data/QcReportOtherData.java b/src/main/java/com/xujie/sys/modules/report/data/QcReportOtherData.java new file mode 100644 index 00000000..ce250411 --- /dev/null +++ b/src/main/java/com/xujie/sys/modules/report/data/QcReportOtherData.java @@ -0,0 +1,250 @@ +package com.xujie.sys.modules.report.data; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xujie.sys.common.utils.QueryPage; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@Data +public class QcReportOtherData extends QueryPage { + + @ExcelProperty(index = 0, value = "状态") + private String state; + + @ExcelProperty(index = 1, value = "BU") + private String buDesc; + + @ExcelProperty(index = 2, value = "检验单号") + private String inspectionNo; + + @ExcelProperty(index = 3, value = "标签条码") + private String rollNo; + + @ExcelProperty(index = 4, value = "检验结论") + private String inspectionResult; + + @ExcelProperty(index = 5, value = "处置措施") + private String disposalMeasures; + + @ExcelProperty(index = 6, value = "检验类型") + private String inspectionTypeName; + + @ExcelProperty(index = 7, value = "送检日期") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date taskDate; + + @ExcelProperty(index = 8, value = "检验周期(h)") + private BigDecimal inspectionCycle; + + @ExcelProperty(index = 9, value = "工单号") + private String orderNo; + + @ExcelProperty(index = 10, value = "派工单号") + private String seqNo; + + @ExcelProperty(index = 11, value = "工序") + private String operationDesc; + + @ExcelProperty(index = 12, value = "机台") + private String resourceDesc; + + @ExcelProperty(index = 13, value = "物料编码") + private String partNo; + + @ExcelProperty(index = 14, value = "物料名称") + private String partDesc; + + @ExcelProperty(index = 15, value = "SKU") + private String sku; + + @ExcelProperty(index = 16, value = "PN") + private String cinvSourceCode; + + @ExcelProperty(index = 17, value = "物料类别") + private String invdefinetype; + + @ExcelProperty(index = 18, value = "计量单位") + private String umName; + + @ExcelProperty(index = 19, value = "送检数量") + private BigDecimal rollCount; + + @ExcelProperty(index = 20, value = "抽样数量") + private BigDecimal samplingQty; + + @ExcelProperty(index = 21, value = "质检备注") + private String inspectionRemark; + + @ExcelProperty(index = 22, value = "处置说明") + private String disposalRemark; + + @ExcelProperty(index = 23, value = "开始检验时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date actionDate; + + @ExcelProperty(index = 24, value = "检验时间") + private String inspectorDate; + + @ExcelProperty(index = 25, value = "质检员") + private String inspectorName; + + @ExcelProperty(index = 26, value = "协同人员") + private String operatorName; + + @ExcelProperty(index = 27, value = "责任人") + private String responsiblePersonName; + + @ExcelProperty(index = 28, value = "特殊要求") + private String specialRequirements; + + @ExcelProperty(index = 29, value = "检验项目编码") + private String itemNo; + + @ExcelProperty(index = 30, value = "检验项目名称") + private String itemDesc; + + @ExcelProperty(index = 31, value = "标准值") + private String defaultValue; + + @ExcelProperty(index = 32, value = "上限值") + private BigDecimal maxValue; + + @ExcelProperty(index = 33, value = "下限值") + private BigDecimal minValue; + + @ExcelProperty(index = 34, value = "抽样数量(项目)") + private BigDecimal itemSamplingQty; + + @ExcelProperty(index = 35, value = "不合格数量(项目)") + private BigDecimal unqualifiedQuantity; + + @ExcelProperty(index = 36, value = "实测值") + private String textValue; + + @ExcelProperty(index = 37, value = "项目检验结论") + private String itemResultDesc; + + @ExcelProperty(index = 38, value = "抽样位置A") + private String samplingLocation; + + @ExcelProperty(index = 39, value = "抽样位置B") + private String samplingLocationB; + + @ExcelProperty(index = 40, value = "实测值A") + private String subDetailValue; + + @ExcelProperty(index = 41, value = "实测值B") + private String subDetailValueB; + + @ExcelProperty(index = 42, value = "实测值C") + private String subDetailValueC; + + @ExcelProperty(index = 43, value = "实测值D") + private String subDetailValueD; + + @ExcelProperty(index = 44, value = "实测值E") + private String subDetailValueE; + + @ExcelIgnore + private String site; + + @ExcelIgnore + private String buNo; + + @ExcelIgnore + private String userName; + + @ExcelIgnore + private List states; + + @ExcelIgnore + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startDate; + + @ExcelIgnore + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endDate; + + @ExcelIgnore + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date startDate2; + + @ExcelIgnore + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date endDate2; + + @ExcelIgnore + private String umId; + + @ExcelIgnore + private BigDecimal rollQty; + + @ExcelIgnore + private String poOrderNo; + + @ExcelIgnore + private String poItemNo; + + @ExcelIgnore + private String inspectionTypeNo; + + @ExcelIgnore + private String resourceId; + + @ExcelIgnore + private String supplierNo; + + @ExcelIgnore + private String supplierDesc; + + @ExcelIgnore + private String inspectorNo; + + @ExcelIgnore + private String createBy; + + @ExcelIgnore + private String orderType; + + @ExcelIgnore + private String actionBy; + + @ExcelIgnore + private String submissionRemark; + + @ExcelIgnore + private String submissionType; + + @ExcelIgnore + private String workCenterNo; + + @ExcelIgnore + private String operator; + + @ExcelIgnore + private String responsiblePerson; + + @ExcelIgnore + private String itemResult; + + @ExcelIgnore + private Integer id; + + @ExcelIgnore + private Integer num; + + @ExcelIgnore + private String downloadType; +} diff --git a/src/main/resources/mapper/pms/QcReportMapper.xml b/src/main/resources/mapper/pms/QcReportMapper.xml index 47201d58..1953cab8 100644 --- a/src/main/resources/mapper/pms/QcReportMapper.xml +++ b/src/main/resources/mapper/pms/QcReportMapper.xml @@ -183,6 +183,7 @@ a.work_center_no, a.roll_no, a.um_id, + um.UMName as umName, a.action_date, a.action_by, b.item_no, @@ -204,6 +205,7 @@ left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no left join sys_user as u on a.inspector_no = u.username left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no + left join UM as um on a.site = um.site and a.um_id = um.UMID a.site in (select site from eam_access_site where username = #{query.userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) @@ -919,6 +921,7 @@ a.work_center_no, a.roll_no, a.um_id, + um.UMName as umName, a.action_date, a.action_by, b.item_no, @@ -946,6 +949,7 @@ left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no left join sys_user as u on a.inspector_no = u.username left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no + left join UM as um on a.site = um.site and a.um_id = um.UMID a.site in (select site from eam_access_site where username = #{query.userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) @@ -1098,7 +1102,7 @@ - SELECT a.inspection_no, a.site, @@ -1130,6 +1134,7 @@ a.work_center_no, a.roll_no, a.um_id, + um.UMName as umName, a.action_date, a.action_by, b.item_no, @@ -1157,6 +1162,7 @@ left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no left join sys_user as u on a.inspector_no = u.username left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no + left join UM as um on a.site = um.site and a.um_id = um.UMID a.site in (select site from eam_access_site where username = #{userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{userName}))