This commit is contained in:
wr
2025-01-10 14:27:45 +08:00
parent ec5aae048d
commit 51539f1137
4 changed files with 46 additions and 56 deletions

View File

@@ -238,8 +238,7 @@ public class DetectionServiceImpl {
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getFAmp(), dataRule); DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getFAmp(), dataRule);
result.setCValue(JSON.toJSONString(c)); result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData()).stream().distinct().collect(Collectors.toList()); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
result.setResultFlag(setResultFlag(numbers));
} }
return result; return result;
} }
@@ -271,7 +270,7 @@ public class DetectionServiceImpl {
fData = sourceIssue.getFIn(); fData = sourceIssue.getFIn();
} }
if (P.equals(type)) { if (P.equals(type)) {
fData = sourceIssue.getFIn() * sourceIssue.getFUn()*0.01; fData = sourceIssue.getFIn() * sourceIssue.getFUn() * 0.01;
} }
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num); List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
@@ -288,12 +287,11 @@ public class DetectionServiceImpl {
reflectHarmonic("a", integerBooleanA, harmonicResult, num); reflectHarmonic("a", integerBooleanA, harmonicResult, num);
reflectHarmonic("b", integerBooleanB, harmonicResult, num); reflectHarmonic("b", integerBooleanB, harmonicResult, num);
reflectHarmonic("c", integerBooleanC, harmonicResult, num); reflectHarmonic("c", integerBooleanC, harmonicResult, num);
List<Integer> list = new ArrayList<>(); List<DetectionData> list = new ArrayList<>();
list.addAll(integerBooleanA.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList())); list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList()));
list.addAll(integerBooleanB.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList())); list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList()));
list.addAll(integerBooleanC.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList())); list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList()));
List<Integer> numbers = list.stream().distinct().collect(Collectors.toList()); harmonicResult.setResultFlag(setResultFlag(list));
harmonicResult.setResultFlag(setResultFlag(numbers));
return harmonicResult; return harmonicResult;
} }
@@ -356,16 +354,14 @@ public class DetectionServiceImpl {
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule); DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
result.setCValue(JSON.toJSONString(c)); result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData()); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
result.setResultFlag(setResultFlag(numbers));
} else { } else {
List<PqScriptCheckData> channelTypeBList = checkData.stream() List<PqScriptCheckData> channelTypeBList = checkData.stream()
.filter(x -> TYPE_T.equals(x.getPhase())) .filter(x -> TYPE_T.equals(x.getPhase()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule); DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
result.setTValue(JSON.toJSONString(t)); result.setTValue(JSON.toJSONString(t));
List<Integer> numbers = Arrays.asList(t.getIsData()); result.setResultFlag(setResultFlag(Arrays.asList(t)));
result.setResultFlag(setResultFlag(numbers));
} }
return result; return result;
} }
@@ -448,7 +444,7 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) { if (DUR.equals(dur)) {
retainATime = channelTypeAList.get(0).getDipData().getRetainTime(); retainATime = channelTypeAList.get(0).getDipData().getRetainTime();
} else { } else {
retainATime = channelTypeAList.get(0).getFAmp(); retainATime = channelTypeAList.get(0).getDipData().getFTransValue();
} }
DetectionData a = rangeComparisonList(mag.get(TYPE_A), magErrList, fData, retainATime, dataRule); DetectionData a = rangeComparisonList(mag.get(TYPE_A), magErrList, fData, retainATime, dataRule);
result.setAValue(JSON.toJSONString(a)); result.setAValue(JSON.toJSONString(a));
@@ -460,7 +456,7 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) { if (DUR.equals(dur)) {
retainBTime = channelTypeBList.get(0).getDipData().getRetainTime(); retainBTime = channelTypeBList.get(0).getDipData().getRetainTime();
} else { } else {
retainBTime = channelTypeBList.get(0).getFAmp(); retainBTime = channelTypeBList.get(0).getDipData().getFTransValue();
} }
DetectionData b = rangeComparisonList(mag.get(TYPE_B), magErrList, fData, retainBTime, dataRule); DetectionData b = rangeComparisonList(mag.get(TYPE_B), magErrList, fData, retainBTime, dataRule);
result.setBValue(JSON.toJSONString(b)); result.setBValue(JSON.toJSONString(b));
@@ -472,29 +468,28 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) { if (DUR.equals(dur)) {
retainCTime = channelTypeCList.get(0).getDipData().getRetainTime(); retainCTime = channelTypeCList.get(0).getDipData().getRetainTime();
} else { } else {
retainCTime = channelTypeCList.get(0).getFAmp(); retainCTime = channelTypeCList.get(0).getDipData().getFTransValue();
} }
DetectionData c = rangeComparisonList(mag.get(TYPE_C), magErrList, fData, retainCTime, dataRule); DetectionData c = rangeComparisonList(mag.get(TYPE_C), magErrList, fData, retainCTime, dataRule);
result.setCValue(JSON.toJSONString(c)); result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData()).stream().distinct().collect(Collectors.toList()); result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
result.setResultFlag(setResultFlag(numbers));
return result; return result;
} }
private Integer setResultFlag(List<Integer> numbers) { private Integer setResultFlag(List<DetectionData> numbers) {
numbers = numbers.stream().filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); List<Integer> isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).map(DetectionData::getIsData).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(numbers)) { if (CollUtil.isNotEmpty(isData)) {
if (numbers.size() > 1) { if (isData.size() > 1) {
if (numbers.contains(4)) { if (isData.contains(4)) {
return 4; return 4;
} else if (numbers.contains(2)) { } else if (isData.contains(2)) {
return 2; return 2;
} }
} }
return numbers.get(0); return isData.get(0);
} else { } else {
return 4; return 4;
} }
@@ -675,7 +670,7 @@ public class DetectionServiceImpl {
*/ */
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) { private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) {
List<Double> qualifiedList = harmDataList.stream() List<Double> qualifiedList = harmDataList.stream()
.filter(x -> v == 0 ? x.equals(v) : x > 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()), .filter(x -> x > 0 && NumberUtil.isIn(devSubtractChannelData(x, v, errSysDtl.getErrorValueType()),
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()), BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList()); BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
isData(dataRule, harmDataList, data, qualifiedList); isData(dataRule, harmDataList, data, qualifiedList);
@@ -786,11 +781,11 @@ public class DetectionServiceImpl {
channelData)).collect(Collectors.toList()); channelData)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(errSysDtls)) { if (CollUtil.isNotEmpty(errSysDtls)) {
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class); PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
if (DUR.equals(errSysDtl.getScriptType())) { if (DUR.equals(errSysDtl.getScriptCode())) {
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())));
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
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())));
detectionData.setData(list.get(0)); detectionData.setData(list.get(0));
List<Double> qualifiedList = list.stream() List<Double> qualifiedList = list.stream()
.filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()), .filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()),
@@ -800,10 +795,10 @@ public class DetectionServiceImpl {
isData(dataRule, qualifiedList, detectionData, qualifiedList); isData(dataRule, qualifiedList, detectionData, qualifiedList);
} }
} else { } else {
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
detectionData.setResultData(channelData);
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
detectionData.setResultData(channelData);
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
detectionData.setData(list.get(0)); detectionData.setData(list.get(0));
setDetection(dataRule, list, errSysDtl, detectionData, channelData); setDetection(dataRule, list, errSysDtl, detectionData, channelData);
} }

