|
@@ -307,10 +307,13 @@
|
|
|
</select>
|
|
|
<!--按管网名称分类查询设备数量-->
|
|
|
<select id="selectDeviceCount" resultType="java.util.Map">
|
|
|
- select t1.id sceneId,t1.scene_name sceneName,sum(if(t5.id is null,0,1)) deviceCount
|
|
|
+ select t1.id sceneId,t1.scene_name sceneName,sum(if(t5.id is null,0,1)) deviceCount,sum(if(t7.device_id is null,0,1)) alarmCount
|
|
|
from sms_scene t1
|
|
|
- <include refid="deviceLeftJoins"/>
|
|
|
- where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网'
|
|
|
+ <include refid="deviceInnerJoins"/>
|
|
|
+ left join(
|
|
|
+ select a1.scene_id, a1.device_id from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
|
|
|
+ )t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
|
|
|
+ where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{sceneTypeName}
|
|
|
<if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
and t1.id in
|
|
|
<foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|
|
@@ -336,7 +339,7 @@
|
|
|
left join sms_device_parm t2 on t2.device_id=t1.id and t2.is_map=1 and t2.status=1
|
|
|
left join sms_device_attribute t3 on t2.attribute_id=t3.id and t3.status=1
|
|
|
left join (
|
|
|
- select a1.device_id,count(1) alarm_count from sms_alarm_details a1 where a1.device_id= #{deviceId} and a1.`status` = 1 and a1.state = 1
|
|
|
+ select a1.device_id,count(1) alarm_count from sms_alarm_details a1 where a1.device_id= #{deviceId} and a1.`status` = 1 and a1.state = 1
|
|
|
)t4 on t4.device_id=t1.id
|
|
|
left join sms_alarm_details t6 on t6.device_id=t1.id and t6.attribute_id=t2.attribute_id and t6.status = 1 and t6.state=1
|
|
|
where t1. status = 1 and t1. enable_state = 1 and t1.id= #{deviceId}
|
|
@@ -348,7 +351,7 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="deviceInnerJoins"/>
|
|
|
left join(
|
|
|
- select a1.scene_id, a1.device_id from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
|
|
|
+ select a1.scene_id, a1.device_id from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
|
|
|
)t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
|
|
|
where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网'
|
|
|
<choose>
|
|
@@ -470,7 +473,7 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="deviceInnerJoins"/>
|
|
|
left join(
|
|
|
- select a1.scene_id, a1.device_id ,count(1) alarm_count from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
|
|
|
+ select a1.scene_id, a1.device_id ,count(1) alarm_count from sms_alarm_details a1 where a1.`status` = 1 and a1.state = 1 group by a1.scene_id, a1.device_id
|
|
|
)t7 on t7.scene_id=t2.scene_id and t7.device_id=t2.device_id
|
|
|
where t1.parent_scene_id = 0 and t1. status = 1 and t1. enable_state = 1 and t3.scene_type_name = '管网' and t5.scene_type_name = #{onlineDataDto.sceneTypeName}
|
|
|
<if test="onlineDataDto.sceneIds != null and onlineDataDto.sceneIds.size() > 0">
|
|
@@ -524,7 +527,7 @@
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
inner join sms_month_report t8 on t8.device_id=t2.device_id and t8.attribute_id =t5.attribute_id
|
|
|
- and t8.year = year(now() + interval-1 day) and t8.month = month(now() + interval-1 day) and t8.day = day(now() + interval-1 day)
|
|
|
+ and t8.year = year(now() + interval-1 day) and t8.month = month(now() + interval-1 day) and t8.day = day(now() + interval-1 day)
|
|
|
where t1.parent_scene_id = 0 and t1. status = 1 and t5.parm_type in(3) and t3.scene_type_name = '水厂'
|
|
|
<if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
and t1.id in
|