liurunyu
2024-11-23 7c94f000ca94776eb62e8296bf4f42473085f242
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
@@ -202,10 +203,10 @@
        if(this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0){
            state.rtuTotal = this.taskVo.rtuAddrList.size() ;
            if(this.upgradeRtus != null && this.upgradeRtus.size() > 0){
                Collection<UpgradeRtu> col = this.upgradeRtus.values() ;
                for(UpgradeRtu info : col){
                AtomicBoolean hasRunning = new AtomicBoolean(false);
                this.upgradeRtus.values().forEach(info ->{
                    if(info.state == UpgradeRtu.STATE_OFFLINE){
                        state.offLineTotal ++ ;
                        state.failTotal++;
                    }else if(info.state == UpgradeRtu.STATE_UNSTART){
                        state.unStartTotal ++ ;
                    }else if(info.state == UpgradeRtu.STATE_RUNNING){
@@ -216,11 +217,22 @@
                        state.failOneTotal++;
                        state.failTotal++;
                    }else if(info.state == UpgradeRtu.STATE_FAIL) {
                        state.failMultiTotal++;
                        state.failTotal++;
                    }else if(info.state == UpgradeRtu.STATE_FAILOFFLINE) {
                        state.failTotal++;
                        state.failOffTotal++;
                    }
                    if(info.isOver){
                        state.overTotal++;
                    }else{
                        hasRunning.set(true);
                    }
                });
                if(!hasRunning.get()){
                    state.allOver = true ;
                }else{
                    state.allOver = false ;
                }
            }
        }
@@ -271,7 +283,7 @@
     * 判断是否没用任何一个RTU进行过升级,而且超过了时限
     * @return -1:无一RTU升级且超时,0:无RTU升级但未超时等待,1有RTU升级正常执行
     */
    protected int countNoOneRtuUpgrade(){
    protected int countNoOneRtuUpgradeInDuration(){
        if(this.upgradeRtus == null || upgradeRtus.size() == 0){
            //当前没有任何一个设备进行过升级
            Long now = System.currentTimeMillis() ;
@@ -297,7 +309,7 @@
    /**
     * 统计当前正在升级的RTU数量,为同时升级数量限制做准备
     */
    protected void statisticsRunningRtuCount(){
    protected void countRunningRtuCount(){
        int runningTotal = 0 ;
        Collection<UpgradeRtu> col = this.upgradeRtus.values() ;
        for(UpgradeRtu info : col){
@@ -309,9 +321,9 @@
    }
    /**
     * 统计需要升级但当前离线RTU的情况
     * 统计需要升级但当前离线RTU的情况,超过时限的设备为升级完成
     */
    protected void statisticsOffRtuCountAndSet() {
    protected void countOffRtuAndSetIfOver() {
        Long now = System.currentTimeMillis() ;
        if(now - this.setupDtLong > UpgradeUnit.confVo.rtuOffLineWaitDuration){
            //rtu离线,等待其升级的时长(毫秒),超过配置的最大时长,设置其升级失败,且设置升级任务完成
@@ -330,7 +342,7 @@
    /**
     * 统计是否升级全部结束
     */
    protected boolean statisticsIsAllOver() {
    protected boolean countIsAllOver() {
        if (this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0) {
            Collection<UpgradeRtu> col = this.upgradeRtus.values() ;
            for(UpgradeRtu info : col){