From 7987c4f005f5bd8739411d08e4e3bfb67e4df9ef Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 01 十二月 2019 13:48:07 +0800
Subject: [PATCH] 优化设备脚本查询

---
 java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml
index e4596eb..c486ae4 100644
--- a/java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml
@@ -92,7 +92,16 @@
         unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id
         bId,t.user_id,t.user_id userId
         from building_unit t
+        <if test="communityId!=null and communityId != ''">
+            ,f_floor ff ,s_community_member cm
+        </if>
         where 1 =1
+        <if test="communityId!=null and communityId != ''">
+            and t.`floor_id` = ff.`floor_id`
+            AND ff.`floor_id` = cm.`member_id`
+            AND cm.`member_type_cd` = '390001200004'
+            and cm.community_id = #{communityId}
+        </if>
         <if test="floorId !=null and floorId != ''">
             and t.floor_id= #{floorId}
         </if>
@@ -243,4 +252,37 @@
         </if>
     </select>
 
+    <select id="getFloorAndUnitInfo" parameterType="Map" resultType="Map">
+        SELECT
+          bu.`unit_id` unitId,
+          bu.`unit_num` unitNum,
+          f.`floor_id` floorId,
+          f.`floor_num` floorNum
+        FROM
+          f_floor f,
+          building_unit bu
+        WHERE f.`floor_id` = bu.`floor_id`
+          AND f.`status_cd` = '0'
+          AND bu.`status_cd` = '0'
+          <if test="floorId != null and floorId !=''">
+              and bu.floor_id = #{floorId}
+          </if>
+        <if test="floorNum != null and floorNum !=''">
+            and f.floor_num = #{floorNum}
+        </if>
+        <if test="unitId != null and unitId !=''">
+            and bu.unit_id = #{unitId}
+        </if>
+        <if test="unitIds != null">
+            and bu.unit_id in
+            <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="unitNum != null and unitNum !=''">
+            and bu.unit_num = #{unitNum}
+        </if>
+
+    </select>
+
 </mapper>

--
Gitblit v1.8.0