View File

@@ -69,7 +69,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
List<Double> harmNum = param.getHarmNum(); List<Double> harmNum = param.getHarmNum();
Map<String, List<RawDataVO>> info=new HashMap<>(3); Map<String, List<RawDataVO>> info=new LinkedHashMap<>(3);
RawDataVO dataVO; RawDataVO dataVO;
List<RawDataVO> rawDataVOS; List<RawDataVO> rawDataVOS;
for (AdHarmonicResult harmonicResult : adHarmonicResults) { for (AdHarmonicResult harmonicResult : adHarmonicResults) {
@@ -129,7 +129,7 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
List<Double> harmNum = param.getHarmNum(); List<Double> harmNum = param.getHarmNum();
Map<String, RawResultDataVO> info=new HashMap<>(3); Map<String, RawResultDataVO> info=new LinkedHashMap<>(3);
RawResultDataVO dataVO; RawResultDataVO dataVO;
for (AdHarmonicResult harmonicResult : adHarmonicResults) { for (AdHarmonicResult harmonicResult : adHarmonicResults) {
for (Double i : harmNum) { for (Double i : harmNum) {

View File

@@ -62,7 +62,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
.eq(ObjectUtil.isNotNull(param.getScriptId()), AdNonHarmonicResult::getScriptId, param.getScriptId()) .eq(ObjectUtil.isNotNull(param.getScriptId()), AdNonHarmonicResult::getScriptId, param.getScriptId())
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdNonHarmonicResult::getSort, param.getIndex()); .in(ObjectUtil.isNotEmpty(param.getIndex()), AdNonHarmonicResult::getSort, param.getIndex());
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
Map<String, List<RawDataVO>> info = new HashMap<>(2); Map<String, List<RawDataVO>> info = new LinkedHashMap<>(2);
Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType)); Map<String, List<AdNonHarmonicResult>> adTypeMap = adHarmonicResults.stream().collect(Collectors.groupingBy(AdNonHarmonicResult::getAdType));
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet())); List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId,Function.identity())); Map<String, DictTree> dictTreeByName = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId,Function.identity()));
@@ -98,7 +98,7 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl<AdNonHarmonicMapper, A
List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); List<AdNonHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper);
Map<String, RawResultDataVO> info = new HashMap<>(2); Map<String, RawResultDataVO> info = new LinkedHashMap<>(2);
Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity())); Map<String, AdNonHarmonicResult> adTypeMap = adHarmonicResults.stream().collect(Collectors.toMap(AdNonHarmonicResult::getAdType, Function.identity()));
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet())); List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));

