From 60fe15f3a5e572b5393374c741cf645966e54cde Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 29 七月 2025 14:26:35 +0800
Subject: [PATCH] 修改农户开关阀次数统计中的bug

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml                     |   52 ++++++++++++++++++++++++++++++++--------------------
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java |    6 ++++++
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
index 3c10897..f27912b 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -692,11 +692,14 @@
         SELECT COUNT(*) AS recordCount
         FROM se_client cli
         <where>
-            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
-                (SELECT COUNT(*)
-                FROM rm_open_close_valve_history his
-                WHERE his.client_id = cli.id
+            (SELECT COUNT(*)
+            FROM rm_open_close_valve_history his
+            WHERE his.client_id = cli.id
+            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+            </if>
+            <if test="openCount != null">
+                > #{openCount}
             </if>
         </where>
     </select>
@@ -714,16 +717,19 @@
                 <where>
                     his.client_id = cli.id
                     <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
-                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}
+                        AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}
                     </if>
                 </where>) AS openCount
         FROM se_client cli
         <where>
-            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
-               (SELECT COUNT(*)
-               FROM rm_open_close_valve_history his
-               WHERE his.client_id = cli.id
-                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+            (SELECT COUNT(*)
+            FROM rm_open_close_valve_history his
+            WHERE his.client_id = cli.id
+            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
+                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+            </if>
+            <if test="openCount != null">
+                > #{openCount}
             </if>
         </where>
         ORDER BY cli.id
@@ -739,11 +745,14 @@
         SELECT COUNT(*) AS recordCount
         FROM se_client cli
         <where>
-            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
-                (SELECT COUNT(*)
-                FROM rm_open_close_valve_history his
-                WHERE his.client_id = cli.id
-                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) &lt; #{openCount}
+            (SELECT COUNT(*)
+            FROM rm_open_close_valve_history his
+            WHERE his.client_id = cli.id
+            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
+                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+            </if>
+            <if test="openCount != null">
+                &lt; #{openCount}
             </if>
         </where>
     </select>
@@ -766,11 +775,14 @@
                 </where>) AS openCount
         FROM se_client cli
         <where>
-            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
-                (SELECT COUNT(*)
-                FROM rm_open_close_valve_history his
-                WHERE his.client_id = cli.id
-                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) &lt; #{openCount}
+            (SELECT COUNT(*)
+            FROM rm_open_close_valve_history his
+            WHERE his.client_id = cli.id
+            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
+                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+            </if>
+            <if test="openCount != null">
+                &lt; #{openCount}
             </if>
         </where>
         ORDER BY cli.id
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
index bd809b3..061c0d3 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
@@ -49,6 +49,9 @@
             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
         try {
+            if(qo.getOpenCount() == null){
+                qo.setOpenCount(0);
+            }
             return BaseResponseUtils.buildSuccess(clientSv.getLargeOpenCountClients(qo));
         } catch (Exception e) {
             log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);
@@ -69,6 +72,9 @@
             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
         try {
+            if(qo.getOpenCount() == null){
+                qo.setOpenCount(0);
+            }
             return BaseResponseUtils.buildSuccess(clientSv.getSmallOpenCountClients(qo));
         } catch (Exception e) {
             log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);

--
Gitblit v1.8.0