From 267e622c876bea09b61af34fc93cd08b022aa423 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 05 十二月 2024 14:50:40 +0800 Subject: [PATCH] 1、优化代码; 2、实现新功能:查询RTU设备在通信中间件中的状态。 --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java | 83 ++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 51 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java index 5768ebf..dcaf611 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java @@ -2,9 +2,13 @@ import com.alibaba.fastjson2.JSONObject; import com.dy.common.aop.SsoAop; -import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1; -import com.dy.common.mw.protocol.p206V1_0_0.downVos.*; +import com.dy.common.multiDataSource.DataSourceContext; +import com.dy.common.mw.protocol.p206V1.CodeV1; +import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; +import com.dy.common.mw.protocol.p206V1.downVos.*; +import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; import com.dy.common.mw.protocol.p206V202404.CodeV202404; +import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo; import com.dy.common.util.IDLongGenerator; import com.dy.common.webUtil.BaseResponse; @@ -31,9 +35,6 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Objects; - -//import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com97Vo; -//import com.dy.common.mw.protocol.p206V1_0_0.downVos.ComXyVo; /** * @author ZhuBaoMin @@ -71,7 +72,7 @@ /** * 閫氱敤鏌ヨ鎺ュ彛 - * p206V1_0_1 + * p206V1 * 66 鏌ヨIP鍜岀鍙� * 67 鏌ヨ娴侀噺閲囬泦鍛ㄦ湡 * 68 鏌ヨ鐢ㄦ埛浣欓鎶ヨ鍊� @@ -94,11 +95,6 @@ Long operator = po.getOperator(); Long comId = idLongGenerator.generate(); - // 鑾峰彇绯荤粺鍙傛暟 - if(!setuped) { - setUp(); - } - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { @@ -106,12 +102,13 @@ } String rtuAddr = job_rtu.getString("rtuAddr"); String protocol = job_rtu.getString("protocol"); - String orgTag = job_rtu.getString("orgTag"); + //String orgTag = job_rtu.getString("orgTag"); + String orgTag = DataSourceContext.get(); comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); // 鑾峰彇鍔熻兘鐮� String commandCode = po.getCommandCode(); - if(protocol.equals("p206V202404")) { + if(protocol.equals(ProtocolConstantV206V202404.protocolName)) { // 鍒涘缓瑙嗗浘 ComCdXyVo param = new ComCdXyVo(); param.controllerType = controllerType; @@ -133,7 +130,7 @@ myParam.setRtuResultSendWebUrl(rtuCallbackUrl_rm); myParam.setOperator(operator); return dealWithCommandResult(myParam); - } else if(protocol.equals("p206V1_0_1")) { + } else if(protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { // 鍒涘缓瑙嗗浘 ComXyVo param = new ComXyVo(); param.setCommandCode(commandCode); @@ -147,7 +144,7 @@ myParam.setComId(comId); myParam.setComType((byte)2); myParam.setCommandCode(commandCode); - myParam.setCommandName(CodeV1_0_1.getCodeName(commandCode)); + myParam.setCommandName(CodeV1.getCodeName(commandCode)); myParam.setIntakeId(intakeId); myParam.setRtuAddr(rtuAddr); myParam.setProtocol(protocol); @@ -179,11 +176,6 @@ Long operator = po.getOperator(); Long comId = idLongGenerator.generate(); - // 鑾峰彇绯荤粺鍙傛暟 - if(!setuped) { - setUp(); - } - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { @@ -191,14 +183,15 @@ } String rtuAddr = job_rtu.getString("rtuAddr"); String protocol = job_rtu.getString("protocol"); - String orgTag = job_rtu.getString("orgTag"); + //String orgTag = job_rtu.getString("orgTag"); + String orgTag = DataSourceContext.get(); comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); // 鑾峰彇鍔熻兘鐮� String commandCode = po.getCommandCode(); - if(protocol.equals("p206V202404")) { + if(protocol.equals(ProtocolConstantV206V202404.protocolName)) { return BaseResponseUtils.buildSuccess(""); - } else if(protocol.equals("p206V1_0_1")) { + } else if(protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { // 鍒涘缓瑙嗗浘 Com37Vo param = new Com37Vo(); param.setSeconds(po.getSeconds()); @@ -212,7 +205,7 @@ myParam.setComId(comId); myParam.setComType((byte)2); myParam.setCommandCode(commandCode); - myParam.setCommandName(CodeV1_0_1.getCodeName(commandCode)); + myParam.setCommandName(CodeV1.getCodeName(commandCode)); myParam.setIntakeId(intakeId); myParam.setRtuAddr(rtuAddr); myParam.setProtocol(protocol); @@ -244,11 +237,6 @@ Long operator = po.getOperator(); Long comId = idLongGenerator.generate(); - // 鑾峰彇绯荤粺鍙傛暟 - if(!setuped) { - setUp(); - } - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { @@ -256,14 +244,15 @@ } String rtuAddr = job_rtu.getString("rtuAddr"); String protocol = job_rtu.getString("protocol"); - String orgTag = job_rtu.getString("orgTag"); + //String orgTag = job_rtu.getString("orgTag"); + String orgTag = DataSourceContext.get(); comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); // 鑾峰彇鍔熻兘鐮� String commandCode = po.getCommandCode(); - if(protocol.equals("p206V202404")) { + if(protocol.equals(ProtocolConstantV206V202404.protocolName)) { return BaseResponseUtils.buildSuccess(""); - } else if(protocol.equals("p206V1_0_1")) { + } else if(protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { // 鍒涘缓瑙嗗浘 Com21Vo param = new Com21Vo(); param.setIp(po.getIp()); @@ -278,7 +267,7 @@ myParam.setComId(comId); myParam.setComType((byte)2); myParam.setCommandCode(commandCode); - myParam.setCommandName(CodeV1_0_1.getCodeName(commandCode)); + myParam.setCommandName(CodeV1.getCodeName(commandCode)); myParam.setIntakeId(intakeId); myParam.setRtuAddr(rtuAddr); myParam.setProtocol(protocol); @@ -310,11 +299,6 @@ Long operator = po.getOperator(); Long comId = idLongGenerator.generate(); - // 鑾峰彇绯荤粺鍙傛暟 - if(!setuped) { - setUp(); - } - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { @@ -322,14 +306,15 @@ } String rtuAddr = job_rtu.getString("rtuAddr"); String protocol = job_rtu.getString("protocol"); - String orgTag = job_rtu.getString("orgTag"); + //String orgTag = job_rtu.getString("orgTag"); + String orgTag = DataSourceContext.get(); comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); // 鑾峰彇鍔熻兘鐮� String commandCode = po.getCommandCode(); - if(protocol.equals("p206V202404")) { + if(protocol.equals(ProtocolConstantV206V202404.protocolName)) { return BaseResponseUtils.buildSuccess(""); - } else if(protocol.equals("p206V1_0_1")) { + } else if(protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { // 鍒涘缓瑙嗗浘 Com38Vo param = new Com38Vo(); param.setRemainMoneyAlarm(po.getRemainMoneyAlarm()); @@ -343,7 +328,7 @@ myParam.setComId(comId); myParam.setComType((byte)2); myParam.setCommandCode(commandCode); - myParam.setCommandName(CodeV1_0_1.getCodeName(commandCode)); + myParam.setCommandName(CodeV1.getCodeName(commandCode)); myParam.setIntakeId(intakeId); myParam.setRtuAddr(rtuAddr); myParam.setProtocol(protocol); @@ -375,11 +360,6 @@ Long operator = po.getOperator(); Long comId = idLongGenerator.generate(); - // 鑾峰彇绯荤粺鍙傛暟 - if(!setuped) { - setUp(); - } - // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚 JSONObject job_rtu = getRtu(intakeId, null); if(job_rtu == null) { @@ -387,14 +367,15 @@ } String rtuAddr = job_rtu.getString("rtuAddr"); String protocol = job_rtu.getString("protocol"); - String orgTag = job_rtu.getString("orgTag"); + //String orgTag = job_rtu.getString("orgTag"); + String orgTag = DataSourceContext.get(); comSendUrl = env.getProperty(pro_mw + "." + orgTag + "." + key_mw); // 鑾峰彇鍔熻兘鐮� String commandCode = po.getCommandCode(); - if(protocol.equals("p206V202404")) { + if(protocol.equals(ProtocolConstantV206V202404.protocolName)) { return BaseResponseUtils.buildSuccess(""); - } else if(protocol.equals("p206V1_0_1")) { + } else if(protocol.equals(ProtocolConstantV206V1.protocolName) || protocol.equals(ProtocolConstantV206V2.protocolName)) { // 鍒涘缓瑙嗗浘 Com39Vo param = new Com39Vo(); param.setBatteryVoltAlarm(po.getBatteryVoltAlarm()); @@ -408,7 +389,7 @@ myParam.setComId(comId); myParam.setComType((byte)2); myParam.setCommandCode(commandCode); - myParam.setCommandName(CodeV1_0_1.getCodeName(commandCode)); + myParam.setCommandName(CodeV1.getCodeName(commandCode)); myParam.setIntakeId(intakeId); myParam.setRtuAddr(rtuAddr); myParam.setProtocol(protocol); -- Gitblit v1.8.0