zhubaomin
2024-11-29 13396d9d413c38786f40e02569b034fd4061d0d5
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
1 文件已重命名
18个文件已修改
1个文件已删除
786 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global(sp沙盘系统).yml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global(test测试系统).yml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global(ym元谋系统).yml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global(开发测试---166PC机).yml 386 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java
@@ -65,7 +65,7 @@
            case STATE_FAILONE:
                return "一包死";
            case STATE_FAIL:
                return "升级中死";
                return "多包死";
            case STATE_FAILOFFLINE:
                return "离线失败";
            default:
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
File was renamed from pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java
@@ -19,33 +19,71 @@
 * @Date: 2024/10/23 11:45
 * @Description
 */
public abstract class ToRtuMwCom {
public abstract class Web2RtuMw {
    /**
     * pro_mw:属性
     * tag从控制器中获取
     * key_mw:url的key
     */
    private static final String pro_mw = "mw";
    private static final String key_mw = "comSendUrl";
    private static final String keyUg_mw = "ugTaskSendUrl";
    private static final String pro_url = "url";
    protected static final String ContextComSend = "/rtuMw/com/send";
    protected static final String ContextRtuLogFile = "/rtuMw/com/rtuLogFile";
    protected static final String ContextRtuLogText = "/rtuMw/com/rtuLogText";
    protected static final String ContextUgTaskSend = "/rtuMw/com/upgradeRtu";
    protected static final String ContextUgForceOver = "/rtuMw/com/ugForceOver";
    /**
     * å¾—到向通信中间件发送数据的URL
     * @param env
     * @return
     */
    protected String getToMwUrl(Environment env) {
        return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
    protected String get2MwUrl(Environment env) {
        return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + pro_url);
    }
    /**
     * å¾—到向通信中间件发送强制停止升级的命令URL
     * @param env
     * @return
     */
    protected String get2MwRequestUrl(Environment env, String context) {
        return get2MwUrl(env) + context;
    }
    /**
     * å¾—到向通信中间件发送数据的URL
     * @param env
     * å‘通信中间件发送rtu远程升级任务
     * @param restTemplate SpringBoot的RestTemplate
     * @param toMwUrl åˆ°é€šä¿¡ä¸­é—´ä»¶çš„web请求Url
     * @param param è¯·æ±‚参数
     * @return
     */
    protected String getToMwUgUrl(Environment env) {
        return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + keyUg_mw);
    protected BaseResponse sendRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object param) {
        String url = UriComponentsBuilder.fromUriString(toMwUrl)
                .build()
                .toUriString();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<?> httpEntity ;
        if(param != null){
            httpEntity = new HttpEntity<>(param, headers);
        }else{
            httpEntity = new HttpEntity<>(headers);
        }
        ResponseEntity<BaseResponse> response = null;
        try {
            // é€šè¿‡Post方式调用接口
            response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }
        if(response == null){
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }else{
            return response.getBody();
        }
    }
    /**
@@ -74,58 +112,4 @@
        return com ;
    }
    /**
     * å‘送命令
     *
     * @return
     */
    protected BaseResponse sendCom2Mw(RestTemplate restTemplate, String comSendUrl, Command com) {
        String url = UriComponentsBuilder.fromUriString(comSendUrl)
                .build()
                .toUriString();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers);
        ResponseEntity<BaseResponse> response = null;
        try {
            // é€šè¿‡Post方式调用接口
            response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }
        if(response == null){
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }else{
            return response.getBody();
        }
    }
    /**
     * å‘通信中间件发送rtu远程升级任务
     * @param restTemplate
     * @param comSendUrl
     * @param vo
     * @return
     */
    protected BaseResponse sendUpgradeTask2Mw(RestTemplate restTemplate, String comSendUrl, UpgradeTaskVo vo) {
        String url = UriComponentsBuilder.fromUriString(comSendUrl)
                .build()
                .toUriString();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<UpgradeTaskVo> httpEntity = new HttpEntity<>(vo, headers);
        ResponseEntity<BaseResponse> response = null;
        try {
            // é€šè¿‡Post方式调用接口
            response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }
        if(response == null){
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");
        }else{
            return response.getBody();
        }
    }
}
pipIrr-platform/pipIrr-global/src/main/resources/application-global(spɳÅÌϵͳ).yml
@@ -310,22 +310,16 @@
#通讯中间件相关配置
#protocol: DYJS_2023,DYJS_2024
mw:
    #命令发送地址(中缀是机构tag,其也是数据源后缀名称)
    #命令发送通信中间件地址
    ym:
        url: "http://127.0.0.1:8070"
        comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
    sp:
        url: "http://127.0.0.1:8073"
        comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
    test:
        url: "http://127.0.0.1:8072"
        comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
    #监测控制模块回调地址
    rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
    #rtu远程升级模块回调地址
