liurunyu
2024-11-14 d8a23595de99686655d3d3372842b08116afebf6
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java
@@ -112,6 +112,14 @@
    private static ThreadJob threadJob ;
    protected void resetDemo(){
        if(threadJob != null){
            threadJob.stop() ;
            threadJob = null ;
        }
        cache = null ;
    }
    protected void demo(){
        if(cache == null){
            UgRtuTask tpo = this.sv.selectLastTask() ;
@@ -137,7 +145,17 @@
                            threadJob = new ThreadJob() {
                                @Override
                                public Object execute() throws Exception {
                                    runDemo() ;
                                    while(!this.stop){
                                        if(!runDemo()){
                                            this.stop = true ;
                                        }else{
                                            try {
                                                Thread.sleep(500);
                                            } catch (InterruptedException e) {
                                                e.printStackTrace();
                                            }
                                        }
                                    }
                                    return null;
                                }
                            };
@@ -162,22 +180,11 @@
            }
        }
    }
    private void runDemo(){
        boolean hasRunning = true ;
        while (true){
            for(UpgradeRtu rtu : cache.ugRtuStateList){
                this.rtuUpgrade(rtu) ;
            }
            hasRunning = this.statisticsNowUpgradeState() ;
            if(!hasRunning){
                break ;
            }
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
    private boolean runDemo(){
        for(UpgradeRtu rtu : cache.ugRtuStateList){
            this.rtuUpgrade(rtu) ;
        }
        return this.statisticsNowUpgradeState() ;
    }
    private void rtuUpgrade(UpgradeRtu rtu){
        if(rtu.lastDownDt == null){
@@ -212,13 +219,45 @@
            return ;
        }
        int n = Integer.parseInt(new CreateRandom().create(2)) ;
        if(n == 44 || n == 45 || n == 54){
        if(n == 4
                || n == 14
                || n == 24
                || n == 34
                || n == 44
                || n == 54
                || n == 64
                || n == 74
                || n == 84
                || n == 95
                || n == 45
                || n == 46
                || n == 47
                || n == 48
                || n == 49){
            if(rtu.currentPackage == 1){
                //1包死
                rtu.state = UpgradeRtu.STATE_FAILONE ;
                return ;
            }
        }
        if(n == 40
                || n == 41
                || n == 42
                || n == 43
                || n == 44
                || n == 45
                || n == 46
                || n == 47
                || n == 48
                || n == 49){
            if(rtu.currentPackage != 1){
                //升死
                rtu.state = UpgradeRtu.STATE_FAIL ;
                return ;
            }
        }
        if(rtu.currentPackage == rtu.totalPackage){
            //升级结束
            rtu.state = UpgradeRtu.STATE_SUCCESS ;