From 0b3ff378a9faaf9d7a4831b7f0de67378fe0dfea Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 30 五月 2023 12:20:15 +0800
Subject: [PATCH] optimize 统计

---
 java110-db/src/main/resources/mapper/community/MaintainancePlanMachineV1ServiceDaoImplMapper.xml |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/MaintainancePlanMachineV1ServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/MaintainancePlanMachineV1ServiceDaoImplMapper.xml
index 1f9df27..5bb7536 100644
--- a/java110-db/src/main/resources/mapper/community/MaintainancePlanMachineV1ServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/MaintainancePlanMachineV1ServiceDaoImplMapper.xml
@@ -22,6 +22,7 @@
         communityId,t.machine_name,t.machine_name machineName
         from maintainance_plan_machine t
         where 1 =1
+        and t.status_cd = '0'
         <if test="mpmId !=null and mpmId != ''">
             and t.mpm_id= #{mpmId}
         </if>
@@ -33,9 +34,6 @@
         </if>
         <if test="planId !=null and planId != ''">
             and t.plan_id= #{planId}
-        </if>
-        <if test="statusCd !=null and statusCd != ''">
-            and t.status_cd= #{statusCd}
         </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
@@ -84,6 +82,7 @@
         select count(1) count
         from maintainance_plan_machine t
         where 1 =1
+        and t.status_cd = '0'
         <if test="mpmId !=null and mpmId != ''">
             and t.mpm_id= #{mpmId}
         </if>
@@ -96,9 +95,6 @@
         <if test="planId !=null and planId != ''">
             and t.plan_id= #{planId}
         </if>
-        <if test="statusCd !=null and statusCd != ''">
-            and t.status_cd= #{statusCd}
-        </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>
@@ -109,4 +105,26 @@
 
     </select>
 
+
+    <!-- 鏌ヨ淇濆吇璁惧淇℃伅 add by wuxw 2018-07-03 -->
+    <select id="queryMaintainancePlanMachinesGroupCount" parameterType="Map" resultType="Map">
+        select t.plan_id planId,count(1) machineCount
+        from maintainance_plan_machine t
+        where 1 =1
+        and t.status_cd = 0
+
+        <if test="planIds !=null ">
+            and t.plan_id in
+            <foreach collection="planIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        group  by t.plan_id
+
+    </select>
+
 </mapper>

--
Gitblit v1.8.0