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 dcd1e4e6..bb1845c4 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 @@ -472,44 +472,36 @@ public class DetectionServiceImpl { List channelTypeAList = sourceIssue.getChannelList().stream() .filter(x -> ("Ua").equals(x.getChannelType())) .collect(Collectors.toList()); - Double retainATime; - if (DUR.equals(dur)) { - retainATime = channelTypeAList.get(0).getDipData().getRetainTime(); - } else { - retainATime = channelTypeAList.get(0).getDipData().getFTransValue(); - } - DetectionData a = rangeComparisonList(mag.get(TYPE_A), magErrList, fData, retainATime, dataRule); + DetectionData a = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeAList, TYPE_A); result.setAValue(JSON.toJSONString(a)); List channelTypeBList = sourceIssue.getChannelList().stream() .filter(x -> ("Ub").equals(x.getChannelType())) .collect(Collectors.toList()); - Double retainBTime; - if (DUR.equals(dur)) { - retainBTime = channelTypeBList.get(0).getDipData().getRetainTime(); - } else { - retainBTime = channelTypeBList.get(0).getDipData().getFTransValue(); - } - DetectionData b = rangeComparisonList(mag.get(TYPE_B), magErrList, fData, retainBTime, dataRule); + + DetectionData b = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeBList, TYPE_B); result.setBValue(JSON.toJSONString(b)); List channelTypeCList = sourceIssue.getChannelList().stream() .filter(x -> ("Uc").equals(x.getChannelType())) .collect(Collectors.toList()); - Double retainCTime; - if (DUR.equals(dur)) { - retainCTime = channelTypeCList.get(0).getDipData().getRetainTime(); - } else { - retainCTime = channelTypeCList.get(0).getDipData().getFTransValue(); - } - DetectionData c = rangeComparisonList(mag.get(TYPE_C), magErrList, fData, retainCTime, dataRule); + DetectionData c = setDetectionData(dataRule, mag, fData, dur, magErrList, channelTypeCList, TYPE_C); result.setCValue(JSON.toJSONString(c)); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c))); - return result; } + private DetectionData setDetectionData(DictDataEnum dataRule, Map> mag, Double fData, String dur, List magErrList, List channelTypeCList, String typeC) { + DetectionData c; + if (DUR.equals(dur)) { + c = rangeDURComparisonList(mag.get(typeC), magErrList, fData, channelTypeCList.get(0).getDipData().getRetainTime(), dataRule); + } else { + c = rangeDURComparisonList(mag.get(typeC), magErrList, fData, channelTypeCList.get(0).getDipData().getFTransValue(), dataRule); + } + return c; + } + private Integer setResultFlag(List numbers) { List isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).filter(x -> 4 != x.getIsData()).map(DetectionData::getIsData).distinct().collect(Collectors.toList()); @@ -678,16 +670,14 @@ public class DetectionServiceImpl { data.setIsData(4); data.setNum(harm); data.setData(harmDataList.get(0)); - + Double v = issueHarmMap.get(harm); + data.setResultData(v); if (ObjectUtil.isNotNull(errSysDtl)) { PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class); errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType())); - Double v = issueHarmMap.get(harm); - data.setResultData(v); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(6); nf.setGroupingUsed(false); - data.setRadius(nf.format(-errSys.getMaxErrorValue()) + "~" + nf.format(-errSys.getMaxErrorValue())); setDetection(dataRule, harmDataList, errSys, data, v); } @@ -813,41 +803,54 @@ public class DetectionServiceImpl { detectionData.setIsData(4); if (CollUtil.isNotEmpty(list)) { detectionData.setData(list.get(0)); + detectionData.setResultData(channelData); + //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 + //获得误差体系 + List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), data, channelData, x.getConditionType()), + x.getStartFlag(), + startRadiusEnd(x.getEndValue(), data, channelData, x.getConditionType()), + x.getEndFlag(), + channelData)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(errSysDtls)) { + PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); + NumberFormat nf = NumberFormat.getInstance(); + nf.setMaximumFractionDigits(6); + nf.setGroupingUsed(false); + errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType())); + detectionData.setRadius(nf.format(-errSysDtl.getMaxErrorValue()) + "~" + nf.format(-errSysDtl.getMaxErrorValue())); + setDetection(dataRule, list, errSysDtl, detectionData, channelData); + } } - //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 - //获得误差体系 - List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), data, channelData, x.getConditionType()), - x.getStartFlag(), - startRadiusEnd(x.getEndValue(), data, channelData, x.getConditionType()), - x.getEndFlag(), - channelData)).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(errSysDtls)) { - PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); - NumberFormat nf = NumberFormat.getInstance(); - nf.setMaximumFractionDigits(6); - nf.setGroupingUsed(false); - if (DUR.equals(errSysDtl.getScriptCode())) { - if (CollUtil.isNotEmpty(list)) { - detectionData.setResultData(BigDecimal.valueOf(1.0 / data).doubleValue() * channelData); - detectionData.setRadius(nf.format(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue()))) - + "~" + nf.format(BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue())))); - 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 (CollUtil.isNotEmpty(list)) { - errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType())); - detectionData.setResultData(channelData); + return detectionData; + } - detectionData.setRadius(nf.format(-errSysDtl.getMaxErrorValue()) + "~" + nf.format(-errSysDtl.getMaxErrorValue())); - detectionData.setData(list.get(0)); - setDetection(dataRule, list, errSysDtl, detectionData, channelData); - } + public DetectionData rangeDURComparisonList(List list, List pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { + DetectionData detectionData = new DetectionData(); + detectionData.setIsData(4); + if (CollUtil.isNotEmpty(list)) { + detectionData.setData(list.get(0)); + detectionData.setResultData(BigDecimal.valueOf(1.0 / data).doubleValue() * channelData); + + //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 + //获得误差体系 + List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), data, channelData, x.getConditionType()), + x.getStartFlag(), + startRadiusEnd(x.getEndValue(), data, channelData, x.getConditionType()), + x.getEndFlag(), + channelData)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(errSysDtls)) { + PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); + NumberFormat nf = NumberFormat.getInstance(); + nf.setMaximumFractionDigits(6); + nf.setGroupingUsed(false); + detectionData.setRadius(nf.format(BigDecimal.valueOf(1.0 / data * (channelData - errSysDtl.getMaxErrorValue()))) + + "~" + nf.format(BigDecimal.valueOf(1.0 / data * (channelData + errSysDtl.getMaxErrorValue())))); + 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); } } return detectionData; @@ -1000,7 +1003,7 @@ public class DetectionServiceImpl { if (integerListMap.containsKey(i)) { if (i.equals(1.0)) { integerListMap.get(1.0).add(multiply(fund, fund)); - }else{ + } else { if (type.equals("A")) { integerListMap.get(i).add(multiply(harm.getList().getA().get((int) (i - num)), fund)); }