1.调整源下发参数单位信息

This commit is contained in:
wr
2025-01-02 14:38:06 +08:00
parent f45a344db8
commit 1859f22109
5 changed files with 40 additions and 30 deletions

View File

@@ -27,4 +27,6 @@ public interface IResultService {
* @Date: 2024/12/31 15:14
*/
List<DetectionInfoVO> treeData(ResultParam param);
}

View File

@@ -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<DetectionInfoVO> infoVOS = new ArrayList<>();
Map<Integer, Set<Integer>> finalResultMap = resultMap;
@@ -170,14 +172,15 @@ public class ResultServiceImpl implements IResultService {
List<PqScriptDtls> 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<PqScriptDtls> scriptDtlIndex, List<PqScriptDtls> vol, StringBuffer buffer, String valueType, String name, String unit, Boolean fly) {
private static void dtlsSetBuffer(List<PqScriptDtls> scriptDtlIndex, StringBuffer buffer, String valueType, String name, String unit, Boolean fly) {
LinkedHashMap<Double, List<PqScriptDtls>> 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<PqScriptDtls> scriptDtlIndex, List<PqScriptDtls> vol, StringBuffer buffer, String valueType, String name, String unit) {
private static void dtlsSetBufferDip(List<PqScriptDtls> scriptDtlIndex,StringBuffer buffer, String valueType, String name, String unit) {
List<PqScriptDtls> 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<PqScriptDtls> scriptDtlIndex, List<PqScriptDtls> vol, StringBuffer buffer, String valueType, String name) {
private static void dtlsSetBufferFlicker(List<PqScriptDtls> scriptDtlIndex,StringBuffer buffer, String valueType, String name) {
List<PqScriptDtls> 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() + ") ");
}

View File

@@ -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)

View File

@@ -73,6 +73,7 @@ public class PqErrSysDtls implements Serializable {
/**
* 误差最大值
*/
@TableField("Max_Error_Value")
private Double maxErrorValue;
/**

View File

@@ -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<PqScriptDtlsMapper, PqS
if (isValueType) {
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
if (VOL.equals(pqScriptDtl.getValueType())) {
pqScriptDtl.setValue(pqScriptDtl.getValue() * volt);
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(volt.toString()));
pqScriptDtl.setValue(result.doubleValue());
}
if (CUR.equals(pqScriptDtl.getValueType())) {
pqScriptDtl.setValue(pqScriptDtl.getValue() * curr);
BigDecimal volValue = new BigDecimal(pqScriptDtl.getValue());
BigDecimal result = volValue.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(curr.toString()));
pqScriptDtl.setValue(result.doubleValue());
}
}
}