liurunyu
2024-11-20 f695fa17fce26c0266ff682622d761767a8dcbfa
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java
@@ -75,10 +75,13 @@
    }
    /**
     * 结束当前升级任务
     * 强制结束当前升级任务,
     * 此功能可能不会开放出去,
     * 因为强制结束升级任务,对一个未升级完成的RTU就会卡死,
     * 所以当强制结束升级任务,代码逻辑并没有强制结果RTU升级过程,如果升级过程也强制停止,那么RTU真会卡死
     * @throws Exception
     */
    public void overUpgradeTask() throws Exception {
    public void forceOverUpgradeTask() throws Exception {
        if(this.task != null){
            this.stop();
            this.task.forceOver();
@@ -192,15 +195,25 @@
            }else{
                if(!this.task.taskIsOver){
                    //升级任务未完成
                    //工作1:统计当前正在升级的RTU数量,为受限同时升级数量做准备
                    this.task.statisticsRunningRtuCount() ;
                    //工作1:判断是否无任何一个RTU进行过升级,并且达到时限,则认为当前升级任务完成
                    //-1:无一RTU升级且超时,0:无RTU升级但未超时等待,1有RTU升级正常执行
                    int temp = this.task.countNoOneRtuUpgradeInDuration() ;
                    if(temp == -1){
                        this.task.taskIsOver = true ;
                        //任务已经完成
                        this.stop();
                    }else if(temp == 1){
                        //工作2:统计当前正在升级的RTU数量,为同时升级数量限制做准备
                        this.task.countRunningRtuCount() ;
                    //工作2:统计需要升级但当前离线RTU的情况
                    this.task.statisticsOffRtuCountAndSet() ;
                        //工作3:统计需要升级但当前离线RTU的情况,超过时限的设备为升级完成
                        this.task.countOffRtuAndSetIfOver() ;
                    //工作3:统计是否全部升级完成
                    this.task.taskIsOver = this.task.statisticsIsAllOver() ;
                        //工作4:统计是否全部升级完成
                        this.task.taskIsOver = this.task.countIsAllOver() ;
                    }else if(temp == 0){
                        //不作为
                    }
                    if(this.task.taskIsOver){
                        if(!this.task.taskOverType.equals(UpgradeTask.TaskOverType_Force)){
                            //任务不是强制结束的
@@ -208,16 +221,20 @@
                            this.task.taskOverDt = DateTime.yyyy_MM_dd_HH_mm_ss() ;//任务完成时间(yyyy-mm-dd HH:MM:SS)
                        }
                        //任务完成,执行最后一次升级状态通知
                        //工作4:升级状态通知
                        if(!first){
                            this.notifyUpgradeStatus() ;
                        }
                        //工作5:升级状态通知
                        //if(!first){
                        //    this.notifyUpgradeStatus() ;
                        //}
                    }else{
                        //任务未完成,继续执行升级状态通知
                        //工作4: 升级状态通知
                        if(!first){
                            this.notifyUpgradeStatus() ;
                        }
                        //工作5: 升级状态通知
                        //if(!first){
                        //    this.notifyUpgradeStatus() ;
                        //}
                    }
                    //工作5:升级状态通知
                    if(!first){
                        this.notifyUpgradeStatus() ;
                    }
                }else{
                    //任务已经完成