|
|
|
|
@@ -4,15 +4,18 @@ package com.njcn.gather.detection.service.impl;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import com.njcn.gather.detection.pojo.po.DevData;
|
|
|
|
|
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
|
|
|
|
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
|
|
|
|
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
|
|
|
|
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
|
|
|
|
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
|
|
|
|
|
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
|
|
|
|
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
|
|
|
|
|
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
|
|
|
|
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
|
|
|
|
import com.njcn.gather.storage.service.DetectionDataDealService;
|
|
|
|
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -34,6 +37,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
public class DetectionServiceImpl {
|
|
|
|
|
|
|
|
|
|
public final IPqErrSysDtlsService pqErrSysDtlsService;
|
|
|
|
|
public final IPqScriptCheckDataService pqScriptCheckDataService;
|
|
|
|
|
public final DetectionDataDealService detectionDataDealService;
|
|
|
|
|
|
|
|
|
|
public final String TYPE_A = "A";
|
|
|
|
|
public final String TYPE_B = "B";
|
|
|
|
|
public final String TYPE_C = "C";
|
|
|
|
|
@@ -41,6 +47,9 @@ public class DetectionServiceImpl {
|
|
|
|
|
public final String U = "U";
|
|
|
|
|
public final String I = "I";
|
|
|
|
|
public final String F = "F";
|
|
|
|
|
public final String P = "P";
|
|
|
|
|
public final String MAG = "MAG";
|
|
|
|
|
public final String DUR = "DUR";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -50,8 +59,9 @@ public class DetectionServiceImpl {
|
|
|
|
|
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, Integer> stringBooleanMap = new LinkedHashMap<>();
|
|
|
|
|
String code="1";
|
|
|
|
|
devDataMap.forEach(((key, value) -> {
|
|
|
|
|
stringBooleanMap.put(key, DetectionIndexProcessing(value, errorSysId, devIdMapComm, dataRule, issue));
|
|
|
|
|
stringBooleanMap.put(key, DetectionIndexProcessing(value,code, errorSysId, devIdMapComm, dataRule, issue));
|
|
|
|
|
}));
|
|
|
|
|
return stringBooleanMap;
|
|
|
|
|
}
|
|
|
|
|
@@ -66,7 +76,7 @@ public class DetectionServiceImpl {
|
|
|
|
|
* @param sourceIssue 源下发的参数
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Integer DetectionIndexProcessing(List<DevData> dev, String errorSysId, Map<String, String> devIdMapComm, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
|
|
|
|
public Integer DetectionIndexProcessing(List<DevData> dev,String code, String errorSysId, Map<String, String> devIdMapComm, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
|
|
|
|
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
|
|
|
|
|
param.setIndex(sourceIssue.getIndex());
|
|
|
|
|
param.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
@@ -77,72 +87,407 @@ public class DetectionServiceImpl {
|
|
|
|
|
* 频率
|
|
|
|
|
*/
|
|
|
|
|
case "FREQ":
|
|
|
|
|
return isQualified(dev, devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ").getResultFlag();
|
|
|
|
|
AdNonHarmonicResult freq = isQualified(dev, devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(freq),code);
|
|
|
|
|
return freq.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 电压
|
|
|
|
|
*/
|
|
|
|
|
case "V":
|
|
|
|
|
//System.out.println(isQualified(dev, devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ"));
|
|
|
|
|
return isQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS").getResultFlag();
|
|
|
|
|
AdNonHarmonicResult vrms = isQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(vrms),code);
|
|
|
|
|
return vrms.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 电流
|
|
|
|
|
*/
|
|
|
|
|
case "I":
|
|
|
|
|
return isQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS").getResultFlag();
|
|
|
|
|
AdNonHarmonicResult irms = isQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(irms),code);
|
|
|
|
|
return irms.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 谐波电压
|
|
|
|
|
*/
|
|
|
|
|
case "HV":
|
|
|
|
|
return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag();
|
|
|
|
|
AdHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, 2);
|
|
|
|
|
detectionDataDealService.acceptAdResult(Arrays.asList(harmV),code);
|
|
|
|
|
return harmV.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 谐波电流
|
|
|
|
|
*/
|
|
|
|
|
case "HI":
|
|
|
|
|
return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 谐波有功功率
|
|
|
|
|
*/
|
|
|
|
|
case "HP":
|
|
|
|
|
break;
|
|
|
|
|
AdHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, 2);
|
|
|
|
|
detectionDataDealService.acceptAdResult(Arrays.asList(harmI),code);
|
|
|
|
|
return harmI.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 间谐波电压
|
|
|
|
|
*/
|
|
|
|
|
case "HSV":
|
|
|
|
|
return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, DictDataEnum.AT_WILL_VALUE, 1).getResultFlag();
|
|
|
|
|
AdHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, 1);
|
|
|
|
|
detectionDataDealService.acceptAdResult(Arrays.asList(harmInV),code);
|
|
|
|
|
return harmInV.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 间谐波电流
|
|
|
|
|
*/
|
|
|
|
|
case "HSI":
|
|
|
|
|
return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, DictDataEnum.AT_WILL_VALUE, 1).getResultFlag();
|
|
|
|
|
AdHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, 1);
|
|
|
|
|
detectionDataDealService.acceptAdResult(Arrays.asList(harmInI),code);
|
|
|
|
|
return harmInI.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 三相电压不平衡度
|
|
|
|
|
*/
|
|
|
|
|
case "IMBV":
|
|
|
|
|
break;
|
|
|
|
|
AdNonHarmonicResult vUnban = isUnBalanceOrFlickerQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "V_UNBAN");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(vUnban),code);
|
|
|
|
|
return vUnban.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 三相电流不平衡度
|
|
|
|
|
*/
|
|
|
|
|
case "IMBA":
|
|
|
|
|
break;
|
|
|
|
|
AdNonHarmonicResult iUnban = isUnBalanceOrFlickerQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "I_UNBAN");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(iUnban),code);
|
|
|
|
|
return iUnban.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 谐波有功功率
|
|
|
|
|
*/
|
|
|
|
|
case "HP":
|
|
|
|
|
AdHarmonicResult harmP = isHarmQualified(dev, devIdMapComm, pqErrSysDtls, P, sourceIssue, dataRule, 2);
|
|
|
|
|
detectionDataDealService.acceptAdResult(Arrays.asList(harmP),code);
|
|
|
|
|
return harmP.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 功率
|
|
|
|
|
*/
|
|
|
|
|
case "P":
|
|
|
|
|
break;
|
|
|
|
|
return 4;
|
|
|
|
|
/**
|
|
|
|
|
* 闪变
|
|
|
|
|
*/
|
|
|
|
|
case "F":
|
|
|
|
|
break;
|
|
|
|
|
AdNonHarmonicResult pst = isUnBalanceOrFlickerQualified(dev, devIdMapComm, pqErrSysDtls, null, sourceIssue, dataRule, "PST");
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(pst),code);
|
|
|
|
|
return pst.getResultFlag();
|
|
|
|
|
/**
|
|
|
|
|
* 暂态
|
|
|
|
|
*/
|
|
|
|
|
case "VOLTAGE":
|
|
|
|
|
break;
|
|
|
|
|
return isVoltageQualified(dev, devIdMapComm, pqErrSysDtls, sourceIssue, dataRule,code);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(非谐波类型)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param code 源下发的装置通道code(->desc)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
Double fData = 1.0;
|
|
|
|
|
if (U.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFUn();
|
|
|
|
|
}
|
|
|
|
|
if (I.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFIn();
|
|
|
|
|
}
|
|
|
|
|
if (F.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFFreq();
|
|
|
|
|
}
|
|
|
|
|
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
|
|
|
|
String[] split = dev.get(0).getId().split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
result.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
result.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
result.setIndex(sourceIssue.getIndex());
|
|
|
|
|
result.setDataType("avg");
|
|
|
|
|
if (map.containsKey(TYPE_T)) {
|
|
|
|
|
DetectionData t = rangeComparisonList(map.get(TYPE_T), pqErrSysDtls, fData, 1.0, dataRule);
|
|
|
|
|
result.setTValue(t.getData() + "_" + t.getIsData());
|
|
|
|
|
result.setResultFlag(t.getIsData());
|
|
|
|
|
} else {
|
|
|
|
|
//取出源所对应的相别信息
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "a").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setAValue(a.getData() + "_" + a.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "b").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setBValue(b.getData() + "_" + b.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "c").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setCValue(c.getData() + "_" + c.getIsData());
|
|
|
|
|
|
|
|
|
|
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData()).stream().distinct().collect(Collectors.toList());
|
|
|
|
|
return getAdNonHarmonicResult(result, numbers);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(谐波类型)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param num 处理数组下标位数
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public AdHarmonicResult isHarmQualified(List<DevData> dev,
|
|
|
|
|
Map<String, String> devIdMapComm,
|
|
|
|
|
List<PqErrSysDtls> pqErrSysDtls,
|
|
|
|
|
String type,
|
|
|
|
|
SourceIssue sourceIssue,
|
|
|
|
|
DictDataEnum dataRule,
|
|
|
|
|
Integer num) {
|
|
|
|
|
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num);
|
|
|
|
|
Double fData = 1.0;
|
|
|
|
|
if (U.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFUn();
|
|
|
|
|
}
|
|
|
|
|
if (I.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFIn();
|
|
|
|
|
}
|
|
|
|
|
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
|
|
|
|
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
|
|
|
|
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
|
|
|
|
AdHarmonicResult harmonicResult = new AdHarmonicResult();
|
|
|
|
|
String[] split = dev.get(0).getId().split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
harmonicResult.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
harmonicResult.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
harmonicResult.setIndex(sourceIssue.getIndex());
|
|
|
|
|
harmonicResult.setAdType(pqErrSysDtls.get(0).getScriptType());
|
|
|
|
|
harmonicResult.setDataType("avg");
|
|
|
|
|
reflectHarmonic("a", integerBooleanA, harmonicResult);
|
|
|
|
|
reflectHarmonic("b", integerBooleanA, harmonicResult);
|
|
|
|
|
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()));
|
|
|
|
|
List<Integer> numbers = list.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
return getAdHarmonicResult(harmonicResult, numbers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(三相不平衡和闪变)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public AdNonHarmonicResult isUnBalanceOrFlickerQualified(List<DevData> dev,
|
|
|
|
|
Map<String, String> devIdMapComm,
|
|
|
|
|
List<PqErrSysDtls> pqErrSysDtls,
|
|
|
|
|
String type,
|
|
|
|
|
SourceIssue sourceIssue,
|
|
|
|
|
DictDataEnum dataRule,
|
|
|
|
|
String code) {
|
|
|
|
|
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
|
|
|
|
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
|
|
|
|
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
|
|
|
|
);
|
|
|
|
|
Map<String, List<Double>> map = devListMap(dev, dataRule, code);
|
|
|
|
|
Double fData = 1.0;
|
|
|
|
|
if (U.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFUn();
|
|
|
|
|
}
|
|
|
|
|
if (I.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFIn();
|
|
|
|
|
}
|
|
|
|
|
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
|
|
|
|
String[] split = dev.get(0).getId().split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
result.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
result.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
result.setIndex(sourceIssue.getIndex());
|
|
|
|
|
result.setDataType("avg");
|
|
|
|
|
//取出源所对应的相别信息
|
|
|
|
|
List<PqScriptCheckData> channelTypeAList = checkData.stream()
|
|
|
|
|
.filter(x -> TYPE_A.equals(x.getPhase()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getValue(), dataRule);
|
|
|
|
|
result.setAValue(a.getData() + "_" + a.getIsData());
|
|
|
|
|
|
|
|
|
|
List<PqScriptCheckData> channelTypeBList = checkData.stream()
|
|
|
|
|
.filter(x -> TYPE_B.equals(x.getPhase()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getValue(), dataRule);
|
|
|
|
|
result.setBValue(b.getData() + "_" + b.getIsData());
|
|
|
|
|
|
|
|
|
|
List<PqScriptCheckData> channelTypeCList = checkData.stream()
|
|
|
|
|
.filter(x -> TYPE_C.equals(x.getPhase()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getValue(), dataRule);
|
|
|
|
|
result.setCValue(c.getData() + "_" + c.getIsData());
|
|
|
|
|
|
|
|
|
|
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData());
|
|
|
|
|
return getAdNonHarmonicResult(result, numbers);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param code 计划code
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Integer isVoltageQualified(List<DevData> dev,
|
|
|
|
|
Map<String, String> devIdMapComm,
|
|
|
|
|
List<PqErrSysDtls> pqErrSysDtls,
|
|
|
|
|
SourceIssue sourceIssue,
|
|
|
|
|
DictDataEnum dataRule,
|
|
|
|
|
String code
|
|
|
|
|
) {
|
|
|
|
|
//电压幅值处理数据
|
|
|
|
|
Map<String, List<Double>> mag = devListMap(dev, dataRule, MAG);
|
|
|
|
|
//暂降时间处理数据
|
|
|
|
|
Map<String, List<Double>> dur = devListMap(dev, dataRule, DUR);
|
|
|
|
|
//理论上根据检测脚本,能知道误差体系,可以知道多个误差体系
|
|
|
|
|
List<PqErrSysDtls> magErrList = pqErrSysDtls.stream().filter(x -> MAG.equals(x.getScriptType())).collect(Collectors.toList());
|
|
|
|
|
List<PqErrSysDtls> durErrList = pqErrSysDtls.stream().filter(x -> DUR.equals(x.getScriptType())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
AdNonHarmonicResult magResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, mag, magErrList, sourceIssue.getFUn(), MAG);
|
|
|
|
|
AdNonHarmonicResult durResult = voltageResult(dev.get(0).getId(), devIdMapComm, sourceIssue, dataRule, dur, durErrList, sourceIssue.getFFreq(), DUR);
|
|
|
|
|
detectionDataDealService.acceptAdNonResult(Arrays.asList(magResult,magResult),code);
|
|
|
|
|
List<Integer> numbers = Arrays.asList(magResult.getResultFlag(), durResult.getResultFlag()).stream().distinct().collect(Collectors.toList());
|
|
|
|
|
if (numbers.contains(4)) {
|
|
|
|
|
return 4;
|
|
|
|
|
} else if (numbers.contains(2)) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param devId 装置监测点id(ip_通道)
|
|
|
|
|
* @param devIdMapComm ip_通道,装置名称
|
|
|
|
|
* @param sourceIssue 源下发信息
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param mag
|
|
|
|
|
* @param magErrList
|
|
|
|
|
* @param fData
|
|
|
|
|
* @Description:
|
|
|
|
|
* @return: com.njcn.gather.storage.pojo.po.AdNonHarmonicResult
|
|
|
|
|
* @Author: wr
|
|
|
|
|
* @Date: 2024/12/30 14:54
|
|
|
|
|
*/
|
|
|
|
|
private AdNonHarmonicResult voltageResult(String devId,
|
|
|
|
|
Map<String, String> devIdMapComm,
|
|
|
|
|
SourceIssue sourceIssue,
|
|
|
|
|
DictDataEnum dataRule,
|
|
|
|
|
Map<String, List<Double>> mag,
|
|
|
|
|
List<PqErrSysDtls> magErrList,
|
|
|
|
|
Double fData,
|
|
|
|
|
String dur
|
|
|
|
|
) {
|
|
|
|
|
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
|
|
|
|
String[] split = devId.split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
result.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
result.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
result.setIndex(sourceIssue.getIndex());
|
|
|
|
|
result.setDataType("avg");
|
|
|
|
|
//取出源所对应的相别信息
|
|
|
|
|
List<SourceIssue.ChannelListDTO> 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).getFAmp();
|
|
|
|
|
}
|
|
|
|
|
DetectionData a = rangeComparisonList(mag.get(TYPE_A), magErrList, fData, retainATime, dataRule);
|
|
|
|
|
result.setAValue(a.getData() + "_" + a.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> 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).getFAmp();
|
|
|
|
|
}
|
|
|
|
|
DetectionData b = rangeComparisonList(mag.get(TYPE_B), magErrList, fData, retainBTime, dataRule);
|
|
|
|
|
result.setBValue(b.getData() + "_" + b.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> 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).getFAmp();
|
|
|
|
|
}
|
|
|
|
|
DetectionData c = rangeComparisonList(mag.get(TYPE_C), magErrList, fData, retainCTime, dataRule);
|
|
|
|
|
result.setCValue(c.getData() + "_" + c.getIsData());
|
|
|
|
|
|
|
|
|
|
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData()).stream().distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return getAdNonHarmonicResult(result, numbers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AdNonHarmonicResult getAdNonHarmonicResult(AdNonHarmonicResult result, List<Integer> numbers) {
|
|
|
|
|
if (numbers.size() > 2) {
|
|
|
|
|
result.setResultFlag(4);
|
|
|
|
|
} else if (numbers.size() > 1) {
|
|
|
|
|
if (numbers.contains(4)) {
|
|
|
|
|
result.setResultFlag(4);
|
|
|
|
|
} else if (numbers.contains(2)) {
|
|
|
|
|
result.setResultFlag(2);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result.setResultFlag(numbers.get(0));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AdHarmonicResult getAdHarmonicResult(AdHarmonicResult result, List<Integer> numbers) {
|
|
|
|
|
if (numbers.size() > 2) {
|
|
|
|
|
result.setResultFlag(4);
|
|
|
|
|
} else if (numbers.size() > 1) {
|
|
|
|
|
if (numbers.contains(4)) {
|
|
|
|
|
result.setResultFlag(4);
|
|
|
|
|
} else if (numbers.contains(2)) {
|
|
|
|
|
result.setResultFlag(2);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result.setResultFlag(numbers.get(0));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 处理非谐波类型取值
|
|
|
|
|
*
|
|
|
|
|
@@ -209,124 +554,6 @@ public class DetectionServiceImpl {
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(非谐波类型)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param code 源下发的装置通道code(->desc)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
Double fData = 1.0;
|
|
|
|
|
if (U.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFUn();
|
|
|
|
|
}
|
|
|
|
|
if (I.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFIn();
|
|
|
|
|
}
|
|
|
|
|
if (F.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFFreq();
|
|
|
|
|
}
|
|
|
|
|
AdNonHarmonicResult result = new AdNonHarmonicResult();
|
|
|
|
|
String[] split = dev.get(0).getId().split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
result.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
result.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
result.setIndex(sourceIssue.getIndex());
|
|
|
|
|
result.setDataType("avg");
|
|
|
|
|
if (map.containsKey(TYPE_T)) {
|
|
|
|
|
DetectionData t = rangeComparisonList(map.get(TYPE_T), pqErrSysDtls, fData, 1.0, dataRule);
|
|
|
|
|
result.setTValue(t.getData() + "_" + t.getIsData());
|
|
|
|
|
result.setResultFlag(t.getIsData());
|
|
|
|
|
} else {
|
|
|
|
|
//取出源所对应的相别信息
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "a").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData a = rangeComparisonList(map.get(TYPE_A), pqErrSysDtls, fData, channelTypeAList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setAValue(a.getData() + "_" + a.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "b").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData b = rangeComparisonList(map.get(TYPE_B), pqErrSysDtls, fData, channelTypeBList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setBValue(b.getData() + "_" + b.getIsData());
|
|
|
|
|
|
|
|
|
|
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + "c").equals(x.getChannelType()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
DetectionData c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getFAmp(), dataRule);
|
|
|
|
|
result.setCValue(c.getData() + "_" + c.getIsData());
|
|
|
|
|
|
|
|
|
|
List<Integer> numbers = Arrays.asList(a.getIsData(), b.getIsData(), a.getIsData());
|
|
|
|
|
if (numbers.stream().allMatch(n -> n == 1)) {
|
|
|
|
|
result.setResultFlag(1);
|
|
|
|
|
}
|
|
|
|
|
if (numbers.stream().allMatch(n -> n == 2)) {
|
|
|
|
|
result.setResultFlag(2);
|
|
|
|
|
}
|
|
|
|
|
if (numbers.contains(4)) {
|
|
|
|
|
result.setResultFlag(4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(谐波类型)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @param num 处理数组下标位数
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public AdHarmonicResult isHarmQualified(List<DevData> dev, Map<String, String> devIdMapComm, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
|
|
|
|
|
Map<String, Map<Double, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num);
|
|
|
|
|
Double fData = 1.0;
|
|
|
|
|
if (U.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFUn();
|
|
|
|
|
}
|
|
|
|
|
if (I.equals(type)) {
|
|
|
|
|
fData = sourceIssue.getFIn();
|
|
|
|
|
}
|
|
|
|
|
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData);
|
|
|
|
|
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData);
|
|
|
|
|
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData);
|
|
|
|
|
AdHarmonicResult harmonicResult = new AdHarmonicResult();
|
|
|
|
|
String[] split = dev.get(0).getId().split("_");
|
|
|
|
|
String devID = devIdMapComm.get(split[0]);
|
|
|
|
|
harmonicResult.setMonitorId(devID + "_" + split[1]);
|
|
|
|
|
harmonicResult.setScriptId(sourceIssue.getScriptId());
|
|
|
|
|
harmonicResult.setIndex(sourceIssue.getIndex());
|
|
|
|
|
harmonicResult.setDataType("avg");
|
|
|
|
|
reflectHarmonic("a", integerBooleanA, harmonicResult);
|
|
|
|
|
reflectHarmonic("b", integerBooleanA, harmonicResult);
|
|
|
|
|
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<Double, DetectionData> dataMap = integerBooleanA.stream().collect(Collectors.toMap(DetectionData::getNum, Function.identity()));
|
|
|
|
|
dataMap.forEach((key, value) -> {
|
|
|
|
|
@@ -348,45 +575,6 @@ public class DetectionServiceImpl {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(闪变)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean isFlickerQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态)
|
|
|
|
|
*
|
|
|
|
|
* @param dev 处理过后的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type (电压还是电流)
|
|
|
|
|
* @param sourceIssue 源下发所对应的参数
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Boolean isVoltageQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
|
|
|
|
//电压幅值处理数据
|
|
|
|
|
Map<String, List<Double>> MAG = devListMap(dev, dataRule, "MAG");
|
|
|
|
|
//暂降时间处理数据
|
|
|
|
|
Map<String, List<Double>> DUR = devListMap(dev, dataRule, "DUR");
|
|
|
|
|
//理论上根据检测脚本,能知道误差体系,可以知道多个误差体系
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param type U,I
|
|
|
|
|
@@ -397,13 +585,37 @@ public class DetectionServiceImpl {
|
|
|
|
|
* @param fData
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<DetectionData> harmRangeComparison(List<PqErrSysDtls> pqErrSysDtls, String type, String phase, SourceIssue sourceIssue, DictDataEnum dataRule, Map<Double, List<Double>> devMap, Double fData) {
|
|
|
|
|
public List<DetectionData> harmRangeComparison(List<PqErrSysDtls> pqErrSysDtls,
|
|
|
|
|
String type,
|
|
|
|
|
String phase,
|
|
|
|
|
SourceIssue sourceIssue,
|
|
|
|
|
DictDataEnum dataRule,
|
|
|
|
|
Map<Double, List<Double>> devMap,
|
|
|
|
|
Double fData, Integer num) {
|
|
|
|
|
List<DetectionData> info = new ArrayList<>();
|
|
|
|
|
//根据谐波几次相值/额定值
|
|
|
|
|
Map<Double, Double> issueHarmMap = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
|
|
|
|
.flatMap(x -> x.getHarmList().stream())
|
|
|
|
|
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFApm()));
|
|
|
|
|
Map<Double, Double> issueHarmMap;
|
|
|
|
|
if (P.equals(type)) {
|
|
|
|
|
List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
|
|
|
|
.eq(PqScriptCheckData::getIndex, sourceIssue.getIndex())
|
|
|
|
|
.eq(PqScriptCheckData::getPhase, phase)
|
|
|
|
|
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
|
|
|
|
);
|
|
|
|
|
issueHarmMap = checkData.stream().collect(Collectors.toMap(PqScriptCheckData::getHarmNum, PqScriptCheckData::getValue));
|
|
|
|
|
} else {
|
|
|
|
|
if (1 == num) {
|
|
|
|
|
issueHarmMap = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
|
|
|
|
.flatMap(x -> x.getInharmList().stream())
|
|
|
|
|
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> x.getFApm()));
|
|
|
|
|
} else {
|
|
|
|
|
issueHarmMap = sourceIssue.getChannelList().stream()
|
|
|
|
|
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
|
|
|
|
.flatMap(x -> x.getHarmList().stream())
|
|
|
|
|
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFApm()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
|
|
|
|
|
issueHarmMap.forEach((key, value) -> {
|
|
|
|
|
//获得误差体系
|
|
|
|
|
@@ -486,7 +698,7 @@ public class DetectionServiceImpl {
|
|
|
|
|
.flatMap(x -> x.getInharmList().stream().map(f -> f.getInharm()))
|
|
|
|
|
.sorted().distinct().collect(Collectors.toList());
|
|
|
|
|
} else {
|
|
|
|
|
harmNum = sourceIssue.getChannelList().stream()
|
|
|
|
|
harmNum = sourceIssue.getChannelList().stream()
|
|
|
|
|
.flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm()))
|
|
|
|
|
.sorted().distinct().collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
@@ -528,17 +740,17 @@ public class DetectionServiceImpl {
|
|
|
|
|
/**
|
|
|
|
|
* 处理数据是否合格
|
|
|
|
|
*
|
|
|
|
|
* @param listT 原始的数据
|
|
|
|
|
* @param list 原始的数据
|
|
|
|
|
* @param pqErrSysDtls 误差体系
|
|
|
|
|
* @param data 源下发的额定信息(额定电压,额定电流)
|
|
|
|
|
* @param channelData 源下发的通道信息的值包括 {Ua, Ub, Uc, Ux, Ia, Ib, Ic, Ix ,NULL}
|
|
|
|
|
* @param dataRule 数据处理原则
|
|
|
|
|
* @returnd
|
|
|
|
|
*/
|
|
|
|
|
public DetectionData rangeComparisonList(List<Double> listT, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
|
|
|
|
public DetectionData rangeComparisonList(List<Double> list, List<PqErrSysDtls> pqErrSysDtls, Double data, Double channelData, DictDataEnum dataRule) {
|
|
|
|
|
DetectionData detectionData = new DetectionData();
|
|
|
|
|
detectionData.setIsData(4);
|
|
|
|
|
detectionData.setData(listT.get(0));
|
|
|
|
|
detectionData.setData(list.get(0));
|
|
|
|
|
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
|
|
|
|
|
//获得误差体系
|
|
|
|
|
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), data, x.getConditionType()),
|
|
|
|
|
@@ -548,10 +760,42 @@ public class DetectionServiceImpl {
|
|
|
|
|
channelData)).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(errSysDtls)) {
|
|
|
|
|
PqErrSysDtls errSysDtl = errSysDtls.get(0);
|
|
|
|
|
if (0 == errSysDtl.getErrorValueType()) {
|
|
|
|
|
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0));
|
|
|
|
|
if (DUR.equals(errSysDtl.getScriptType())) {
|
|
|
|
|
List<Double> 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());
|
|
|
|
|
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() == qualifiedList.size()) {
|
|
|
|
|
detectionData.setIsData(1);
|
|
|
|
|
} else {
|
|
|
|
|
detectionData.setIsData(2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
detectionData.setIsData(2);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (0 == errSysDtl.getErrorValueType()) {
|
|
|
|
|
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0));
|
|
|
|
|
}
|
|
|
|
|
setDetection(dataRule, list, errSysDtl, detectionData, channelData);
|
|
|
|
|
}
|
|
|
|
|
setDetection(dataRule, listT, errSysDtl, detectionData, channelData);
|
|
|
|
|
}
|
|
|
|
|
return detectionData;
|
|
|
|
|
}
|
|
|
|
|
@@ -624,12 +868,20 @@ public class DetectionServiceImpl {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Double multiply(Double devData, Double channelData, Integer type) {
|
|
|
|
|
if (0 == type) {
|
|
|
|
|
return BigDecimal.valueOf(devData).multiply(BigDecimal.valueOf(channelData))
|
|
|
|
|
.setScale(7, RoundingMode.HALF_UP).doubleValue();
|
|
|
|
|
} else {
|
|
|
|
|
return BigDecimal.valueOf(devData).doubleValue();
|
|
|
|
|
if (ObjectUtil.isNotNull(type)) {
|
|
|
|
|
if (0 == type) {
|
|
|
|
|
return BigDecimal.valueOf(devData).multiply(BigDecimal.valueOf(channelData))
|
|
|
|
|
.setScale(7, RoundingMode.HALF_UP).doubleValue();
|
|
|
|
|
} else {
|
|
|
|
|
if (ObjectUtil.isNotNull(devData)) {
|
|
|
|
|
return BigDecimal.valueOf(devData).doubleValue();
|
|
|
|
|
} else {
|
|
|
|
|
return devData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return devData;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -653,13 +905,13 @@ public class DetectionServiceImpl {
|
|
|
|
|
for (Double i : harmNum) {
|
|
|
|
|
if (integerListMap.containsKey(i)) {
|
|
|
|
|
if (type.equals("A")) {
|
|
|
|
|
integerListMap.get(num!=1?i:i+0.5).add(multiply(harm.getList().getA().get((int) (i - num)), fund));
|
|
|
|
|
integerListMap.get(num != 1 ? i : i + 0.5).add(multiply(harm.getList().getA().get((int) (i - num)), fund));
|
|
|
|
|
}
|
|
|
|
|
if (type.equals("B")) {
|
|
|
|
|
integerListMap.get(num!=1?i:i+0.5).add(multiply(harm.getList().getB().get((int) (i - num)), fund));
|
|
|
|
|
integerListMap.get(num != 1 ? i : i + 0.5).add(multiply(harm.getList().getB().get((int) (i - num)), fund));
|
|
|
|
|
}
|
|
|
|
|
if (type.equals("C")) {
|
|
|
|
|
integerListMap.get(num!=1?i:i+0.5).add(multiply(harm.getList().getC().get((int) (i - num)), fund));
|
|
|
|
|
integerListMap.get(num != 1 ? i : i + 0.5).add(multiply(harm.getList().getC().get((int) (i - num)), fund));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -676,7 +928,7 @@ public class DetectionServiceImpl {
|
|
|
|
|
if (type.equals("C")) {
|
|
|
|
|
integerList.add(multiply(harm.getList().getC().get((int) (i - num)), fund));
|
|
|
|
|
}
|
|
|
|
|
integerListMap.put(num!=1?i:i+0.5, integerList);
|
|
|
|
|
integerListMap.put(num != 1 ? i : i + 0.5, integerList);
|
|
|
|
|
}
|
|
|
|
|
map.put(type, integerListMap);
|
|
|
|
|
}
|
|
|
|
|
|