From 82eb6782bd9264798bea70220d4199d559759dcb Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期六, 24 十月 2020 17:52:53 +0800
Subject: [PATCH] 优化代码

---
 java110-db/src/main/resources/mapper/common/MachineServiceDaoImplMapper.xml |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/common/MachineServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/common/MachineServiceDaoImplMapper.xml
index 4c741f5..7900e16 100644
--- a/java110-db/src/main/resources/mapper/common/MachineServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/common/MachineServiceDaoImplMapper.xml
@@ -147,18 +147,12 @@
         t.state,c.location_type locationTypeCd, c.location_name locationTypeName, t.location_obj_id locationObjId,
         t.location_type_cd,t.location_obj_id,
         td1.name stateName,t.create_time createTime,t.direction,td3.name directionName
-        from machine t,t_dict td,t_dict td1,t_dict td3, community_location c
+        from machine t
+        left join t_dict td on t.machine_type_cd=td.status_cd and td.table_name='machine' and td.table_columns='machine_type_cd'
+        left join t_dict td1 on t.state = td1.status_cd and td1.table_name='machine' and td1.table_columns='state'
+        left join t_dict td3 on t.direction = td3.status_cd and td3.table_name='machine' and td3.table_columns='direction'
+        left join community_location c on t.location_type_cd = c.location_id and t.status_cd = '0'
         where 1 =1
-        and t.machine_type_cd=td.status_cd
-        and td.table_name='machine'
-        and td.table_columns='machine_type_cd'
-        and t.state = td1.status_cd
-        and td1.table_name='machine'
-        and td1.table_columns='state'
-        and t.direction = td3.status_cd
-        and td3.table_name='machine'
-        and td3.table_columns='direction'
-        and t.location_type_cd = c.location_id
         <if test="machineMac !=null and machineMac != ''">
             and t.machine_mac= #{machineMac}
         </if>
@@ -273,17 +267,12 @@
     <!-- 鏌ヨ璁惧鏁伴噺 add by wuxw 2018-07-03 -->
     <select id="queryMachinesCount" parameterType="Map" resultType="Map">
         select count(1) count
-        from machine t,t_dict td,t_dict td1,t_dict td3
+        from machine t
+        left join t_dict td on t.machine_type_cd=td.status_cd and td.table_name='machine' and td.table_columns='machine_type_cd'
+        left join t_dict td1 on t.state = td1.status_cd and td1.table_name='machine' and td1.table_columns='state'
+        left join t_dict td3 on t.direction = td3.status_cd and td3.table_name='machine' and td3.table_columns='direction'
+        left join community_location c on t.location_type_cd = c.location_id and t.status_cd = '0'
         where 1 =1
-        and t.machine_type_cd=td.status_cd
-        and td.table_name='machine'
-        and td.table_columns='machine_type_cd'
-        and t.state = td1.status_cd
-        and td1.table_name='machine'
-        and td1.table_columns='state'
-        and t.direction = td3.status_cd
-        and td3.table_name='machine'
-        and td3.table_columns='direction'
         <if test="machineMac !=null and machineMac != ''">
             and t.machine_mac= #{machineMac}
         </if>

--
Gitblit v1.8.0