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 2d8edda3..23f87ae6 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 @@ -1,5 +1,6 @@ package com.njcn.gather.detection.pojo.enums; +import cn.hutool.core.util.ObjectUtil; import lombok.Getter; /** @@ -10,15 +11,31 @@ import lombok.Getter; @Getter public enum DetectionCodeEnum { + FREQ("FREQ", "频率"), + VRMS("VRMS", "相电压有效值"), + DELTA_V("DELTA_V", "电压偏差"), + VA("VA", "电压相角"), U1("U1", "基波电压"), V2_50("V2-50", "谐波电压"), - SV_1_49("SV_1-49", "间谐波电压"), - I1("I1", "基波电流"), I2_50("I2-50", "谐波电流"), - SI_1_49("SI_1-49", "间谐波电压"), P2_50("P2-50", "谐波有功功率"), + SV_1_49("SV_1-49", "间谐波电压"), + SI_1_49("SI_1-49", "间谐波电压"), + MAG("MAG", "电压幅值"), + DUR("DUR", "持续时间"), + IRMS("IRMS", "电流有效值"), + IA("IA", "电流相角"), + V_UNBAN("V_UNBAN", "三相电压负序不平衡度"), + I_UNBAN("I_UNBAN", "三相电流负序不平衡度"), + PST("PST", "短时间闪变"), + I1("I1", "基波电流"), + + + + + UNKNOWN_ERROR("-1", "未知异常"), ; @@ -29,4 +46,12 @@ public enum DetectionCodeEnum { this.code = code; this.message = message; } + public static DetectionCodeEnum getDetectionCodeByCode(String code) { + for (DetectionCodeEnum detectionCodeEnum : DetectionCodeEnum.values()) { + if (ObjectUtil.equals(code, detectionCodeEnum.getCode())) { + return detectionCodeEnum; + } + } + return UNKNOWN_ERROR; + } } 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 58d258e1..d498e9c6 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 @@ -303,6 +303,7 @@ public class DetectionServiceImpl { if (CollUtil.isNotEmpty(dtlsCheckData)) { harmonicResult.setAdType(dtlsCheckData.get(0).getValueType()); } + //电压下百分比给百分比直接算 电流是是下百分比给的是幅值要转换算 List integerBooleanA = harmRangeComparison(new ArrayList<>(), type, TYPE_A, sourceIssue, dataRule, devHarmMap.get(TYPE_A), fData, num); List integerBooleanB = harmRangeComparison(new ArrayList<>(), type, TYPE_B, sourceIssue, dataRule, devHarmMap.get(TYPE_B), fData, num); List integerBooleanC = harmRangeComparison(new ArrayList<>(), type, TYPE_C, sourceIssue, dataRule, devHarmMap.get(TYPE_C), fData, num); @@ -809,8 +810,10 @@ public class DetectionServiceImpl { } else { Double percent; if (I.equals(type)) { + //电流是百分比转换成赋值算的 percent = fData * 0.01; } else { + //电压是百分比算的 percent = 1.0; } if (1 == num) { 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 f51a84e1..69107d5f 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 @@ -17,6 +17,11 @@ public class TreeDataVO { */ private String scriptTypeName; + /** + * code + */ + private String scriptTypeCode; + /** * 源下发的描述 */ 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 15f0ec29..7c8620cf 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 @@ -167,6 +167,7 @@ public class ResultServiceImpl implements IResultService { //大相检测信息 TreeDataVO infoVO = new TreeDataVO(); infoVO.setScriptTypeName(dictTree.getName()); + infoVO.setScriptTypeCode(dictTree.getId()); //额定条件下频率准确度测试 LinkedHashMap> subTypeMap = value.stream() .sorted(Comparator.comparing(PqScriptDtls::getIndex)) @@ -176,6 +177,7 @@ public class ResultServiceImpl implements IResultService { if (!"VOLTAGE".equals(dictTree.getCode())) { TreeDataVO subType = new TreeDataVO(); subType.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); + subType.setScriptTypeCode(subKey); LinkedHashMap> indexMap = subValue.stream() .sorted(Comparator.comparing(PqScriptDtls::getIndex)) .collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList())); @@ -212,11 +214,13 @@ public class ResultServiceImpl implements IResultService { if (CollUtil.isNotEmpty(subSingleTypeMap)) { TreeDataVO subType = new TreeDataVO(); subType.setScriptTypeName(subName.get("Single").replace("XX", dictTree.getName())); + subType.setScriptTypeCode(dictTree.getCode()); //单影响量下频率准测量集合 List subSingleList = new ArrayList<>(); subSingleTypeMap.forEach((subKey, subValue) -> { TreeDataVO treeDataVO = new TreeDataVO(); treeDataVO.setScriptTypeName(subName.get(subKey).replace("XX", dictTree.getName())); + treeDataVO.setScriptTypeCode(subKey); List subTypeList = new ArrayList<>(); LinkedHashMap> indexMap = subValue.stream() diff --git a/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java b/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java index 0ea940e1..7164d97c 100644 --- a/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java +++ b/detection/src/main/java/com/njcn/gather/script/controller/PqScriptController.java @@ -130,7 +130,7 @@ public class PqScriptController extends BaseController { @ApiOperation("获取指定模式下的所有检测脚本") @ApiImplicitParam(name = "patternId", value = "模式Id", required = true) public HttpResult>> getAllPqScript(@RequestParam("patternId") String patternId) { - String methodDescribe = getMethodDescribe("getAllPqScript"); + String methodDescribe = getMethodDescribe("getAll"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId); List> result = pqScriptService.listAllPqScript(patternId); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); @@ -142,7 +142,7 @@ public class PqScriptController extends BaseController { @ApiOperation("根据脚本id查询检测脚本详情") @ApiImplicitParam(name = "id", value = "检测脚本id", required = true) public HttpResult> dls(@RequestBody PqScriptIssueParam param) { - String methodDescribe = getMethodDescribe("list"); + String methodDescribe = getMethodDescribe("dlsDetails"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param); List sourceIssues = pqScriptDtlsService.listSourceIssue(param); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe); @@ -154,10 +154,10 @@ public class PqScriptController extends BaseController { @ApiOperation("添加检测脚本") @ApiImplicitParam(name = "id", value = "检测脚本id", required = true) public HttpResult addScriptDtls(@RequestBody PqScriptDtlsParam sourceIssue) { - String methodDescribe = getMethodDescribe("list"); + String methodDescribe = getMethodDescribe("addScriptDtls"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceIssue); Boolean b = pqScriptDtlsService.saveScriptDtls(sourceIssue); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b , methodDescribe); } } diff --git a/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptDtlsMapper.xml b/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptDtlsMapper.xml index d497a316..f45dfe15 100644 --- a/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptDtlsMapper.xml +++ b/detection/src/main/java/com/njcn/gather/script/mapper/mapping/PqScriptDtlsMapper.xml @@ -6,11 +6,11 @@ diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptDtlsParam.java b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptDtlsParam.java index 33f4f4bf..27166c09 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptDtlsParam.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/param/PqScriptDtlsParam.java @@ -1,9 +1,7 @@ package com.njcn.gather.script.pojo.param; import com.alibaba.fastjson.annotation.JSONField; -import com.njcn.gather.script.pojo.po.SourceIssue; import lombok.Data; -import lombok.NoArgsConstructor; import java.util.List; @@ -60,7 +58,7 @@ public class PqScriptDtlsParam { private Double fFreq; /** - * + * 装置下发参数 */ @JSONField(name = "channelList", ordinal = 7) private List checkDataList; @@ -69,10 +67,8 @@ public class PqScriptDtlsParam { * 通道信息 */ @JSONField(name = "channelList", ordinal = 8) - private List channelList; + private List channelList; - - @NoArgsConstructor @Data public static class CheckData { @@ -110,9 +106,10 @@ public class PqScriptDtlsParam { * 是否参与误差比较:0-不参与 1-参与 */ private Integer errorFlag; + + } - @NoArgsConstructor @Data public static class ChannelListDTO { @@ -168,31 +165,30 @@ public class PqScriptDtlsParam { * 谐波叠加列表 */ @JSONField(name = "harmList", ordinal = 9) - private List harmList; + private List harmList; /** * 间谐波叠加列表 */ @JSONField(name = "inharmList", ordinal = 10) - private List inharmList; + private List inharmList; /** * 暂态数据 */ @JSONField(name = "dipData", ordinal = 11) - private SourceIssue.ChannelListDTO.DipDataDTO dipData; + private DipDataDTO dipData; /** * 闪变数据 */ @JSONField(name = "flickerData", ordinal = 12) - private SourceIssue.ChannelListDTO.FlickerDataDTO flickerData; + private FlickerDataDTO flickerData; /** * 谐波叠加列表 */ - @NoArgsConstructor @Data public static class HarmModel { @@ -219,7 +215,6 @@ public class PqScriptDtlsParam { /** * 间谐波叠加列表 */ - @NoArgsConstructor @Data public static class InharmModel { @@ -247,7 +242,6 @@ public class PqScriptDtlsParam { /** * 暂态数据 */ - @NoArgsConstructor @Data public static class DipDataDTO { @@ -294,7 +288,6 @@ public class PqScriptDtlsParam { /** * 闪变数据 */ - @NoArgsConstructor @Data public static class FlickerDataDTO { diff --git a/detection/src/main/java/com/njcn/gather/script/pojo/po/PqScriptDtls.java b/detection/src/main/java/com/njcn/gather/script/pojo/po/PqScriptDtls.java index c5d3eef0..80a49b1d 100644 --- a/detection/src/main/java/com/njcn/gather/script/pojo/po/PqScriptDtls.java +++ b/detection/src/main/java/com/njcn/gather/script/pojo/po/PqScriptDtls.java @@ -32,7 +32,7 @@ public class PqScriptDtls implements Serializable { /** * 总检测脚本中的测试项序号 */ - @TableField("Index") + @TableField("`index`") private Integer index; /** diff --git a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java index 6f8948cb..02c6d86b 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java +++ b/detection/src/main/java/com/njcn/gather/script/service/IPqScriptDtlsService.java @@ -5,7 +5,6 @@ import com.njcn.gather.script.pojo.param.PqScriptDtlsParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.SourceIssue; -import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO; import java.util.List; @@ -83,7 +82,7 @@ public interface IPqScriptDtlsService extends IService { * 查询当前检测小项的信息 * @return */ - List scriptDtlsList(); + List scriptDtlsList(PqScriptDtlsParam sourceIssue); Boolean saveCheck(); } 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 090a2392..2a60d68c 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 @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum; import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.pojo.enums.CommonEnum; @@ -20,11 +21,12 @@ import com.njcn.gather.script.pojo.po.PqScript; import com.njcn.gather.script.pojo.po.PqScriptCheckData; import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.pojo.po.SourceIssue; -import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO; import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.script.util.ScriptDtlsDesc; +import com.njcn.gather.script.util.UnbanUtil; import com.njcn.gather.system.dictionary.pojo.po.DictTree; +import com.njcn.gather.system.dictionary.service.IDictTreeService; import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.service.IDevTypeService; import lombok.RequiredArgsConstructor; @@ -75,6 +77,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl listSourceIssue(PqScriptIssueParam param) { List sourceIssues = new ArrayList<>(); - //校验终端额定电压电流是否相同 - List list = pqDevService.list(new LambdaQueryWrapper() - .eq(PqDev::getPlanId, param.getPlanId()) - .in(PqDev::getId, param.getDevIds()) - .eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) - ); - Set devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet()); - List devTypes = devTypeService.listByIds(devTypeSet); + Set voltSet =new HashSet<>(1); + Set currSet =new HashSet<>(1); + if(CollUtil.isNotEmpty(param.getDevIds())){ + //校验终端额定电压电流是否相同 + List list = pqDevService.list(new LambdaQueryWrapper() + .eq(PqDev::getPlanId, param.getPlanId()) + .in(PqDev::getId, param.getDevIds()) + .eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) + ); + Set devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet()); + List devTypes = devTypeService.listByIds(devTypeSet); + //额定电压信息 + voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet()); + //额定电流信息 + currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet()); + }else{ + voltSet.add(1.0); + currSet.add(1.0); + param.setIsPhaseSequence("-1"); + } - //额定电压信息 - Set voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet()); - //额定电流信息 - Set currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet()); if (voltSet.size() == 1 && currSet.size() == 1) { Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get(); @@ -162,7 +173,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl info = new ArrayList<>(); List checkList = new ArrayList<>(); - Integer i=sourceIssue.getIndex(); - if(ObjectUtil.isNotNull(sourceIssue.getIndex())){ + Integer i = sourceIssue.getIndex(); + if (ObjectUtil.isNotNull(sourceIssue.getIndex())) { this.remove(new MPJLambdaWrapper() - .eq(PqScriptDtls::getScriptId,sourceIssue.getScriptId()) - .eq(PqScriptDtls::getIndex,sourceIssue.getIndex()) + .eq(PqScriptDtls::getScriptId, sourceIssue.getScriptId()) + .eq(PqScriptDtls::getIndex, sourceIssue.getIndex()) ); pqScriptCheckDataService.remove(new MPJLambdaWrapper() - .eq(PqScriptCheckData::getScriptId,sourceIssue.getScriptId()) - .eq(PqScriptCheckData::getIndex,sourceIssue.getIndex()) + .eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId()) + .eq(PqScriptCheckData::getIndex, sourceIssue.getIndex()) ); - }else{ - i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()); + } else { + i = this.baseMapper.selectMaxIndex(sourceIssue.getScriptId()) + 1; } List checkDataList = sourceIssue.getCheckDataList(); PqScriptCheckData data; - for (PqScriptDtlsParam.CheckData checkData : checkDataList) { - data=new PqScriptCheckData(); - data.setScriptId(sourceIssue.getScriptId()); - data.setIndex(i); - data.setValueType(checkData.getValueType()); - data.setDataType(checkData.getDataType()); - data.setPhase(checkData.getPhase()); - data.setValue(checkData.getValue()); - data.setHarmNum(checkData.getHarmNum()); - data.setEnable(checkData.getEnable()); - data.setErrorFlag(checkData.getErrorFlag()); - checkList.add(data); + if (CollUtil.isNotEmpty(checkDataList)) { + for (PqScriptDtlsParam.CheckData checkData : checkDataList) { + data = new PqScriptCheckData(); + data.setScriptId(sourceIssue.getScriptId()); + data.setIndex(i); + data.setValueType(checkData.getValueType()); + data.setDataType(checkData.getDataType()); + data.setPhase(checkData.getPhase()); + data.setValue(checkData.getValue()); + data.setHarmNum(checkData.getHarmNum()); + data.setEnable(checkData.getEnable()); + data.setErrorFlag(checkData.getErrorFlag()); + checkList.add(data); + } } + //频率赋值 PqScriptDtls dtls = setScriptDtls(sourceIssue, i); dtls.setValueType(FREQ); @@ -263,95 +277,307 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl harmList = channelListDTO.getHarmList(); - for (SourceIssue.ChannelListDTO.HarmModel harmModel : harmList) { - PqScriptDtls harm = setScriptDtls(sourceIssue, i); + if (CollUtil.isNotEmpty(sourceIssue.getChannelList())) { + //开始遍历通道信息 + for (PqScriptDtlsParam.ChannelListDTO channelListDTO : sourceIssue.getChannelList()) { + String phase = channelListDTO.getChannelType().substring(1, 2).toUpperCase(); + //电压或者电流 + if (channelListDTO.getChannelFlag()) { + PqScriptDtls uOri = setScriptDtls(sourceIssue, i); + uOri.setPhase(phase); if (channelListDTO.getChannelType().contains("U")) { - harm.setValueType(HARM_V); + uOri.setValueType(VOL); } if (channelListDTO.getChannelType().contains("I")) { - harm.setValueType(HARM_I); + uOri.setValueType(CUR); } - harm.setPhase(phase); - harm.setHarmNum(harmModel.getHarm()); - harm.setValue(harmModel.getFAmp()); - harm.setAngle(harmModel.getFPhase()); - info.add(harm); + uOri.setValue(channelListDTO.getFAmp()); + uOri.setAngle(channelListDTO.getFPhase()); + info.add(uOri); } - } - //间谐波 - if (channelListDTO.getInHarmFlag()) { - List inharmList = channelListDTO.getInharmList(); - for (SourceIssue.ChannelListDTO.InharmModel inharmModel : inharmList) { - PqScriptDtls inHarm = setScriptDtls(sourceIssue, i); - if (channelListDTO.getChannelType().contains("U")) { - inHarm.setValueType(INHARM_V); + //谐波值 + if (channelListDTO.getHarmFlag()) { + List harmList = channelListDTO.getHarmList(); + for (PqScriptDtlsParam.ChannelListDTO.HarmModel harmModel : harmList) { + PqScriptDtls harm = setScriptDtls(sourceIssue, i); + if (channelListDTO.getChannelType().contains("U")) { + harm.setValueType(HARM_V); + } + if (channelListDTO.getChannelType().contains("I")) { + harm.setValueType(HARM_I); + } + harm.setPhase(phase); + harm.setHarmNum(harmModel.getHarm()); + harm.setValue(harmModel.getFAmp()); + harm.setAngle(harmModel.getFPhase()); + info.add(harm); } - if (channelListDTO.getChannelType().contains("I")) { - inHarm.setValueType(INHARM_I); - } - inHarm.setPhase(phase); - inHarm.setHarmNum(inharmModel.getInharm()); - inHarm.setValue(inharmModel.getFAmp()); - inHarm.setAngle(inharmModel.getFPhase()); - info.add(inHarm); } - } - //暂态 - if (channelListDTO.getDipFlag()) { - SourceIssue.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData(); - PqScriptDtls dip = setScriptDtls(sourceIssue, i); - dip.setValueType(DIP); - dip.setPhase(phase); - dip.setTransValue(dipData.getFTransValue()); - dip.setRetainTime(dipData.getRetainTime()); - info.add(dip); + //间谐波 + if (channelListDTO.getInHarmFlag()) { + List inharmList = channelListDTO.getInharmList(); + for (PqScriptDtlsParam.ChannelListDTO.InharmModel inharmModel : inharmList) { + PqScriptDtls inHarm = setScriptDtls(sourceIssue, i); + if (channelListDTO.getChannelType().contains("U")) { + inHarm.setValueType(INHARM_V); + } + if (channelListDTO.getChannelType().contains("I")) { + inHarm.setValueType(INHARM_I); + } + inHarm.setPhase(phase); + inHarm.setHarmNum(inharmModel.getInharm()); + inHarm.setValue(inharmModel.getFAmp()); + inHarm.setAngle(inharmModel.getFPhase()); + info.add(inHarm); + } + } + //暂态 + if (channelListDTO.getDipFlag()) { + PqScriptDtlsParam.ChannelListDTO.DipDataDTO dipData = channelListDTO.getDipData(); + PqScriptDtls dip = setScriptDtls(sourceIssue, i); + dip.setValueType(DIP); + dip.setPhase(phase); + dip.setTransValue(dipData.getFTransValue()); + dip.setRetainTime(dipData.getRetainTime()); + info.add(dip); - } - //闪变 - if (channelListDTO.getFlickerFlag()) { - SourceIssue.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData(); - PqScriptDtls dip = setScriptDtls(sourceIssue, i); - dip.setValueType(DIP); - dip.setPhase(phase); - dip.setChagFre(flickerData.getFChagFre()); - dip.setChagValue(flickerData.getFChagValue()); - info.add(dip); + } + //闪变 + if (channelListDTO.getFlickerFlag()) { + PqScriptDtlsParam.ChannelListDTO.FlickerDataDTO flickerData = channelListDTO.getFlickerData(); + PqScriptDtls dip = setScriptDtls(sourceIssue, i); + dip.setValueType(FLICKER); + dip.setPhase(phase); + dip.setChagFre(flickerData.getFChagFre()); + dip.setChagValue(flickerData.getFChagValue()); + info.add(dip); + } } } if (CollUtil.isNotEmpty(info)) { this.saveBatch(info); } - if(CollUtil.isNotEmpty(checkList)){ + if (CollUtil.isNotEmpty(checkList)) { pqScriptCheckDataService.saveBatch(checkList); } return true; } @Override - public List scriptDtlsList() { - return Collections.emptyList(); + public List scriptDtlsList(PqScriptDtlsParam sourceIssue) { + List info=new ArrayList<>(); + //获取所有下拉值情况 + List checkDataList = sourceIssue.getCheckDataList(); + if(CollUtil.isNotEmpty(checkDataList)){ + List ids = checkDataList.stream().map(PqScriptDtlsParam.CheckData::getValueType).collect(Collectors.toList()); + List dictTreeById = dictTreeService.getDictTreeById(ids); + Map dicTreeMap = dictTreeById.stream().collect(Collectors.toMap(DictTree::getId, DictTree::getCode)); + PqScriptDtlsParam.CheckData checkData; + for (PqScriptDtlsParam.CheckData channelListDTO : checkDataList) { + if(dicTreeMap.containsKey(channelListDTO.getValueType())){ + String code = dicTreeMap.get(channelListDTO.getValueType()); + DetectionCodeEnum codeEnum = DetectionCodeEnum.getDetectionCodeByCode(code); + List channelList = sourceIssue.getChannelList(); + List list; + switch (codeEnum){ + case FREQ: + checkData=new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(sourceIssue.getFFreq()); + checkData.setPhase("T"); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + break; + case U1: + case VRMS: + if(CollUtil.isNotEmpty(channelList)){ + list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); + rmsCheck(info, channelListDTO, list); + } + break; + case DELTA_V: + 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()); + checkData.setValue(0.0); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + break; + case VA: + 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()); + checkData.setValue(listDTO.getFPhase()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + break; + case V2_50: + if(CollUtil.isNotEmpty(channelList)){ + list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); + harmCheck(info, channelListDTO, list); + } + break; + case I2_50: + if(CollUtil.isNotEmpty(channelList)){ + list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList()); + harmCheck(info, channelListDTO, list); + } + break; + case P2_50: + break; + case SV_1_49: + if(CollUtil.isNotEmpty(channelList)){ + list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); + inHarmCheck(info, channelListDTO, list); + } + break; + case SI_1_49: + if(CollUtil.isNotEmpty(channelList)){ + list= channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList()); + inHarmCheck(info, channelListDTO, list); + } + break; + case MAG: + 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().getFTransValue()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + 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()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + break; + case IRMS: + case IA: + if(CollUtil.isNotEmpty(channelList)){ + list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList()); + rmsCheck(info, channelListDTO, list); + } + break; + case V_UNBAN: + list = channelList.stream().filter(x -> x.getChannelType().contains("U")).collect(Collectors.toList()); + unbanCheck(info, channelListDTO, channelList, list); + break; + case I_UNBAN: + list = channelList.stream().filter(x -> x.getChannelType().contains("I")).collect(Collectors.toList()); + unbanCheck(info, channelListDTO, channelList, list); + break; + case PST: + break; + + default: + break; + } + } + } + } + return info; } + private void unbanCheck(List info, PqScriptDtlsParam.CheckData channelListDTO, List channelList, List list) { + 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(UnbanUtil.calculateUnbalance(a.getFAmp(),a.getFPhase(),b.getFAmp(),b.getFPhase(),c.getFAmp(),c.getFPhase())); + checkData.setPhase("T"); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + + private void rmsCheck(List info, PqScriptDtlsParam.CheckData channelListDTO, List list) { + PqScriptDtlsParam.CheckData checkData; + for (PqScriptDtlsParam.ChannelListDTO listDTO : list) { + checkData=new PqScriptDtlsParam.CheckData(); + checkData.setErrorFlag(channelListDTO.getErrorFlag()); + checkData.setEnable(channelListDTO.getEnable()); + checkData.setValue(listDTO.getFAmp()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + + private void inHarmCheck(List info, PqScriptDtlsParam.CheckData channelListDTO, List uList) { + PqScriptDtlsParam.CheckData checkData; + for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) { + 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()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setHarmNum(inharmModel.getInharm()); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + } + } + + private void harmCheck(List info, PqScriptDtlsParam.CheckData channelListDTO, List uList) { + PqScriptDtlsParam.CheckData checkData; + for (PqScriptDtlsParam.ChannelListDTO listDTO : uList) { + 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()); + checkData.setPhase(listDTO.getChannelType().substring(1,2)); + checkData.setHarmNum(harmModel.getHarm()); + checkData.setDataType(channelListDTO.getDataType()); + checkData.setValueType(channelListDTO.getValueType()); + info.add(checkData); + } + } + } + } + + @Override public Boolean saveCheck() { return null; @@ -373,7 +599,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl