正式检测检测项进度,小相详情展示
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.njcn.gather.device.script.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/9
|
||||
*/
|
||||
@Getter
|
||||
public enum ResultUnitEnum {
|
||||
|
||||
FREQ_UNIT("Hz", "频率"),
|
||||
V_RELATIVE_UNIT("%Un", "电压"),
|
||||
V_ABSOLUTELY_UNIT("V", "电压"),
|
||||
I_RELATIVE_UNIT("%In", "电流"),
|
||||
I_ABSOLUTELY_UNIT("A", "电流"),
|
||||
HV_UNIT("%", "谐波电压"),
|
||||
HI_UNIT("%", "谐波电流"),
|
||||
HP_UNIT("W", "谐波有功功率"),
|
||||
HSV_UNIT("%", "间谐波电压"),
|
||||
HSI_UNIT("%", "间谐波电流"),
|
||||
VOLTAGE_MAG_UNIT("周波", "暂态持续时间"),
|
||||
VOLTAGE_DUR_UNIT("%", "暂态深度"),
|
||||
IMBV_UNIT("%", "电压不平衡度"),
|
||||
IMBA_UNIT("%", "电流不平衡度"),
|
||||
|
||||
;
|
||||
|
||||
private String unit;
|
||||
private String name;
|
||||
|
||||
ResultUnitEnum(String unit, String name) {
|
||||
this.unit = unit;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.njcn.gather.device.script.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.gather.device.script.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/1/13 22:05
|
||||
*/
|
||||
public class ScriptDtlsDesc {
|
||||
public static StringBuffer getStringBuffer(List<PqScriptDtls> scriptDtlIndex, Boolean isValueType) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("输入:");
|
||||
appendValue(scriptDtlIndex, buffer, "Freq", "频率", ResultUnitEnum.FREQ_UNIT.getUnit(), null);
|
||||
appendValue(scriptDtlIndex, buffer, "VOL", "U", isValueType ? ResultUnitEnum.V_RELATIVE_UNIT.getUnit() : ResultUnitEnum.V_ABSOLUTELY_UNIT.getUnit(), "相角=");
|
||||
appendValue(scriptDtlIndex, buffer, "CUR", "I", isValueType ? ResultUnitEnum.I_RELATIVE_UNIT.getUnit() : ResultUnitEnum.I_ABSOLUTELY_UNIT.getUnit(), "相角=");
|
||||
dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_V", "h", ResultUnitEnum.HV_UNIT.getUnit(), true);
|
||||
dtlsSetBuffer(scriptDtlIndex, buffer, "Harm_I", "h", ResultUnitEnum.HI_UNIT.getUnit(), true);
|
||||
dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_V", "i", ResultUnitEnum.HSV_UNIT.getUnit(), false);
|
||||
dtlsSetBuffer(scriptDtlIndex, buffer, "InHarm_I", "i", ResultUnitEnum.HSI_UNIT.getUnit(), false);
|
||||
dtlsSetBufferDip(scriptDtlIndex, buffer, "Dip", "暂态", ResultUnitEnum.HSI_UNIT.getUnit());
|
||||
dtlsSetBufferFlicker(scriptDtlIndex, buffer, "Flicker", "闪变");
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static void appendValue(List<PqScriptDtls> scriptDtlIndex, StringBuffer buffer, String valueType, String prefix, String unit, String suffix) {
|
||||
List<PqScriptDtls> values = scriptDtlIndex.stream()
|
||||
.filter(x -> valueType.equals(x.getValueType()))
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(values)) {
|
||||
for (PqScriptDtls dtls : values) {
|
||||
buffer.append(prefix + dtls.getPhase().toLowerCase() + "=" + dtls.getValue() + unit);
|
||||
if (suffix != null) {
|
||||
buffer.append("," + suffix + dtls.getAngle() + "° ");
|
||||
} else {
|
||||
buffer.append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public 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::getHarmNum))
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getHarmNum, LinkedHashMap::new, Collectors.toList()));
|
||||
harmNumMap.forEach((harmNum, value) -> {
|
||||
if (fly) {
|
||||
buffer.append(name + String.format("%.0f", harmNum) + "(");
|
||||
} else {
|
||||
buffer.append(name + harmNum + "(");
|
||||
}
|
||||
appendValues(buffer, value, 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 : list) {
|
||||
buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit()
|
||||
+ ",暂态持续时间=" + dtls.getRetainTime().intValue() + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 : list) {
|
||||
buffer.append(dtls.getPhase() + "相(变动频度=" + dtls.getChagFre()
|
||||
+ "次/min,变动量=" + dtls.getChagValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() + ") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendValues(StringBuffer buffer, List<PqScriptDtls> values, String unit) {
|
||||
if (CollUtil.isNotEmpty(values)) {
|
||||
for (PqScriptDtls dtls : values) {
|
||||
buffer.append(dtls.getPhase() + "相=" + dtls.getValue() + unit);
|
||||
}
|
||||
buffer.append(") ");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user