1.调整检测脚本的返回信息

2.增加误差体系查询接口
This commit is contained in:
wr
2024-12-30 08:37:21 +08:00
parent 39f890dd4c
commit 7f5c132573
9 changed files with 152 additions and 105 deletions

View File

@@ -430,7 +430,7 @@ public class SocketDevResponseService {
if (successComm.size() == monitorIdListComm.size()) { if (successComm.size() == monitorIdListComm.size()) {
SourceIssue sourceIssue = SocketManager.getSourceTarget(socketDataMsg.getRequestId()); SourceIssue sourceIssue = SocketManager.getSourceTarget(socketDataMsg.getRequestId());
System.out.println("获取sourceIssue"+sourceIssue); System.out.println("获取sourceIssue"+sourceIssue);
Map<String, Integer> flag = detectionServiceImpl.text(devDataList,devIdMapComm ,sourceIssue, DictDataEnum.AT_WILL_VALUE); Map<String, Integer> flag = detectionServiceImpl.text(devDataList,param.getErrorSysId(),devIdMapComm,sourceIssue, DictDataEnum.AT_WILL_VALUE);
System.out.println(flag); System.out.println(flag);
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>(); WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();

View File

@@ -17,7 +17,6 @@ public class PreDetectionParam {
*/ */
private String operateType = "0"; private String operateType = "0";
/** /**
* 检测计划id * 检测计划id
*/ */
@@ -42,4 +41,9 @@ public class PreDetectionParam {
* 源id * 源id
*/ */
private String sourceId; private String sourceId;
/**
* 所属误差体系
*/
private String errorSysId;
} }

View File

@@ -11,8 +11,14 @@ import lombok.Data;
@Data @Data
public class DetectionData { public class DetectionData {
/** /**
* 是否是符合数据 * 第几次谐波
*/
private Integer num;
/**
* 原始数据
*/ */
private Integer isData; private Integer isData;

View File

@@ -10,14 +10,17 @@ import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls; import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.device.err.service.IPqErrSysDtlsService; import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
import com.njcn.gather.device.script.pojo.po.SourceIssue; import com.njcn.gather.device.script.pojo.po.SourceIssue;
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -43,11 +46,11 @@ public class DetectionServiceImpl {
* 开始处理指标类型 * 开始处理指标类型
* 一共20组数据开始处理格式 * 一共20组数据开始处理格式
*/ */
public Map<String, Integer> text(List<DevData> dev,Map<String, String> devIdMapComm, SourceIssue issue, DictDataEnum dataRule) { public Map<String, Integer> text(List<DevData> dev, String errorSysId, Map<String, String> devIdMapComm, SourceIssue issue, DictDataEnum dataRule) {
Map<String, List<DevData>> devDataMap = dev.stream().collect(Collectors.groupingBy(DevData::getId)); Map<String, List<DevData>> devDataMap = dev.stream().collect(Collectors.groupingBy(DevData::getId));
Map<String, Integer> stringBooleanMap = new LinkedHashMap<>(); Map<String, Integer> stringBooleanMap = new LinkedHashMap<>();
devDataMap.forEach(((key, value) -> { devDataMap.forEach(((key, value) -> {
stringBooleanMap.put(key, DetectionIndexProcessing(value,devIdMapComm, dataRule, issue)); stringBooleanMap.put(key, DetectionIndexProcessing(value, errorSysId, devIdMapComm, dataRule, issue));
})); }));
return stringBooleanMap; return stringBooleanMap;
} }
@@ -62,26 +65,29 @@ public class DetectionServiceImpl {
* @param sourceIssue 源下发的参数 * @param sourceIssue 源下发的参数
* @return * @return
*/ */
public Integer DetectionIndexProcessing(List<DevData> dev,Map<String, String> devIdMapComm, DictDataEnum dataRule, SourceIssue sourceIssue) { public Integer DetectionIndexProcessing(List<DevData> dev, String errorSysId, Map<String, String> devIdMapComm, DictDataEnum dataRule, SourceIssue sourceIssue) {
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam(); PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
param.setIndex(sourceIssue.getIndex());
param.setScriptId(sourceIssue.getScriptId());
param.setErrorSysId(errorSysId);
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param); List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param);
switch ("V") { switch ("V") {
/** /**
* 频率 * 频率
*/ */
case "FREQ": case "FREQ":
return isQualified(dev,devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ").getResultFlag(); return isQualified(dev, devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ").getResultFlag();
/** /**
* 电压 * 电压
*/ */
case "V": case "V":
System.out.println(isQualified(dev,devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ")); System.out.println(isQualified(dev, devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ"));
return isQualified(dev,devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS").getResultFlag(); return isQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS").getResultFlag();
/** /**
* 电流 * 电流
*/ */
case "I": case "I":
return isQualified(dev,devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS").getResultFlag(); return isQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS").getResultFlag();
/** /**
* 谐波类 * 谐波类
*/ */
@@ -181,9 +187,10 @@ public class DetectionServiceImpl {
* @param type (电压还是电流) * @param type (电压还是电流)
* @param sourceIssue 源下发所对应的参数 * @param sourceIssue 源下发所对应的参数
* @param dataRule 数据处理原则 * @param dataRule 数据处理原则
* @param code 源下发的装置通道code(->desc)
* @return * @return
*/ */
public AdNonHarmonicResult isQualified(List<DevData> dev,Map<String, String> devIdMapComm, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, String code) { public AdNonHarmonicResult isQualified(List<DevData> dev, Map<String, String> devIdMapComm, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, String code) {
Map<String, List<Double>> map = devListMap(dev, dataRule, code); Map<String, List<Double>> map = devListMap(dev, dataRule, code);
Double fData = 1.0; Double fData = 1.0;
if (U.equals(type)) { if (U.equals(type)) {
@@ -195,16 +202,16 @@ public class DetectionServiceImpl {
if (F.equals(type)) { if (F.equals(type)) {
fData = sourceIssue.getFFreq(); fData = sourceIssue.getFFreq();
} }
AdNonHarmonicResult result=new AdNonHarmonicResult(); AdNonHarmonicResult result = new AdNonHarmonicResult();
String[] split = dev.get(0).getId().split("_"); String[] split = dev.get(0).getId().split("_");
String devID = devIdMapComm.get(split); String devID = devIdMapComm.get(split[0]);
result.setMonitorId(devID+"_"+split[1]); result.setMonitorId(devID + "_" + split[1]);
result.setScriptId(sourceIssue.getScriptId()); result.setScriptId(sourceIssue.getScriptId());
result.setIndex(sourceIssue.getIndex()); result.setIndex(sourceIssue.getIndex());
result.setDataType("avg"); result.setDataType("avg");
if (map.containsKey(TYPE_T)) { if (map.containsKey(TYPE_T)) {
DetectionData t = rangeComparisonList(map.get(TYPE_T), pqErrSysDtls, fData, 1.0, dataRule); DetectionData t = rangeComparisonList(map.get(TYPE_T), pqErrSysDtls, fData, 1.0, dataRule);
result.setTValue(t.getData()+"_"+t.getIsData()); result.setTValue(t.getData() + "_" + t.getIsData());
result.setResultFlag(t.getIsData()); result.setResultFlag(t.getIsData());
} else { } else {
//取出源所对应的相别信息 //取出源所对应的相别信息
@@ -212,29 +219,29 @@ public class DetectionServiceImpl {
.filter(x -> (type + "a").equals(x.getChannelType())) .filter(x -> (type + "a").equals(x.getChannelType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getFAmp(), dataRule); DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getFAmp(), dataRule);
result.setAValue(a.getData()+"_"+a.getIsData()); result.setAValue(a.getData() + "_" + a.getIsData());
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream() List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
.filter(x -> (type + "b").equals(x.getChannelType())) .filter(x -> (type + "b").equals(x.getChannelType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getFAmp(), dataRule); DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getFAmp(), dataRule);
result.setBValue(b.getData()+"_"+b.getIsData()); result.setBValue(b.getData() + "_" + b.getIsData());
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream() List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
.filter(x -> (type + "c").equals(x.getChannelType())) .filter(x -> (type + "c").equals(x.getChannelType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
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(c.getData()+"_"+c.getIsData()); result.setCValue(c.getData() + "_" + c.getIsData());
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData()); List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData());
if(numbers.stream().allMatch(n -> n == 1)){ if (numbers.stream().allMatch(n -> n == 1)) {
result.setResultFlag(1); result.setResultFlag(1);
} }
if(numbers.stream().allMatch(n -> n == 2)){ if (numbers.stream().allMatch(n -> n == 2)) {
result.setResultFlag(1); result.setResultFlag(2);
} }
if(numbers.stream().allMatch(n -> n == 3)){ if (numbers.contains(4)) {
result.setResultFlag(1); result.setResultFlag(4);
} }
} }
return result; return result;
@@ -251,7 +258,7 @@ public class DetectionServiceImpl {
* @param num 处理数组下标位数 * @param num 处理数组下标位数
* @return * @return
*/ */
public Boolean isHarmQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) { public AdHarmonicResult isHarmQualified(List<DevData> dev, Map<String, String> devIdMapComm, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
Map<String, Map<Integer, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num); Map<String, Map<Integer, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num);
Double fData = 1.0; Double fData = 1.0;
if (U.equals(type)) { if (U.equals(type)) {
@@ -260,25 +267,54 @@ public class DetectionServiceImpl {
if (I.equals(type)) { if (I.equals(type)) {
fData = sourceIssue.getFIn(); fData = sourceIssue.getFIn();
} }
Map<Integer, Boolean> integerBooleanMapA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData); List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData);
Map<Integer, Boolean> integerBooleanMapB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData); List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData);
Map<Integer, Boolean> integerBooleanMapC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData); List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData);
List<Boolean> list = new ArrayList<>(); AdHarmonicResult harmonicResult = new AdHarmonicResult();
list.addAll(integerBooleanMapA.values()); String[] split = dev.get(0).getId().split("_");
list.addAll(integerBooleanMapB.values()); String devID = devIdMapComm.get(split[0]);
list.addAll(integerBooleanMapC.values()); harmonicResult.setMonitorId(devID + "_" + split[1]);
if (CollUtil.isNotEmpty(list)) { harmonicResult.setScriptId(sourceIssue.getScriptId());
List<Boolean> integerList = list.stream().filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); harmonicResult.setIndex(sourceIssue.getIndex());
if (integerList.size() == list.size()) { harmonicResult.setDataType("avg");
List<Boolean> booleans = integerList.stream().distinct().collect(Collectors.toList()); reflectHarmonic("a", integerBooleanA, harmonicResult);
if (booleans.size() > 1) { reflectHarmonic("b", integerBooleanA, harmonicResult);
return false; reflectHarmonic("c", integerBooleanA, harmonicResult);
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()));
if (list.stream().allMatch(n -> n == 1)) {
harmonicResult.setResultFlag(1);
}
if (list.stream().allMatch(n -> n == 2)) {
harmonicResult.setResultFlag(2);
}
if (list.contains(4)) {
harmonicResult.setResultFlag(4);
}
return harmonicResult;
}
private void reflectHarmonic(String phase, List<DetectionData> integerBooleanA, AdHarmonicResult harmonicResult) {
Map<Integer, DetectionData> dataMap = integerBooleanA.stream().collect(Collectors.toMap(DetectionData::getNum, Function.identity()));
dataMap.forEach((key, value) -> {
try {
// 设置 id 字段
Field idField = AdHarmonicResult.class.getDeclaredField(phase + "Value" + key);
idField.setAccessible(true);
if (ObjectUtil.isNull(value.getIsData())) {
idField.set(harmonicResult, value.getData());
} else { } else {
return booleans.get(0); idField.set(harmonicResult, value.getData() + "_" + value.getIsData());
} }
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} }
}
return null; });
} }
@@ -330,8 +366,8 @@ public class DetectionServiceImpl {
* @param fData * @param fData
* @return * @return
*/ */
public Map<Integer, Boolean> harmRangeComparison(List<PqErrSysDtls> pqErrSysDtls, String type, String phase, SourceIssue sourceIssue, DictDataEnum dataRule, Map<Integer, List<Double>> devMap, Double fData) { public List<DetectionData> harmRangeComparison(List<PqErrSysDtls> pqErrSysDtls, String type, String phase, SourceIssue sourceIssue, DictDataEnum dataRule, Map<Integer, List<Double>> devMap, Double fData) {
Map<Integer, Boolean> map = new LinkedHashMap<>(); List<DetectionData> info = new ArrayList<>();
//根据谐波几次相值/额定值 //根据谐波几次相值/额定值
Map<Integer, Double> issueHarmMap = sourceIssue.getChannelList().stream() Map<Integer, Double> issueHarmMap = sourceIssue.getChannelList().stream()
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType())) .filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
@@ -352,49 +388,70 @@ public class DetectionServiceImpl {
} }
}); });
devMap.forEach((harm, harmDataList) -> { devMap.forEach((harm, harmDataList) -> {
Boolean harmBigNum = getHarmNum(dataRule, harmDataList, errSysDtlMap.get(harm), issueHarmMap.get(harm), fData); PqErrSysDtls errSysDtl = errSysDtlMap.get(harm);
if (ObjectUtil.isNotNull(harmBigNum)) { DetectionData data = new DetectionData();
map.put(harm, harmBigNum); data.setIsData(4);
} data.setNum(harm);
data.setData(harmDataList.get(0));
});
return map;
}
public Boolean getHarmNum(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, Double channelData, Double fData) {
if (ObjectUtil.isNotNull(errSysDtl)) { if (ObjectUtil.isNotNull(errSysDtl)) {
if (0 == errSysDtl.getErrorValueType()) { if (0 == errSysDtl.getErrorValueType()) {
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), fData, 0)); errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), fData, 0));
} }
Double v = issueHarmMap.get(harm);
setDetection(dataRule, harmDataList, errSysDtl, data, v);
}
info.add(data);
});
return info;
}
/**
* @param dataRule 数据处理原则
* @param harmDataList 原始数据集合
* @param errSysDtl 误差体系
* @param data 初始化原始数据
* @param v 源下发的数据
* @Description:
* @Author: wr
* @Date: 2024/12/29 18:10
*/
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 -> NumberUtil.isIn(devSubtractChannelData(x, channelData, errSysDtl.getErrorValueType()), .filter(x -> 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());
if (CollUtil.isNotEmpty(qualifiedList)) {
data.setData(qualifiedList.get(0));
switch (dataRule) { switch (dataRule) {
case AT_WILL_VALUE: case AT_WILL_VALUE:
case CP95_VALUE: case CP95_VALUE:
case AVG_VALUE: case AVG_VALUE:
if (qualifiedList.size() > 0) { if (qualifiedList.size() > 0) {
return true; data.setIsData(1);
} else {
data.setIsData(2);
} }
break; break;
case SECTION_VALUE: case SECTION_VALUE:
case Own_value: case Own_value:
if (qualifiedList.size() == harmDataList.size()) { if (qualifiedList.size() == harmDataList.size()) {
return true; data.setIsData(1);
} else {
data.setIsData(2);
} }
break; break;
} }
return false; } else {
data.setIsData(2);
} }
return null;
} }
public Map<String, Map<Integer, List<Double>>> devHarmListMap(List<DevData> dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) { public Map<String, Map<Integer, List<Double>>> devHarmListMap(List<DevData> dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
Map<String, Map<Integer, List<Double>>> map = new HashMap<>(3);
List<Integer> harmNum = sourceIssue.getChannelList().stream() List<Integer> harmNum = sourceIssue.getChannelList().stream()
.flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm())) .flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm()))
.sorted().distinct().collect(Collectors.toList()); .sorted().distinct().collect(Collectors.toList());
Map<String, Map<Integer, List<Double>>> map = new HashMap<>(3);
for (DevData devData : dev) { for (DevData devData : dev) {
DevData.SqlDataDTO fund = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst().get(); DevData.SqlDataDTO 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(); DevData.SqlDataHarmDTO harm = devData.getSqlDataHarm().stream().filter(x -> 49 == x.getNum()).collect(Collectors.toList()).stream().findFirst().get();
@@ -441,7 +498,7 @@ public class DetectionServiceImpl {
* @returnd * @returnd
*/ */
public DetectionData rangeComparisonList(List<Double> listT, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) { public DetectionData rangeComparisonList(List<Double> listT, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
DetectionData detectionData=new DetectionData(); DetectionData detectionData = new DetectionData();
detectionData.setIsData(4); detectionData.setIsData(4);
detectionData.setData(listT.get(0)); detectionData.setData(listT.get(0));
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断 //先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
@@ -456,33 +513,7 @@ public class DetectionServiceImpl {
if (0 == errSysDtl.getErrorValueType()) { if (0 == errSysDtl.getErrorValueType()) {
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0)); errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0));
} }
List<Double> qualifiedList = listT.stream().filter(x -> NumberUtil.isIn(devSubtractChannelData(x, channelData, errSysDtl.getErrorValueType()), setDetection(dataRule, listT, errSysDtl, detectionData, channelData);
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
if(CollUtil.isNotEmpty(qualifiedList)){
detectionData.setData(qualifiedList.get(0));
switch (dataRule) {
case AT_WILL_VALUE:
case CP95_VALUE:
case AVG_VALUE:
if (qualifiedList.size() > 0) {
detectionData.setIsData(1);
}else{
detectionData.setIsData(2);
}
break;
case SECTION_VALUE:
case Own_value:
if (qualifiedList.size() == listT.size()) {
detectionData.setIsData(1);
}else{
detectionData.setIsData(2);
}
break;
}
}else{
detectionData.setIsData(2);
}
} }
return detectionData; return detectionData;
} }

