diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index d5095b43..5bd7c217 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -318,6 +318,7 @@ public class SocketSourceResponseService { //告诉前端当前项开始了 WebSocketVO> webSocketVO = new WebSocketVO<>(); webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1]+stepBegin); + webSocketVO.setDesc(SocketManager.getSourceList().get(0).getDesc()); List devListRes = new ArrayList<>(); devList.forEach(item->{ DevLineTestResult devLineTestResult = new DevLineTestResult(); diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/WebSocketVO.java b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/WebSocketVO.java index cac182ac..931fe48d 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/WebSocketVO.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/WebSocketVO.java @@ -19,6 +19,8 @@ public class WebSocketVO { private Integer code; + private String desc; + private T data; } 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 94b5bd20..1b654fb6 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 @@ -11,6 +11,7 @@ import com.njcn.gather.device.script.pojo.po.PqScriptCheckData; import com.njcn.gather.device.script.pojo.po.PqScriptDtls; import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.device.script.service.IPqScriptDtlsService; +import com.njcn.gather.device.script.util.ScriptDtlsDesc; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.result.pojo.enums.ResultUnitEnum; @@ -174,7 +175,7 @@ public class ResultServiceImpl implements IResultService { dtlType.setIndex(index); dtlType.setScriptType(scriptDtlIndexList.get(0).getScriptType()); ratedScriptTypeName(scriptDtlIndexList, isValueType, dtlType, dictTree); - dtlType.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString()); dtlType.setFly(conform(finalResultMap.get(index))); subTypeList.add(dtlType); } @@ -223,7 +224,7 @@ public class ResultServiceImpl implements IResultService { if ("Freq".equals(subKey)) { freqScriptTypeName(scriptDtlIndexList, dictTree, isValueType, dtlType); } - dtlType.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dtlType.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString()); dtlType.setFly(conform(finalResultMap.get(index))); subTypeList.add(dtlType); } @@ -266,7 +267,7 @@ public class ResultServiceImpl implements IResultService { dlt.setScriptTypeName("特征幅值=" + dtls.getTransValue() + "%Un,持续时间=" + dtls.getRetainTime().intValue() + "周波"); dlt.setIndex(dtls.getIndex()); dlt.setScriptType(scriptDtlIndexList.get(0).getScriptType()); - dlt.setSourceDesc(getStringBuffer(scriptDtlIndexList, isValueType).toString()); + dlt.setSourceDesc(ScriptDtlsDesc.getStringBuffer(scriptDtlIndexList, isValueType).toString()); dlt.setFly(conform(finalResultMap.get(dtls.getIndex()))); info.add(dlt); } @@ -745,37 +746,6 @@ public class ResultServiceImpl implements IResultService { } - private StringBuffer getStringBuffer(List 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; - } - - private void appendValue(List scriptDtlIndex, StringBuffer buffer, String valueType, String prefix, String unit, String suffix) { - List 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(" "); - } - } - } - } @Override public ResultVO resultData(ResultParam param) { @@ -810,56 +780,6 @@ public class ResultServiceImpl implements IResultService { return resultVO; } - private 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::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 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 : list) { - buffer.append(dtls.getPhase() + "相(暂态深度=" + dtls.getTransValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() - + ",暂态持续时间=" + dtls.getRetainTime().intValue() + ResultUnitEnum.VOLTAGE_MAG_UNIT.getUnit() + ") "); - } - } - } - - private 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 : list) { - buffer.append(dtls.getPhase() + "相(变动频度=" + dtls.getChagFre() - + "次/min,变动量=" + dtls.getChagValue() + ResultUnitEnum.VOLTAGE_DUR_UNIT.getUnit() + ") "); - } - } - } - - private void appendValues(StringBuffer buffer, List values, String unit) { - if (CollUtil.isNotEmpty(values)) { - for (PqScriptDtls dtls : values) { - buffer.append(dtls.getPhase() + "相=" + dtls.getValue() + unit); - } - buffer.append(") "); - } - } - private Integer conform(Set numbers) { if (numbers.size() > 1) { if (numbers.contains(4)) { diff --git a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java index fd3dead3..a5bbe36d 100644 --- a/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java +++ b/device/src/main/java/com/njcn/gather/device/script/pojo/po/SourceIssue.java @@ -44,6 +44,11 @@ public class SourceIssue { @JSONField(serialize = false) private List devValueTypeList; + + @JSONField(serialize = false) + private String desc; + + /** * 检测类型 */ 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 4bff5ff6..7dde3659 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 @@ -20,6 +20,7 @@ import com.njcn.gather.device.script.pojo.po.PqScriptDtls; import com.njcn.gather.device.script.pojo.po.SourceIssue; import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.device.script.service.IPqScriptDtlsService; +import com.njcn.gather.device.script.util.ScriptDtlsDesc; import com.njcn.gather.system.dictionary.pojo.po.DictTree; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -125,6 +126,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr,param.getIndexList()); + Boolean isValueType = pqScriptMapper.selectScriptIsValueType(param.getScriptId()); if (CollUtil.isNotEmpty(pqScriptDtls)) { /** * 1.获取全部检测点脚本 @@ -157,6 +159,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl