From 04821fd724cc279ae6d41f968f79c767cfd9233e Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期四, 12 九月 2024 17:17:55 +0800
Subject: [PATCH] 优化代码 指定时间段内开阀次数高于指定值的农户        指定时间段内开阀次数低于指定值的农户

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 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 12007b5..bff8b95 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -654,11 +654,19 @@
                cli.clientNum,
                CONCAT(cli.districtTitle, cli.address) AS address,
                cli.phone,
-               cli.idCard
+               cli.idCard,
+                (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}
+                    </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(*)
+               (SELECT COUNT(*)
                FROM rm_open_close_valve_history his
                WHERE his.client_id = cli.id
                  AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
@@ -693,7 +701,15 @@
                cli.clientNum,
                CONCAT(cli.districtTitle, cli.address) AS address,
                cli.phone,
-               cli.idCard
+               cli.idCard,
+                (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}
+                    </if>
+                </where>) AS openCount
         FROM se_client cli
         <where>
             <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">

--
Gitblit v1.8.0