View File

@@ -109,6 +109,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
AdPlan plan = iAdPlanService.getById(param.getPlanId()); AdPlan plan = iAdPlanService.getById(param.getPlanId());
PqSource pqSource = pqSourceService.getById(plan.getDatasourceId()); PqSource pqSource = pqSourceService.getById(plan.getDatasourceId());
if (ObjectUtil.isNotNull(plan)) { if (ObjectUtil.isNotNull(plan)) {
plan.setErrorSysId(plan.getId());
String code = dictDataService.getDictDataById(plan.getPattern()).getCode(); String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code); DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
switch (dictDataEnumByCode) { switch (dictDataEnumByCode) {

View File

@@ -8,6 +8,7 @@ import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
import com.njcn.gather.device.err.pojo.param.PqErrSysParam; import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls; import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.device.err.service.IPqErrSysDtlsService; import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -34,7 +35,7 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
@Override @Override
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) { public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
return this.lambdaQuery().eq(PqErrSysDtls::getErrorSysId, pqErrSysId).orderBy(true, true,PqErrSysDtls::getSort).list(); return this.lambdaQuery().eq(PqErrSysDtls::getErrorSysId, pqErrSysId).orderBy(true, true, PqErrSysDtls::getSort).list();
} }
@Override @Override
@@ -75,13 +76,16 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId()) // .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
// .in(PqErrSysDtls::getErrorSysId, param.getType()) // .in(PqErrSysDtls::getErrorSysId, param.getType())
); );
//根据检测脚本id和检测序号查询出检测子项目 // PqScriptCheckDataParam script = new PqScriptCheckDataParam();
// script.setScriptId(param.getScriptId());
// script.setIndex(param.getIndex());
// script.setIsValueTypeName(false);
// List<String> valueType = pqScriptCheckDataService.getValueType(script);
// //根据检测脚本id和检测序号查询出检测子项目
// return this.list(new LambdaQueryWrapper<PqErrSysDtls>() // return this.list(new LambdaQueryWrapper<PqErrSysDtls>()
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId()) // .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
// .in(PqErrSysDtls::getErrorSysId, param.getType()) // .in(PqErrSysDtls::getScriptType, valueType)
// ); // );
// return new ArrayList<>();
} }
} }

View File

@@ -14,7 +14,7 @@ public class PqScriptCheckDataParam {
@ApiModelProperty("总检测脚本中的测试项序号") @ApiModelProperty("总检测脚本中的测试项序号")
private Integer index; private Integer index;
@ApiModelProperty("检测指标类型(true:展示名称 false展示id 默认false)") @ApiModelProperty("检测指标类型(true:code(I$real) false展示id 默认false)")
private Boolean isValueTypeName=false; private Boolean isValueTypeName=false;
} }

View File

@@ -39,7 +39,7 @@ public class DataDealController extends BaseController {
adHarmonicResult.setAdType("aaaa"); adHarmonicResult.setAdType("aaaa");
adHarmonicResult.setMonitorId("ss"); adHarmonicResult.setMonitorId("ss");
adHarmonicResult.setScriptDtlsId("ddd"); adHarmonicResult.setScriptId("ddd");
adHarmonicResult.setTimeId(LocalDateTime.now()); adHarmonicResult.setTimeId(LocalDateTime.now());
list2.add(adHarmonicResult); list2.add(adHarmonicResult);
@@ -48,7 +48,7 @@ public class DataDealController extends BaseController {
adHarmonicResult2.setAdType("aaaabb"); adHarmonicResult2.setAdType("aaaabb");
adHarmonicResult2.setMonitorId("ssbb"); adHarmonicResult2.setMonitorId("ssbb");
adHarmonicResult2.setScriptDtlsId("dddbb"); adHarmonicResult2.setScriptId("dddbb");
adHarmonicResult2.setTimeId(LocalDateTime.now()); adHarmonicResult2.setTimeId(LocalDateTime.now());
list2.add(adHarmonicResult2); list2.add(adHarmonicResult2);

View File

@@ -36,6 +36,7 @@ public class AdHarmonicResult {
*/ */
private String scriptId; private String scriptId;
private Integer index; private Integer index;
/** /**