pipIrr-platform/pipIrr-global/src/main/resources/application-global(test²âÊÔϵͳ).yml
@@ -310,22 +310,16 @@
#通讯中间件相关配置
#protocol: DYJS_2023,DYJS_2024
mw:
    #命令发送地址(中缀是机构tag,其也是数据源后缀名称)
    #命令发送通信中间件地址
    ym:
        url: "http://127.0.0.1:8070"
        comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
    sp:
        url: "http://127.0.0.1:8073"
        comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
    test:
        url: "http://127.0.0.1:8072"
        comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
    #监测控制模块回调地址
    rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
    #rtu远程升级模块回调地址
pipIrr-platform/pipIrr-global/src/main/resources/application-global(ymԪıϵͳ).yml
@@ -310,22 +310,16 @@
#通讯中间件相关配置
#protocol: DYJS_2023,DYJS_2024
mw:
    #命令发送地址(中缀是机构tag,其也是数据源后缀名称)
    #命令发送通信中间件地址
    ym:
        url: "http://127.0.0.1:8070"
        comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
    sp:
        url: "http://127.0.0.1:8073"
        comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
    test:
        url: "http://127.0.0.1:8072"
        comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
    #监测控制模块回调地址
    rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
    #rtu远程升级模块回调地址
pipIrr-platform/pipIrr-global/src/main/resources/application-global(¿ª·¢²âÊÔ---166PC»ú).yml
File was deleted
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -310,22 +310,16 @@
#通讯中间件相关配置
#protocol: DYJS_2023,DYJS_2024
mw:
    #命令发送地址(中缀是机构tag,其也是数据源后缀名称)
    #命令发送通信中间件地址
    ym:
        url: "http://127.0.0.1:8070"
        comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
    sp:
        url: "http://127.0.0.1:8073"
        comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
    test:
        url: "http://127.0.0.1:8072"
        comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
        ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
        rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
        rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
    #监测控制模块回调地址
    rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
    #rtu远程升级模块回调地址
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml
@@ -337,10 +337,10 @@
    SELECT
        COUNT(*) AS recordCount
    FROM se_card_operate ope
        INNER JOIN se_client cli ON ope.client_id = cli.id
        INNER JOIN se_client_card card ON card.id = ope.card_id
        LEFT JOIN se_payment_method pay ON ope.payment_id = pay.id
        INNER JOIN ba_user us ON ope.operator = us.id
    LEFT JOIN se_client cli ON ope.client_id = cli.id
    LEFT JOIN se_client_card card ON card.id = ope.card_id
    LEFT JOIN se_payment_method pay ON ope.payment_id = pay.id
    LEFT JOIN ba_user us ON ope.operator = us.id
    <where>
      AND ope.operate_type IN(1,2,3,5,10)
      AND ope.operate_valid = 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java
