| | |
| | | } |
| | | } |
| | | if(cache == null){ |
| | | cache = info; |
| | | //此时不做任务操作,只保障cache不为空, 等待下次发来数据 |
| | | if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ |
| | | List<UpgradeRtu> overList = info.ugRtuStateList.stream().filter(itemVo -> itemVo.isOver).collect(Collectors.toList()) ; |
| | | if(overList != null && overList.size() > 0){ |
| | | cache = info; |
| | | this.save2Db(info.ugTaskId, overList); |
| | | } |
| | | } |
| | |
| | | if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ |
| | | //此时保证两个集合都不为null |
| | | this.save2Db(info.ugTaskId, info.ugRtuStateList, cache.ugRtuStateList); |
| | | cache = info; |
| | | } |
| | | //cache赋值必须放在上面处理的后面,否则上面的比较不成功 |
| | | cache = info; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | @Override |
| | | public Object execute() throws Exception { |
| | | while(!this.stop){ |
| | | if(!runDemo()){ |
| | | if(!runInDemo()){ |
| | | this.stop = true ; |
| | | }else{ |
| | | try { |
| | |
| | | } |
| | | } |
| | | } |
| | | private boolean runDemo(){ |
| | | private boolean runInDemo(){ |
| | | for(UpgradeRtu rtu : cache.ugRtuStateList){ |
| | | this.rtuUpgrade(rtu) ; |
| | | } |
| | |
| | | //离线的,不处理 |
| | | return ; |
| | | } |
| | | int n = Integer.parseInt(new CreateRandom().create(2)) ; |
| | | 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 == 45){ |
| | | if(rtu.currentPackage != 1){ |
| | | //升死 |
| | | rtu.state = UpgradeRtu.STATE_FAIL ; |
| | | return ; |
| | | } |
| | | } |
| | | |
| | | if(rtu.currentPackage == rtu.totalPackage){ |
| | | //升级结束 |
| | |
| | | rtu.isOver = true ; |
| | | return ; |
| | | } |
| | | if(rtu.reTryTimes >= 2){ |
| | | //重试次数达到最大值 |
| | | if(rtu.state == UpgradeRtu.STATE_FAILONE || |
| | | rtu.state == UpgradeRtu.STATE_FAIL){ |
| | | //又失败了,认为结束了 |
| | | rtu.isOver = true ; |
| | | return ; |
| | | } |
| | | } |
| | | |
| | | if(rtu.state != UpgradeRtu.STATE_FAILONE && |
| | | rtu.state != UpgradeRtu.STATE_FAIL){ |
| | | int n = Integer.parseInt(new CreateRandom().create(3)) ; |
| | | if(n == 540 || n == 541 || n == 542 || n == 543 || n == 544 || n == 545 || n == 546 || n == 547 || n == 548 || n == 549 ){ |
| | | if(rtu.currentPackage == 1){ |
| | | //1包死 |
| | | rtu.state = UpgradeRtu.STATE_FAILONE ; |
| | | return ; |
| | | } |
| | | } |
| | | |
| | | if(n == 450 || n == 451 || n == 452 || n == 453 || n == 454 || n == 455){ |
| | | if(rtu.currentPackage != 1){ |
| | | //升死 |
| | | rtu.state = UpgradeRtu.STATE_FAIL ; |
| | | return ; |
| | | } |
| | | } |
| | | |
| | | if(rtu.state == UpgradeRtu.STATE_FAILONE || |
| | | rtu.state == UpgradeRtu.STATE_FAIL){ |
| | | if(rtu.reTryTimes < 2){ |
| | | rtu.state = UpgradeRtu.STATE_RUNNING ; |
| | | rtu.currentPackage = 1 ; |
| | |
| | | rtu.currentPackage += 1 ; |
| | | rtu.currentRamAddr = 0x00 + UpgradeRtu.RAMADDRADD ; |
| | | rtu.lastDownDt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | rtu.reTryTimes = 0 ; |
| | | rtu.isOver = false ; |
| | | } |
| | | |
| | |
| | | for(UpgradeRtu rtu : cache.ugRtuStateList){ |
| | | if(rtu.state == UpgradeRtu.STATE_OFFLINE){ |
| | | cache.ugOverallState.offLineTotal ++ ; |
| | | cache.ugOverallState.failTotal++; |
| | | }else if(rtu.state == UpgradeRtu.STATE_UNSTART){ |
| | | cache.ugOverallState.unStartTotal ++ ; |
| | | }else if(rtu.state == UpgradeRtu.STATE_RUNNING){ |
| | |
| | | }else if(rtu.state == UpgradeRtu.STATE_SUCCESS) { |
| | | cache.ugOverallState.successTotal++; |
| | | }else if(rtu.state == UpgradeRtu.STATE_FAILONE) { |
| | | cache.ugOverallState.failOneTotal++; |
| | | cache.ugOverallState.dieOneTotal++; |
| | | cache.ugOverallState.failTotal++; |
| | | }else if(rtu.state == UpgradeRtu.STATE_FAIL) { |
| | | cache.ugOverallState.dieMultiTotal++; |
| | | cache.ugOverallState.failTotal++; |
| | | } |
| | | if(rtu.isOver){ |
| | |
| | | if(!hasRunning){ |
| | | cache.ugOverallState.allOver = true ; |
| | | } |
| | | if(cache.ugOverallState.allOver){ |
| | | cache.ugOverallState.overTotal = 0; |
| | | if(cache.ugRtuStateList != null && cache.ugRtuStateList.size() > 0){ |
| | | for(UpgradeRtu rtu : cache.ugRtuStateList){ |
| | | rtu.isOver = true ; |
| | | cache.ugOverallState.overTotal++; |
| | | } |
| | | } |
| | | } |
| | | return hasRunning ; |
| | | } |
| | | } |