From 2daa780ed9c74cb689f7c1e6a13f8aadebd57208 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 15 五月 2025 16:59:09 +0800
Subject: [PATCH] 表阀一体协议,修改域名及端口解析,适应空值情况。
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 82 +++++++++++++++++++++++++++++++++--------
1 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
index 775888b..5b26ebc 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -7,12 +7,14 @@
import com.dy.rtuMw.server.forTcp.TcpSessionCache;
import com.dy.rtuMw.server.local.CommandInnerDeaLer;
import com.dy.rtuMw.server.local.ReturnCommand;
+import com.dy.rtuMw.server.msCenter.MsCenterUnit;
import com.dy.rtuMw.server.tasks.WebDownComTask;
import com.dy.common.mw.core.CoreUnit;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.CommandType;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.rtuMw.server.tasks.WebDownTransparentComTask;
import com.dy.rtuMw.server.upgrade.UpgradeUnit;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
@@ -144,6 +146,24 @@
return BaseResponseUtils.buildSuccess(list);
}
}
+
+
+ /**
+ * 娉ㄥ唽娑堟伅鎺ユ敹鑰�
+ * @param msReceiverWebUrl 娑堟伅鎺ユ敹鑰厀eb http post url
+ * @return
+ */
+ @GetMapping("/registerMsReceiverWebUrl")
+ public BaseResponse<Boolean> registerMsReceiverWebUrl(String msReceiverWebUrl){
+ try{
+ MsCenterUnit.getInstance().registerMsReceiver(msReceiverWebUrl);
+ }catch (Exception e){
+ log.error("娉ㄥ唽娑堟伅鎺ユ敹鑰呮椂鍙戠敓寮傚父", e);
+ return BaseResponseUtils.buildError("娉ㄥ唽娑堟伅鎺ユ敹鑰呮椂鍙戠敓寮傚父" + (e.getMessage() == null?"":("锛�" + e.getMessage())));
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
/**
* 鎺ユ敹web绯荤粺鍙戞潵鍗囩骇浠诲姟
* @param vo
@@ -172,8 +192,10 @@
String mes = UpgradeUnit.getInstance().forceOverUpgradeTask();
if(mes == null){
mes = "鍋滄鍗囩骇浠诲姟鎴愬姛" ;
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes);
+ }else{
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.FAIL_CODE, mes, mes);
}
- return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes);
}catch (Exception e){
log.error("鍋滄RTU鍗囩骇浠诲姟鏃跺彂鐢熷紓甯�", e);
return BaseResponseUtils.buildError("鍋滄RTU鍗囩骇浠诲姟鏃跺彂鐢熷紓甯�" + (e.getMessage() == null?"":("锛�" + e.getMessage())));
@@ -207,30 +229,23 @@
//閫氫俊涓棿浠跺唴閮ㄥ懡浠わ紝渚嬪鏌ヨ鐩戞帶涓棿浠舵椂閽燂紝鏌ヨRTU鍦ㄧ嚎鎯呭喌绛�
try{
Command reCom = new CommandInnerDeaLer().deal(com) ;
- /*
- boolean error = false ;
- if(reCom.param != null && reCom.param != null){
- CommandBackParam cbp = (CommandBackParam)reCom.param ;
- if(cbp.getSuccess() != null && !cbp.getSuccess().booleanValue()){
- error = true ;
- return BaseResponseUtils.buildError(ReturnCommand.errored(cbp.getMessage(), com.getId(), null));
- }
- }
- if(!error){
- return BaseResponseUtils.buildError(ReturnCommand.errored(cbp.getMessage(), com.getId(), null));
- }
- */
return BaseResponseUtils.buildSuccess(reCom);
}catch(Exception e){
return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍐呴儴鍛戒护鍑洪敊" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) );
}
-
}else if(commandType.equals(CommandType.outerCommand)){
- //鍙戝悜RTU鐨勫閮ㄥ懡浠わ紝寮傛澶勭悊锛寃eb绔痡roups鎴愬憳鍚屾寰楀埌鍛戒护澶勭悊缁撴灉锛屼絾鏋勯�犲懡浠ゅ強涓嬪彂鍛戒护鍜屽懡浠ょ粨鏋滄帴鏀惰寮傛寰楀埌
+ //鍙戝悜RTU鐨勫閮ㄥ懡浠�
try{
return this.dealOuterCommand(com) ;
}catch(Exception e){
return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍙戝悜RTU鐨勫閮ㄥ懡浠ゅ嚭閿�" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) );
+ }
+ }else if(commandType.equals(CommandType.outerTransCommand)){
+ //鍙戝悜RTU鐨勫閮ㄩ�忎紶鍛戒护
+ try{
+ return this.dealOutTransparentCommand(com) ;
+ }catch(Exception e){
+ return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍙戝悜RTU鐨勫閮ㄩ�忎紶鍛戒护鍑洪敊" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) );
}
}else if(commandType.equals(CommandType.resultCommand)){
return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛岄�氫俊涓棿浠朵笉鎺ョ粨鏋滅被鍨嬬殑鍛戒护锛�", com.getId(), com.getCode()));
@@ -286,4 +301,39 @@
return BaseResponseUtils.buildSuccess(ReturnCommand.successed("鍛戒护宸叉帴鍙楋紝鍗冲皢鏋勯�犲苟涓嬪彂鍛戒护銆�", command.getId(), command.getCode()));
}
+
+
+ /**
+ * 澶勭悊鍙戝悜RTU鐨勫閮ㄥ懡浠�
+ * @return 缁撴灉
+ */
+ private BaseResponse<Command> dealOutTransparentCommand(Command command){
+ String rtuAddr = command.getRtuAddr() ;
+ if(rtuAddr == null || rtuAddr.trim().equals("")){
+ return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU鍦板潃涓虹┖锛�", command.getId(), command.getCode())) ;
+ }
+ rtuAddr = rtuAddr.trim() ;
+ Boolean onLine = TcpSessionCache.isConnect(rtuAddr);
+ if(onLine == null){
+ return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU锛堝湴鍧�=" + rtuAddr + "锛夋湭涓婄嚎锛�", command.getId(), command.getCode())) ;
+ }else if(!onLine.booleanValue()){
+ if(!ServerProperties.isLowPower){
+ return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU锛堝湴鍧�=" + rtuAddr + "锛夌绾匡紒", command.getId(), command.getCode())) ;
+ }
+ }
+
+ //鐢熸垚寮傛浠诲姟
+ WebDownTransparentComTask task = new WebDownTransparentComTask() ;
+ task.data = command ;
+ try{
+ log.info("鏋勯�犱笅鍙戣繙绋嬮�忎紶鍛戒护" + command.getCode() + "鐨勬牳蹇冧换鍔★紝骞舵斁鍏ヤ换鍔¢槦鍒椾腑");
+ CoreUnit.getInstance().pushCoreTask(task);
+ }catch(Exception e){
+ log.error(e.getMessage(), e);
+ return BaseResponseUtils.buildError(ReturnCommand.errored("閫忎紶鍛戒护澶勭悊澶辫触" + e.getMessage(), command.getId(), command.getCode())) ;
+ }
+
+ return BaseResponseUtils.buildSuccess(ReturnCommand.successed("閫忎紶鍛戒护宸叉帴鍙楋紝鍗冲皢鏋勯�犲苟涓嬪彂鍛戒护銆�", command.getId(), command.getCode()));
+ }
+
}
--
Gitblit v1.8.0