Browse Source

2024-08-28

检验明细导出
java8
fengyuan_yang 2 years ago
parent
commit
0243c87423
  1. 9
      src/main/java/com/xujie/sys/modules/pms/data/QcReportData.java
  2. 3
      src/main/java/com/xujie/sys/modules/pms/mapper/QcReportMapper.java
  3. 42
      src/main/java/com/xujie/sys/modules/pms/service/Impl/QcReportServiceImpl.java
  4. 250
      src/main/java/com/xujie/sys/modules/report/data/QcReportOtherData.java
  5. 8
      src/main/resources/mapper/pms/QcReportMapper.xml

9
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;
}

3
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<QcDetailReport> getIPQCDetailReportCount(Page<QcDetailReport> qcDetailReportPage, @Param("query") QcDetailReport data);
List<QcDetailReport> downloadIPQCDetailRecord(QcDetailReport data);
List<QcReportOtherData> downloadIPQCDetailRecord(QcDetailReport data);
IPage<QcDetailReport> getFAIDetailReport(Page<QcDetailReport> qcDetailReportPage, @Param("query") QcDetailReport data);

42
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<QcDetailReport> list = this.qcReportMapper.getIQCDetailReportCount(new Page<QcDetailReport>(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<QcDetailReport> list = this.qcReportMapper.getIPQCDetailReportCount(new Page<QcDetailReport>(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<QcDetailReport> getAllData(int writeCount, int pageSize, QcDetailReport data, Map<String ,String> result) {
private List<QcDetailReport> getIQCData(int writeCount, int pageSize, QcDetailReport data, Map<String ,String> result) {
List<QcDetailReport> allData = new ArrayList<>();
for (int i = 0; i < writeCount; i++) {
PageHelper.startPage(i + 1, pageSize);
List<QcDetailReport> 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<QcDetailReport> 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<QcReportOtherData> getIPQCData(int writeCount, int pageSize, QcDetailReport data, Map<String ,String> result) {
List<QcReportOtherData> allData = new ArrayList<>();
for (int i = 0; i < writeCount; i++) {
PageHelper.startPage(i + 1, pageSize);
List<QcReportOtherData> 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<String, String> getOperatorNameMap() {
String type1 = "coordination";
String type2 = "responsible";

250
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<String> 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;
}

8
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
<where>
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
<where>
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 @@
</where>
</select>
<!-- 导出IPQC明细 -->
<select id="downloadIPQCDetailRecord" parameterType="QcDetailReport" resultType="QcDetailReport">
<select id="downloadIPQCDetailRecord" parameterType="QcDetailReport" resultType="QcReportOtherData">
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
<where>
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}))

Loading…
Cancel
Save