微调
This commit is contained in:
@@ -70,6 +70,10 @@ public class SocketDevResponseService {
|
||||
* 装置名称
|
||||
*/
|
||||
Map<String, String> devNameMapComm = new HashMap<>();
|
||||
/**
|
||||
* 装置id
|
||||
*/
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
/**
|
||||
* 成功结束的装置
|
||||
*/
|
||||
@@ -426,7 +430,7 @@ public class SocketDevResponseService {
|
||||
if (successComm.size() == monitorIdListComm.size()) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceTarget(socketDataMsg.getRequestId());
|
||||
System.out.println("获取sourceIssue"+sourceIssue);
|
||||
Map<String, Integer> flag = detectionServiceImpl.text(devDataList, sourceIssue, DictDataEnum.AT_WILL_VALUE);
|
||||
Map<String, Integer> flag = detectionServiceImpl.text(devDataList,devIdMapComm ,sourceIssue, DictDataEnum.AT_WILL_VALUE);
|
||||
System.out.println(flag);
|
||||
|
||||
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();
|
||||
@@ -676,6 +680,7 @@ public class SocketDevResponseService {
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
this.devNameMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
|
||||
this.devIdMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.SourceIssue;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -41,22 +43,11 @@ public class DetectionServiceImpl {
|
||||
* 开始处理指标类型
|
||||
* 一共20组数据,开始处理格式
|
||||
*/
|
||||
public Map<String, Integer> text(List<DevData> dev, SourceIssue issue, DictDataEnum dataRule) {
|
||||
public Map<String, Integer> text(List<DevData> dev,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<>();
|
||||
devDataMap.forEach(((key, value) -> {
|
||||
Integer num;
|
||||
Boolean b = DetectionIndexProcessing(value, dataRule, issue);
|
||||
if (ObjectUtil.isNotNull(b)) {
|
||||
if (b) {
|
||||
num = 1;
|
||||
} else {
|
||||
num = 2;
|
||||
}
|
||||
} else {
|
||||
num = 4;
|
||||
}
|
||||
stringBooleanMap.put(key, num);
|
||||
stringBooleanMap.put(key, DetectionIndexProcessing(value,devIdMapComm, dataRule, issue));
|
||||
}));
|
||||
return stringBooleanMap;
|
||||
}
|
||||
@@ -71,7 +62,7 @@ public class DetectionServiceImpl {
|
||||
* @param sourceIssue 源下发的参数
|
||||
* @return
|
||||
*/
|
||||
public Boolean DetectionIndexProcessing(List<DevData> dev, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
||||
public Integer DetectionIndexProcessing(List<DevData> dev,Map<String, String> devIdMapComm, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
||||
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
|
||||
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param);
|
||||
switch ("V") {
|
||||
@@ -79,22 +70,23 @@ public class DetectionServiceImpl {
|
||||
* 频率
|
||||
*/
|
||||
case "FREQ":
|
||||
return isQualified(dev, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ");
|
||||
return isQualified(dev,devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ").getResultFlag();
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
case "V":
|
||||
return isQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS");
|
||||
System.out.println(isQualified(dev,devIdMapComm, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ"));
|
||||
return isQualified(dev,devIdMapComm, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS").getResultFlag();
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
case "I":
|
||||
return isQualified(dev, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS");
|
||||
return isQualified(dev,devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS").getResultFlag();
|
||||
/**
|
||||
* 谐波类
|
||||
*/
|
||||
case "H":
|
||||
return isHarmQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule, 2);
|
||||
break;
|
||||
/**
|
||||
* 功率
|
||||
*/
|
||||
@@ -104,8 +96,8 @@ public class DetectionServiceImpl {
|
||||
* 闪变
|
||||
*/
|
||||
case "F":
|
||||
|
||||
/**
|
||||
break;
|
||||
/**
|
||||
* 暂态
|
||||
*/
|
||||
case "VOLTAGE":
|
||||
@@ -191,7 +183,7 @@ public class DetectionServiceImpl {
|
||||
* @param dataRule 数据处理原则
|
||||
* @return
|
||||
*/
|
||||
public Boolean isQualified(List<DevData> dev, 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);
|
||||
Double fData = 1.0;
|
||||
if (U.equals(type)) {
|
||||
@@ -203,31 +195,49 @@ public class DetectionServiceImpl {
|
||||
if (F.equals(type)) {
|
||||
fData = sourceIssue.getFFreq();
|
||||
}
|
||||
AdNonHarmonicResult result=new AdNonHarmonicResult();
|
||||
String[] split = dev.get(0).getId().split("_");
|
||||
String devID = devIdMapComm.get(split);
|
||||
result.setMonitorId(devID+"_"+split[1]);
|
||||
result.setScriptId(sourceIssue.getScriptId());
|
||||
result.setIndex(sourceIssue.getIndex());
|
||||
result.setDataType("avg");
|
||||
if (map.containsKey(TYPE_T)) {
|
||||
return 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.setResultFlag(t.getIsData());
|
||||
} else {
|
||||
//取出源所对应的相别信息
|
||||
List<SourceIssue.ChannelListDTO> channelTypeAList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + "a").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
Boolean 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());
|
||||
|
||||
List<SourceIssue.ChannelListDTO> channelTypeBList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + "b").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
Boolean 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());
|
||||
|
||||
|
||||
List<SourceIssue.ChannelListDTO> channelTypeCList = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + "c").equals(x.getChannelType()))
|
||||
.collect(Collectors.toList());
|
||||
Boolean c = rangeComparisonList(map.get(TYPE_C), pqErrSysDtls, fData, channelTypeCList.get(0).getFAmp(), dataRule);
|
||||
if (ObjectUtil.isAllNotEmpty(a, b, c)) {
|
||||
return a && b && c;
|
||||
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 (ObjectUtil.isAllEmpty(a, b, c)) {
|
||||
return null;
|
||||
if(numbers.stream().allMatch(n -> n == 2)){
|
||||
result.setResultFlag(1);
|
||||
}
|
||||
if(numbers.stream().allMatch(n -> n == 3)){
|
||||
result.setResultFlag(1);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,7 +440,10 @@ public class DetectionServiceImpl {
|
||||
* @param dataRule 数据处理原则
|
||||
* @returnd
|
||||
*/
|
||||
public Boolean 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.setIsData(4);
|
||||
detectionData.setData(listT.get(0));
|
||||
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
|
||||
//获得误差体系
|
||||
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), data, x.getConditionType()),
|
||||
@@ -446,24 +459,32 @@ public class DetectionServiceImpl {
|
||||
List<Double> qualifiedList = listT.stream().filter(x -> NumberUtil.isIn(devSubtractChannelData(x, channelData, errSysDtl.getErrorValueType()),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
switch (dataRule) {
|
||||
case AT_WILL_VALUE:
|
||||
case CP95_VALUE:
|
||||
case AVG_VALUE:
|
||||
if (qualifiedList.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SECTION_VALUE:
|
||||
case Own_value:
|
||||
if (qualifiedList.size() == listT.size()) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
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 false;
|
||||
}
|
||||
return null;
|
||||
return detectionData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user