From 7711e570f5b34316ffc19648cce2a35cfe01d1b1 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 23 Sep 2026 17:46:53 +0800 Subject: [PATCH] =?UTF-8?q?2026-09-23=20=E4=BC=98=E5=8C=96iqc=E7=9A=84?= =?UTF-8?q?=E3=80=90=E4=BB=BB=E5=8A=A1=E9=87=8D=E8=BD=BD=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/heai/modules/pms/mapper/QcMapper.java | 2 + .../pms/service/Impl/QcServiceImpl.java | 203 ++++++------------ src/main/resources/mapper/pms/QcMapper.xml | 30 +++ 3 files changed, 98 insertions(+), 137 deletions(-) diff --git a/src/main/java/com/heai/modules/pms/mapper/QcMapper.java b/src/main/java/com/heai/modules/pms/mapper/QcMapper.java index d6525be..8a84ca8 100644 --- a/src/main/java/com/heai/modules/pms/mapper/QcMapper.java +++ b/src/main/java/com/heai/modules/pms/mapper/QcMapper.java @@ -283,6 +283,8 @@ public interface QcMapper { List selectPartAttributeByPartNo(@Param("site") String site, @Param("buNo") String buNo, @Param("partNo") String partNo, @Param("attributeType") String attributeType, @Param("inspectionTypeNo") String inspectionTypeNo, @Param("supplierNo") String supplierNo, @Param("ipqcInspectionMethod") String ipqcInspectionMethod); + List selectPartAttributeByEmptySupplier(@Param("site") String site, @Param("buNo") String buNo, @Param("partNo") String partNo, @Param("attributeType") String attributeType, @Param("inspectionTypeNo") String inspectionTypeNo, @Param("ipqcInspectionMethod") String ipqcInspectionMethod); + void saveFAIRecord(QcFAIRecordData data); IPage qcFAIInspectionSearch(Page qcFAIRecordDataPage,@Param("query") QcFAIRecordData data); diff --git a/src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java b/src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java index 866d5b5..6105557 100644 --- a/src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java +++ b/src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java @@ -3869,156 +3869,85 @@ public class QcServiceImpl implements QcService { } /** - * 任务重载 + * 按物料属性设置重新生成 IQC 任务单和检验明细 */ @Override @Transactional public void iqcRecordOverLoad(QcFAIRecordData data) { - // 新建对象存放主记录 - QcFAIRecordData qcFAIRecordData = new QcFAIRecordData(); for (QcFAIRecordData recordData : data.getSubmitList()) { - // 删除明细记录信息 qcMapper.deleteIQCDetailedRecord(recordData); - // 删除子明细记录信息 qcMapper.deleteIQCSubDetailedRecord(recordData); - // 删除数据采集的数据 - //qcMapper.deleteEquipmentDataAcquisition(recordData); - // 删除文件 qcMapper.deleteInspectionFiles(recordData); - // 拿到供应商编码 - String supplierNo = ""; - if (StringUtils.isNotBlank(recordData.getSupplierNo())) { - supplierNo = recordData.getSupplierNo(); + if (recordData.getRollCount() == null) { + recordData.setRollCount(recordData.getRollQty() == null ? BigDecimal.ZERO : recordData.getRollQty()); } - // 主记录信息赋值 - qcFAIRecordData.setSite(recordData.getSite()); - qcFAIRecordData.setBuNo(recordData.getBuNo()); - qcFAIRecordData.setInspectionNo(recordData.getInspectionNo()); // 检验单号 - qcFAIRecordData.setInspectionTypeNo(recordData.getInspectionTypeNo()); // 检验类型编码 - qcFAIRecordData.setPartNo(recordData.getPartNo()); - qcFAIRecordData.setPartDesc(recordData.getPartDesc()); - qcFAIRecordData.setRollQty(recordData.getRollQty()); - qcFAIRecordData.setSupplierNo(supplierNo); - qcFAIRecordData.setActionDate(null); - // 明细记录信息赋值 - String partNo = recordData.getPartNo(); - String attributeType1 = "A"; + String supplierNo = StringUtils.defaultString(recordData.getSupplierNo(), ""); String inspectionMethod = resolveIqcInspectionMethod(recordData); - // 优先按partNo走模板匹配(与 selectTemplateByPartNo 逻辑保持一致) - recordData.setInspectionTypeNo(qcFAIRecordData.getInspectionTypeNo()); - List partAttribute = null; - if (StringUtils.isBlank(inspectionMethod)) { - partAttribute = qcMapper.selectTemplateByPartNoForOverLoad(recordData); - } - // 兼容老逻辑:未匹配到时回退到属性模板;有检验方式时直接按检验方式匹配 - if (partAttribute == null || partAttribute.isEmpty()) { - partAttribute = qcMapper.selectPartAttributeByPartNo(recordData.getSite(), recordData.getBuNo(), partNo, attributeType1, qcFAIRecordData.getInspectionTypeNo(), supplierNo, inspectionMethod); - } - if (partAttribute != null && !partAttribute.isEmpty()) { - // 检验周期 - if (partAttribute.get(0).getInspectionCycle() != null) { - qcFAIRecordData.setInspectionCycle(partAttribute.get(0).getInspectionCycle()); - } - // 获取抽样数量 - // 如果该检验模板有维护抽样方案 - if (StringUtils.isNotBlank(partAttribute.get(0).getSamplingProgrammeNo())) { - QcSamplingInspectionProgrammeData samplingInspectionProgrammeData = new QcSamplingInspectionProgrammeData(); - samplingInspectionProgrammeData.setSite(partAttribute.get(0).getSite()); - samplingInspectionProgrammeData.setBuNo(partAttribute.get(0).getBuNo()); - samplingInspectionProgrammeData.setSamplingProgrammeNo(partAttribute.get(0).getSamplingProgrammeNo()); - // 获取抽样方案维护的矩阵详情 - List dataList = qcMapper.searchSamplingProgrammeDetails(samplingInspectionProgrammeData); - // 根据抽样方案确定抽样数 - for (QcSamplingInspectionProgrammeData programmeData : dataList) { - if (programmeData.getSamplingLevelNo().equals(partAttribute.get(0).getSamplingLevelNo()) && (recordData.getRollCount().compareTo(programmeData.getMinQty()) > 0 || recordData.getRollCount().compareTo(programmeData.getMinQty()) == 0) && (recordData.getRollCount().compareTo(programmeData.getMaxQty()) < 0 || recordData.getRollCount().compareTo(programmeData.getMaxQty()) == 0) ){ - qcFAIRecordData.setSamplingQty(programmeData.getSamplingQty()); - } - } - } else if (partAttribute.get(0).getDefaultSamplingQuantity() != null) { - // 没有维护抽样方案,再根据默认抽样数来确定 - qcFAIRecordData.setSamplingQty(partAttribute.get(0).getDefaultSamplingQuantity()); - } else if (partAttribute.get(0).getDefaultSamplingProportion() != null) { - // 也没有维护默认抽样数,最后根据默认抽样比例来确定 - BigDecimal d = partAttribute.get(0).getDefaultSamplingProportion().multiply(recordData.getRollCount()).divide(new BigDecimal(100), 3, BigDecimal.ROUND_HALF_UP); - qcFAIRecordData.setSamplingQty(d); - } - - // 按模板批量写入明细(默认值优先取 qc_part_attr_detailed) - for (QcFAIRecordData template : partAttribute) { - QcFAIRecordData detailData = new QcFAIRecordData(); - detailData.setSite(recordData.getSite()); - detailData.setBuNo(recordData.getBuNo()); - detailData.setInspectionNo(qcFAIRecordData.getInspectionNo()); - detailData.setTemplateId(template.getTemplateId()); - detailData.setSamplingLevelNo(template.getSamplingLevelNo()); - detailData.setSamplingLevelDesc(template.getSamplingLevelDesc()); - detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo()); - detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc()); - detailData.setAql(template.getAql()); - detailData.setAc(template.getAc()); - detailData.setRe(template.getRe()); - detailData.setSamplingQty(qcFAIRecordData.getSamplingQty()); - detailData.setPartNo(partNo); - qcMapper.saveIQCDetailedRecordByTemplate(detailData); - } - } else { - // 获取物料的类别编码 - String familyId = qcMapper.selectFamilyIdByPartNo(partNo,recordData.getSite()); - String attributeType2 = "B"; - // 获取该类别属性下维护的IQC检验模板 - List familyAttribute = qcMapper.selectPartAttributeByPartNo(recordData.getSite(), recordData.getBuNo(), familyId, attributeType2, qcFAIRecordData.getInspectionTypeNo(), supplierNo, inspectionMethod); - if (!familyAttribute.isEmpty()) { - // 获取检验周期 - if (familyAttribute.get(0).getInspectionCycle() != null) { - qcFAIRecordData.setInspectionCycle(familyAttribute.get(0).getInspectionCycle()); - } - // 获取抽样数量 - // 如果该检验模板有维护抽样方案 - if (StringUtils.isNotBlank(familyAttribute.get(0).getSamplingProgrammeNo())) { - QcSamplingInspectionProgrammeData samplingInspectionProgrammeData = new QcSamplingInspectionProgrammeData(); - samplingInspectionProgrammeData.setSite(familyAttribute.get(0).getSite()); - samplingInspectionProgrammeData.setBuNo(familyAttribute.get(0).getBuNo()); - samplingInspectionProgrammeData.setSamplingProgrammeNo(familyAttribute.get(0).getSamplingProgrammeNo()); - // 获取抽样方案维护的矩阵详情 - List dataList = qcMapper.searchSamplingProgrammeDetails(samplingInspectionProgrammeData); - // 根据抽样方案确定抽样数 - for (QcSamplingInspectionProgrammeData programmeData : dataList) { - if (programmeData.getSamplingLevelNo().equals(familyAttribute.get(0).getSamplingLevelNo()) && (recordData.getRollCount().compareTo(programmeData.getMinQty()) > 0 || recordData.getRollCount().compareTo(programmeData.getMinQty()) == 0) && (recordData.getRollCount().compareTo(programmeData.getMaxQty()) < 0 || recordData.getRollCount().compareTo(programmeData.getMaxQty()) == 0) ){ - qcFAIRecordData.setSamplingQty(programmeData.getSamplingQty()); - } - } - } else if (familyAttribute.get(0).getDefaultSamplingQuantity() != null) { - // 没有维护抽样方案,再根据默认抽样数来确定 - qcFAIRecordData.setSamplingQty(familyAttribute.get(0).getDefaultSamplingQuantity()); - } else if (familyAttribute.get(0).getDefaultSamplingProportion() != null) { - // 也没有维护默认抽样数,最后根据默认抽样比例来确定 - qcFAIRecordData.setSamplingQty(familyAttribute.get(0).getDefaultSamplingProportion().multiply(qcFAIRecordData.getRollCount()).divide(new BigDecimal(100),3,BigDecimal.ROUND_HALF_UP)); - } - - // 按模板批量写入明细(默认值优先取 qc_part_attr_detailed) - for (QcFAIRecordData template : familyAttribute) { - QcFAIRecordData detailData = new QcFAIRecordData(); - detailData.setSite(recordData.getSite()); - detailData.setBuNo(recordData.getBuNo()); - detailData.setInspectionNo(qcFAIRecordData.getInspectionNo()); - detailData.setTemplateId(template.getTemplateId()); - detailData.setSamplingLevelNo(template.getSamplingLevelNo()); - detailData.setSamplingLevelDesc(template.getSamplingLevelDesc()); - detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo()); - detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc()); - detailData.setAql(template.getAql()); - detailData.setAc(template.getAc()); - detailData.setRe(template.getRe()); - detailData.setSamplingQty(qcFAIRecordData.getSamplingQty()); - detailData.setPartNo(partNo); - qcMapper.saveIQCDetailedRecordByTemplate(detailData); - } - } + String inspectionTypeNo = StringUtils.defaultIfBlank(recordData.getInspectionTypeNo(), "105"); + QcFAIRecordData masterData = new QcFAIRecordData(); + masterData.setSite(recordData.getSite()); + masterData.setBuNo(recordData.getBuNo()); + masterData.setInspectionNo(recordData.getInspectionNo()); + masterData.setInspectionTypeNo(inspectionTypeNo); + masterData.setPartNo(recordData.getPartNo()); + masterData.setPartDesc(recordData.getPartDesc()); + masterData.setRollQty(recordData.getRollQty()); + masterData.setSupplierNo(supplierNo); + masterData.setActionDate(null); + + List templates = selectIqcTemplatesForReload(recordData, inspectionTypeNo, supplierNo, inspectionMethod); + if (templates == null || templates.isEmpty()) { + String methodTip = StringUtils.isBlank(inspectionMethod) ? "" : "、检验方式【" + inspectionMethod + "】"; + throw new RuntimeException("检验单【" + recordData.getInspectionNo() + "】未找到物料【" + recordData.getPartNo() + "】" + methodTip + "的IQC检验模板,请先在物料属性设置中维护"); + } + applySamplingFromTemplate(masterData, recordData, templates.get(0)); + for (QcFAIRecordData template : templates) { + QcFAIRecordData sampling = new QcFAIRecordData(); + applySamplingFromTemplate(sampling, recordData, template); + QcFAIRecordData detailData = new QcFAIRecordData(); + detailData.setSite(recordData.getSite()); + detailData.setBuNo(recordData.getBuNo()); + detailData.setInspectionNo(masterData.getInspectionNo()); + detailData.setTemplateId(template.getTemplateId()); + detailData.setSamplingLevelNo(template.getSamplingLevelNo()); + detailData.setSamplingLevelDesc(template.getSamplingLevelDesc()); + detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo()); + detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc()); + detailData.setAql(template.getAql()); + detailData.setAc(template.getAc()); + detailData.setRe(template.getRe()); + detailData.setSamplingQty(sampling.getSamplingQty() != null ? sampling.getSamplingQty() : masterData.getSamplingQty()); + detailData.setPartNo(recordData.getPartNo()); + qcMapper.saveIQCDetailedRecordByTemplate(detailData); + } + qcMapper.updateIQCRecord(masterData); + } + } + + /** + * 按物料属性检验模板清单匹配。有供应商时优先供应商模板,没有再取未填供应商的模板。 + */ + private List selectIqcTemplatesForReload(QcFAIRecordData recordData, String inspectionTypeNo, String supplierNo, String inspectionMethod) { + List templates = selectIqcAttributeTemplates(recordData.getSite(), recordData.getBuNo(), recordData.getPartNo(), "A", inspectionTypeNo, supplierNo, inspectionMethod); + if (templates == null || templates.isEmpty()) { + String familyId = qcMapper.selectFamilyIdByPartNo(recordData.getPartNo(), recordData.getSite()); + if (StringUtils.isNotBlank(familyId)) { + templates = selectIqcAttributeTemplates(recordData.getSite(), recordData.getBuNo(), familyId, "B", inspectionTypeNo, supplierNo, inspectionMethod); } - // 更新IQC主记录信息 - qcMapper.updateIQCRecord(qcFAIRecordData); } + return templates; + } + + private List selectIqcAttributeTemplates(String site, String buNo, String attributeNo, String attributeType, String inspectionTypeNo, String supplierNo, String inspectionMethod) { + List templates = null; + if (StringUtils.isNotBlank(supplierNo)) { + templates = qcMapper.selectPartAttributeByPartNo(site, buNo, attributeNo, attributeType, inspectionTypeNo, supplierNo, inspectionMethod); + } + if (templates == null || templates.isEmpty()) { + templates = qcMapper.selectPartAttributeByEmptySupplier(site, buNo, attributeNo, attributeType, inspectionTypeNo, inspectionMethod); + } + return templates; } @Override diff --git a/src/main/resources/mapper/pms/QcMapper.xml b/src/main/resources/mapper/pms/QcMapper.xml index 750881f..bcf7c17 100644 --- a/src/main/resources/mapper/pms/QcMapper.xml +++ b/src/main/resources/mapper/pms/QcMapper.xml @@ -1892,6 +1892,36 @@ + +