From 3a6ac2949244e6a3f70e165cd3802f1d90b78819 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 24 十月 2024 11:20:41 +0800
Subject: [PATCH] 格式化SQL语句

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml |   41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml
index c0d4f0e..29835ac 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrFlowMonitoringMapper.xml
@@ -211,43 +211,52 @@
     <select id="getRecordCountOfFlowMonitoring" resultType="java.lang.Integer">
         SELECT COUNT(*) AS recordCountOfFlowMonitoring
         from    pr_flow_monitoring pfm
-        INNER JOIN ba_district country ON pfm.countyId = country.id
-        INNER JOIN ba_district town ON pfm.townId = town.id
-        INNER JOIN ba_district village ON pfm.villageId = village.id
-        INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id
+        LEFT JOIN pr_flowmeter pf ON pf.monitoringId = pfm.id
+        LEFT JOIN ba_district country ON pfm.countyId = country.id
+        LEFT JOIN ba_district town ON pfm.townId = town.id
+        LEFT JOIN ba_district village ON pfm.villageId = village.id
         <where>
             pfm.deleted = 0
             <if test = "name != null and name !=''">
                 AND pfm.`name` like CONCAT('%',#{name},'%')
             </if>
-            <if test = "bindState != null and bindState > 0">
-                AND pmofl.operateType = ${bindState}
+            <if test = "bindState ==1 ">
+                AND pf.monitoringId IS NOT NULL
+            </if>
+            <if test = "bindState ==2 or bindState =='' ">
+                AND pf.monitoringId IS  NULL
             </if>
         </where>
     </select>
 
     <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇娴侀噺鐩戞祴绔欏疄浣撹褰�-->
     <select id="getPrFlowMonitoring" parameterType="map" resultType="com.dy.pipIrrGlobal.voPr.VoFlowMonitoring">
-        select (@i:=@i+1)                                           AS id,
+        select  CAST(pfm.id AS char)                                AS id,
                 CONCAT(country.`name`, town.`name`, village.`name`) AS address,
                 pfm.`name`                                          AS `name`,
-                pmofl.operateType                                   AS bindState
+                (CASE
+                 WHEN pf.monitoringId IS NOT NULL THEN "宸茬粦瀹�"
+                 WHEN pf.monitoringId IS  NULL  THEN "鏈粦瀹�"
+                 END)                                               AS bindState
         from    pr_flow_monitoring pfm
-        INNER JOIN ba_district country ON pfm.countyId = country.id
-        INNER JOIN ba_district town ON pfm.townId = town.id
-        INNER JOIN ba_district village ON pfm.villageId = village.id
-        INNER JOIN pr_monitoring_flowmeter pmofl ON pmofl.monitoringId = pfm.id,
-        (SELECT @i:=0) AS itable
+        LEFT JOIN pr_flowmeter pf ON pf.monitoringId = pfm.id
+        LEFT JOIN ba_district country ON pfm.countyId = country.id
+        LEFT JOIN ba_district town ON pfm.townId = town.id
+        LEFT JOIN ba_district village ON pfm.villageId = village.id
+
         <where>
             pfm.deleted = 0
             <if test = "name != null and name !=''">
                 AND pfm.`name` like CONCAT('%',#{name},'%')
             </if>
-            <if test = "bindState != null and bindState > 0">
-                AND pmofl.operateType = ${bindState}
+            <if test = "bindState ==1 ">
+                AND pf.monitoringId IS NOT NULL
+            </if>
+            <if test = "bindState ==2 or bindState =='' ">
+                AND pf.monitoringId IS  NULL
             </if>
         </where>
-        ORDER BY pmofl.operateDt DESC
+        ORDER BY pfm.operateDt DESC
         <trim prefix="limit " >
             <if test="start != null and count != null">
                 #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}

--
Gitblit v1.8.0