diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index 95c4b5fa..a30b89d1 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -502,61 +502,57 @@ public class DetectionServiceImpl { * @param dataRule */ public Map> devListMap(List dev, DictDataEnum dataRule, String code) { - //设置 Map> map = new HashMap<>(3); - List a = new ArrayList<>(); - List b = new ArrayList<>(); - List c = new ArrayList<>(); - List t = new ArrayList<>(); + List sqlDataDTOS = dev.stream().flatMap(x -> x.getSqlData().stream().filter(j -> code.equals(j.getDesc()))) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(sqlDataDTOS)) { List list = sqlDataDTOS.stream().map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); - a = list.stream() + List a = list.stream() .filter(x -> ObjectUtil.isNotNull(x.getA())) .map(DevData.SqlDataDTO.ListDTO::getA) .sorted(Comparator.comparing(Double::doubleValue).reversed()) .collect(Collectors.toList()); - b = list.stream() + List b = list.stream() .filter(x -> ObjectUtil.isNotNull(x.getB())) .map(DevData.SqlDataDTO.ListDTO::getB) .sorted(Comparator.comparing(Double::doubleValue).reversed()) .collect(Collectors.toList()); - c = list.stream() + List c = list.stream() .filter(x -> ObjectUtil.isNotNull(x.getC())) .map(DevData.SqlDataDTO.ListDTO::getC) .sorted(Comparator.comparing(Double::doubleValue).reversed()) .collect(Collectors.toList()); - t = list.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) + List t = list.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) .map(DevData.SqlDataDTO.ListDTO::getT) .sorted(Comparator.comparing(Double::doubleValue).reversed()) .collect(Collectors.toList()); - } - switch (dataRule) { - case SECTION_VALUE: - a = getDoubles(a, 1, 19); - b = getDoubles(b, 1, 19); - c = getDoubles(c, 1, 19); - t = getDoubles(t, 1, 19); - break; - case CP95_VALUE: - a = getDoubles(a, 1, 2); - b = getDoubles(b, 1, 2); - c = getDoubles(c, 1, 2); - t = getDoubles(t, 1, 2); - break; - case AVG_VALUE: - a = getAvgDoubles(a); - b = getAvgDoubles(b); - c = getAvgDoubles(c); - t = getAvgDoubles(t); - break; - } - map.put(TYPE_A, a); - map.put(TYPE_B, b); - map.put(TYPE_C, c); - if (CollUtil.isNotEmpty(t)) { - map.put(TYPE_T, t); + switch (dataRule) { + case SECTION_VALUE: + a = getDoubles(a, 1, 19); + b = getDoubles(b, 1, 19); + c = getDoubles(c, 1, 19); + t = getDoubles(t, 1, 19); + break; + case CP95_VALUE: + a = getDoubles(a, 1, 2); + b = getDoubles(b, 1, 2); + c = getDoubles(c, 1, 2); + t = getDoubles(t, 1, 2); + break; + case AVG_VALUE: + a = getAvgDoubles(a); + b = getAvgDoubles(b); + c = getAvgDoubles(c); + t = getAvgDoubles(t); + break; + } + map.put(TYPE_A, a); + map.put(TYPE_B, b); + map.put(TYPE_C, c); + if (CollUtil.isNotEmpty(t)) { + map.put(TYPE_T, t); + } } return map; } @@ -722,16 +718,20 @@ public class DetectionServiceImpl { if (first.isPresent()) { fund = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst().get(); } - DevData.SqlDataHarmDTO harm = devData.getSqlDataHarm().stream().filter(x -> 49 == x.getNum()).collect(Collectors.toList()).stream().findFirst().get(); - if (ObjectUtil.isNotNull(fund)) { - harmPut(TYPE_A, map, harmNum, harm, String.valueOf(fund.getList().getA()), num); - harmPut(TYPE_B, map, harmNum, harm, String.valueOf(fund.getList().getB()), num); - harmPut(TYPE_C, map, harmNum, harm, String.valueOf(fund.getList().getC()), num); - } else { - harmPut(TYPE_A, map, harmNum, harm, "1.0", num); - harmPut(TYPE_B, map, harmNum, harm, "1.0", num); - harmPut(TYPE_C, map, harmNum, harm, "1.0", num); + List harmList = devData.getSqlDataHarm().stream().collect(Collectors.toList()); + if (CollUtil.isNotEmpty(harmList)) { + DevData.SqlDataHarmDTO harm = harmList.get(0); + if (ObjectUtil.isNotNull(fund)) { + harmPut(TYPE_A, map, harmNum, harm, String.valueOf(fund.getList().getA()), num); + harmPut(TYPE_B, map, harmNum, harm, String.valueOf(fund.getList().getB()), num); + harmPut(TYPE_C, map, harmNum, harm, String.valueOf(fund.getList().getC()), num); + } else { + harmPut(TYPE_A, map, harmNum, harm, "1.0", num); + harmPut(TYPE_B, map, harmNum, harm, "1.0", num); + harmPut(TYPE_C, map, harmNum, harm, "1.0", num); + } } + } map.forEach((typeKey, typeValue) -> { typeValue.forEach((key, value) -> { diff --git a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java index 20ae58dd..3baa0df5 100644 --- a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java +++ b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java @@ -14,6 +14,7 @@ import java.util.List; @NoArgsConstructor @Data public class SourceIssue { + /** * 检测小项dtls Id */