From 9c4100d5a1ada3f8539d80199b3d8da534f9a982 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 29 七月 2025 15:34:43 +0800 Subject: [PATCH] 优化SQL语句,以提高查询速度 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 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 e6cad81..b1b6d29 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml @@ -789,17 +789,17 @@ SELECT COUNT(*) FROM se_client cli inner join ( - SELECT client_id, COUNT(*) AS openCount - FROM rm_open_close_valve_history - <where> - <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> - op_dt BETWEEN #{timeStart} AND #{timeStop} + SELECT client_id, COUNT(*) AS openCount + FROM rm_open_close_valve_history + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> + op_dt BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + group by client_id + <if test="openCount != null and openCount > 0"> + having openCount < #{openCount} </if> - </where> - group by client_id - <if test="openCount != null and openCount > 0"> - having openCount < #{openCount} - </if> ) as his on his.client_id = cli.id </select> <!-- 2025-07-29 涓嬮潰SQL鏌ヨ澶參锛屽簾寮� --> -- Gitblit v1.8.0