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);
result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData()).stream().distinct().collect(Collectors.toList());
result.setResultFlag(setResultFlag(numbers));
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
}
return result;
}
@@ -271,7 +270,7 @@ public class DetectionServiceImpl {
fData = sourceIssue.getFIn();
}
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);
@@ -288,12 +287,11 @@ public class DetectionServiceImpl {
reflectHarmonic("a", integerBooleanA, harmonicResult, num);
reflectHarmonic("b", integerBooleanB, harmonicResult, num);
reflectHarmonic("c", integerBooleanC, harmonicResult, num);
List<Integer> list = new ArrayList<>();
list.addAll(integerBooleanA.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList()));
list.addAll(integerBooleanB.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList()));
list.addAll(integerBooleanC.stream().map(DetectionData::getIsData).distinct().collect(Collectors.toList()));
List<Integer> numbers = list.stream().distinct().collect(Collectors.toList());
harmonicResult.setResultFlag(setResultFlag(numbers));
List<DetectionData> list = new ArrayList<>();
list.addAll(integerBooleanA.stream().distinct().collect(Collectors.toList()));
list.addAll(integerBooleanB.stream().distinct().collect(Collectors.toList()));
list.addAll(integerBooleanC.stream().distinct().collect(Collectors.toList()));
harmonicResult.setResultFlag(setResultFlag(list));
return harmonicResult;
}
@@ -356,16 +354,14 @@ public class DetectionServiceImpl {
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData());
result.setResultFlag(setResultFlag(numbers));
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
} else {
List<PqScriptCheckData> channelTypeBList = checkData.stream()
.filter(x -> TYPE_T.equals(x.getPhase()))
.collect(Collectors.toList());
DetectionData t = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
result.setTValue(JSON.toJSONString(t));
List<Integer> numbers = Arrays.asList(t.getIsData());
result.setResultFlag(setResultFlag(numbers));
result.setResultFlag(setResultFlag(Arrays.asList(t)));
}
return result;
}
@@ -448,7 +444,7 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) {
retainATime = channelTypeAList.get(0).getDipData().getRetainTime();
} else {
retainATime = channelTypeAList.get(0).getFAmp();
retainATime = channelTypeAList.get(0).getDipData().getFTransValue();
}
DetectionData a = rangeComparisonList(mag.get(TYPE_A), magErrList, fData, retainATime, dataRule);
result.setAValue(JSON.toJSONString(a));
@@ -460,7 +456,7 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) {
retainBTime = channelTypeBList.get(0).getDipData().getRetainTime();
} else {
retainBTime = channelTypeBList.get(0).getFAmp();
retainBTime = channelTypeBList.get(0).getDipData().getFTransValue();
}
DetectionData b = rangeComparisonList(mag.get(TYPE_B), magErrList, fData, retainBTime, dataRule);
result.setBValue(JSON.toJSONString(b));
@@ -472,29 +468,28 @@ public class DetectionServiceImpl {
if (DUR.equals(dur)) {
retainCTime = channelTypeCList.get(0).getDipData().getRetainTime();
} else {
retainCTime = channelTypeCList.get(0).getFAmp();
retainCTime = channelTypeCList.get(0).getDipData().getFTransValue();
}
DetectionData c = rangeComparisonList(mag.get(TYPE_C), magErrList, fData, retainCTime, dataRule);
result.setCValue(JSON.toJSONString(c));
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), c.getIsData()).stream().distinct().collect(Collectors.toList());
result.setResultFlag(setResultFlag(numbers));
result.setResultFlag(setResultFlag(Arrays.asList(a, b, c)));
return result;
}
private Integer setResultFlag(List<Integer> numbers) {
numbers = numbers.stream().filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(numbers)) {
if (numbers.size() > 1) {
if (numbers.contains(4)) {
private Integer setResultFlag(List<DetectionData> numbers) {
List<Integer> isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).map(DetectionData::getIsData).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(isData)) {
if (isData.size() > 1) {
if (isData.contains(4)) {
return 4;
} else if (numbers.contains(2)) {
} else if (isData.contains(2)) {
return 2;
}
}
return numbers.get(0);
return isData.get(0);
} else {
return 4;
}
@@ -675,7 +670,7 @@ public class DetectionServiceImpl {
*/
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double v) {
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()))).collect(Collectors.toList());
isData(dataRule, harmDataList, data, qualifiedList);
@@ -786,11 +781,11 @@ public class DetectionServiceImpl {
channelData)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(errSysDtls)) {
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
if (DUR.equals(errSysDtl.getScriptType())) {
if (DUR.equals(errSysDtl.getScriptCode())) {
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())));
if (CollUtil.isNotEmpty(list)) {
detectionData.setData(list.get(0));
List<Double> qualifiedList = list.stream()
.filter(x -> NumberUtil.isIn(BigDecimal.valueOf(x.doubleValue()),
@@ -800,10 +795,10 @@ public class DetectionServiceImpl {
isData(dataRule, qualifiedList, detectionData, qualifiedList);
}
} else {
if (CollUtil.isNotEmpty(list)) {
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
detectionData.setResultData(channelData);
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
if (CollUtil.isNotEmpty(list)) {
detectionData.setData(list.get(0));
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<Double> harmNum = param.getHarmNum();
Map<String, List<RawDataVO>> info=new HashMap<>(3);
Map<String, List<RawDataVO>> info=new LinkedHashMap<>(3);
RawDataVO dataVO;
List<RawDataVO> rawDataVOS;
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<Double> harmNum = param.getHarmNum();
Map<String, RawResultDataVO> info=new HashMap<>(3);
Map<String, RawResultDataVO> info=new LinkedHashMap<>(3);
RawResultDataVO dataVO;
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
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())
.in(ObjectUtil.isNotEmpty(param.getIndex()), AdNonHarmonicResult::getSort, param.getIndex());
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));
List<DictTree> dictTreeById = dictTreeService.getDictTreeById(new ArrayList<>(adTypeMap.keySet()));
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);
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()));
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)){
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds)
.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);
}
DynamicTableNameHandler.remove();
@@ -53,7 +53,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
if(CollUtil.isNotEmpty(monitorIds)){
this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds)
.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);
}
@@ -66,16 +66,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
public Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList, String code) {
String adNonTableResult = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(adNonTableResult + code);
for (AdNonHarmonicResult item : adNonHarmonicResultList) {
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>()
.eq(AdNonHarmonicResult::getMonitorId, item.getMonitorId())
.eq(AdNonHarmonicResult::getSort, item.getSort())
.eq(AdNonHarmonicResult::getScriptId, item.getScriptId())
);
}
List<String> monitorIds = adNonHarmonicResultList.stream().map(AdNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(monitorIds)){
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds)
.eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId())
.eq(AdNonHarmonicResult::getSort,adNonHarmonicResultList.get(0).getSort()));
adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
}
DynamicTableNameHandler.remove();
return true;
}
@@ -85,15 +82,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
public Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList, String code) {
String adTableResult = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(adTableResult + code);
for (AdHarmonicResult item : adHarmonicResultList) {
this.remove(new LambdaQueryWrapper<AdHarmonicResult>()
.eq(AdHarmonicResult::getMonitorId, item.getMonitorId())
.eq(AdHarmonicResult::getSort, item.getSort())
.eq(AdHarmonicResult::getScriptId, item.getScriptId())
);
}
List<String> monitorIds = adHarmonicResultList.stream().map(AdHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(monitorIds)){
this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds)
.eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId())
.eq(AdHarmonicResult::getSort,adHarmonicResultList.get(0).getSort()));
this.saveBatch(adHarmonicResultList, 100);
}
DynamicTableNameHandler.remove();
return true;
}