From 6ff3d7e33637e67b2000a3abd1dfec162e868bd4 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 25 Mar 2025 14:28:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E7=9B=B8=E8=A7=92=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E5=92=8C=E9=80=BB=E8=BE=91=E5=A4=84?= =?UTF-8?q?=E7=90=86=202.=E4=BF=AE=E6=AD=A3=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF=E6=8C=81=E7=9B=B8?= =?UTF-8?q?=E8=A7=92=E5=90=AF=E7=94=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketDevResponseService.java | 78 ++++++++++++------- entrance/src/main/resources/application.yml | 16 +++- 2 files changed, 64 insertions(+), 30 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index d339384c..0130c04f 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -35,6 +35,7 @@ import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import com.njcn.gather.system.pojo.enums.DicDataEnum; import com.njcn.gather.system.reg.service.ISysRegResService; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.lang.reflect.Field; @@ -81,7 +82,8 @@ public class SocketDevResponseService { private final ISysTestConfigService sysTestConfigService; private final AdHarmonicService adHarmonicService; private final IAdPlanService adPlanService; - + @Value("${phaseAngle.isEnable}") + private Boolean isPhaseAngle; // private final ExecutorService executorPool = Executors.newFixedThreadPool(10); @@ -563,12 +565,12 @@ public class SocketDevResponseService { coefficientVO.setCIeData(String.valueOf(optionalIC)); if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) { - Integer aXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUa_gain() / optionalA).setScale(0,RoundingMode.HALF_UP).intValue(); - Integer bXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUb_gain() / optionalB).setScale(0,RoundingMode.HALF_UP).intValue(); - Integer cXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUc_gain() / optionalC).setScale(0,RoundingMode.HALF_UP).intValue(); - Integer aIXi =BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIa_gain() / optionalIA).setScale(0,RoundingMode.HALF_UP).intValue(); - Integer bIXi =BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIb_gain() / optionalIB).setScale(0,RoundingMode.HALF_UP).intValue(); - Integer cIXi =BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIc_gain() / optionalIC).setScale(0,RoundingMode.HALF_UP).intValue(); + Integer aXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUa_gain() / optionalA).setScale(0, RoundingMode.HALF_UP).intValue(); + Integer bXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUb_gain() / optionalB).setScale(0, RoundingMode.HALF_UP).intValue(); + Integer cXi = BigDecimal.valueOf(devParameter.getDevVolt() * startF.getF().getUc_gain() / optionalC).setScale(0, RoundingMode.HALF_UP).intValue(); + Integer aIXi = BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIa_gain() / optionalIA).setScale(0, RoundingMode.HALF_UP).intValue(); + Integer bIXi = BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIb_gain() / optionalIB).setScale(0, RoundingMode.HALF_UP).intValue(); + Integer cIXi = BigDecimal.valueOf(devParameter.getDevCurr() * startF.getF().getIc_gain() / optionalIC).setScale(0, RoundingMode.HALF_UP).intValue(); coefficientVO.setAVuXi(aXi.toString()); coefficientVO.setBVuXi(bXi.toString()); @@ -1285,13 +1287,22 @@ public class SocketDevResponseService { List data, List dataPhase) { StringBuffer str = new StringBuffer(); - if (data.size() == dataPhase.size()) { + if(isPhaseAngle){ + if(CollUtil.isNotEmpty(data)&&CollUtil.isNotEmpty(dataPhase)){ + if (data.size() == dataPhase.size()) { + DevData.SqlDataDTO.ListDTO dto = data.get(0).getList(); + DevData.SqlDataDTO.ListDTO phase = dataPhase.get(0).getList(); + str.append("装置(" + type + "a=" + String.format("%.4f", dto.getA()) + ",相角=" + String.format("%.4f", phase.getA()) + "° " + + type + "b=" + String.format("%.4f", dto.getB()) + ",相角=" + String.format("%.4f", phase.getB()) + "° " + + type + "c=" + String.format("%.4f", dto.getC()) + ",相角=" + String.format("%.4f", phase.getC()) + "° "); + str.append(")"); + } + } + }else{ DevData.SqlDataDTO.ListDTO dto = data.get(0).getList(); - DevData.SqlDataDTO.ListDTO phase = dataPhase.get(0).getList(); - - str.append("装置(" + type + "a=" + String.format("%.4f", dto.getA()) + ",相角=" + String.format("%.4f", phase.getA()) + "° " + - type + "b=" + String.format("%.4f", dto.getB()) + ",相角=" + String.format("%.4f", phase.getB()) + "° " + - type + "c=" + String.format("%.4f", dto.getC()) + ",相角=" + String.format("%.4f", phase.getC()) + "° "); + str.append("装置(" + type + "a=" + String.format("%.4f", dto.getA()) + + type + "b=" + String.format("%.4f", dto.getB()) + + type + "c=" + String.format("%.4f", dto.getC()) ); str.append(")"); } return str.toString(); @@ -1366,20 +1377,33 @@ public class SocketDevResponseService { //源信息 Map sourceMap = channelList.stream() .collect(Collectors.toMap(x -> x.getChannelType(), Function.identity())); - Boolean a = getaBoolean(sourceMap.get(type + "a"), data.get(0).getList().getA(), dataPhase.get(0).getList().getA()); - Boolean b = getaBoolean(sourceMap.get(type + "b"), data.get(0).getList().getB(), dataPhase.get(0).getList().getB()); - Boolean c = getaBoolean(sourceMap.get(type + "c"), data.get(0).getList().getC(), dataPhase.get(0).getList().getC()); + Boolean a = getaBoolean(sourceMap.get(type + "a"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getA() : null, + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getA(): null); + Boolean b = getaBoolean(sourceMap.get(type + "b"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getB(): null, + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getB(): null); + Boolean c = getaBoolean(sourceMap.get(type + "c"), CollUtil.isNotEmpty(data) ? data.get(0).getList().getC(): null, + CollUtil.isNotEmpty(dataPhase) ? dataPhase.get(0).getList().getC(): null); compareDev.setIsQualified(a && b && c); compareDev.setDesc(name + (compareDev.getIsQualified() ? "合格->" : "不合格->") + stepTag + desc + stepTag + devMessage(type, data, dataPhase)); return compareDev; } - private static Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) { - return NumberUtil.isIn(BigDecimal.valueOf(devData), - BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95), - BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05)) - && - phaseBoolean(channelListDTO, devPhase); + private Boolean getaBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devData, Double devPhase) { + Boolean isDev = false; + Boolean isPhase = false; + if(ObjectUtil.isNotNull(devData)){ + isDev= NumberUtil.isIn(BigDecimal.valueOf(devData), + BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95), + BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05)); + } + if(isPhaseAngle){ + if(ObjectUtil.isNotNull(devPhase)){ + isPhase = phaseBoolean(channelListDTO, devPhase); + } + }else{ + isPhase=true; + } + return isDev && isPhase; } @@ -1391,7 +1415,7 @@ public class SocketDevResponseService { * @param devPhase 装置返回角度 * @return */ - private static Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) { + private Boolean phaseBoolean(SourceIssue.ChannelListDTO channelListDTO, Double devPhase) { Double phase = devPhase; if (devPhase < -180) { phase = devPhase + 360; @@ -1603,8 +1627,8 @@ public class SocketDevResponseService { List c = tem.getC(); Class example = (Class) adHarmonicResult.getClass(); - if(DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) || DicDataEnum.HSI.getCode().equals(sourceIssue.getType())){ - for (int i = 1; i < a.size()+1; i++) { + if (DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) || DicDataEnum.HSI.getCode().equals(sourceIssue.getType())) { + for (int i = 1; i < a.size() + 1; i++) { try { Field aField = example.getDeclaredField("aValue" + i); Field bField = example.getDeclaredField("bValue" + i); @@ -1620,8 +1644,8 @@ public class SocketDevResponseService { e.printStackTrace(); } } - }else{ - for (int i = 2; i <= a.size()+1; i++) { + } else { + for (int i = 2; i <= a.size() + 1; i++) { try { Field aField = example.getDeclaredField("aValue" + i); Field bField = example.getDeclaredField("bValue" + i); diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml index e2ecc40e..28ec2188 100644 --- a/entrance/src/main/resources/application.yml +++ b/entrance/src/main/resources/application.yml @@ -9,6 +9,9 @@ spring: url: jdbc:mysql://192.168.1.24:13306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT username: root password: njcnpqs +# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT +# username: root +# password: root #初始化建立物理连接的个数、最小、最大连接数 initial-size: 5 min-idle: 5 @@ -41,15 +44,22 @@ mybatis-plus: #指定主键生成策略 id-type: assign_uuid - +phaseAngle: + isEnable: false socket: source: - ip: 192.168.1.24 + ip: 192.168.1.138 port: 62000 device: - ip: 192.168.1.24 + ip: 192.168.1.138 port: 61000 +# source: +# ip: 192.168.1.121 +# port: 10086 +# device: +# ip: 192.168.1.121 +# port: 61000 webSocket: port: 7777