diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java index a4d725b5..c20e457b 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java @@ -44,6 +44,7 @@ public enum DetectionCodeEnum { TOTW("TotW", "三相总有功功率"), TOTVA("TotVA", "三相总视在功率"), TOTVAR("TotVAr", "三相总无功功率"), + TOTPF("TotPF","三相功率因数"), // P_FUND("P_FUND", "基波有功功率"), // P_HVAR("P_HVAR", "基波无功功率"), // P_HVA("P_HVA", "基波视在功率"), 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 80906004..b3174abd 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 @@ -806,6 +806,38 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl x.getChannelType().contains("U")).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(channelU)) { + Double valueTotW = 0.0; + Double valueTotVA = 0.0; + for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) { + //获取电流通道 + 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)) { + //cos(电压角度-电流角度) + double v = listDTO.getFPhase() - channelI.get(0).getFPhase(); + if (v == 90 || v == -90 || v == 270 || v == -270) { + valueTotW += 0.0; + } else { + valueTotW += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180); + } + valueTotVA += channelI.get(0).getFAmp() * listDTO.getFAmp(); + } + } + checkData = new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(valueTotW / valueTotVA); + checkData.setPhase("T"); + checkData.setPid(channelListDTO.getPid()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + break; case UNKNOWN_ERROR: break; default: