diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/DetectionData.java b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/DetectionData.java index c489082d..9193b161 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/DetectionData.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/DetectionData.java @@ -15,7 +15,7 @@ public class DetectionData { /** * 第几次谐波 */ - private Integer num; + private Double num; /** * 原始数据 diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index 1c2a0276..c2ff9a90 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -4,6 +4,7 @@ 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.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.vo.DetectionData; import com.njcn.gather.device.err.pojo.param.PqErrSysParam; @@ -89,9 +90,39 @@ public class DetectionServiceImpl { case "I": return isQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS").getResultFlag(); /** - * 谐波类 + * 谐波电压 */ - case "H": + case "HV": + return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag(); + /** + * 谐波电流 + */ + case "HI": + return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag(); + /** + * 谐波有功功率 + */ + case "HP": + break; + /** + * 间谐波电压 + */ + case "HSV": + return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, U, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag(); + /** + * 间谐波电流 + */ + case "HSI": + return isHarmQualified(dev, devIdMapComm, pqErrSysDtls, I, sourceIssue, DictDataEnum.AT_WILL_VALUE, 2).getResultFlag(); + /** + * 三相电压不平衡度 + */ + case "IMBV": + break; + /** + * 三相电流不平衡度 + */ + case "IMBA": break; /** * 功率 @@ -259,7 +290,7 @@ public class DetectionServiceImpl { * @return */ public AdHarmonicResult isHarmQualified(List dev, Map devIdMapComm, List pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) { - Map>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num); + Map>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num); Double fData = 1.0; if (U.equals(type)) { fData = sourceIssue.getFUn(); @@ -297,11 +328,11 @@ public class DetectionServiceImpl { } private void reflectHarmonic(String phase, List integerBooleanA, AdHarmonicResult harmonicResult) { - Map dataMap = integerBooleanA.stream().collect(Collectors.toMap(DetectionData::getNum, Function.identity())); + Map dataMap = integerBooleanA.stream().collect(Collectors.toMap(DetectionData::getNum, Function.identity())); dataMap.forEach((key, value) -> { try { // 设置 id 字段 - Field idField = AdHarmonicResult.class.getDeclaredField(phase + "Value" + key); + Field idField = AdHarmonicResult.class.getDeclaredField(phase + "Value" + key.intValue()); idField.setAccessible(true); if (ObjectUtil.isNull(value.getIsData())) { idField.set(harmonicResult, value.getData()); @@ -366,14 +397,14 @@ public class DetectionServiceImpl { * @param fData * @return */ - public List harmRangeComparison(List pqErrSysDtls, String type, String phase, SourceIssue sourceIssue, DictDataEnum dataRule, Map> devMap, Double fData) { + public List harmRangeComparison(List pqErrSysDtls, String type, String phase, SourceIssue sourceIssue, DictDataEnum dataRule, Map> devMap, Double fData) { List info = new ArrayList<>(); //根据谐波几次相值/额定值 - Map issueHarmMap = sourceIssue.getChannelList().stream() + Map 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 errSysDtlMap = new LinkedHashMap<>(); + Map errSysDtlMap = new LinkedHashMap<>(); issueHarmMap.forEach((key, value) -> { //获得误差体系 List errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(x.getStartValue(), @@ -447,11 +478,18 @@ public class DetectionServiceImpl { } - public Map>> devHarmListMap(List dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) { - Map>> map = new HashMap<>(3); - List harmNum = sourceIssue.getChannelList().stream() - .flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm())) - .sorted().distinct().collect(Collectors.toList()); + public Map>> devHarmListMap(List dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) { + Map>> map = new HashMap<>(3); + List harmNum; + if (1 == num) { + harmNum = sourceIssue.getChannelList().stream() + .flatMap(x -> x.getInharmList().stream().map(f -> f.getInharm())) + .sorted().distinct().collect(Collectors.toList()); + } else { + harmNum = sourceIssue.getChannelList().stream() + .flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm())) + .sorted().distinct().collect(Collectors.toList()); + } for (DevData devData : dev) { 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(); @@ -609,36 +647,36 @@ public class DetectionServiceImpl { * @param harm 基波信息 * @param fund 2-50次谐波信息 */ - public void harmPut(String type, Map>> map, List harmNum, DevData.SqlDataHarmDTO harm, String fund, Integer num) { + public void harmPut(String type, Map>> map, List harmNum, DevData.SqlDataHarmDTO harm, String fund, Integer num) { if (map.containsKey(type)) { - Map> integerListMap = map.get(type); - for (Integer i : harmNum) { + Map> integerListMap = map.get(type); + for (Double i : harmNum) { if (integerListMap.containsKey(i)) { if (type.equals("A")) { - integerListMap.get(i).add(multiply(harm.getList().getA().get(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(i).add(multiply(harm.getList().getB().get(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(i).add(multiply(harm.getList().getC().get(i - num), fund)); + integerListMap.get(num!=1?i:i+0.5).add(multiply(harm.getList().getC().get((int) (i - num)), fund)); } } } } else { - Map> integerListMap = new LinkedHashMap<>(5); - for (Integer i : harmNum) { + Map> integerListMap = new LinkedHashMap<>(5); + for (Double i : harmNum) { List integerList = new ArrayList<>(); if (type.equals("A")) { - integerList.add(multiply(harm.getList().getA().get(i - num), fund)); + integerList.add(multiply(harm.getList().getA().get((int) (i - num)), fund)); } if (type.equals("B")) { - integerList.add(multiply(harm.getList().getB().get(i - num), fund)); + integerList.add(multiply(harm.getList().getB().get((int) (i - num)), fund)); } if (type.equals("C")) { - integerList.add(multiply(harm.getList().getC().get(i - num), fund)); + integerList.add(multiply(harm.getList().getC().get((int) (i - num)), fund)); } - integerListMap.put(i, integerList); + integerListMap.put(num!=1?i:i+0.5, integerList); } map.put(type, integerListMap); } diff --git a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java index 46b47722..bb7105e8 100644 --- a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java +++ b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java @@ -163,7 +163,7 @@ public class SourceIssue { * 谐波次数 */ @JSONField(name = "harm", ordinal = 1) - private Integer harm; + private Double harm; /** * 谐波含有率 diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java index 11f937b7..bd45f8cd 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptCheckDataServiceImpl.java @@ -43,9 +43,9 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl pqScriptCheckData = this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper); if(CollUtil.isNotEmpty(pqScriptCheckData)){ if (param.getIsValueTypeName()) { - return pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).collect(Collectors.toList()); + return pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).distinct().collect(Collectors.toList()); } else { - return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).collect(Collectors.toList()); + return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList()); } } return new ArrayList<>(); diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java index 0be95b11..dce9bfdb 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java @@ -139,6 +139,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl freq = value.stream().filter(x -> FREQ.equals(x.getValueType())).collect(Collectors.toList()); + if(key==6){ + System.out.println(); + } if (CollUtil.isNotEmpty(freq)) { PqScriptDtls freqDtls = freq.get(0); SourceIssue issue = new SourceIssue(); @@ -343,7 +346,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl