|
|
|
@ -4864,6 +4864,8 @@ public class QcServiceImpl implements QcService { |
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否合格 |
|
|
|
// 将实测值根据num分组 |
|
|
|
//Map<Integer, List<SubDetailValues>> numType = subDetailList.stream().collect(Collectors.groupingBy(SubDetailValues::getNum)); |
|
|
|
// 获取检验单使用的模板中的项目 |
|
|
|
List<QcInspectionStandardData> templateDetails = qcMapper.getInspectionTemplateDetail(data); |
|
|
|
// 记录不符合上下限的实测值数量 |
|
|
|
@ -4872,59 +4874,72 @@ public class QcServiceImpl implements QcService { |
|
|
|
// 判断有没有维护多维度检验标准 |
|
|
|
List<QcInspectionStandardData> standardList = qcMapper.getInspectionStandards(templateDetail); |
|
|
|
if (!standardList.isEmpty()) { // 多标准 |
|
|
|
// 将检验标准按type分组,便于查找 |
|
|
|
Map<String, List<QcInspectionStandardData>> standardsByType = standardList.stream() |
|
|
|
.collect(Collectors.groupingBy(QcInspectionStandardData::getCollectionSource)); |
|
|
|
|
|
|
|
// map中是否已存在该key |
|
|
|
if (!countMap.containsKey(templateDetail.getItemNo())) { // 没有则新建并赋初始值 |
|
|
|
countMap.put(templateDetail.getItemNo(), 0); |
|
|
|
} |
|
|
|
// 该项目的实测值 |
|
|
|
List<SubDetailValues> 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<QcInspectionStandardData> 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<Object> params = new ArrayList<>(); |
|
|
|
params.add(data.getSite()); |
|
|
|
params.add(data.getBuNo()); |
|
|
|
params.add(templateDetail.getItemNo()); |
|
|
|
params.add(data.getInspectionNo()); |
|
|
|
//执行方法 |
|
|
|
List<Map<String, Object>> 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<String, List<QcInspectionStandardData>> standardsByType = standardList.stream() |
|
|
|
// .collect(Collectors.groupingBy(QcInspectionStandardData::getCollectionSource)); |
|
|
|
// // map中是否已存在该key |
|
|
|
// if (!countMap.containsKey(templateDetail.getItemNo())) { // 没有则新建并赋初始值 |
|
|
|
// countMap.put(templateDetail.getItemNo(), 0); |
|
|
|
// } |
|
|
|
// // 该项目的实测值 |
|
|
|
// List<SubDetailValues> 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<QcInspectionStandardData> 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<SubDetailValues> allSubDetails = qcMapper.querySubDetails(data); |
|
|
|
|