zhubaomin
2024-11-14 a0e0f51ebbfdb6b3d6371eaa1b3b3fc8560dc9d7
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
3个文件已修改
146 ■■■■ 已修改文件
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/QueryVo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java 101 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/QueryVo.java
@@ -17,5 +17,11 @@
    @Schema(description = "控制器地址")
    public String rtuAddr ;
    @Schema(description = "状态")
    public Integer status ;//进行中 : 1    已结束 : 0
    @Schema(description = "结果")
    public Integer result ;//成功  :  1    失败  : 0
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -122,6 +122,23 @@
        vo.softBytesCalculate = ppo.programCalculateBytes ;
        vo.softByteSrc16 = ppo.programCrc16 ;
    }
    /**
     *  监视:
     * 重置,演示的重置
     * @return 操作结果
     */
    @GetMapping(path = "/demoReset")
    @SsoAop()
    public BaseResponse<Boolean> demoReset(){
        if(RtuUpgradeStateReceiverCtrl.cache == null){
            //return BaseResponseUtils.buildError("当前没有升级任务") ;
            //正式运行时,下面两行去掉,上面一行打开
            RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class);
            ctrl.resetDemo();
            ctrl.demo();
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
    /**
     *  监视:
@@ -134,7 +151,7 @@
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回操作成功与否数据(BaseResponse.content:Boolean)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
                            schema = @Schema(implementation = VoWatch.class))}
            )
    })
    @GetMapping(path = "/curUpgradeState")
@@ -155,25 +172,23 @@
        vo.upgrade = this.sv.selectTaskDetail(RtuUpgradeStateReceiverCtrl.cache.ugTaskId);
        vo.overall = RtuUpgradeStateReceiverCtrl.cache.ugOverallState ;
        vo.rtus = new ArrayList<>() ;
        if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0){
            if(qvo.rtuAddr != null && !qvo.rtuAddr.trim().equals("")){
                qvo.pageCurr = 1 ;
                final String queryAddr = qvo.rtuAddr ;
                RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.stream().filter(rtu -> rtu.rtuAddr.equals(queryAddr)).forEach(ugRtu -> {
                    VoWatch.VoWatchRtu rtu = new VoWatch.VoWatchRtu() ;
                    rtu.fromCache(ugRtu) ;
                    vo.rtus.add(rtu) ;
                }); ;
            }else{
        List<UpgradeRtu> listFiltered = null ;
        if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0) {
            listFiltered = filterByQuery(qvo) ;
            if (listFiltered.size() > 0) {
                if(qvo.pageCurr < 1){
                    qvo.pageCurr = 1 ;
                }
                int start = (qvo.pageCurr - 1) * qvo.pageSize ;
                if(start >= RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size()){
                    start = RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() - 1 ;
                if(start >= listFiltered.size()){
                    if(listFiltered.size()%qvo.pageSize > 0){
                        start = listFiltered.size() - listFiltered.size()%qvo.pageSize ;
                    }else{
                        start = listFiltered.size() - qvo.pageSize ;
                    }
                }
                for(int i = start; i < (start + qvo.pageSize) && i < RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size(); i++){
                    UpgradeRtu ugRtu = RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.get(i) ;
                for(int i = start; i < (start + qvo.pageSize) && i < listFiltered.size(); i++){
                    UpgradeRtu ugRtu = listFiltered.get(i) ;
                    VoWatch.VoWatchRtu rtu = new VoWatch.VoWatchRtu() ;
                    rtu.fromCache(ugRtu) ;
                    vo.rtus.add(rtu) ;
@@ -183,7 +198,61 @@
        rsVo.obj = vo ;
        rsVo.pageSize = qvo.pageSize ;
        rsVo.pageCurr = qvo.pageCurr ;
        rsVo.calculateAndSet(0L + vo.rtus.size(), null);
        rsVo.calculateAndSet(0L + (listFiltered==null?0:listFiltered.size()), null);
        return BaseResponseUtils.buildSuccess(rsVo) ;
    }
    private List<UpgradeRtu> filterByQuery(QueryVo qvo){
        if (qvo.status != null || qvo.result != null) {
            final Integer qvoStatus = qvo.status ;
            final Integer qvoResult = qvo.result ;
            final String qvoRtuAddr = qvo.rtuAddr ;
            return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.stream().filter(rtu -> {
                boolean ok = false;
                if (qvoStatus != null) {
                    if (qvoStatus.intValue() == 1) {
                        if (rtu.state == UpgradeRtu.STATE_RUNNING) {
                            ok = true;
                        }else{
                            ok = false ;
                        }
                    } else if (qvoStatus.intValue() == 0) {
                        if (rtu.isOver) {
                            ok = true;
                        }else{
                            ok = false ;
                        }
                    }
                }
                if (qvoResult != null) {
                    if (qvoResult.intValue() == 1) {
                        if (rtu.state == UpgradeRtu.STATE_SUCCESS) {
                            ok = true;
                        }else{
                            ok = false ;
                        }
                    } else if (qvoResult.intValue() == 0) {
                        if (rtu.state == UpgradeRtu.STATE_OFFLINE
                                || rtu.state == UpgradeRtu.STATE_FAILONE
                                || rtu.state == UpgradeRtu.STATE_FAIL
                                || rtu.state == UpgradeRtu.STATE_FAILOFFLINE) {
                            ok = true;
                        }else{
                            ok = false ;
                        }
                    }
                }
                if(qvoRtuAddr != null && !qvoRtuAddr.trim().equals("")){
                    if(rtu.rtuAddr.equals(qvoRtuAddr)){
                        ok = true;
                    }else{
                        ok = false ;
                    }
                }
                return ok;
            }).toList() ;
        }else{
            return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList ;
        }
    }
}
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){