liurunyu
2024-10-25 126c2efc23cb8a02e4ff4d300050a590b8a0f1fa
取水口管理功能中去除顯示在線情況,優化SQL語句。
5个文件已修改
145 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java
@@ -110,12 +110,6 @@
    @ColumnWidth(20)
    private Date findDt;
    /**
     * 是否在线
     */
    @ExcelIgnore
    private Boolean isOnLine;
    @Schema(title = "绑定次数")
    @ExcelProperty(value = {"${title}", "绑定次数"})
    @ColumnWidth(10)
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -231,14 +231,9 @@
        LEFT JOIN ba_district town ON ge.townId = town.id
        LEFT JOIN ba_district village ON ge.villageId = village.id
        LEFT JOIN pr_controller cont ON ge.id = cont.intakeId
        left JOIN JSON_TABLE(
        <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
        #{onLineMap},
        '$[*]' COLUMNS(
        rtuAddr VARCHAR(20) PATH '$.rtuAddr',
        isOnLine BOOLEAN PATH '$.isOnLine'
        )
        ) rtus ON cont.rtuAddr = rtus.rtuAddr
        <if test = "bindNumber != null and bindNumber > 0">
            JOIN (SELECT intakeId, COUNT(*) num FROM pr_intake_controller WHERE operateType = 1 group by intakeId) AS bindNumTb on bindNumTb.intakeId= ge.id
        </if>
        <where>
            ge.deleted = 0
            AND divi.deleted = 0
@@ -255,10 +250,10 @@
                AND blo.id = #{blockId}
            </if>
            <if test="isBinded == 0">
            <if test="isBinded != null and isBinded == 0">
                AND ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0)
            </if>
            <if test="isBinded == 1">
            <if test="isBinded != null and isBinded == 1">
                AND ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0)
            </if>
            <if test="isBinded == null">
@@ -269,21 +264,20 @@
            <if test = "rtuAddr != null and rtuAddr !=''">
                AND cont.rtuAddr like CONCAT('%',#{rtuAddr},'%')
            </if>
            <if test="isOnLine != null and isOnLine !='' ">
                AND rtus.isOnLine = #{isOnLine}
            </if>
            <if test="protocol != null and protocol !='' ">
                AND cont.protocol = #{protocol}
            </if>
            <if test = "bindNumber != null and bindNumber > 0">
                AND (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) = ${bindNumber}
                AND bindNumTb.num = #{bindNumber}
            </if>
        </where>
    </select>
    <!--根据指定条件获取取水口记录-->
    <select id="getIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoIntake">
        SELECT CAST(ge.id AS char)                                 AS intakeId,
        WITH intakeIds AS(SELECT intakeId FROM pr_controller where deleted = 0)
        SELECT CAST(ge.id AS char)                          AS intakeId,
        ge.`name`                                           AS intakeName,
        CAST(divi.id AS char)                               AS divideId,
        divi.`name`                                         AS divideName,
@@ -293,18 +287,14 @@
        cont.rtuAddr                                        AS rtuAddr,
        cont.protocol                                       AS protocol,
        cont.findDt                                         AS findDt,
        rtus.isOnLine                                       AS isOnLine,
        (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) AS bindNumber,
        bindNumTb.num                                       AS bindNumber,
        ge.lng,
        ge.lat,
        ge.remarks,
        ge.operator,
        ge.operateDt                                        As operateDt,
        (CASE
        WHEN ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0) THEN '未绑定'
        WHEN ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0) THEN '已绑定'
        END)                                            AS isBind,
        CONCAT(country.`name`, town.`name`, village.`name`) AS address
        IF(ge.id IN (SELECT intakeId FROM intakeIds),'已绑定','未绑定')    AS isBind,
        CONCAT(country.`name`, town.`name`, village.`name`)              AS address
        FROM pr_intake ge
        INNER JOIN pr_divide divi ON ge.divideId = divi.id
        INNER JOIN ba_block blo ON divi.blockId = blo.id
@@ -312,14 +302,7 @@
        LEFT JOIN ba_district town ON ge.townId = town.id
        LEFT JOIN ba_district village ON ge.villageId = village.id
        LEFT JOIN pr_controller cont ON ge.id = cont.intakeId
        left JOIN JSON_TABLE(
        <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
        #{onLineMap},
        '$[*]' COLUMNS(
        rtuAddr VARCHAR(20) PATH '$.rtuAddr',
        isOnLine BOOLEAN PATH '$.isOnLine'
        )
        ) rtus ON cont.rtuAddr = rtus.rtuAddr
        JOIN (SELECT intakeId, COUNT(*) num FROM pr_intake_controller WHERE operateType = 1 group by intakeId) AS bindNumTb on bindNumTb.intakeId= ge.id
        <where>
            ge.deleted = 0
            AND divi.deleted = 0
