Browse Source

过滤已删除关联

lin 4 years ago
parent
commit
8c5b116f7e

+ 2 - 2
src/main/resources/mapper/DeviceMapper.xml

@@ -507,7 +507,7 @@
     left join sc_organization so on(so.id = sc.org_id)
     left join sc_device_type sdt on(sdt.id = sd.device_type_id)
     left join sc_device_manufacturer sdm on(sdm.id = sd.manufacturer_id)
-    left join sc_grid_management sgm on(sgm.device_id = sd.id)
+    left join sc_grid_management sgm on(sgm.device_id = sd.id and sgm.status = 1)
     left join sc_user su on(su.id = sgm.user_id)
     where sd.status = 1
     <if test="siteId != null"> and sd.site_id = #{siteId}</if>
@@ -550,7 +550,7 @@
     right join (
     select sd.building_id,count(1) as device_count
     from sc_device sd
-    left join sc_grid_management sgm on(sgm.device_id = sd.id)
+    left join sc_grid_management sgm on(sgm.device_id = sd.id and sgm.status = 1)
     <if test="province != null or city != null or region != null or communityId != null">left join sc_building sb on (sb.id = sd.building_id and sb.status = 1)</if>
     <if test="orgId != null">left join sc_community sc on(sc.id = sd.community_id)</if>
     where sd.status = 1

+ 2 - 2
src/main/resources/mapper/WarningLogMapper.xml

@@ -144,7 +144,7 @@
     left join sc_building sb on(sb.id = sd.building_id)
     left join sc_device_type sdt1 on(sdt1.id = sd.device_type_id)
     left join sc_device_manufacturer sdm1 on(sdm1.id = sdt1.manufacturer_id)
-    left join sc_grid_management sgm on(sgm.device_id = sd.id)
+    left join sc_grid_management sgm on(sgm.device_id = sd.id and sgm.status = 1)
     where swl.status = 1 and sd.status = 1 and sgm.status = 1
     <if test="siteId != null"> and sd.site_id = #{siteId}</if>
     <if test="deviceId != null"> and sd.id = #{deviceId}</if>
@@ -184,7 +184,7 @@
     select sd.building_id,count(1) as device_count
     from sc_warning_log swl
     left join sc_device sd on(sd.id = swl.device_id)
-    left join sc_grid_management sgm on(sgm.device_id = sd.id)
+    left join sc_grid_management sgm on(sgm.device_id = sd.id and sgm.status = 1)
     where swl.status = 1 and sd.status = 1 and sgm.status = 1
     <if test="siteId != null"> and sd.site_id = #{siteId}</if>
     <if test="userId != null"> and sgm.user_id = #{userId}</if>