@@ -88,12 +88,19 @@
     * å› ä¸ºå¼ºåˆ¶ç»“束升级任务,对一个未升级完成的RTU就会卡死,
     * æ‰€ä»¥å½“强制结束升级任务,代码逻辑并没有强制结果RTU升级过程,如果升级过程也强制停止,那么RTU真会卡死
     */
    public void forceOverUpgradeTask() {
    public String forceOverUpgradeTask() {
        if(this.task != null){
            this.stop();
            this.task.forceOver();
            this.task.countRunningRtuCount();
            if(this.task.curUgRunningRtuTotal > 0){
                return "当前存在升级中的设备,不能结束升级任务" ;
            }else{
                this.stop();
                this.task.forceOver();
                return null ;
            }
        }else{
            return "当前没有升级任务" ;
        }
        this.task = null ;
    }
    /**
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java
@@ -52,7 +52,7 @@
    ///////////////////////////////////////////////////
    //以下内部控制用
    @JSONField(serialize = false)
    private int curUgRunningRtuTotal = 0 ;//当前正在升级的RTU个数
    protected int curUgRunningRtuTotal = 0 ;//当前正在升级的RTU个数
    public UpgradeTask() {
        this.curUgRunningRtuTotal = 0 ;
@@ -176,7 +176,6 @@
            }
        }
    }
    /**
     * å¼ºåˆ¶ç»“束升级任务
     */
@@ -190,6 +189,7 @@
        }
    }
    /**
     * å½“前升级状态
     * @return
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java
@@ -56,7 +56,7 @@
    @Override
    public void stop(UnitCallbackInterface callback) throws Exception {
        overUpgradeTask() ;
        forceOverUpgradeTask() ;
    }
@@ -73,12 +73,15 @@
    }
    /**
     * åœæ­¢å½“前升级任务
     * ç»“束当前升级任务
     * @throws Exception
     * @return null:结束任务成功,否则返回失败原因
     */
    public void overUpgradeTask() throws Exception {
    public String forceOverUpgradeTask() throws Exception {
        if(manager != null ){
            manager.forceOverUpgradeTask() ;
            return manager.forceOverUpgradeTask() ;
        }else{
            return "通信中间件内部错误" ;
        }
    }
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -1,6 +1,7 @@
package com.dy.rtuMw.web.com;
import com.dy.common.softUpgrade.state.UpgradeTaskVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.rtuMw.resource.ResourceUnit;
import com.dy.rtuMw.server.ServerProperties;
import com.dy.rtuMw.server.forTcp.TcpSessionCache;
@@ -161,6 +162,25 @@
    }
    /**
     * æŽ¥æ”¶web系统发来强制结束升级任务
     * @return
     */
    @PostMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE)
    public BaseResponse<String> ugForceOver() {
        log.info("收到停止RTU升级任务命令") ;
        try{
            String mes = UpgradeUnit.getInstance().forceOverUpgradeTask();
            if(mes == null){
                mes = "停止升级任务成功" ;
            }
            return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes);
        }catch (Exception e){
            log.error("停止RTU升级任务时发生异常", e);
            return BaseResponseUtils.buildError("停止RTU升级任务时发生异常" + (e.getMessage() == null?"":(":" + e.getMessage())));
        }
    }
    /**
     * æŽ¥æ”¶web系统发来的命令
     * @param com
     * @return
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java
@@ -53,7 +53,7 @@
                        if(ServerProperties.argMultiDie){
                            if(count9602 > 10){
                                int random =  CreateRandom.create_between(10, 100) ;
                                if(random > 98){
                                if(random > 90){
                                    UpHeartBeat.upHeartBeat = true ;//使能上行心跳
                                }else{
                                    UpCd9602.upData() ;
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java
@@ -9,7 +9,6 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoUg.UgRtuTask;
import com.dy.pipIrrGlobal.voUg.VoUgResult;
import com.dy.pipIrrGlobal.voUg.VoUgRtuResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -83,7 +82,8 @@
     * @param response
     */
    @RequestMapping(value = "/exportAll", method = RequestMethod.GET)
    public void exportUgFail(HttpServletResponse response, QueryUgResultVo vo) throws Exception {
    @SsoAop()
    public void exportAll(HttpServletResponse response, QueryUgResultVo vo) throws Exception {
        if(vo.state != null && vo.state == 1){
            //查询升级成功的
            vo.fail = null ;
@@ -95,7 +95,7 @@
        setExcelRespProp(response, "升级结果列表");
        List<VoUgResult> rsList = this.sv.selectAll(vo);
        EasyExcel.write(response.getOutputStream())
                .head(VoUgRtuResult.class)
                .head(VoUgResult.class)
                .excelType(ExcelTypeEnum.XLSX)
                .sheet("升级结果列表")
                .doWrite(rsList);
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
@@ -9,7 +9,7 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.rtuMw.CodeLocal;
import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom;
import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
@@ -29,7 +29,7 @@
 */
@Slf4j
@Service
public class MonitorSv extends ToRtuMwCom {
public class MonitorSv extends Web2RtuMw {
    @Autowired
    private PrIntakeMapper prIntakeMapper;
@@ -76,8 +76,8 @@
            //向通信中间件发关命令,查询部分RTU在线情况
            Command com = this.createInnerCommand(CodeLocal.onLinePart);
            com.setParam(rtuAddrs) ;
            String comSendUrl = this.getToMwUrl(this.env) ;
            BaseResponse res = sendCom2Mw(restTemplate, comSendUrl, com) ;
            String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
            BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ;
            if(res != null){
                if(res.isSuccess()){
                    Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
@@ -114,8 +114,8 @@
    private QueryResultVo<List<VoOnLineIntake>> selectIntakesOnOrOffLine(QueryVo vo) {
        //向通信中间件发关命令,查询部分RTU在线情况
        Command com = this.createInnerCommand(CodeLocal.onLineAll);
        String comSendUrl = this.getToMwUrl(this.env) ;
        BaseResponse res = sendCom2Mw(restTemplate, comSendUrl, com) ;
        String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
        BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ;
        if(res != null){
            if(res.isSuccess()){
                Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java
@@ -1,9 +1,9 @@
package com.dy.pipIrrRemote.rtu;
import com.dy.common.aop.SsoAop;
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -32,11 +32,7 @@
@Slf4j
@RestController
@RequestMapping(path="rtuLog")
public class RtuLogCtrl {
    private static final String pro_mw = "mw";
    private static final String key_mw_file = "rtuLogFileUrl";
    private static final String key_mw_text = "rtuLogTextUrl";
public class RtuLogCtrl extends Web2RtuMw {
    private Environment env ;
    private RestTemplate restTemplate;
@@ -55,10 +51,10 @@
    @GetMapping(path = "file")
    @SsoAop()
    public BaseResponse<List<String>> rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){
        String mwUrlRtuLogFile = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_file);
        String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogFile) ;
        ServletOutputStream out = null ;
        try{
            byte[] bs = this.requestMw4File(rtuAddr, mwUrlRtuLogFile) ;
            byte[] bs = this.requestMw4File(rtuAddr, rqUrl) ;
            if(bs != null && bs.length > 0){
                String fileReName = rtuAddr + ".log" ;
                //URLEncoder.encode可以防止中文乱码
@@ -91,8 +87,9 @@
    @GetMapping(path="text")
    @SsoAop()
    public BaseResponse<List<String>> rtuLogText(String rtuAddr){
        String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text);
        BaseResponse<List<String>> text = this.requestMw4Text(rtuAddr, mwUrlRtuLogText);
        String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogText) ;
        //String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text);
        BaseResponse<List<String>> text = this.requestMw4Text(rtuAddr, rqUrl);
        if (text != null){
            if (text.getContent().get(0).contains("控制器")){
                return BaseResponseUtils.buildErrorMsg(""+text.getContent().get(0)+"") ;
@@ -101,7 +98,6 @@
        }else {
            return BaseResponseUtils.buildErrorMsg("获取日志文件为null") ;
        }
//        return this.requestMw4Text(rtuAddr, mwUrlRtuLogText) ;
    }
@@ -141,5 +137,4 @@
        return (response==null?null:response.getBody());
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -3,7 +3,6 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.dy.common.aop.SsoAop;
import com.dy.common.softUpgrade.state.UpgradeRtu;
import com.dy.common.softUpgrade.state.UpgradeTaskVo;
import com.dy.common.springUtil.SpringContextUtil;
import com.dy.common.webUtil.BaseResponse;
@@ -12,8 +11,7 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram;
import com.dy.pipIrrGlobal.pojoUg.UgRtuTask;
import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom;
import com.dy.pipIrrGlobal.voPr.VoDivide;
import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
import com.dy.pipIrrGlobal.voUg.VoUgRtuResult;
import com.dy.pipIrrGlobal.voUg.VoWatch;
import io.swagger.v3.oas.annotations.Operation;
@@ -35,7 +33,6 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@@ -48,7 +45,7 @@
@Tag(name = "rtu远程升级任务", description = "rtu远程升级任务相关操作")
@RestController
@RequestMapping(path = "rtuUpgrade")
public class RtuUpgradeCtrl extends ToRtuMwCom {
public class RtuUpgradeCtrl extends Web2RtuMw {
    @Autowired
    private RtuUpgradeSv sv ;
@@ -108,8 +105,8 @@
        vo.rtuAddrList = taskRtuAddrs ;
        vo.callbackWebUrl = ugCallbackUrl_rm ;
        String ugSendUrl = this.getToMwUgUrl(this.env) ;
        BaseResponse res = sendUpgradeTask2Mw(restTemplate, ugSendUrl, vo) ;
        String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ;
        BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, vo) ;
        if(res != null){
            if(res.isSuccess()){
                this.sv.setUpgradeTaskExecuted(id);
@@ -127,6 +124,41 @@
            return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ;
        }
    }
    /**
     * ä¸‹å‘强制结束当前rtu远程升级任务
     * @return æ“ä½œç»“æžœ
     */
    @Operation(summary = "下发强制结束当前rtu远程升级任务", description = "下发强制结束当前rtu远程升级任务")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回操作成功与否数据(BaseResponse.content:Boolean)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = String.class))}
            )
    })
    @GetMapping(path = "/forceOver")
    @SsoAop()
    public BaseResponse<String> forceOver() {
        String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ;
        BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, null) ;
        if(res != null){
            if(res.isSuccess()){
                return BaseResponseUtils.buildSuccess(true) ;
            }else{
                String msg = res.getContent()==null?null:(String)res.getContent() ;
                if(msg == null){
                    msg = res.getMsg() ;
                }
                log.error("通信中间件执行下发强制结束当前rtu远程升级任务失败:" + msg) ;
                return BaseResponseUtils.buildErrorMsg("通信中间件执行强制结束当前rtu远程升级任务失败:" + msg) ;
            }
        }else{
            log.error("通信中间件返回结果为null") ;
            return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ;
        }
    }
    private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){
        vo.id = "" + tpo.id ;
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java
@@ -49,15 +49,8 @@
    @Hidden //不公开接口,其只有通信中间件调用
    @PostMapping(path = "/receive")
    public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo info, HttpServletRequest req, HttpServletResponse rep){
        /*
        log.info("接收到的RTU远程升级状态数据为:{}", info.toString("532328000214"));
        //进行排序
        //Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder());
        //info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList());
        //通信中间件传过来的机构tag,以用于查找数据源
        String token = req.getHeader(Constant.UserTokenKeyInHeader);
        DataSourceContext.set(token);
        if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){
            if(info.ugRtuStateList.size() < 10){
                for (UpgradeRtu rtuVo : info.ugRtuStateList) {
@@ -65,6 +58,16 @@
                }
            }
        }
         */
        //进行排序
        Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder());
        info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList());
        //通信中间件传过来的机构tag,以用于查找数据源
        String token = req.getHeader(Constant.UserTokenKeyInHeader);
        DataSourceContext.set(token);
        if(cache == null){
            cache = info;
            //此时不做任务操作,只保障cache不为空, ç­‰å¾…下次发来数据
@@ -80,12 +83,11 @@
                //此时保证两个集合都不为null
                this.save2Db(info.ugTaskId, info.ugRtuStateList, cache.ugRtuStateList);
            }
            if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){
                //此时保证两个集合都不为null
                info.ugRtuStateList.stream().sorted(Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder())).collect(Collectors.toList());
            }
            //cache赋值必须放在上面处理的后面,否则上面的比较不成功
            cache = info;
            if(info.ugOverallState != null && info.ugOverallState.allOver){
                this.saveTaskOver(info.ugTaskId) ;
            }
        }
        return null;
    }