@@ -327,19 +310,16 @@
            <if test="intakeName != null and intakeName != ''">
                AND ge.name LIKE CONCAT('%', #{intakeName}, '%')
            </if>
            <if test="divideId != null and divideId != ''">
                AND divi.id = #{divideId}
            </if>
            <if test="blockId != null and blockId != ''">
                AND blo.id = #{blockId}
            </if>
            <if test="isBinded == 0">
            <if test="isBinded != null and isBinded == 0">
                AND ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0)
            </if>
            <if test="isBinded == 1">
            <if test="isBinded != null and isBinded == 1">
                AND ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0)
            </if>
            <if test="isBinded == null">
@@ -347,17 +327,14 @@
            <if test="address != null and address != ''">
                AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%')
            </if>
            <if test = "rtuAddr != null and rtuAddr !=''">
            <if test="rtuAddr != null and rtuAddr !=''">
                AND cont.rtuAddr like CONCAT('%',#{rtuAddr},'%')
            </if>
            <if test="isOnLine != null and isOnLine !='' ">
                AND rtus.isOnLine = #{isOnLine}
            </if>
            <if test="protocol != null and protocol !='' ">
                AND cont.protocol = #{protocol}
            </if>
            <if test = "bindNumber != null and bindNumber > 0">
                AND (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) = ${bindNumber}
            <if test="bindNumber != null and bindNumber > 0">
                AND bindNumTb.num = #{bindNumber}
            </if>
        </where>
        ORDER BY ge.operateDt DESC
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
@@ -12,7 +12,6 @@
import com.dy.pipIrrGlobal.voPr.VoIntake;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
import com.dy.pipIrrProject.intake.qo.OnLineIntakesQO;
import com.dy.pipIrrProject.result.ProjectResultCode;
import com.taobao.api.ApiException;
import io.swagger.v3.oas.annotations.Operation;
@@ -290,14 +289,13 @@
    }
    /**
     * 此功能已經移植到remote模塊的MonitroCtrl中
     * 获取取水口列表(在线和不在线)
     *
     * @param qo
     * @return
     */
    @GetMapping(path = "all_intakes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
     @GetMapping(path = "all_intakes")
     @SsoAop()
     public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
        try {
            QueryResultVo<List<VoOnLineIntake>> res = intakeSv.selectOnLineIntakes(qo);
            return BaseResponseUtils.buildSuccess(res);
@@ -305,8 +303,8 @@
            log.error("查询取水口异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
     }
     */
    /**
     * 根据操作员获取常用取水口(在线和不在线)
     *
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
@@ -134,44 +134,15 @@
     * @return 取水口记录列表
     */
    public QueryResultVo<List<VoIntake>> getIntakes(QueryVo queryVo) {
        Command com = new Command();
        com.id = Command.defaultId;
        com.code = "LCD0001";
        com.type = "innerCommand";
        comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
        BaseResponse baseResponse = sendCom2Mw(com);
        JSONObject response = (JSONObject) JSON.toJSON(baseResponse);
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        Long itemTotal = prIntakeMapper.getRecordCount(params);
        if (response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            JSONArray jsonArray = new JSONArray();
            if(attachment != null) {
                HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
                for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("rtuAddr", entry.getKey());
                    jsonObject.put("isOnLine", entry.getValue());
                    jsonArray.add(jsonObject);
                }
            }
            queryVo.setOnLineMap(jsonArray.toJSONString());
            Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
            Long itemTotal = prIntakeMapper.getRecordCount(params);
            QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
            rsVo.pageSize = queryVo.pageSize;
            rsVo.pageCurr = queryVo.pageCurr;
            rsVo.calculateAndSet(itemTotal, params);
            rsVo.obj = prIntakeMapper.getIntakes(params);
            return rsVo;
        } else {
            QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
            return rsVo;
        }
        QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
        rsVo.pageSize = queryVo.pageSize;
        rsVo.pageCurr = queryVo.pageCurr;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = prIntakeMapper.getIntakes(params);
        return rsVo;
    }
    /**
@@ -249,11 +220,12 @@
    }
    /**
     * 此功能已經移植到remote模塊的MonitroSv中
     *
     * 获取取水口列表
     *
     * @return
     */
    public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(OnLineIntakesQO qo) {
     public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(OnLineIntakesQO qo) {
        Command com = new Command();
        com.id = Command.defaultId;
        com.code = "LCD0001";
@@ -287,8 +259,8 @@
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
            return rsVo;
        }
    }
     }
     */
    /**
     * 根据操作员获取常用取水口
     *
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java
@@ -40,18 +40,6 @@
    @Schema(description = "控制器地址")
    private String rtuAddr;
    /**
     * 中间件返回的RTU在线情况对象数组
     */
    private String onLineMap;
    /**
     * 是否在线
     */
    @Max(value = 1,message = "是否在线仅允许为真或假")
    @Min(value = 0,message = "是否在线仅允许为真或假")
    private Boolean isOnLine;
    @Schema(description = "通信协议")
    private String protocol;