From b2f839b83897b043a3be451fc0d46d2cc776f2e3 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 25 Jun 2024 15:18:13 +0800 Subject: [PATCH] =?UTF-8?q?2024-06-25=20=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pms/data/QcInspectionStandardData.java | 1 + .../pms/service/Impl/QcServiceImpl.java | 113 ++++++++++-------- src/main/resources/mapper/pms/QcMapper.xml | 7 +- 3 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/xujie/sys/modules/pms/data/QcInspectionStandardData.java b/src/main/java/com/xujie/sys/modules/pms/data/QcInspectionStandardData.java index 3e9dd871..22565107 100644 --- a/src/main/java/com/xujie/sys/modules/pms/data/QcInspectionStandardData.java +++ b/src/main/java/com/xujie/sys/modules/pms/data/QcInspectionStandardData.java @@ -17,5 +17,6 @@ public class QcInspectionStandardData { private BigDecimal minValue; private String condition; private String collectionSource; + private Integer seqNo; private List standardList; } diff --git a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcServiceImpl.java b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcServiceImpl.java index 16f27694..606b29b7 100644 --- a/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/pms/service/Impl/QcServiceImpl.java @@ -4864,6 +4864,8 @@ public class QcServiceImpl implements QcService { } // 判断是否合格 + // 将实测值根据num分组 + //Map> numType = subDetailList.stream().collect(Collectors.groupingBy(SubDetailValues::getNum)); // 获取检验单使用的模板中的项目 List templateDetails = qcMapper.getInspectionTemplateDetail(data); // 记录不符合上下限的实测值数量 @@ -4872,59 +4874,72 @@ public class QcServiceImpl implements QcService { // 判断有没有维护多维度检验标准 List standardList = qcMapper.getInspectionStandards(templateDetail); if (!standardList.isEmpty()) { // 多标准 - // 将检验标准按type分组,便于查找 - Map> standardsByType = standardList.stream() - .collect(Collectors.groupingBy(QcInspectionStandardData::getCollectionSource)); + // map中是否已存在该key if (!countMap.containsKey(templateDetail.getItemNo())) { // 没有则新建并赋初始值 countMap.put(templateDetail.getItemNo(), 0); } - // 该项目的实测值 - List collect1 = subDetailList.stream().filter(a -> a.getItemNo().equals(templateDetail.getItemNo())).collect(Collectors.toList()); - // 遍历每个实测值 - for (SubDetailValues subDetailValues : collect1) { - // 如果实际填入值为数值 - if (isNumberString(subDetailValues.getSubDetailValue())) { - // 实测值 - BigDecimal value = new BigDecimal(subDetailValues.getSubDetailValue()); - String valueType = subDetailValues.getCollectionSource(); - List matchingStandards = standardsByType.get(valueType); - // 如果没有找到对应类型的检验标准,则跳过此实测值 - if (matchingStandards == null) { - continue; - } - boolean compliant = true; // 假设当前值初始时是符合标准的 - // 遍历当前type对应的检验标准集合 - for (QcInspectionStandardData standard : matchingStandards) { - boolean isOutOfRange = false; // 用于标记实测值是否超出范围 - // 检查是否超出上限 - if (standard.getMaxValue() != null && value.compareTo(standard.getMaxValue()) > 0) { - isOutOfRange = true; - } - // 检查是否低于下限 - else if (standard.getMinValue() != null && value.compareTo(standard.getMinValue()) < 0) { - isOutOfRange = true; - } - // 如果实测值超出范围 - if (isOutOfRange) { - // 根据条件逻辑更新合规状态 - compliant &= standard.getCondition().equals("||"); - if (standard.getCondition().equals("&&")) { - compliant = false; - break; // 不再检查后续标准 - } - } - } - // 如果当前值不符合任何一条标准,则计数加一 - if (!compliant) { - Integer n = countMap.get(subDetailValues.getItemNo()); - countMap.put(subDetailValues.getItemNo(), ++n); - } - } else { // 实际填入值不是数值,判断为不合格 - Integer n = countMap.get(subDetailValues.getItemNo()); - countMap.put(subDetailValues.getItemNo(), ++n); - } - } + List params = new ArrayList<>(); + params.add(data.getSite()); + params.add(data.getBuNo()); + params.add(templateDetail.getItemNo()); + params.add(data.getInspectionNo()); + //执行方法 + List> resultList = procedureDao.getProcedureData("getqc_inspection_standards", params); + countMap.put(resultList.get(0).get("itemNo").toString(), Integer.valueOf(resultList.get(0).get("count").toString())); +// // 将检验标准按type分组,便于查找 +// Map> standardsByType = standardList.stream() +// .collect(Collectors.groupingBy(QcInspectionStandardData::getCollectionSource)); +// // map中是否已存在该key +// if (!countMap.containsKey(templateDetail.getItemNo())) { // 没有则新建并赋初始值 +// countMap.put(templateDetail.getItemNo(), 0); +// } +// // 该项目的实测值 +// List collect1 = subDetailList.stream().filter(a -> a.getItemNo().equals(templateDetail.getItemNo())).collect(Collectors.toList()); +// // 遍历每个实测值 +// for (SubDetailValues subDetailValues : collect1) { +// // 如果实际填入值为数值 +// if (isNumberString(subDetailValues.getSubDetailValue())) { +// // 实测值 +// BigDecimal value = new BigDecimal(subDetailValues.getSubDetailValue()); +// String valueType = subDetailValues.getCollectionSource(); +// List matchingStandards = standardsByType.get(valueType); +// // 如果没有找到对应类型的检验标准,则跳过此实测值 +// if (matchingStandards == null) { +// continue; +// } +// boolean compliant = true; // 假设当前值初始时是符合标准的 +// // 遍历当前type对应的检验标准集合 +// for (QcInspectionStandardData standard : matchingStandards) { +// boolean isOutOfRange = false; // 用于标记实测值是否超出范围 +// // 检查是否超出上限 +// if (standard.getMaxValue() != null && value.compareTo(standard.getMaxValue()) > 0) { +// isOutOfRange = true; +// } +// // 检查是否低于下限 +// else if (standard.getMinValue() != null && value.compareTo(standard.getMinValue()) < 0) { +// isOutOfRange = true; +// } +// // 如果实测值超出范围 +// if (isOutOfRange) { +// // 根据条件逻辑更新合规状态 +// compliant &= standard.getCondition().equals("||"); +// if (standard.getCondition().equals("&&")) { +// compliant = false; +// break; // 不再检查后续标准 +// } +// } +// } +// // 如果当前值不符合任何一条标准,则计数加一 +// if (!compliant) { +// Integer n = countMap.get(subDetailValues.getItemNo()); +// countMap.put(subDetailValues.getItemNo(), ++n); +// } +// } else { // 实际填入值不是数值,判断为不合格 +// Integer n = countMap.get(subDetailValues.getItemNo()); +// countMap.put(subDetailValues.getItemNo(), ++n); +// } +// } } else { // 单标准 data.setItemNo(templateDetail.getItemNo()); List allSubDetails = qcMapper.querySubDetails(data); diff --git a/src/main/resources/mapper/pms/QcMapper.xml b/src/main/resources/mapper/pms/QcMapper.xml index 2e47086c..ec0f8da4 100644 --- a/src/main/resources/mapper/pms/QcMapper.xml +++ b/src/main/resources/mapper/pms/QcMapper.xml @@ -3714,7 +3714,8 @@ min_value, max_value, condition, - collection_source + collection_source, + seq_no from qc_inspection_standards where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo} @@ -3726,10 +3727,10 @@ INSERT INTO qc_inspection_standards - (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source) + (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no) VALUES - (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}) + (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})