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 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 49 insertions(+), 6 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..cb816f9 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">
@@ -732,7 +748,16 @@
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>
<if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterConsumption != null">
@@ -770,7 +795,16 @@
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>
<if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and amountSpent != null">
@@ -809,7 +843,16 @@
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>
<if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterDuration != null">
--
Gitblit v1.8.0