From 1ffdd87a0a34c9428ba1fe6acf56811f791f6f27 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 30 十月 2024 11:16:07 +0800
Subject: [PATCH] 2024-10-30 农户问题上报添加接口

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 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 f7bf939..a75444d 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -232,7 +232,7 @@
         LEFT JOIN ba_district village ON ge.villageId = village.id
         LEFT JOIN pr_controller cont ON ge.id = cont.intakeId
         <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
+            LEFT 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
@@ -302,7 +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
-        JOIN (SELECT intakeId, COUNT(*) num FROM pr_intake_controller WHERE operateType = 1 group by intakeId) AS bindNumTb on bindNumTb.intakeId= ge.id
+        LEFT 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
@@ -637,26 +637,28 @@
 
     <!--鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛-->
     <select id="getUsedIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
-        SELECT DISTINCT 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 rm_command_history com ON con.rtuAddr = com.rtu_addr
-        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
+        SELECT
+            com.intake_id AS intakeId,
+            con.rtuAddr,
+            inta.name AS intakeNum,
+            rtus.isOnLine
+        FROM pr_common_intakes com
+            INNER JOIN pr_intake inta ON inta.id = com.intake_id
+            INNER JOIN pr_controller con ON con.intakeId = com.intake_id
+            LEFT JOIN JSON_TABLE(
+                <!--'[{"rtuAddr":"530115059980","isOnLine":true},{"rtuAddr":"620201000030","isOnLine":true}]',-->
+                #{onLineMap},
+                '$[*]' COLUMNS (
+                    rtuAddr VARCHAR(20) PATH '$.rtuAddr',
+                    isOnLine BOOLEAN PATH '$.isOnLine'
+                )
+            ) rtus ON con.rtuAddr = rtus.rtuAddr
         <where>
-            <if test="operator != null">
-                com.operator = #{operator}
+            <if test="operatorId != null">
+                AND com.operator_id = #{operatorId}
             </if>
         </where>
+        ORDER BY com.last_used_time DESC,com.usage_count DESC
     </select>
 
     <!--鍙栨按鍙e悕绉版崲鍙栨按鍙D锛屾壂鐮佸紑闃�浣跨敤-->

--
Gitblit v1.8.0