From d5a24d68b0ddb3faade00504dabc0643db7d056c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 26 十一月 2024 11:26:18 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 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 9c606ec..b19ea75 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
@@ -13,6 +13,7 @@
 
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * @Author: liurunyu
@@ -136,8 +137,7 @@
                     //rtu涓嶅湪鍗囩骇涔嬪垪
                     return ;
                 }
-            }
-            if(ugRtu != null){
+            }else{
                 if(ugRtu.isOver){
                     //褰撳墠RTU宸茬粡鍗囩骇瀹屾垚锛屾棤闇�鍐嶅崌绾�
                     return;
@@ -173,9 +173,6 @@
                          ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ;
                     }
                 }
-            }else{
-                //rtu涓嶅湪鍗囩骇涔嬪垪
-                return ;
             }
         }
     }
@@ -202,19 +199,21 @@
         if(this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0){
             state.rtuTotal = this.taskVo.rtuAddrList.size() ;
             if(this.upgradeRtus != null && this.upgradeRtus.size() > 0){
-                this.upgradeRtus.values().stream().forEach(info ->{
+                AtomicBoolean hasRunning = new AtomicBoolean(false);
+                this.upgradeRtus.values().forEach(info ->{
                     if(info.state == UpgradeRtu.STATE_OFFLINE){
-                        state.offLineTotal ++ ;
+                        state.offLineTotal++ ;
                     }else if(info.state == UpgradeRtu.STATE_UNSTART){
                         state.unStartTotal ++ ;
                     }else if(info.state == UpgradeRtu.STATE_RUNNING){
                         state.runningTotal ++ ;
                     }else if(info.state == UpgradeRtu.STATE_SUCCESS) {
                         state.successTotal++;
-                    }else if(info.state == UpgradeRtu.STATE_FAIL) {
-                        state.failTotal++;
                     }else if(info.state == UpgradeRtu.STATE_FAILONE) {
                         state.failOneTotal++;
+                        state.failTotal++;
+                    }else if(info.state == UpgradeRtu.STATE_FAIL) {
+                        state.failMultiTotal++;
                         state.failTotal++;
                     }else if(info.state == UpgradeRtu.STATE_FAILOFFLINE) {
                         state.failTotal++;
@@ -222,8 +221,15 @@
                     }
                     if(info.isOver){
                         state.overTotal++;
+                    }else{
+                        hasRunning.set(true);
                     }
                 });
+                if(!hasRunning.get()){
+                    state.allOver = true ;
+                }else{
+                    state.allOver = false ;
+                }
             }
         }
         return state ;
@@ -266,7 +272,9 @@
     }
 
     ///////////////////////////////////////////////////////////
-    //浠ヤ笅鏂规硶涓哄唴閮ㄦ湇鍔★紝涓嶅澶栨彁渚涙湇鍔�
+    //
+    //   浠ヤ笅鏂规硶涓哄唴閮ㄦ湇鍔★紝涓嶅澶栨彁渚涙湇鍔�
+    //
     ///////////////////////////////////////////////////////////
 
     /**
@@ -312,20 +320,26 @@
 
     /**
      * 缁熻闇�瑕佸崌绾т絾褰撳墠绂荤嚎RTU鐨勬儏鍐碉紝瓒呰繃鏃堕檺鐨勮澶囦负鍗囩骇瀹屾垚
+     * @return -1:娌℃湁瓒呮椂锛�0瓒呮椂浜嗕笖鏃犲洜绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU锛�>0绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU鏁伴噺
      */
-    protected void countOffRtuAndSetIfOver() {
+    protected int countOffRtuAndSetIfOver() {
         Long now = System.currentTimeMillis() ;
         if(now - this.setupDtLong > UpgradeUnit.confVo.rtuOffLineWaitDuration){
             //rtu绂荤嚎锛岀瓑寰呭叾鍗囩骇鐨勬椂闀�(姣)锛岃秴杩囬厤缃殑鏈�澶ф椂闀匡紝璁剧疆鍏跺崌绾уけ璐ワ紝涓旇缃崌绾т换鍔″畬鎴�
+            int count = 0 ;
             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_OFFLINE){
                         info.isOver = true ;
                         info.state = UpgradeRtu.STATE_FAILOFFLINE ;
+                        count ++ ;
                     }
                 }
             }
+            return count ;
+        }else{
+            return -1 ;
         }
     }
 

--
Gitblit v1.8.0