From d15cae9e8d2cabf8d0f3ed41f2f88b04131f8c76 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 31 七月 2025 14:18:58 +0800
Subject: [PATCH] 增加查询单个设备(RTU或FBox)是否在线的功能接口

---
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
index fc76796..8d2d2c5 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
@@ -46,6 +46,23 @@
     private RestTemplate restTemplate;
 
     /**
+     * 鏌ヨ璁惧鏄惁鍦ㄧ嚎
+     *
+     * @return
+     */
+    public Boolean isOnLine4Rtu(String devId) {
+        return selectOnOrOffLine4Rtu(devId) ;
+    }
+
+    /**
+     * 鏌ヨ璁惧鏄惁鍦ㄧ嚎
+     *
+     * @return
+     */
+    public Boolean isOnLine4Mqtt(String devId) {
+        return selectOnOrOffLine4Mqtt(devId) ;
+    }
+    /**
      * 鑾峰彇宸茬粡缁戝畾鎺у埗鍣ㄧ殑鍙栨按鍙e垪琛紙骞舵爣璁板湪绾夸笌涓嶅湪绾匡級
      *
      * @return
@@ -152,6 +169,79 @@
 
 
     /**
+     * 鏌ヨRTU鍦ㄧ嚎鎴栫绾跨姸鎬�
+     * @param rtuAddr
+     * @return
+     */
+    private Boolean selectOnOrOffLine4Rtu(String rtuAddr) {
+        //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+        Command com = this.createInnerCommand(CodeLocal.onPartLineMqtt);
+        com.setParam(rtuAddr) ;
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
+        BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ;
+        if(res != null){
+            if(res.isSuccess()){
+                Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
+                CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ;
+                if(bakParam != null){
+                    if(bakParam.getSuccess().booleanValue()){
+                        //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋�
+                        HashMap<String, Boolean> onLineMap = JSON.parseObject(JSON.toJSONString(reCom.getAttachment()), HashMap.class);
+                        Boolean flag = onLineMap.get(rtuAddr);
+                        if(flag != null){
+                            return flag ;
+                        }
+                    }
+                }else{
+                    log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟");
+                }
+            }else{
+                log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+            }
+        }else{
+            log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null");
+        }
+        return null ;
+    }
+
+
+    /**
+     * 鏌ヨMQTT鍦ㄧ嚎鎴栫绾跨姸鎬�
+     * @param devId
+     * @return
+     */
+    private Boolean selectOnOrOffLine4Mqtt(String devId) {
+        //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+        Command com = this.createInnerCommand(CodeLocal.onPartLineMqtt);
+        com.setParam(devId) ;
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
+        BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ;
+        if(res != null){
+            if(res.isSuccess()){
+                Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
+                CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ;
+                if(bakParam != null){
+                    if(bakParam.getSuccess().booleanValue()){
+                        //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋�
+                        HashMap<String, Boolean> onLineMap = JSON.parseObject(JSON.toJSONString(reCom.getAttachment()), HashMap.class);
+                        Boolean flag = onLineMap.get(devId);
+                        if(flag != null){
+                            return flag ;
+                        }
+                    }
+                }else{
+                    log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟");
+                }
+            }else{
+                log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+            }
+        }else{
+            log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null");
+        }
+        return null ;
+    }
+
+    /**
      * 鏌ヨ鍙栨按鍙o紝鍦ㄧ嚎鎴栫绾跨姸鎬�
      * @param vo
      * @return

--
Gitblit v1.8.0