From 1859f22109a1d1fddc7c09d001f4886449611f76 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Thu, 2 Jan 2025 14:38:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E6=BA=90=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8D=95=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gather/result/service/IResultService.java | 2 + .../service/impl/ResultServiceImpl.java | 50 +++++++++---------- .../err/pojo/param/PqErrSysDtlsParam.java | 6 +-- .../device/err/pojo/po/PqErrSysDtls.java | 1 + .../service/impl/PqScriptDtlsServiceImpl.java | 11 +++- 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java index c70721d3..5ca2b418 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java +++ b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java @@ -27,4 +27,6 @@ public interface IResultService { * @Date: 2024/12/31 15:14 */ List treeData(ResultParam param); + + } 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 06182b6e..28e5e7fc 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,6 +5,7 @@ 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.PqScriptDtls; @@ -26,6 +27,7 @@ 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; @@ -138,7 +140,7 @@ public class ResultServiceImpl implements IResultService { subName.put("Freq", "频率对XX测量的影响"); subName.put("Harm", "谐波对XX测量的影响"); Boolean isValueType = scriptMapper.selectScriptIsValueType(param.getScriptId()); - + PqDevVO dev = pqDevService.getPqDevById(param.getDevId()); List infoVOS = new ArrayList<>(); Map> finalResultMap = resultMap; @@ -170,14 +172,15 @@ public class ResultServiceImpl implements IResultService { List vol = scriptDtlIndex.stream().filter(x -> "VOL".equals(x.getValueType())) .sorted(Comparator.comparing(PqScriptDtls::getPhase)).collect(Collectors.toList()); if (CollUtil.isNotEmpty(vol)) { - String unit; + Float unit = 1f; if (isValueType) { - unit = ResultUnitEnum.V_RELATIVE_UNIT.getUnit(); - } else { - unit = ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(); - } + unit = dev.getDevVolt(); + } for (PqScriptDtls dtls : vol) { - buffer.append("U" + dtls.getPhase().toLowerCase() + "=" + dtls.getValue() + unit + " "); + 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() + " "); } } @@ -185,22 +188,20 @@ public class ResultServiceImpl implements IResultService { .sorted(Comparator.comparing(PqScriptDtls::getPhase)) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(cur)) { - String unit; + Float unit = 1f; if (isValueType) { - unit = ResultUnitEnum.I_RELATIVE_UNIT.getUnit(); - } else { - unit = ResultUnitEnum.I_ABSOLUTELY_UNIT.getUnit(); + unit = dev.getDevCurr(); } for (PqScriptDtls dtls : vol) { - buffer.append("I" + dtls.getPhase().toLowerCase() + "=" + dtls.getValue() + unit + " "); + buffer.append("I" + dtls.getPhase().toLowerCase() + "=" + dtls.getValue()*0.01*unit + ResultUnitEnum.I_ABSOLUTELY_UNIT.getUnit() + " "); } } - dtlsSetBuffer(scriptDtlIndex, vol, buffer, "Harm_V", "次谐波电压幅值", ResultUnitEnum.HV_UNIT.getUnit(), true); - dtlsSetBuffer(scriptDtlIndex, vol, buffer, "Harm_I", "次谐波电流幅值", ResultUnitEnum.HI_UNIT.getUnit(), true); - dtlsSetBuffer(scriptDtlIndex, vol, buffer, "InHarm_V", "次间谐波电压幅值", ResultUnitEnum.HSV_UNIT.getUnit(), false); - dtlsSetBuffer(scriptDtlIndex, vol, buffer, "InHarm_I", "次间谐波电流幅值", ResultUnitEnum.HSI_UNIT.getUnit(), false); - dtlsSetBufferDip(scriptDtlIndex, vol, buffer, "Dip", "暂态", ResultUnitEnum.HSI_UNIT.getUnit()); - dtlsSetBufferFlicker(scriptDtlIndex, vol, buffer, "Flicker", "闪变"); + dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_V", "次谐波电压幅值", ResultUnitEnum.HV_UNIT.getUnit(), true); + dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_I", "次谐波电流幅值", ResultUnitEnum.HI_UNIT.getUnit(), true); + dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_V", "次间谐波电压幅值", ResultUnitEnum.HSV_UNIT.getUnit(), false); + dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_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()); @@ -226,7 +227,7 @@ public class ResultServiceImpl implements IResultService { return infoVOS; } - private static void dtlsSetBuffer(List scriptDtlIndex, List vol, StringBuffer buffer, String valueType, String name, String unit, Boolean fly) { + private static void dtlsSetBuffer(List scriptDtlIndex, StringBuffer buffer, String valueType, String name, String unit, Boolean fly) { LinkedHashMap> harmNumMap = scriptDtlIndex.stream() .filter(x -> valueType.equals(x.getValueType())) .sorted(Comparator.comparing(PqScriptDtls::getIndex)) @@ -242,7 +243,7 @@ public class ResultServiceImpl implements IResultService { .sorted(Comparator.comparing(PqScriptDtls::getPhase)) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(list)) { - for (PqScriptDtls dtls : vol) { + for (PqScriptDtls dtls : list) { buffer.append(dtls.getPhase() + "相=" + dtls.getValue() + unit + " "); } buffer.append(") "); @@ -253,13 +254,13 @@ public class ResultServiceImpl implements IResultService { } - private static void dtlsSetBufferDip(List scriptDtlIndex, List vol, StringBuffer buffer, String valueType, String name, String unit) { + private static void dtlsSetBufferDip(List scriptDtlIndex,StringBuffer buffer, String valueType, String name, String unit) { List list = scriptDtlIndex.stream().filter(x -> valueType.equals(x.getValueType())) .sorted(Comparator.comparing(PqScriptDtls::getPhase)) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(list)) { buffer.append(name + " "); - for (PqScriptDtls dtls : vol) { + for (PqScriptDtls dtls : list) { buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() + " 暂态持续时间=" + dtls.getRetainTime() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() + ") "); } @@ -267,14 +268,13 @@ public class ResultServiceImpl implements IResultService { } - private static void dtlsSetBufferFlicker(List scriptDtlIndex, List vol, StringBuffer buffer, String valueType, String name) { + private static void dtlsSetBufferFlicker(List scriptDtlIndex,StringBuffer buffer, String valueType, String name) { List list = scriptDtlIndex.stream().filter(x -> valueType.equals(x.getValueType())) .sorted(Comparator.comparing(PqScriptDtls::getPhase)) .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(list)) { buffer.append(name + " "); - for (PqScriptDtls dtls : vol) { + for (PqScriptDtls dtls : list) { buffer.append(dtls.getPhase() + "相(变动频度=" + dtls.getTransValue() + "次/min 变动量=" + dtls.getRetainTime() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() + ") "); } diff --git a/device/src/main/java/com/njcn/gather/device/err/pojo/param/PqErrSysDtlsParam.java b/device/src/main/java/com/njcn/gather/device/err/pojo/param/PqErrSysDtlsParam.java index ebaf4c48..33594eea 100644 --- a/device/src/main/java/com/njcn/gather/device/err/pojo/param/PqErrSysDtlsParam.java +++ b/device/src/main/java/com/njcn/gather/device/err/pojo/param/PqErrSysDtlsParam.java @@ -27,13 +27,13 @@ public class PqErrSysDtlsParam { private String scriptType; @ApiModelProperty(value = "误差判断起始值", required = true) - private Float startValue; + private Double startValue; @ApiModelProperty(value = "是否包含起始值", required = true) private Integer startFlag; @ApiModelProperty(value = "误差判断结束值", required = true) - private Float endValue; + private Double endValue; @ApiModelProperty(value = "是否包含结束值", required = true) private Integer endFlag; @@ -48,7 +48,7 @@ public class PqErrSysDtlsParam { @ApiModelProperty(value = "最大值误差", required = true) @NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL) - private Float maxErrorValue; + private Double maxErrorValue; @ApiModelProperty(value = "误差值类型", required = true) @NotNull(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK) diff --git a/device/src/main/java/com/njcn/gather/device/err/pojo/po/PqErrSysDtls.java b/device/src/main/java/com/njcn/gather/device/err/pojo/po/PqErrSysDtls.java index 0b3cd31c..95a69ed2 100644 --- a/device/src/main/java/com/njcn/gather/device/err/pojo/po/PqErrSysDtls.java +++ b/device/src/main/java/com/njcn/gather/device/err/pojo/po/PqErrSysDtls.java @@ -73,6 +73,7 @@ public class PqErrSysDtls implements Serializable { /** * 误差最大值 */ + @TableField("Max_Error_Value") private Double maxErrorValue; /** 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 976ae754..86259ab3 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 @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -223,10 +224,16 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl