package com.dy.pipIrrGlobal.voUg; 
 | 
  
 | 
import com.dy.common.softUpgrade.state.UpgradeRtu; 
 | 
import com.dy.common.softUpgrade.state.UpgradeState; 
 | 
import lombok.AllArgsConstructor; 
 | 
import lombok.Data; 
 | 
import lombok.NoArgsConstructor; 
 | 
  
 | 
import java.util.List; 
 | 
  
 | 
/** 
 | 
 * @Author: liurunyu 
 | 
 * @Date: 2024/11/14 9:14 
 | 
 * @Description 监视RTU远程升级状态值对象 
 | 
 */ 
 | 
@Data 
 | 
@AllArgsConstructor 
 | 
@NoArgsConstructor 
 | 
public class VoWatch { 
 | 
    public VoUpgradeDetail upgrade ; 
 | 
    public UpgradeState overall ;//全局统计 
 | 
    public List<VoWatchRtu> rtus ;//一个控制器升级情况 
 | 
  
 | 
    @Data 
 | 
    @AllArgsConstructor 
 | 
    @NoArgsConstructor 
 | 
    public static class VoWatchRtu{ 
 | 
        public String rtuAddr ;     //控制器地址 
 | 
        public Integer rate ;       //进度 
 | 
        public String state;        //升级状态 
 | 
        public Integer status;      //过程状态(0:离线,1:升级中,2:升级成功,3升级失败),前端利用其设置卡片样式 
 | 
        public Integer reTryTimes ; //重试次数 
 | 
        public Boolean over ;       //是否结束(true:是,false:否) 
 | 
        public Boolean success ;    //是否成功(null:进行中,true:是,false:否) 
 | 
  
 | 
        public void fromCache(UpgradeRtu ugRtu){ 
 | 
            this.rtuAddr = ugRtu.rtuAddr ; 
 | 
  
 | 
            this.rate = (ugRtu.currentPackage * 1000)/ugRtu.totalPackage ;//前端实现是1000份的进度条 
 | 
  
 | 
            this.state = UpgradeRtu.getStateName(ugRtu.state) ; 
 | 
  
 | 
            //过程状态(0:离线,1:升级中,2:升级成功,3升级失败),前端利用其设置卡片样式 
 | 
            this.status = 1 ;//默认升级中 
 | 
            if(ugRtu.state == UpgradeRtu.STATE_OFFLINE){ 
 | 
                this.status = 0 ; 
 | 
            }else if(ugRtu.state == UpgradeRtu.STATE_SUCCESS){ 
 | 
                this.status = 2 ; 
 | 
            }else { 
 | 
                if(ugRtu.isOver && ugRtu.state != UpgradeRtu.STATE_SUCCESS){ 
 | 
                    this.status = 3; 
 | 
                } 
 | 
            } 
 | 
  
 | 
  
 | 
            this.reTryTimes = ugRtu.reTryTimes ; 
 | 
  
 | 
            this.over = ugRtu.isOver ; 
 | 
  
 | 
            if(ugRtu.isOver){ 
 | 
                this.success = (ugRtu.state == UpgradeRtu.STATE_SUCCESS ? true : false) ; 
 | 
            }else{ 
 | 
                this.success = null ; 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
} 
 |