View File

@@ -37,7 +37,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
if(CollUtil.isNotEmpty(monitorIds)){ if(CollUtil.isNotEmpty(monitorIds)){
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds) adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds)
.eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId()) .eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId())
.eq(AdNonHarmonicResult::getAdType,adNonHarmonicResultList.get(0).getAdType())); .eq(AdNonHarmonicResult::getSort,adNonHarmonicResultList.get(0).getSort()));
adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100); adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
} }
DynamicTableNameHandler.remove(); DynamicTableNameHandler.remove();
@@ -53,7 +53,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
if(CollUtil.isNotEmpty(monitorIds)){ if(CollUtil.isNotEmpty(monitorIds)){
this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds) this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds)
.eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId()) .eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId())
.eq(AdHarmonicResult::getAdType,adHarmonicResultList.get(0).getAdType())); .eq(AdHarmonicResult::getSort,adHarmonicResultList.get(0).getSort()));
this.saveBatch(adHarmonicResultList, 100); this.saveBatch(adHarmonicResultList, 100);
} }
@@ -66,16 +66,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
public Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList, String code) { public Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList, String code) {
String adNonTableResult = "ad_non_harmonic_result_"; String adNonTableResult = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(adNonTableResult + code); DynamicTableNameHandler.setTableName(adNonTableResult + code);
List<String> monitorIds = adNonHarmonicResultList.stream().map(AdNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
for (AdNonHarmonicResult item : adNonHarmonicResultList) { if(CollUtil.isNotEmpty(monitorIds)){
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>() adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds)
.eq(AdNonHarmonicResult::getMonitorId, item.getMonitorId()) .eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId())
.eq(AdNonHarmonicResult::getSort, item.getSort()) .eq(AdNonHarmonicResult::getSort,adNonHarmonicResultList.get(0).getSort()));
.eq(AdNonHarmonicResult::getScriptId, item.getScriptId()) adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
);
} }
adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
DynamicTableNameHandler.remove(); DynamicTableNameHandler.remove();
return true; return true;
} }
@@ -85,15 +82,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
public Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList, String code) { public Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList, String code) {
String adTableResult = "ad_harmonic_result_"; String adTableResult = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(adTableResult + code); DynamicTableNameHandler.setTableName(adTableResult + code);
for (AdHarmonicResult item : adHarmonicResultList) { List<String> monitorIds = adHarmonicResultList.stream().map(AdHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
this.remove(new LambdaQueryWrapper<AdHarmonicResult>() if(CollUtil.isNotEmpty(monitorIds)){
.eq(AdHarmonicResult::getMonitorId, item.getMonitorId()) this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds)
.eq(AdHarmonicResult::getSort, item.getSort()) .eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId())
.eq(AdHarmonicResult::getScriptId, item.getScriptId()) .eq(AdHarmonicResult::getSort,adHarmonicResultList.get(0).getSort()));
this.saveBatch(adHarmonicResultList, 100);
);
} }
this.saveBatch(adHarmonicResultList, 100);
DynamicTableNameHandler.remove(); DynamicTableNameHandler.remove();
return true; return true;
} }