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/ParkingSpaceServiceDaoImplMapper.xml |  124 ++++++++++++++++++++++++----------------
 1 files changed, 74 insertions(+), 50 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/ParkingSpaceServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/ParkingSpaceServiceDaoImplMapper.xml
index b97f07b..f890818 100644
--- a/java110-db/src/main/resources/mapper/community/ParkingSpaceServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/ParkingSpaceServiceDaoImplMapper.xml
@@ -95,57 +95,81 @@
 
     <!-- 鏌ヨ鍋滆溅浣嶄俊鎭� add by wuxw 2018-07-03 -->
     <select id="getParkingSpaceInfo" parameterType="Map" resultType="Map">
-        select t.area,t1.name type_cd,t1.name typeCd,t.num,t.ps_id,t.ps_id psId,t.remark,t.status_cd,t.status_cd
-        statusCd,t2.name state,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.user_id,t.user_id userId
-        from p_parking_space t,t_dict t1,t_dict t2 where t.type_cd=t1.status_cd and t1.table_name='p_parking_space'
-        and t.state = t2.status_cd and t2.table_name='p_parking_space'
-        <if test="area !=null and area != ''">
-            and t.area= #{area}
-        </if>
-        <if test="typeCd !=null and typeCd != ''">
-            and t.type_cd= #{typeCd}
-        </if>
-        <if test="num !=null and num != ''">
-            and t.num= #{num}
-        </if>
-        <if test="psId !=null and psId != ''">
-            and t.ps_id= #{psId}
-        </if>
-        <if test="remark !=null and remark != ''">
-            and t.remark= #{remark}
-        </if>
-        <if test="statusCd !=null and statusCd != ''">
-            and t.status_cd= #{statusCd}
-        </if>
-        <if test="state !=null and state != ''">
-            and t.state= #{state}
-        </if>
-        <if test="states != null and states != null">
-            and t.state in
-            <foreach collection="states" item="item" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
-        </if>
-        <if test="psIds != null and psIds != null">
-            and t.ps_id in
-            <foreach collection="psIds" item="item" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
-        </if>
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
-        <if test="bId !=null and bId != ''">
-            and t.b_id= #{bId}
-        </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
+        SELECT
+            t.area,
+            t.`type_cd` typeCd,
+            t.`type_cd`,
+            t.num,
+            t.ps_id psId,
+            t.ps_id,
+            t.remark,
+            t.status_cd statusCd,
+            t.status_cd,
+            t.`state`,
+            t.community_id,
+            t.community_id communityId,
+            t.b_id,
+            t.b_id bId,
+            t.user_id,
+            t.user_id userId,
+            td.name stateName,
+            td1.name typeCdName
+        FROM
+          p_parking_space t,t_dict td,t_dict td1
+        <where>
+            t.state = td.status_cd
+            and td.table_name='p_parking_space'
+            and td.table_columns='state'
+            and t.type_cd = td1.status_cd
+            and td1.table_name='p_parking_space'
+            and td1.table_columns='type_cd'
+            <if test="area !=null and area != ''">
+                and t.area= #{area}
+            </if>
+            <if test="typeCd !=null and typeCd != ''">
+                and t.type_cd= #{typeCd}
+            </if>
+            <if test="num !=null and num != ''">
+                and t.num= #{num}
+            </if>
+            <if test="psId !=null and psId != ''">
+                and t.ps_id= #{psId}
+            </if>
+            <if test="remark !=null and remark != ''">
+                and t.remark= #{remark}
+            </if>
+            <if test="statusCd !=null and statusCd != ''">
+                and t.status_cd= #{statusCd}
+            </if>
+            <if test="state !=null and state != ''">
+                and t.state= #{state}
+            </if>
+            <if test="states != null and states != null">
+                and t.state in
+                <foreach collection="states" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="psIds != null and psIds != null">
+                and t.ps_id in
+                <foreach collection="psIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="communityId !=null and communityId != ''">
+                and t.community_id= #{communityId}
+            </if>
+            <if test="bId !=null and bId != ''">
+                and t.b_id= #{bId}
+            </if>
+            <if test="userId !=null and userId != ''">
+                and t.user_id= #{userId}
+            </if>
 
-        <if test="page != -1 and page != null ">
-            limit #{page}, #{row}
-        </if>
-
+            <if test="page != -1 and page != null ">
+                limit #{page}, #{row}
+            </if>
+        </where>
     </select>
 
 

--
Gitblit v1.8.0