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-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
index e29382e..81fa856 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
@@ -176,7 +176,6 @@
             }
         }
     }
-
     /**
      * 寮哄埗缁撴潫鍗囩骇浠诲姟
      */
@@ -189,6 +188,7 @@
             //this.upgradeState.clear();
         }
     }
+
 
     /**
      * 褰撳墠鍗囩骇鐘舵��
@@ -311,7 +311,7 @@
     /**
      * 缁熻褰撳墠姝e湪鍗囩骇鐨凴TU鏁伴噺锛屼负鍚屾椂鍗囩骇鏁伴噺闄愬埗鍋氬噯澶�
      */
-    protected void countRunningRtuCount(){
+    protected int countRunningRtuCount(){
         int runningTotal = 0 ;
         Collection<UpgradeRtu> col = this.upgradeRtus.values() ;
         for(UpgradeRtu info : col){
@@ -319,7 +319,7 @@
                 runningTotal ++ ;
             }
         }
-        this.curUgRunningRtuTotal = runningTotal ;
+        return this.curUgRunningRtuTotal = runningTotal ;
     }
 
     /**
@@ -348,6 +348,37 @@
     }
 
     /**
+     * 缁熻:宸茬粡杩涘崌绾т絾RTU鍙堣繘鍏ュ仠姝㈠崌绾у彂鍛嗙姸鎬侊紝瓒呰繃涓�瀹氭椂闄愶紝璁剧疆璁惧涓�鍖呮鎴栧鍖呮锛屽苟璁剧疆涓哄崌绾у畬鎴�
+     * @return -1:娌℃湁瓒呮椂锛�0瓒呮椂浜嗕笖鏃犲洜绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU锛�>0绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU鏁伴噺
+     */
+    protected int countRunningIdleRtuAndSetIfOver() {
+        Long now = System.currentTimeMillis() ;
+        int count = -1 ;
+        if(now - this.setupDtLong > UpgradeUnit.confVo.rtuOffLineWaitDuration){
+            //璁剧疆涓婂彞锛岄槻姝㈤绻佽繘鍏ヤ笅闈㈣鍙ヨ繘琛岃绠�
+            if (this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0) {
+                Collection<UpgradeRtu> col = this.upgradeRtus.values() ;
+                for(UpgradeRtu info : col){
+                    if(info.state == UpgradeRtu.STATE_RUNNING && info.isOver == false){
+                        //鍗囩骇涓紝浣嗘湭鍗囩骇瀹屾垚
+                        if(now - info.lastDownDtAt > UpgradeUnit.confVo.runningAndIdleDuration){
+                            if(info.currentPackage <= 1){
+                                //涓�鍖呮
+                                info.state = UpgradeRtu.STATE_FAILONE ;
+                            }else{
+                                //澶氬寘姝�
+                                info.state = UpgradeRtu.STATE_FAIL ;
+                            }
+                            info.isOver = true ;
+                            count ++ ;
+                        }
+                    }
+                }
+            }
+        }
+        return count ;
+    }
+    /**
      * 缁熻鏄惁鍗囩骇鍏ㄩ儴缁撴潫
      */
     protected boolean countIsAllOver() {

--
Gitblit v1.8.0