@@ -110,15 +112,30 @@
    private void save2Db(String taskId, List<UpgradeRtu> newList, List<UpgradeRtu> oldList){
        List<UpgradeRtu> newOverList = newList.stream().filter(vo -> vo.isOver).collect(Collectors.toList()) ;
        List<UpgradeRtu> oldNoOverList = newList.stream().filter(vo -> !vo.isOver).collect(Collectors.toList()) ;
        boolean oldExist = false ;
        for(UpgradeRtu nvo : newOverList){
            if(nvo != null) {
                if(oldNoOverList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr))){
                    //上次没有升级结束,而当前升级结束了
                    this.sv.saveRtuUpgradeState(Long.parseLong(taskId), nvo);
                }
            oldExist = false ;
            if(oldNoOverList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr))){
                oldExist = true ;
            }
            if(!oldExist){
                //上次没有升级结束,而当前升级结束了
                this.sv.saveRtuUpgradeState(Long.parseLong(taskId), nvo);
            }
        }
    }
    /**
     * ä¿å­˜å‡çº§ä»»åŠ¡å·²ç»æ‰§è¡Œå®Œæˆ
     * @param taskId
     */
    private void saveTaskOver(String taskId){
        this.sv.updateTaskOver(taskId) ;
    }
    /////////////////////////////////////////////////////
    //
    // ä»¥ä¸‹æ¨¡æ‹Ÿæ•°æ®
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java
@@ -90,6 +90,14 @@
    }
    /**
     * è®¾ç½®å‡çº§ä»»åŠ¡å·²ç»å®Œæˆ
     * @param taskId
     */
    public void updateTaskOver(String taskId){
        tdao.overById(Long.valueOf(taskId)) ;
    }
    /////////////////////////////////////////////////////
    //
    // ä»¥ä¸‹æ¼”示升级功能用到
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
@@ -412,6 +412,36 @@
        if (list.size() == 0) {
            return new HashMap();
        }
