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 faef9a18..6dc6a005 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 @@ -199,7 +199,7 @@ public class ResultServiceImpl implements IResultService { } } else { dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂降测量准确度测试", 20, 85); - dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂升测量准确度测试", 110, 180); + dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压暂升测量准确度测试", 110, 200); dipScriptTypeName(subValue, scriptSubList, finalResultMap, isValueType, "电压中断测量准确度测试", 0, 10); } @@ -272,6 +272,7 @@ public class ResultServiceImpl implements IResultService { .collect(Collectors.toList()); TreeDataVO vo = new TreeDataVO(); vo.setScriptTypeName(name); + vo.setScriptTypeCode("Base_"+start+"_"+end); TreeDataVO dlt; for (PqScriptDtls dtls : dip) { dlt = new TreeDataVO(); diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index 54706e64..2bf826c7 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -450,15 +450,17 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl x.getChannelType().contains("U")).collect(Collectors.toList()); for (PqScriptDtlsParam.ChannelListDTO listDTO : list) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(listDTO.getFPhase()); - setCheckValue(checkArchive, checkData, listDTO); - checkData.setDataType(channelListDTO.getDataType()); - checkData.setValueType(channelListDTO.getValueType()); - checkData.setPid(channelListDTO.getPid()); - info.add(checkData); + if (listDTO.getChannelFlag()) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(listDTO.getFPhase()); + setCheckValue(checkArchive, checkData, listDTO); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + checkData.setPid(channelListDTO.getPid()); + info.add(checkData); + } } } break; @@ -478,27 +480,30 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl channelU = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); if (CollUtil.isNotEmpty(channelU)) { for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) { - //获取电流通道 - List channelI = channelList.stream() - .filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2))) - .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(channelI)) { - List harmI = channelI.stream() - .flatMap(x -> x.getHarmList().stream()).collect(Collectors.toList()); - Map harmIMap = harmI.stream() - .collect(Collectors.toMap(PqScriptDtlsParam.ChannelListDTO.HarmModel::getHarm, Function.identity())); - List harmList = listDTO.getHarmList(); - if (CollUtil.isNotEmpty(harmList)) { - for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - if (harmIMap.containsKey(harmModel.getHarm())) { - PqScriptDtlsParam.ChannelListDTO.HarmModel i = harmIMap.get(harmModel.getHarm()); - //电压*电流*cos(电压角度-电流角度) - checkData.setValue(i.getFAmp() * harmModel.getFAmp() * Math.cos(harmModel.getFPhase() - i.getFPhase())); + if (listDTO.getHarmFlag()) { + //获取电流通道 + List channelI = channelList.stream() + .filter(PqScriptDtlsParam.ChannelListDTO::getHarmFlag) + .filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2))) + .collect(Collectors.toList()); + if (CollUtil.isNotEmpty(channelI)) { + List harmI = channelI.stream() + .flatMap(x -> x.getHarmList().stream()).collect(Collectors.toList()); + Map harmIMap = harmI.stream() + .collect(Collectors.toMap(PqScriptDtlsParam.ChannelListDTO.HarmModel::getHarm, Function.identity())); + List harmList = listDTO.getHarmList(); + if (CollUtil.isNotEmpty(harmList)) { + for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + if (harmIMap.containsKey(harmModel.getHarm())) { + PqScriptDtlsParam.ChannelListDTO.HarmModel i = harmIMap.get(harmModel.getHarm()); + //电压*电流*cos(电压角度-电流角度) + checkData.setValue(i.getFAmp() * harmModel.getFAmp()/100 * Math.cos(harmModel.getFPhase() - i.getFPhase())); + } + setCheck(info, checkData, channelListDTO, checkArchive, listDTO); } - setCheck(info, checkData, channelListDTO, checkArchive, listDTO); } } } @@ -520,21 +525,25 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl x.getChannelType().contains("U")).collect(Collectors.toList()); for (PqScriptDtlsParam.ChannelListDTO listDTO : list) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(listDTO.getDipData().getFTransValue()); - setCheck(info, checkData, channelListDTO, checkArchive, listDTO); + if (listDTO.getDipFlag()) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(listDTO.getDipData().getFTransValue()); + setCheck(info, checkData, channelListDTO, checkArchive, listDTO); + } } break; case DUR: list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); for (PqScriptDtlsParam.ChannelListDTO listDTO : list) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(listDTO.getDipData().getRetainTime()); - setCheck(info, checkData, channelListDTO, checkArchive, listDTO); + if (listDTO.getDipFlag()) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(listDTO.getDipData().getRetainTime()); + setCheck(info, checkData, channelListDTO, checkArchive, listDTO); + } } break; case IRMS: @@ -546,25 +555,26 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl x.getChannelType().contains("U")).collect(Collectors.toList()); - unbanCheck(info, channelListDTO, channelList, list, checkArchive); + unbanCheck(info, channelListDTO, list, checkArchive); break; case I_UNBAN: list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList()); - unbanCheck(info, channelListDTO, channelList, list, checkArchive); + unbanCheck(info, channelListDTO, list, checkArchive); break; case PST: if (CollUtil.isNotEmpty(channelList)) { list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); for (PqScriptDtlsParam.ChannelListDTO listDTO : list) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - if (ObjectUtil.isNotNull(listDTO.getFlickerData())) { - checkData.setValue(listDTO.getFlickerData().getFlickerValue()); + if (listDTO.getFlickerFlag()) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + if (ObjectUtil.isNotNull(listDTO.getFlickerData())) { + checkData.setValue(listDTO.getFlickerData().getFlickerValue()); + } + setCheck(info, checkData, channelListDTO, checkArchive, listDTO); } - setCheck(info, checkData, channelListDTO, checkArchive, listDTO); } - } break; case I1: @@ -631,19 +641,23 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl info, PqScriptDtlsParam.CheckData channelListDTO, - List channelList, List list, List checkArchive ) { PqScriptDtlsParam.CheckData checkData; if (CollUtil.isNotEmpty(list)) { - PqScriptDtlsParam.ChannelListDTO a = channelList.stream().filter(x -> x.getChannelType().contains("a")).findFirst().get(); - PqScriptDtlsParam.ChannelListDTO b = channelList.stream().filter(x -> x.getChannelType().contains("b")).findFirst().get(); - PqScriptDtlsParam.ChannelListDTO c = channelList.stream().filter(x -> x.getChannelType().contains("c")).findFirst().get(); checkData = new PqScriptDtlsParam.CheckData(); checkData.setErrorFlag(channelListDTO.getErrorFlag()); checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(ThreePhaseUnbalance.calculateUnbalance(a.getFAmp(), a.getFPhase(), b.getFAmp(), b.getFPhase(), c.getFAmp(), c.getFPhase())); + List channelA = list.stream().filter(x -> x.getChannelType().contains("a")).collect(Collectors.toList()); + List channelB = list.stream().filter(x -> x.getChannelType().contains("b")).collect(Collectors.toList()); + List channelC = list.stream().filter(x -> x.getChannelType().contains("c")).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(channelA) && CollUtil.isNotEmpty(channelB) && CollUtil.isNotEmpty(channelC)) { + PqScriptDtlsParam.ChannelListDTO a = channelA.get(0); + PqScriptDtlsParam.ChannelListDTO b = channelB.get(0); + PqScriptDtlsParam.ChannelListDTO c = channelC.get(0); + checkData.setValue(ThreePhaseUnbalance.calculateUnbalance(a.getFAmp(), a.getFPhase(), b.getFAmp(), b.getFPhase(), c.getFAmp(), c.getFPhase())); + } if (CollUtil.isNotEmpty(checkArchive)) { checkData.setValue(checkArchive.get(0).getValue()); } @@ -663,24 +677,27 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(collect)) { - checkData.setValue(collect.get(0).getValue()); - } else { - if (flyDeltaV) { - checkData.setValue(0.0); + if (listDTO.getChannelFlag()) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase()); + List collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(collect)) { + checkData.setValue(collect.get(0).getValue()); } else { - checkData.setValue(listDTO.getFAmp()); + if (flyDeltaV) { + checkData.setValue(0.0); + } else { + checkData.setValue(listDTO.getFAmp()); + } } + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + checkData.setPid(channelListDTO.getPid()); + info.add(checkData); } - checkData.setDataType(channelListDTO.getDataType()); - checkData.setValueType(channelListDTO.getValueType()); - checkData.setPid(channelListDTO.getPid()); - info.add(checkData); + } } @@ -691,19 +708,21 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl inharmList = listDTO.getInharmList(); - if (CollUtil.isNotEmpty(inharmList)) { - for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(inharmModel.getFAmp()); - setCheckValue(checkArchive, checkData, listDTO); - checkData.setHarmNum(inharmModel.getInharm()); - checkData.setDataType(channelListDTO.getDataType()); - checkData.setValueType(channelListDTO.getValueType()); - checkData.setPid(channelListDTO.getPid()); - info.add(checkData); + if (listDTO.getInHarmFlag()) { + List inharmList = listDTO.getInharmList(); + if (CollUtil.isNotEmpty(inharmList)) { + for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(inharmModel.getFAmp()); + setCheckValue(checkArchive, checkData, listDTO); + checkData.setHarmNum(inharmModel.getInharm()); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + checkData.setPid(channelListDTO.getPid()); + info.add(checkData); + } } } } @@ -724,20 +743,22 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl harmList = listDTO.getHarmList(); - if (CollUtil.isNotEmpty(harmList)) { - for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) { - checkData = new PqScriptDtlsParam.CheckData(); - checkData.setErrorFlag(channelListDTO.getErrorFlag()); - checkData.setEnable(channelListDTO.getEnable()); - checkData.setValue(harmModel.getFAmp()); - setCheckValue(checkArchive, checkData, listDTO); - checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase()); - checkData.setHarmNum(harmModel.getHarm()); - checkData.setDataType(channelListDTO.getDataType()); - checkData.setValueType(channelListDTO.getValueType()); - checkData.setPid(channelListDTO.getPid()); - info.add(checkData); + if (listDTO.getHarmFlag()) { + List harmList = listDTO.getHarmList(); + if (CollUtil.isNotEmpty(harmList)) { + for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) { + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(harmModel.getFAmp()); + setCheckValue(checkArchive, checkData, listDTO); + checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase()); + checkData.setHarmNum(harmModel.getHarm()); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + checkData.setPid(channelListDTO.getPid()); + info.add(checkData); + } } } } @@ -757,15 +778,27 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl pqScriptDtls(PqScriptIssueParam param, Double volt, Double curr) { List pqScriptDtls; MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); + List index = new ArrayList<>(); + if (StrUtil.isNotBlank(param.getScriptSubType())) { + String[] split = param.getScriptSubType().split("_"); + if (split.length > 1) { + param.setScriptSubType(split[0]); + List pqScriptDtls1 = this.getBaseMapper().selectList(new LambdaQueryWrapper() + .select(PqScriptDtls::getScriptIndex) + .eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType()) + .eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType()) + .eq(PqScriptDtls::getScriptId, param.getScriptId()) + .ge(PqScriptDtls::getTransValue, split[1]) + .le(PqScriptDtls::getTransValue, split[2])); + index = pqScriptDtls1.stream().map(PqScriptDtls::getScriptIndex).distinct().collect(Collectors.toList()); + } + } queryWrapper.selectAll(PqScriptDtls.class) .selectAs(DictTree::getCode, PqScriptDtls::getScriptCode) .leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType) .eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType()) .eq(StrUtil.isNotBlank(param.getScriptSubType()), PqScriptDtls::getScriptSubType, param.getScriptSubType()) -// .eq(PqScriptDtls::getIndex, 1) -// .le(PqScriptDtls::getIndex, 30) -// .in(PqScriptDtls::getIndex, Arrays.asList(1,7)) - + .in(CollUtil.isNotEmpty(index), PqScriptDtls::getScriptIndex, index) .eq(CollUtil.isNotEmpty(param.getDevIds()), PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode()) .orderByAsc(PqScriptCheckData::getScriptIndex) ; diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java index 415c0121..68f0c97e 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java @@ -159,7 +159,6 @@ public class AdHarmonicServiceImpl extends ServiceImpl numbers) { + List isData = numbers.stream().filter(x -> ObjectUtil.isNotNull(x.getData())).filter(x -> 4 != x.getIsData()).map(RawResultDataVO.DetectionData::getIsData).distinct().collect(Collectors.toList()); + return getInteger(isData); + } + private static Integer getInteger(List isData) { + if (CollUtil.isNotEmpty(isData)) { + if (isData.size() > 1) { + if (isData.contains(2)) { + return 2; + } + } + return isData.get(0); + } else { + return 4; + } + } public Double isHarmOrInHarm(Double value) { if (value == value.longValue()) {