From 11c95b6b4290aa88b87790bb8976bc96b24aec5e Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Sat, 4 Jan 2025 15:25:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=AD=A3=E5=BC=8F=E6=A3=80=E6=B5=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=AF=A6=E6=83=85=E6=A3=80=E6=B5=8B=E6=A0=91=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gather/result/pojo/vo/TreeDataVO.java | 10 + .../service/impl/ResultServiceImpl.java | 709 ++++++++++++++++-- 2 files changed, 636 insertions(+), 83 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/result/pojo/vo/TreeDataVO.java b/detection/src/main/java/com/njcn/gather/result/pojo/vo/TreeDataVO.java index b0af84da..79aed2bd 100644 --- a/detection/src/main/java/com/njcn/gather/result/pojo/vo/TreeDataVO.java +++ b/detection/src/main/java/com/njcn/gather/result/pojo/vo/TreeDataVO.java @@ -16,6 +16,16 @@ public class TreeDataVO { * 检测项目名称 */ private String scriptTypeName; + + /** + * 源下发的描述 + */ + private String sourceDesc; + + /** + * 谐波次数 + */ + private List harmNum; /** * 测试相 */ diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index 7f5c4a81..c094fded 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -5,10 +5,11 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; -import com.njcn.gather.device.device.pojo.vo.PqDevVO; import com.njcn.gather.device.device.service.IPqDevService; import com.njcn.gather.device.script.mapper.PqScriptMapper; +import com.njcn.gather.device.script.pojo.po.PqScriptCheckData; import com.njcn.gather.device.script.pojo.po.PqScriptDtls; +import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.device.script.service.IPqScriptDtlsService; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; @@ -28,7 +29,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.math.BigDecimal; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -50,6 +50,7 @@ public class ResultServiceImpl implements IResultService { private final IPqScriptDtlsService pqScriptDtlsService; private final PqScriptMapper scriptMapper; private final IDictTreeService dictTreeService; + private final IPqScriptCheckDataService pqScriptCheckDataService; /** * 谐波类code,取树形字典表中的code @@ -111,11 +112,12 @@ public class ResultServiceImpl implements IResultService { public List treeData(ResultParam param) { //根据所有的检测脚本查询出检测信息 List dtlsList = pqScriptDtlsService.list(new MPJLambdaWrapper() - .selectAll(PqScriptDtls.class) - .eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId()) - .eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType()) - .ne(PqScriptDtls::getIndex, -1) - .eq(PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())); + .selectAll(PqScriptDtls.class) + .eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId()) + .eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType()) + .ne(PqScriptDtls::getIndex, -1) + .eq(PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode()) + ); List allResultList = new ArrayList<>(); List indexList = new ArrayList<>(); if (StrUtil.isNotBlank(param.getScriptType())) { @@ -135,109 +137,650 @@ public class ResultServiceImpl implements IResultService { Map dictTreeMap = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, Function.identity())); Map subName = new LinkedHashMap<>(); - subName.put("Base", "额定工作条件下的测量"); - subName.put("VOL", "电压对XX测量的影响"); - subName.put("Freq", "频率对XX测量的影响"); + subName.put("Base", "额定条件XX准确度测试"); + subName.put("VOL", "电压幅值对XX测量的影响"); + subName.put("Freq", "频率变化对XX测量的影响"); subName.put("Harm", "谐波对XX测量的影响"); + subName.put("Single", "单影响量下XX准确度测试"); Boolean isValueType = scriptMapper.selectScriptIsValueType(param.getScriptId()); - PqDevVO dev = pqDevService.getPqDevById(param.getDevId()); List infoVOS = new ArrayList<>(); + //根据检测大项进行分组展示 Map> finalResultMap = resultMap; dtlsSortMap.forEach((key, value) -> { DictTree dictTree = dictTreeMap.get(key); if (ObjectUtil.isNotNull(dictTree)) { List scriptSubList = new ArrayList<>(); - + //大相检测信息 + TreeDataVO infoVO = new TreeDataVO(); + infoVO.setScriptTypeName(dictTree.getName()); + //额定条件下频率准确度测试 LinkedHashMap> subTypeMap = value.stream() .sorted(Comparator.comparing(PqScriptDtls::getIndex)) + .filter(x -> "Base".equals(x.getScriptSubType())) .collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList())); subTypeMap.forEach((subKey, subValue) -> { - List scriptDlsList = new ArrayList<>(); - //根据index进行分组统计小相检测信息 - LinkedHashMap> indexMap = subValue.stream() - .sorted(Comparator.comparing(PqScriptDtls::getIndex)) - .collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList())); - indexMap.forEach((index, scriptDtlIndex) -> { + if (!"VOLTAGE".equals(dictTree.getCode())) { + TreeDataVO subType = new TreeDataVO(); + subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); + LinkedHashMap> indexMap = subValue.stream() + .sorted(Comparator.comparing(PqScriptDtls::getIndex)) + .collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList())); + List subTypeList = new ArrayList<>(); - if (finalResultMap.containsKey(index)) { - Set nums = finalResultMap.get(index); - TreeDataVO childInfo = new TreeDataVO(); - StringBuffer buffer = new StringBuffer(); - buffer.append("输入:"); - List freq = scriptDtlIndex.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(freq)) { - buffer.append("频率=" + freq.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + " "); - } - List vol = scriptDtlIndex.stream().filter(x -> "VOL".equals(x.getValueType())) - .sorted(Comparator.comparing(PqScriptDtls::getPhase)).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(vol)) { - Float unit = 1f; - if (isValueType) { - unit = dev.getDevVolt(); + indexMap.forEach((index, scriptDtlIndexList) -> { + if (finalResultMap.containsKey(index)) { + TreeDataVO dtlType = new TreeDataVO(); + dtlType.setIndex(index); + ratedScriptTypeName(scriptDtlIndexList, isValueType, dtlType, dictTree); + dtlType.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dtlType.setFly(conform(finalResultMap.get(index))); + subTypeList.add(dtlType); } - for (PqScriptDtls dtls : vol) { - BigDecimal volValue = new BigDecimal(dtls.getValue()); - BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP) - .multiply(new BigDecimal(unit.toString())); - buffer.append("U" + dtls.getPhase().toLowerCase() + "=" + result.doubleValue() + ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit() - + ",相角=" + dtls.getAngle() + "° "); - } - - } - List cur = scriptDtlIndex.stream().filter(x -> "CUR".equals(x.getValueType())) - .sorted(Comparator.comparing(PqScriptDtls::getPhase)) - .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(cur)) { - Float unit = 1f; - if (isValueType) { - unit = dev.getDevCurr(); - } - for (PqScriptDtls dtls : cur) { - BigDecimal volValue = new BigDecimal(dtls.getValue()); - BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP) - .multiply(new BigDecimal(unit.toString())); - buffer.append("I" + dtls.getPhase().toLowerCase() + "=" + result.doubleValue() + ResultUnitEnum.I_ABSOLUTELY_UNIT.getUnit() - + ",相角=" + dtls.getAngle() + "° "); - } - } - dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_V", "h", ResultUnitEnum.HV_UNIT.getUnit(), true); - dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_I", "h", ResultUnitEnum.HI_UNIT.getUnit(), true); - dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_V", "i", ResultUnitEnum.HSV_UNIT.getUnit(), false); - dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_I", "i", ResultUnitEnum.HSI_UNIT.getUnit(), false); - dtlsSetBufferDip(scriptDtlIndex, buffer, "Dip", "暂态", ResultUnitEnum.HSI_UNIT.getUnit()); - dtlsSetBufferFlicker(scriptDtlIndex, buffer, "Flicker", "闪变"); - childInfo.setIndex(index); - childInfo.setFly(conform(nums)); - childInfo.setScriptTypeName(buffer.toString()); - scriptDlsList.add(childInfo); - } - }); - if (CollUtil.isNotEmpty(scriptDlsList)) { - TreeDataVO sub = new TreeDataVO(); - sub.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); - sub.setChildren(scriptDlsList); - scriptSubList.add(sub); + }); + subType.setChildren(subTypeList); + scriptSubList.add(subType); + } else { + dipScriptTypeName(subValue, scriptSubList,finalResultMap, isValueType, "电压暂降测量准确度测试", 20, 85); + dipScriptTypeName(subValue, scriptSubList,finalResultMap, isValueType, "电压暂升测量准确度测试", 110, 180); + dipScriptTypeName(subValue, scriptSubList,finalResultMap, isValueType, "电压中断测量准确度测试", 0, 10); } + }); - if (CollUtil.isNotEmpty(scriptSubList)) { - //大相检测信息 - TreeDataVO infoVO = new TreeDataVO(); - infoVO.setScriptTypeName(dictTree.getName()); - infoVO.setChildren(scriptSubList); - infoVOS.add(infoVO); + + + //单影响量下频率准确度测试 + LinkedHashMap> subSingleTypeMap = value.stream() + .sorted(Comparator.comparing(PqScriptDtls::getIndex)) + .filter(x -> !"Base".equals(x.getScriptSubType())) + .collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList())); + if (CollUtil.isNotEmpty(subSingleTypeMap)) { + TreeDataVO subType = new TreeDataVO(); + subType.setScriptTypeName(subName.get("Single").replace("XX", dictTree.getName())); + //单影响量下频率准测量集合 + List subSingleList = new ArrayList<>(); + subSingleTypeMap.forEach((subKey, subValue) -> { + TreeDataVO treeDataVO = new TreeDataVO(); + treeDataVO.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); + List subTypeList = new ArrayList<>(); + + LinkedHashMap> indexMap = subValue.stream() + .sorted(Comparator.comparing(PqScriptDtls::getIndex)) + .collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList())); + indexMap.forEach((index, scriptDtlIndexList) -> { + if (finalResultMap.containsKey(index)) { + TreeDataVO dtlType = new TreeDataVO(); + dtlType.setIndex(index); + if ("Harm".equals(subKey)) { + harmScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType); + } + if ("VOL".equals(subKey)) { + volScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType); + } + if ("Freq".equals(subKey)) { + freqScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType); + } + dtlType.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dtlType.setFly(conform(finalResultMap.get(index))); + subTypeList.add(dtlType); + } + + }); + treeDataVO.setChildren(subTypeList); + subSingleList.add(treeDataVO); + }); + subType.setChildren(subSingleList); + scriptSubList.add(subType); } + infoVO.setChildren(scriptSubList); + infoVOS.add(infoVO); } }); return infoVOS; } + private void dipScriptTypeName(List subValue, List subTypeList,Map> finalResultMap, Boolean isValueType, String name, Integer start, Integer end) { + List info = new ArrayList<>(); + List dip = subValue.stream() + .filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase())) + .filter(x -> x.getTransValue() >= start && x.getTransValue() <= end) + .sorted(Comparator.comparing(PqScriptDtls::getIndex)) + .collect(Collectors.toList()); + TreeDataVO vo = new TreeDataVO(); + vo.setScriptTypeName(name); + TreeDataVO dlt; + for (PqScriptDtls dtls : dip) { + if(finalResultMap.containsKey(dtls.getIndex())){ + dlt = new TreeDataVO(); + List scriptDtlIndexList = subValue.stream().filter(x -> dtls.getIndex().equals(x.getIndex())).collect(Collectors.toList()); + //特征幅值=20%Un,持续时间=1周波 + dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波"); + dlt.setIndex(dtls.getIndex()); + dlt.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dlt.setFly(conform(finalResultMap.get(dtls.getIndex()))); + info.add(dlt); + } + + } + vo.setChildren(info); + subTypeList.add(vo); + } + + private void ratedScriptTypeName(List scriptDtlIndexList, Boolean isValueType, TreeDataVO dtlType, DictTree dictTree) { + switch (dictTree.getCode()) { + /** + * 频率 + */ + case "FREQ": + List f = scriptDtlIndexList.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName(dictTree.getName() + "=" + f.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit()); + break; + /** + * 电压 + */ + case "V": + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + List v = scriptDtlIndexList.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName(dictTree.getName() + "=" + v.get(0).getValue().intValue() + unit); + break; + /** + * 电流 + */ + case "I": + String unitI; + if (isValueType) { + unitI = ResultUnitEnum.I_RELATIVE_UNIT.getUnit(); + } else { + unitI = ResultUnitEnum.I_ABSOLUTELY_UNIT.getUnit(); + } + List I = scriptDtlIndexList.stream().filter(x -> "CUR".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName(dictTree.getName() + "=" + I.get(0).getValue().intValue() + unitI); + break; + /** + * 谐波电压 + */ + case "HV": + /** + * 谐波电流 + */ + case "HI": + String valueType; + if ("HV".equals(dictTree.getCode())) { + valueType = "Harm_V"; + } else { + valueType = "Harm_I"; + } + List hv = scriptDtlIndexList.stream().filter(x -> valueType.equals(x.getValueType())).collect(Collectors.toList()); + LinkedHashMap> harmNumMap = hv.stream() + .sorted(Comparator.comparing(PqScriptDtls::getHarmNum)) + .collect(Collectors.groupingBy(PqScriptDtls::getHarmNum, LinkedHashMap::new, Collectors.toList())); + if (harmNumMap.size() > 1) { + //叠加2~50次谐波电压(含有率为GB/T) + dtlType.setScriptTypeName("叠加" + harmNumMap.entrySet().iterator().next().getValue().get(0).getHarmNum().intValue() + "~" + + new ArrayList<>(harmNumMap.entrySet()).get(harmNumMap.size() - 1).getValue().get(0).getHarmNum().intValue() + + "次" + dictTree.getName() + "(含有率为GB/T)"); + } else { + //叠加5%的2次谐波电压 + dtlType.setScriptTypeName("叠加" + hv.get(0).getValue().intValue() + ResultUnitEnum.HV_UNIT.getUnit() + "的" + hv.get(0).getHarmNum().intValue() + "次" + dictTree.getName()); + } + break; + /** + * 间谐波电压 + */ + case "HSV": + /** + * 间谐波电流 + */ + case "HSI": + //叠加1.5/5.5/7.5/49.5次间谐波,含有率为。。。 + String in; + if ("HSV".equals(dictTree.getCode())) { + in = "InHarm_V"; + } else { + in = "InHarm_I"; + } + List harmInNumList = scriptDtlIndexList.stream().filter(x -> in.equals(x.getValueType()) && "A".equals(x.getPhase())) + .sorted(Comparator.comparing(PqScriptDtls::getHarmNum)) + .distinct().collect(Collectors.toList()); + + if (harmInNumList.size() > 1) { + StringBuffer a = new StringBuffer(); + a.append("叠加"); + for (int i = 0; i < harmInNumList.size(); i++) { + if (i == harmInNumList.size() - 1) { + a.append(harmInNumList.get(i).getHarmNum()); + } else { + a.append(harmInNumList.get(i).getHarmNum() + "/"); + } + } + a.append("次" + dictTree.getName()); + dtlType.setScriptTypeName(a.toString()); + } else { + //叠加5%的2次谐波电压 + dtlType.setScriptTypeName("叠加" + harmInNumList.get(0).getValue().intValue() + ResultUnitEnum.HV_UNIT.getUnit() + "的" + harmInNumList.get(0).getHarmNum() + "次" + dictTree.getName()); + } + + break; + /** + * 三相电压不平衡度 + */ + case "IMBV": + List list = pqScriptCheckDataService.list(new MPJLambdaWrapper() + .eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId()) + .eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex()) + ); + //三相负序电压不平衡度=0% + dtlType.setScriptTypeName(dictTree.getName() + "=" + list.get(0).getValue() + ResultUnitEnum.IMBV_UNIT.getUnit()); + break; + /** + * 三相电流不平衡度 + */ + case "IMBA": + List imba = pqScriptCheckDataService.list(new MPJLambdaWrapper() + .eq(PqScriptCheckData::getScriptId, scriptDtlIndexList.get(0).getScriptId()) + .eq(PqScriptCheckData::getIndex, scriptDtlIndexList.get(0).getIndex()) + ); + //三相负序电流不平衡度=0% + dtlType.setScriptTypeName(dictTree.getName() + "=" + imba.get(0).getValue() + ResultUnitEnum.IMBV_UNIT.getUnit()); + break; + /** + * 谐波有功功率 + */ + case "HP": + //10%的2次谐波电压,40%的2次谐波电流 + List hpv = scriptDtlIndexList.stream().filter(x -> "Harm_V".equals(x.getValueType())).collect(Collectors.toList()); + List hpI = scriptDtlIndexList.stream().filter(x -> "Harm_I".equals(x.getValueType())).collect(Collectors.toList()); + LinkedHashMap> harmNumVMap = hpv.stream() + .sorted(Comparator.comparing(PqScriptDtls::getHarmNum)) + .collect(Collectors.groupingBy(PqScriptDtls::getHarmNum, LinkedHashMap::new, Collectors.toList())); + + LinkedHashMap> harmNumIMap = hpI.stream() + .sorted(Comparator.comparing(PqScriptDtls::getHarmNum)) + .collect(Collectors.groupingBy(PqScriptDtls::getHarmNum, LinkedHashMap::new, Collectors.toList())); + StringBuffer a = new StringBuffer(); + if (harmNumVMap.size() > 1) { + ArrayList> lists = new ArrayList<>(harmNumVMap.values()); + Map> hpvMap = lists.stream().flatMap(x -> x.stream().filter(j -> "A".equals(j.getPhase()))).collect(Collectors.groupingBy(PqScriptDtls::getValue)); + hpvMap.forEach((key, value) -> { + a.append(key.intValue() + ResultUnitEnum.HV_UNIT.getUnit() + "的"); + for (int i = 0; i < value.size(); i++) { + if (i == value.size() - 1) { + a.append(value.get(i).getHarmNum().intValue()); + } else { + a.append(value.get(i).getHarmNum().intValue() + "、"); + } + } + a.append("次" + ResultUnitEnum.HV_UNIT.getName()); + }); + } else { + PqScriptDtls dtls = harmNumVMap.entrySet().iterator().next().getValue().get(0); + a.append(dtls.getValue().intValue() + ResultUnitEnum.HV_UNIT.getUnit() + "的" + dtls.getHarmNum().intValue() + ResultUnitEnum.HV_UNIT.getName()); + } + a.append(","); + if (harmNumIMap.size() > 1) { + ArrayList> lists = new ArrayList<>(harmNumIMap.values()); + Map> hpvMap = lists.stream().flatMap(x -> x.stream().filter(j -> "A".equals(j.getPhase()))).collect(Collectors.groupingBy(PqScriptDtls::getValue)); + hpvMap.forEach((key, value) -> { + a.append(key.intValue() + ResultUnitEnum.HI_UNIT.getUnit() + "的"); + for (int i = 0; i < value.size(); i++) { + if (i == value.size() - 1) { + a.append(value.get(i).getHarmNum().intValue()); + } else { + a.append(value.get(i).getHarmNum().intValue() + "、"); + } + } + a.append("次" + ResultUnitEnum.HI_UNIT.getName()); + }); + } else { + PqScriptDtls dtls = harmNumIMap.entrySet().iterator().next().getValue().get(0); + a.append(dtls.getValue().intValue() + ResultUnitEnum.HI_UNIT.getUnit() + "的" + dtls.getHarmNum().intValue() + "次" + ResultUnitEnum.HI_UNIT.getName()); + } + dtlType.setScriptTypeName(a.toString()); + break; + /** + * 功率 + */ + case "P": + break; + /** + * 闪变 + */ + case "F": + //Pst=1(变动率=1.459%*1) + List flicker = scriptDtlIndexList.stream().filter(x -> "Flicker".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("Pst=" + flicker.get(0).getChagFre() + "(变动率=" + flicker.get(0).getChagValue() + "%*" + flicker.get(0).getChagFre() + ")"); + break; + /** + * 暂态 + */ + case "VOLTAGE": + break; + } + } + + private void harmScriptTypeName(List dtls, DictTree dictTree, Boolean isValueType, TreeDataVO dtlType) { + switch (dictTree.getCode()) { + /** + * 频率 + */ + case "FREQ": + List f = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("叠加多次谐波对" + dictTree.getName() + "=" + f.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "的影响"); + break; + /** + * 电压 + */ + case "V": + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + List v = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("叠加多次谐波对" + dictTree.getName() + "=" + v.get(0).getValue() + unit + "的影响"); + break; + /** + * 电流 + */ + case "I": + break; + /** + * 谐波电压 + */ + case "HV": + break; + /** + * 谐波电流 + */ + case "HI": + break; + /** + * 间谐波电压 + */ + case "HSV": + break; + /** + * 间谐波电流 + */ + case "HSI": + break; + /** + * 三相电压不平衡度 + */ + case "IMBV": + break; + /** + * 三相电流不平衡度 + */ + case "IMBA": + break; + /** + * 谐波有功功率 + */ + case "HP": + break; + /** + * 功率 + */ + case "P": + break; + /** + * 闪变 + */ + case "F": + break; + /** + * 暂态 + */ + case "VOLTAGE": + break; + } + } + + private void volScriptTypeName(List dtls, DictTree dictTree, Boolean isValueType, TreeDataVO dtlType) { + switch (dictTree.getCode()) { + /** + * 频率 + */ + case "FREQ": + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + List f = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List v = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName(v.get(0).getValue().intValue() + unit + "对" + dictTree.getName() + "=" + f.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "的影响"); + break; + /** + * 电压 + */ + case "V": + + break; + /** + * 电流 + */ + case "I": + break; + /** + * 谐波电压 + */ + case "HV": + //电压有效值10%,3次谐波电压,含有率 + List hvv = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + List hv = dtls.stream().filter(x -> "Harm_V".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("电压有效值" + hvv.get(0).getValue().intValue() + ResultUnitEnum.HV_UNIT.getUnit() + "," + hv.get(0).getHarmNum().intValue() + "次" + dictTree.getName()); + break; + /** + * 谐波电流 + */ + case "HI": + List hiv = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + List hi = dtls.stream().filter(x -> "Harm_I".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("电压有效值" + hiv.get(0).getValue().intValue() + ResultUnitEnum.HI_UNIT.getUnit() + "," + hi.get(0).getHarmNum().intValue() + "次" + dictTree.getName()); + break; + /** + * 间谐波电压 + */ + case "HSV": + List hsvv = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + List hsv = dtls.stream().filter(x -> "InHarm_V".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("电压有效值" + hsvv.get(0).getValue().intValue() + ResultUnitEnum.HSV_UNIT.getUnit() + "," + hsv.get(0).getHarmNum() + "次" + dictTree.getName()); + break; + /** + * 间谐波电流 + */ + case "HSI": + List hsiv = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + List hsi = dtls.stream().filter(x -> "InHarm_I".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("电压有效值" + hsiv.get(0).getValue().intValue() + ResultUnitEnum.HSI_UNIT.getUnit() + "," + hsi.get(0).getHarmNum() + "次" + dictTree.getName()); + break; + /** + * 三相电压不平衡度 + */ + case "IMBV": + break; + /** + * 三相电流不平衡度 + */ + case "IMBA": + break; + /** + * 谐波有功功率 + */ + case "HP": + break; + /** + * 功率 + */ + case "P": + break; + /** + * 闪变 + */ + case "F": + break; + /** + * 暂态 + */ + case "VOLTAGE": + break; + } + } + + private void freqScriptTypeName(List dtls, DictTree dictTree, Boolean isValueType, TreeDataVO dtlType) { + switch (dictTree.getCode()) { + /** + * 频率 + */ + case "FREQ": + break; + /** + * 电压 + */ + case "V": + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + List f = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List v = dtls.stream().filter(x -> "VOL".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("频率=" + f.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "," + dictTree.getName() + "=" + v.get(0).getValue() + unit); + break; + /** + * 电流 + */ + case "I": + break; + /** + * 谐波电压 + */ + case "HV": + //基波频率为42.5Hz,2次谐波电压 + List hvf = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List hv = dtls.stream().filter(x -> "Harm_V".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("基波频率为" + hvf.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "," + hv.get(0).getHarmNum().intValue() + "次" + dictTree.getName()); + break; + /** + * 谐波电流 + */ + case "HI": + List hif = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List hi = dtls.stream().filter(x -> "Harm_I".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("基波频率为" + hif.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "," + hi.get(0).getHarmNum().intValue() + "次" + dictTree.getName()); + break; + /** + * 间谐波电压 + */ + case "HSV": + List hsvf = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List hsv = dtls.stream().filter(x -> "InHarm_V".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("基波频率为" + hsvf.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "," + hsv.get(0).getHarmNum() + "次" + dictTree.getName()); + break; + /** + * 间谐波电流 + */ + case "HSI": + List hsif = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List hsi = dtls.stream().filter(x -> "InHarm_I".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("基波频率为" + hsif.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + "," + hsi.get(0).getHarmNum() + "次" + dictTree.getName()); + break; + /** + * 三相电压不平衡度 + */ + case "IMBV": + break; + /** + * 三相电流不平衡度 + */ + case "IMBA": + break; + /** + * 谐波有功功率 + */ + case "HP": + break; + /** + * 功率 + */ + case "P": + break; + /** + * 闪变 + */ + case "F": + break; + /** + * 暂态 + */ + case "VOLTAGE": + //频率=42.5H在,特征幅值=60%Un,持续时间=1周波 + List dipf = dtls.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + List dip = dtls.stream().filter(x -> "Dip".equals(x.getValueType())).collect(Collectors.toList()); + dtlType.setScriptTypeName("频率=" + dipf.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + ",特征幅值=" + dip.get(0).getTransValue().intValue() + "%Un,持续时间=" + dip.get(0).getRetainTime().intValue() + "周波"); + break; + } + } + + + private StringBuffer getStringBuffer(List scriptDtlIndex, Boolean isValueType) { + StringBuffer buffer = new StringBuffer(); + buffer.append("输入:"); + List freq = scriptDtlIndex.stream().filter(x -> "Freq".equals(x.getValueType())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(freq)) { + buffer.append("频率=" + freq.get(0).getValue() + ResultUnitEnum.FREQ_UNIT.getUnit() + " "); + } + List vol = scriptDtlIndex.stream().filter(x -> "VOL".equals(x.getValueType())) + .sorted(Comparator.comparing(PqScriptDtls::getPhase)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(vol)) { + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + for (PqScriptDtls dtls : vol) { + buffer.append("U" + dtls.getPhase().toLowerCase() + "=" + dtls.getValue() + unit + ",相角=" + dtls.getAngle() + "° "); + } + + } + List cur = scriptDtlIndex.stream().filter(x -> "CUR".equals(x.getValueType())) + .sorted(Comparator.comparing(PqScriptDtls::getPhase)) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(cur)) { + String unit; + if (isValueType) { + unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); + } else { + unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); + } + for (PqScriptDtls dtls : cur) { + buffer.append("I" + dtls.getPhase().toLowerCase() + "=" + dtls.getValue() + unit + ",相角=" + dtls.getAngle() + "° "); + } + } + dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_V", "h", ResultUnitEnum.HV_UNIT.getUnit(), true); + dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_I", "h", ResultUnitEnum.HI_UNIT.getUnit(), true); + dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_V", "i", ResultUnitEnum.HSV_UNIT.getUnit(), false); + dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_I", "i", ResultUnitEnum.HSI_UNIT.getUnit(), false); + dtlsSetBufferDip(scriptDtlIndex, buffer, "Dip", "暂态", ResultUnitEnum.HSI_UNIT.getUnit()); + dtlsSetBufferFlicker(scriptDtlIndex, buffer, "Flicker", "闪变"); + return buffer; + } + @Override public ResultVO resultData(ResultParam param) { - - return null; }