From daa057cd608dce2c26217b210a5751a501a5d674 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 6 Jan 2026 14:27:05 +0800 Subject: [PATCH] =?UTF-8?q?2026-01-06=20=E7=89=A9=E6=96=99=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E7=AE=A1=E7=90=86->=E8=B4=A8=E9=87=8F=E6=A3=80?= =?UTF-8?q?=E9=AA=8C=E6=A8=A1=E6=9D=BF=E6=96=B0=E5=A2=9E=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pms/data/QcTemplateData.java | 10 +++ .../service/Impl/QcBaseInfoServiceImpl.java | 67 ++++++++++++++++--- .../resources/mapper/pms/QcBaseInfoMapper.xml | 24 ++++--- 3 files changed, 80 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gaotao/modules/pms/data/QcTemplateData.java b/src/main/java/com/gaotao/modules/pms/data/QcTemplateData.java index 97226bd..f8344ca 100644 --- a/src/main/java/com/gaotao/modules/pms/data/QcTemplateData.java +++ b/src/main/java/com/gaotao/modules/pms/data/QcTemplateData.java @@ -97,6 +97,8 @@ public class QcTemplateData extends QueryPage { private String manufacturerName; // 机台编码 private String resourceID; + // 机台编码集合(用于多选) + private List resourceIDList; // 客户编码 private String customerID; // 客户名称 @@ -251,6 +253,14 @@ public class QcTemplateData extends QueryPage { this.resourceID = resourceID; } + public List getResourceIDList() { + return resourceIDList; + } + + public void setResourceIDList(List resourceIDList) { + this.resourceIDList = resourceIDList; + } + public String getManufacturerName() { return manufacturerName; } diff --git a/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java b/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java index c539f42..ca4f9b0 100644 --- a/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java +++ b/src/main/java/com/gaotao/modules/pms/service/Impl/QcBaseInfoServiceImpl.java @@ -1034,22 +1034,58 @@ public class QcBaseInfoServiceImpl implements QcBaseInfoService { partData.setAc(templateData2.getAc()); partData.setRe(templateData2.getRe()); // 物料属性模板 - // IPQC检验类型 + // IPQC/FQC检验类型:支持多工序多机台笛卡尔积 if ("101".equals(partData.getInspectionTypeNo()) || "102".equals(partData.getInspectionTypeNo()) || "103".equals(partData.getInspectionTypeNo()) || "104".equals(partData.getInspectionTypeNo()) || "106".equals(partData.getInspectionTypeNo()) || "107".equals(partData.getInspectionTypeNo())) { - if (StringUtils.isNotBlank(data.getOperation()) && StringUtils.isNotBlank(data.getResourceID())) { - partData.setOperation(data.getOperation()); - partData.setResourceID(data.getResourceID()); - // 校验重复 - List paList = qcBaseInfoMapper.getPA(partData); - if (!paList.isEmpty()) { - throw new RuntimeException("待新增的工序和机台已存在!"); + + // 获取工序列表和机台列表 + List operationList = data.getOperationList(); + List resourceList = data.getResourceIDList(); + + // 判断是否有工序和机台 + boolean hasOperations = operationList != null && !operationList.isEmpty(); + boolean hasResources = resourceList != null && !resourceList.isEmpty(); + + if (hasOperations && hasResources) { + // 生成工序和机台的笛卡尔积 + for (String operation : operationList) { + for (String resourceId : resourceList) { + partData.setOperation(operation); + partData.setResourceID(resourceId); + // 校验重复 + List paList = qcBaseInfoMapper.getPA(partData); + if (!paList.isEmpty()) { + throw new RuntimeException("工序【" + operation + "】和机台【" + resourceId + "】的组合已存在!"); + } + // 新增 + qcBaseInfoMapper.savePartAttributeDetails(partData); + } } - // 新增 + } else if (hasOperations && !hasResources) { + // 只有工序,没有机台:每个工序单独添加 + for (String operation : operationList) { + partData.setOperation(operation); + partData.setResourceID(null); + // 校验重复 + List paList = qcBaseInfoMapper.getPA(partData); + if (!paList.isEmpty()) { + throw new RuntimeException("工序【" + operation + "】已存在!"); + } + // 新增 + qcBaseInfoMapper.savePartAttributeDetails(partData); + } + } else if (!hasOperations && hasResources) { + // 有机台但没工序,不允许:必须选择工序才能选择机台 + throw new RuntimeException("如果想选择机台,必须要先选择工序!"); + } else { + // 既没有工序也没有机台:直接添加模板(不填工序和机台) + partData.setOperation(null); + partData.setResourceID(null); qcBaseInfoMapper.savePartAttributeDetails(partData); } } else if ("105".equals(partData.getInspectionTypeNo())) { // IQC检验类型 - if (!data.getManufacturerList().isEmpty()) { + // IQC:供应商不必填,如果没选供应商则直接添加 + if (data.getManufacturerList() != null && !data.getManufacturerList().isEmpty()) { // 循环选中的供应商 for (String manufacturer : data.getManufacturerList()) { partData.setManufacturerID(manufacturer); @@ -1060,9 +1096,14 @@ public class QcBaseInfoServiceImpl implements QcBaseInfoService { // 新增 qcBaseInfoMapper.savePartAttributeDetails(partData); } + } else { + // 没有选择供应商,直接添加 + partData.setManufacturerID(null); + qcBaseInfoMapper.savePartAttributeDetails(partData); } } else if ("109".equals(partData.getInspectionTypeNo())) { // OQC检验类型 - if (!data.getCustomerList().isEmpty()) { + // OQC:客户不必填,如果没选客户则直接添加 + if (data.getCustomerList() != null && !data.getCustomerList().isEmpty()) { // 循环选中的客户 for (String customer : data.getCustomerList()) { partData.setCustomerID(customer); @@ -1073,6 +1114,10 @@ public class QcBaseInfoServiceImpl implements QcBaseInfoService { // 新增 qcBaseInfoMapper.savePartAttributeDetails(partData); } + } else { + // 没有选择客户,直接添加 + partData.setCustomerID(null); + qcBaseInfoMapper.savePartAttributeDetails(partData); } } else if ("108".equals(partData.getInspectionTypeNo())) { qcBaseInfoMapper.savePartAttributeDetails(partData); diff --git a/src/main/resources/mapper/pms/QcBaseInfoMapper.xml b/src/main/resources/mapper/pms/QcBaseInfoMapper.xml index 7695827..c5e3ed9 100644 --- a/src/main/resources/mapper/pms/QcBaseInfoMapper.xml +++ b/src/main/resources/mapper/pms/QcBaseInfoMapper.xml @@ -288,14 +288,16 @@ qit.inspection_type_name, qat.operation, qat.manufacturer_id, - dbo.qc_get_supplier_name(qt.site, qat.manufacturer_id) as manufacturerName, + vs.supplierName as manufacturerName, qat.resource_id, qat.customer_id as customerID, - dbo.qc_get_customer_name(qt.site, qat.customer_id) as customerName + cu.CustomerName as customerName FROM qc_attribute_template as qat LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site - WHERE qt.site = #{site} AND qat.attribute_no = #{attributeNo} and qt.bu_no = #{buNo} + left join view_Supplier as vs on qat.site = vs.site and qat.manufacturer_id = vs.SupplierID + left join Customer as cu on qat.site = cu.site and qat.customer_id = cu.CustomerID + WHERE qat.site = #{site} AND qat.attribute_no = #{attributeNo} and qat.bu_no = #{buNo} @@ -1297,16 +1299,18 @@ qat.inspection_cycle, qat.operation, qat.manufacturer_id, - dbo.qc_get_supplier_name(qat.site, qat.manufacturer_id) as manufacturerName, + vs.supplierName as manufacturerName, qat.resource_id, qat.customer_id as customerID, - dbo.qc_get_customer_name(qt.site, qat.customer_id) as customerName + cu.CustomerName as customerName FROM qc_attribute_template as qat - LEFT JOIN qc_part_attribute as qpa ON qpa.attribute_no = qat.attribute_no and qat.site = qpa.site and qat.bu_no = qpa.bu_no - LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no - LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no - LEFT JOIN qc_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site - LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no + LEFT JOIN qc_part_attribute as qpa ON qpa.attribute_no = qat.attribute_no and qat.site = qpa.site and qat.bu_no = qpa.bu_no + LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no + LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no + LEFT JOIN qc_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site + LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no + left join view_Supplier as vs on qat.site = vs.site and qat.manufacturer_id = vs.SupplierID + left join Customer as cu on qat.site = cu.site and qat.customer_id = cu.CustomerID WHERE qat.site = #{site} and qpa.attribute_type = #{attributeType} and qpa.attribute_no = #{attributeNo} and qat.bu_no = #{buNo}