//元谋一期陆常丽需求把赠送金额与充值金额分开显示
        for (int i = list.size()-1; i >= 0 ; i--) {
            Optional.ofNullable(list.get(i).getGift()).orElse(0d);
            if (!list.get(i).getGift().equals(0d)){
                Double gift1 = list.get(i).getGift();
                String districtTitle = list.get(i).getDistrictTitle();
                String clientNum = list.get(i).getClientNum();
                String clientName = list.get(i).getClientName();
                String phone = list.get(i).getPhone();
                Date tradeTime = list.get(i).getTradeTime();
                list.get(i).setGift(0d);
                VoTradeDetails voTradeDetail = new VoTradeDetails();
                voTradeDetail.setDistrictTitle(districtTitle);
                voTradeDetail.setClientNum(clientNum);
                voTradeDetail.setClientName(clientName);
                voTradeDetail.setPhone(phone);
                voTradeDetail.setOperateType("赠送");
                voTradeDetail.setTradeTime(tradeTime);
                voTradeDetail.setWaterCost(0d);
                voTradeDetail.setCardCost(0d);
                voTradeDetail.setGift(gift1);
                list.add(voTradeDetail);
                itemTotal = itemTotal + 1;
            }
        }
        rsVo.obj = list;
        rsVo.calculateAndSet(itemTotal, params);
        // éåŽ†äº¤æ˜“æ˜Žç»†è®°å½•ï¼Œæ±‡æ€»è´­æ°´é‡‘é¢ã€è´­å¡é‡‘é¢
        Double totalWaterCost = 0.0;