From 9ad36b2b910aa15e45d5fb40b7e39d8d887a7cb7 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期二, 28 五月 2024 08:26:47 +0800 Subject: [PATCH] 2024-05-27 朱宝民 远程开关阀、RTU在线情况 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml | 127 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 108 insertions(+), 19 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml index ce4228b..920ffce 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml @@ -214,12 +214,12 @@ <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM pr_intake ge - INNER JOIN ba_divide divi ON ge.divideId = divi.id + INNER JOIN pr_divide divi ON ge.divideId = divi.id INNER JOIN ba_block blo ON divi.blockId = blo.id - INNER JOIN ba_district country ON ge.countyId = country.id - INNER JOIN ba_district town ON ge.townId = town.id - INNER JOIN ba_district village ON ge.villageId = village.id - , (SELECT @i:=0) AS itable + LEFT JOIN ba_district country ON ge.countyId = country.id + 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 <where> ge.deleted = 0 AND divi.deleted = 0 @@ -228,22 +228,44 @@ AND ge.name LIKE CONCAT('%', #{intakeName}, '%') </if> - <if test="divideName != null and divideName != ''"> - AND divi.name LIKE CONCAT('%', #{divideName}, '%') + <if test = "divideId != null and divideId !=''"> + AND divi.id = #{divideId} </if> - <if test="blockName != null and blockName != ''"> - AND blo.name = #{blockName} + <if test = "blockId != null and blockId !=''"> + AND blo.id = #{blockId} + </if> + + <if test="isBinded == 0"> + AND ge.id NOT IN(SELECT intakeId FROM pr_controller where deleted = 0) + </if> + <if test="isBinded == 1"> + AND ge.id IN(SELECT intakeId FROM pr_controller where deleted = 0) + </if> + <if test="isBinded == null"> + + </if> + <if test="address != null and address != ''"> + AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%') </if> </where> </select> <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰�--> <select id="getIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoIntake"> - SELECT (@i:=@i+1) AS id, + SELECT + CAST(ge.id AS char) AS intakeId, ge.`name` AS intakeName, + CAST(divi.id AS char) AS divideId, divi.`name` AS divideName, + CAST(blo.id AS char) AS blockId, blo.`name` AS blockName, + CAST(cont.id AS char) AS controllerId, + cont.rtuAddr AS rtuAddr, + 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 "鏈粦瀹�" @@ -253,10 +275,10 @@ FROM pr_intake ge INNER JOIN pr_divide divi ON ge.divideId = divi.id INNER JOIN ba_block blo ON divi.blockId = blo.id - INNER JOIN ba_district country ON ge.countyId = country.id - INNER JOIN ba_district town ON ge.townId = town.id - INNER JOIN ba_district village ON ge.villageId = village.id - , (SELECT @i:=0) AS itable + LEFT JOIN ba_district country ON ge.countyId = country.id + 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 <where> ge.deleted = 0 AND divi.deleted = 0 @@ -264,17 +286,31 @@ <if test="intakeName != null and intakeName != ''"> AND ge.name LIKE CONCAT('%', #{intakeName}, '%') </if> - <if test="divideName != null and divideName != ''"> - AND divi.name LIKE CONCAT('%', #{divideName}, '%') + + <if test = "divideId != null and divideId !=''"> + AND divi.id = #{divideId} </if> - <if test="blockName != null and blockName != ''"> - AND blo.name = #{blockName} + <if test = "blockId != null and blockId !=''"> + AND blo.id = #{blockId} + </if> + + <if test="isBinded == 0"> + AND ge.id NOT IN(SELECT intakeId FROM pr_controller where deleted = 0) + </if> + <if test="isBinded == 1"> + AND ge.id IN(SELECT intakeId FROM pr_controller where deleted = 0) + </if> + <if test="isBinded == null"> + + </if> + <if test="address != null and address != ''"> + AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%') </if> </where> ORDER BY ge.operateDt DESC <if test="pageCurr != null and pageSize != null"> - LIMIT ${pageCurr}, ${pageSize} + LIMIT ${(pageCurr-1)*pageSize}, ${pageSize} </if> </select> @@ -322,4 +358,57 @@ WHERE id NOT IN(SELECT intakeId FROM pr_controller) AND deleted = 0 </select> + <!--鑾峰彇鍙栨按鍙f暟閲忥紙鍦ㄧ嚎鍜屼笉鍦ㄥ厛锛�--> + <select id="getOnLineIntakesCount" resultType="java.lang.Long"> + SELECT + COUNT(*) AS recordCount + FROM pr_controller con + INNER JOIN pr_intake inta ON con.intakeId = inta.id + INNER 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 con.rtuAddr = rtus.rtuAddr + <where> + <if test="isOnLine != null"> + rtus.isOnLine = #{isOnLine} + </if> + <if test="intakeNum != null and intakeNum != ''"> + AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') + </if> + </where> + </select> + + <!--鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鍜屼笉鍦ㄥ厛锛�--> + <select id="getOnLineIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake"> + SELECT + con.intakeId, + con.rtuAddr, + inta.name AS intakeNum, + rtus.isOnLine + FROM pr_controller con + INNER JOIN pr_intake inta ON con.intakeId = inta.id + INNER 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 con.rtuAddr = rtus.rtuAddr + <where> + <if test="isOnLine != null"> + rtus.isOnLine = #{isOnLine} + </if> + <if test="intakeNum != null and intakeNum != ''"> + AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') + </if> + </where> + <if test="pageCurr != null and pageSize != null"> + LIMIT ${(pageCurr-1)*pageSize}, ${pageSize} + </if> + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0