代码微调

This commit is contained in:
wr
2025-01-08 11:21:11 +08:00
parent be232d390f
commit a0a42f8fa3
2 changed files with 45 additions and 44 deletions

View File

@@ -502,61 +502,57 @@ public class DetectionServiceImpl {
* @param dataRule * @param dataRule
*/ */
public Map<String, List<Double>> devListMap(List<DevData> dev, DictDataEnum dataRule, String code) { public Map<String, List<Double>> devListMap(List<DevData> dev, DictDataEnum dataRule, String code) {
//设置
Map<String, List<Double>> map = new HashMap<>(3); Map<String, List<Double>> map = new HashMap<>(3);
List<Double> a = new ArrayList<>();
List<Double> b = new ArrayList<>();
List<Double> c = new ArrayList<>();
List<Double> t = new ArrayList<>();
List<DevData.SqlDataDTO> sqlDataDTOS = dev.stream().flatMap(x -> x.getSqlData().stream().filter(j -> code.equals(j.getDesc()))) List<DevData.SqlDataDTO> sqlDataDTOS = dev.stream().flatMap(x -> x.getSqlData().stream().filter(j -> code.equals(j.getDesc())))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isNotEmpty(sqlDataDTOS)) { if (CollUtil.isNotEmpty(sqlDataDTOS)) {
List<DevData.SqlDataDTO.ListDTO> list = sqlDataDTOS.stream().map(DevData.SqlDataDTO::getList).collect(Collectors.toList()); List<DevData.SqlDataDTO.ListDTO> list = sqlDataDTOS.stream().map(DevData.SqlDataDTO::getList).collect(Collectors.toList());
a = list.stream() List<Double> a = list.stream()
.filter(x -> ObjectUtil.isNotNull(x.getA())) .filter(x -> ObjectUtil.isNotNull(x.getA()))
.map(DevData.SqlDataDTO.ListDTO::getA) .map(DevData.SqlDataDTO.ListDTO::getA)
.sorted(Comparator.comparing(Double::doubleValue).reversed()) .sorted(Comparator.comparing(Double::doubleValue).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
b = list.stream() List<Double> b = list.stream()
.filter(x -> ObjectUtil.isNotNull(x.getB())) .filter(x -> ObjectUtil.isNotNull(x.getB()))
.map(DevData.SqlDataDTO.ListDTO::getB) .map(DevData.SqlDataDTO.ListDTO::getB)
.sorted(Comparator.comparing(Double::doubleValue).reversed()) .sorted(Comparator.comparing(Double::doubleValue).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
c = list.stream() List<Double> c = list.stream()
.filter(x -> ObjectUtil.isNotNull(x.getC())) .filter(x -> ObjectUtil.isNotNull(x.getC()))
.map(DevData.SqlDataDTO.ListDTO::getC) .map(DevData.SqlDataDTO.ListDTO::getC)
.sorted(Comparator.comparing(Double::doubleValue).reversed()) .sorted(Comparator.comparing(Double::doubleValue).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
t = list.stream().filter(x -> ObjectUtil.isNotNull(x.getT())) List<Double> t = list.stream().filter(x -> ObjectUtil.isNotNull(x.getT()))
.map(DevData.SqlDataDTO.ListDTO::getT) .map(DevData.SqlDataDTO.ListDTO::getT)
.sorted(Comparator.comparing(Double::doubleValue).reversed()) .sorted(Comparator.comparing(Double::doubleValue).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
} switch (dataRule) {
switch (dataRule) { case SECTION_VALUE:
case SECTION_VALUE: a = getDoubles(a, 1, 19);
a = getDoubles(a, 1, 19); b = getDoubles(b, 1, 19);
b = getDoubles(b, 1, 19); c = getDoubles(c, 1, 19);
c = getDoubles(c, 1, 19); t = getDoubles(t, 1, 19);
t = getDoubles(t, 1, 19); break;
break; case CP95_VALUE:
case CP95_VALUE: a = getDoubles(a, 1, 2);
a = getDoubles(a, 1, 2); b = getDoubles(b, 1, 2);
b = getDoubles(b, 1, 2); c = getDoubles(c, 1, 2);
c = getDoubles(c, 1, 2); t = getDoubles(t, 1, 2);
t = getDoubles(t, 1, 2); break;
break; case AVG_VALUE:
case AVG_VALUE: a = getAvgDoubles(a);
a = getAvgDoubles(a); b = getAvgDoubles(b);
b = getAvgDoubles(b); c = getAvgDoubles(c);
c = getAvgDoubles(c); t = getAvgDoubles(t);
t = getAvgDoubles(t); break;
break; }
} map.put(TYPE_A, a);
map.put(TYPE_A, a); map.put(TYPE_B, b);
map.put(TYPE_B, b); map.put(TYPE_C, c);
map.put(TYPE_C, c); if (CollUtil.isNotEmpty(t)) {
if (CollUtil.isNotEmpty(t)) { map.put(TYPE_T, t);
map.put(TYPE_T, t); }
} }
return map; return map;
} }
@@ -722,16 +718,20 @@ public class DetectionServiceImpl {
if (first.isPresent()) { if (first.isPresent()) {
fund = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst().get(); 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(); List<DevData.SqlDataHarmDTO> harmList = devData.getSqlDataHarm().stream().collect(Collectors.toList());
if (ObjectUtil.isNotNull(fund)) { if (CollUtil.isNotEmpty(harmList)) {
harmPut(TYPE_A, map, harmNum, harm, String.valueOf(fund.getList().getA()), num); DevData.SqlDataHarmDTO harm = harmList.get(0);
harmPut(TYPE_B, map, harmNum, harm, String.valueOf(fund.getList().getB()), num); if (ObjectUtil.isNotNull(fund)) {
harmPut(TYPE_C, map, harmNum, harm, String.valueOf(fund.getList().getC()), num); harmPut(TYPE_A, map, harmNum, harm, String.valueOf(fund.getList().getA()), num);
} else { harmPut(TYPE_B, map, harmNum, harm, String.valueOf(fund.getList().getB()), num);
harmPut(TYPE_A, map, harmNum, harm, "1.0", num); harmPut(TYPE_C, map, harmNum, harm, String.valueOf(fund.getList().getC()), num);
harmPut(TYPE_B, map, harmNum, harm, "1.0", num); } else {
harmPut(TYPE_C, map, harmNum, harm, "1.0", num); 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) -> { map.forEach((typeKey, typeValue) -> {
typeValue.forEach((key, value) -> { typeValue.forEach((key, value) -> {

View File

@@ -14,6 +14,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public class SourceIssue { public class SourceIssue {
/** /**
* 检测小项dtls Id * 检测小项dtls Id
*/ */