From 77c41c9c22830760c7c4e4094695dbd99968d1ee Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期一, 30 九月 2024 14:11:35 +0800
Subject: [PATCH] 优化代码
---
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml | 155 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 119 insertions(+), 36 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 fd60593..cb816f9 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -637,10 +637,14 @@
<select id="getLargeOpenCountClientsCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
FROM se_client cli
- WHERE (SELECT COUNT(*)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
+ <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}
+ </if>
+ </where>
</select>
<!--鑾峰彇鎸囧畾鏃堕棿娈靛唴寮�闃�娆℃暟瓒呰繃鎸囧畾鍊肩殑鍐滄埛-->
@@ -650,12 +654,24 @@
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 (SELECT COUNT(*)
+ <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}
+ </if>
+ </where>
ORDER BY cli.id
<trim prefix="limit ">
<if test="start != null and count != null">
@@ -668,10 +684,14 @@
<select id="getSmallOpenCountClientsCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
FROM se_client cli
- WHERE (SELECT COUNT(*)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount}
+ <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}
+ </if>
+ </where>
</select>
<!--鑾峰彇鎸囧畾鏃堕棿娈靛唴寮�闃�娆℃暟浣庝簬鎸囧畾鍊肩殑鍐滄埛-->
@@ -681,12 +701,24 @@
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 (SELECT COUNT(*)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount}
+ <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}
+ </if>
+ </where>
ORDER BY cli.id
<trim prefix="limit ">
<if test="start != null and count != null">
@@ -699,10 +731,14 @@
<select id="getLargeWaterConsumptionClientsCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_amount)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterConsumption != null">
+ (SELECT SUM(his.cl_this_amount)
+ FROM rm_open_close_valve_history his
+ WHERE his.client_id = cli.id
+ AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
+ </if>
+ </where>
</select>
<!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍐滄埛-->
@@ -712,12 +748,25 @@
cli.clientNum,
CONCAT(cli.districtTitle, cli.address) AS address,
cli.phone,
- cli.idCard
+ cli.idCard,
+ IFNULL((SELECT SUM(his.cl_this_amount)
+ 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>
+ ),0) AS waterConsumption
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_amount)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterConsumption != null">
+ (SELECT SUM(his.cl_this_amount)
+ FROM rm_open_close_valve_history his
+ WHERE his.client_id = cli.id
+ AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
+ </if>
+ </where>
ORDER BY cli.id
<trim prefix="limit ">
<if test="start != null and count != null">
@@ -730,10 +779,14 @@
<select id="getLargeAmountSpentClientsCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_money)
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and amountSpent != null">
+ (SELECT SUM(his.cl_this_money)
FROM rm_open_close_valve_history his
WHERE his.client_id = cli.id
AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent}
+ </if>
+ </where>
</select>
<!--鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍐滄埛-->
<select id="getLargeAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient">
@@ -742,12 +795,25 @@
cli.clientNum,
CONCAT(cli.districtTitle, cli.address) AS address,
cli.phone,
- cli.idCard
+ cli.idCard,
+ IFNULL((SELECT SUM(his.cl_this_money)
+ 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>
+ ),0) AS amountSpent
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_money)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent}
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and amountSpent != null">
+ (SELECT SUM(his.cl_this_money)
+ FROM rm_open_close_valve_history his
+ WHERE his.client_id = cli.id
+ AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent}
+ </if>
+ </where>
ORDER BY cli.id
<trim prefix="limit ">
<if test="start != null and count != null">
@@ -760,10 +826,14 @@
<select id="getLargeWaterDurationClientsCount" resultType="java.lang.Long">
SELECT COUNT(*) AS recordCount
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_time)
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterDuration != null">
+ (SELECT SUM(his.cl_this_time)
FROM rm_open_close_valve_history his
WHERE his.client_id = cli.id
AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterDuration}
+ </if>
+ </where>
</select>
<!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍐滄埛-->
@@ -773,12 +843,25 @@
cli.clientNum,
CONCAT(cli.districtTitle, cli.address) AS address,
cli.phone,
- cli.idCard
+ cli.idCard,
+ IFNULL((SELECT SUM(his.cl_this_time)
+ 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>
+ ),0) AS waterDuration
FROM se_client cli
- WHERE (SELECT SUM(his.cl_this_time)
- FROM rm_open_close_valve_history his
- WHERE his.client_id = cli.id
- AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterDuration}
+ <where>
+ <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterDuration != null">
+ (SELECT SUM(his.cl_this_time)
+ FROM rm_open_close_valve_history his
+ WHERE his.client_id = cli.id
+ AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterDuration}
+ </if>
+ </where>
ORDER BY cli.id
<trim prefix="limit ">
<if test="start != null and count != null">
--
Gitblit v1.8.0