From c42614978ff12013a1eabebd0289b27169a5784f Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 06 五月 2025 17:25:56 +0800
Subject: [PATCH] 1、实现万功能token(0000-0000-1234-9876-5); 2、web端单独实现命令结果等待器,并相应修改相关部分; 3、web端实现透传命令; 4、修改一些不当注释; 5、优化一些代码。

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java |   64 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 1 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 b96b485..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
@@ -214,11 +234,18 @@
                 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()));
@@ -274,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