From b397edee2be2dfcc3f28eeac50298b4de26b1afa Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 13 十二月 2024 16:53:45 +0800
Subject: [PATCH] 取水口日取水量表中,出现一些大数,明显不正确,发析系统日志,发现一些阀控器会上报一些累计流量为0的数据,且无规律,推测是其不能从水表读取到累计流量时会上报0值。如果间歇上报0值,间歇上报一些非0值,非0值减去0值,就会出现大数,一天中出现几次那么会大数进行累加,数值将更大。为此变更算法,规避这种情况,但也会丢失一些流量值。

---
 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