From be232d390ffcf0ec6c642df3b8b95950fd4441b1 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Wed, 8 Jan 2025 09:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E6=A3=80=E6=B5=8B=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A3=85=E7=BD=AE=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DetectionServiceImpl.java | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) 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 fe617984..95c4b5fa 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 @@ -480,14 +480,19 @@ public class DetectionServiceImpl { private Integer setResultFlag(List numbers) { - if (numbers.size() > 1) { - if (numbers.contains(4)) { - return 4; - } else if (numbers.contains(2)) { - return 2; + numbers = numbers.stream().filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(numbers)) { + if (numbers.size() > 1) { + if (numbers.contains(4)) { + return 4; + } else if (numbers.contains(2)) { + return 2; + } } + return numbers.get(0); + } else { + return 4; } - return numbers.get(0); } /** @@ -668,7 +673,6 @@ public class DetectionServiceImpl { .filter(x -> v == 0 ? x == v : x > 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()), BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList()); - data.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue()); isData(dataRule, harmDataList, data, qualifiedList); } @@ -764,7 +768,6 @@ public class DetectionServiceImpl { public DetectionData rangeComparisonList(List list, List pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { DetectionData detectionData = new DetectionData(); detectionData.setIsData(4); - detectionData.setData(CollUtil.isNotEmpty(list) ? list.get(0) : null); //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 //获得误差体系 List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), data, x.getConditionType()), @@ -775,21 +778,28 @@ public class DetectionServiceImpl { if (CollUtil.isNotEmpty(errSysDtls)) { PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); if (DUR.equals(errSysDtl.getScriptType())) { - List qualifiedList = list.stream() - .filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()), - BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())), - BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue()))) - ).collect(Collectors.toList()); detectionData.setResultData(BigDecimal.valueOf(1.0 / data).doubleValue() * channelData); detectionData.setRadius(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())) + "~" + BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue()))); - isData(dataRule, qualifiedList, detectionData, qualifiedList); + if (CollUtil.isNotEmpty(list)) { + detectionData.setData(list.get(0)); + List qualifiedList = list.stream() + .filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()), + BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue())), + BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue()))) + ).collect(Collectors.toList()); + isData(dataRule, qualifiedList, detectionData, qualifiedList); + } } else { if (0 == errSysDtl.getErrorValueType()) { errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0)); } detectionData.setResultData(channelData); - setDetection(dataRule, list, errSysDtl, detectionData, channelData); + detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue()); + if (CollUtil.isNotEmpty(list)) { + detectionData.setData(list.get(0)); + setDetection(dataRule, list, errSysDtl, detectionData, channelData); + } } } return detectionData;