Selaa lähdekoodia

布撤防查询优化

jingyuanchao 11 kuukautta sitten
vanhempi
commit
015c785165

+ 29 - 9
soc-modules/soc-modules-core/src/main/resources/mapper/device/ProtectionMapper.xml

@@ -13,6 +13,7 @@
     <!--    </select>-->
 
     <select id="pageList" resultType="com.xunmei.core.resumption.vo.protection.ProtectionPageVo">
+        SELECT * FROM (
         select a.id,
         a.name as name,
         a.status as status,
@@ -28,26 +29,45 @@
         a.code as code,
         a.alarm_host_code as deviceCode,
         a.iot_token as iotToken,
-        a.source
-        from iot_alarm_subsystem a inner join sys_device d on (d.business_device_id = a.id or d.id=a.device_id) and d.device_status = 1
+        a.source, c.path
+        from iot_alarm_subsystem a inner join sys_device d on (d.business_device_id = a.id) and d.device_status = 1 and d.del_flag=0
         inner join sys_org c on a.org_id = c.id and c.deleted=0 and c.is_lock=0
+        UNION ALL
+        select a.id,
+        a.name as name,
+        a.status as status,
+        a.org_id as orgId,
+        c.short_name as orgName,
+        a.all_hour as allHour,
+        a.status_update_time as statusUpdateTime,
+        a.status_updator_name as statusUpdatorName,
+        a.status_change_time as statusChangeTime,
+        c.affiliated_area ,
+        c.affiliated_bank,
+        a.in_book,
+        a.code as code,
+        a.alarm_host_code as deviceCode,
+        a.iot_token as iotToken,
+        a.source, c.path
+        from iot_alarm_subsystem a inner join sys_device d on (d.id=a.device_id) and d.device_status = 1 and d.del_flag=0
+        inner join sys_org c on a.org_id = c.id and c.deleted=0 and c.is_lock=0 ) t where  1= 1
         <if test="request.checkSub==true">
-            and c.path like concat((select path from sys_org where id=#{request.orgId}), '%')
+            and t.path like concat((select path from sys_org where id=#{request.orgId}), '%')
         </if>
-        where a.deleted=0 and d.del_flag=0
+
         <if test="request.checkSub==false">
-            and a.org_id = #{request.orgId}
+            and t.orgId = #{request.orgId}
         </if>
         <if test="request.status!=null ">
-            and a.status = #{request.status}
+            and t.status = #{request.status}
         </if>
         <if test="request.key!=null and request.key!=''">
-            and a.name like concat('%',#{request.key},'%')
+            and t.name like concat('%',#{request.key},'%')
         </if>
         <if test="request.startTime!=null and request.endTime!=null">
-            and a.status_change_time >= #{request.startTime} and a.status_change_time&lt;=#{request.endTime}
+            and t.statusChangeTime >= #{request.startTime} and t.statusChangeTime&lt;=#{request.endTime}
         </if>
-        order by a.org_Id asc,a.name,a.id desc
+        order by t.orgId asc,t.name,t.id desc
     </select>
 
     <select id="getHostName" resultType="String">