|
@@ -91,7 +91,14 @@
|
|
|
|
|
|
<sql id="sceneAlarmJoins">
|
|
|
left join (
|
|
|
- select parent_scene_id,count(1) alarm_count
|
|
|
+ select parent_scene_id
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,count(1) alarm_count
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,sum(case when alarm_type='参数报警' then 1 else 0 end) alarm_count
|
|
|
+ ,sum(case when alarm_type='状态报警' then 1 else 0 end) offline_alarm_count
|
|
|
+ </if>
|
|
|
from sms_alarm_details a1
|
|
|
where a1.`status` = 1 and a1.state = 1
|
|
|
<if test="sceneIds != null and sceneIds.size() > 0">
|
|
@@ -102,6 +109,14 @@
|
|
|
</if>
|
|
|
group by parent_scene_id
|
|
|
)t7 on t7.parent_scene_id=t1.id
|
|
|
+ <if test="flag == 1">
|
|
|
+ left join (
|
|
|
+ select parent_scene_id,count(distinct device_id) setting_device_count
|
|
|
+ from sms_alarm_setting
|
|
|
+ where alarm_type='状态报警' and status=1
|
|
|
+ group by parent_scene_id
|
|
|
+ )t10 on t7.parent_scene_id=t10.parent_scene_id
|
|
|
+ </if>
|
|
|
</sql>
|
|
|
|
|
|
<sql id="deviceInnerJoins">
|
|
@@ -183,8 +198,15 @@
|
|
|
<!--查询地图悬浮数据-->
|
|
|
<select id="selectMapSuspension" resultMap="monitorDataMap">
|
|
|
select
|
|
|
- <include refid="Base_Column_List"/>,if (t7.alarm_count>0, 1, 0) scene_state,
|
|
|
- t1.COMPANY_ORG_ID as "companyOrgId"
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,if (t7.alarm_count>0, 1, 0) scene_state,
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,case when t7.offline_alarm_count=t10.setting_device_count then 2
|
|
|
+ when t7.alarm_count>0 or t7.offline_alarm_count>0 then 1 else 0 end scene_state,
|
|
|
+ </if>
|
|
|
+ t1.company_org_id as "companyOrgId"
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
<include refid="sceneAlarmJoins"/>
|
|
@@ -214,7 +236,14 @@
|
|
|
<!--查询地图参数数据-->
|
|
|
<select id="selectMapParam" resultMap="monitorDataMap">
|
|
|
select
|
|
|
- <include refid="Base_Column_List"/>,if (t7.alarm_count>0, 1, 0) scene_state
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ <if test="flag == null or flag == 0">
|
|
|
+ ,if (t7.alarm_count>0, 1, 0) scene_state
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,case when t7.offline_alarm_count=t10.setting_device_count then 2
|
|
|
+ when t7.alarm_count>0 or t7.offline_alarm_count>0 then 1 else 0 end scene_state
|
|
|
+ </if>
|
|
|
from sms_scene t1
|
|
|
<include refid="sceneDeviceJoins"/>
|
|
|
<include refid="sceneAlarmJoins"/>
|
|
@@ -341,12 +370,26 @@
|
|
|
<!--查询设备地图参数数据-->
|
|
|
<select id="selectDeviceMapParam" resultMap="deviceDataMap">
|
|
|
select distinct t1.id device_id,t1.device_code,t1.device_name,t1.point_x,point_y,t1.address,t2.attribute_id, ifnull(t2.remark, t3.`name`) attribute_name,t3.unit,
|
|
|
- t2.seq,case when t2.attribute_id is null then null when t6.id is null then 0 else 1 end is_alarm, if (t4.alarm_count>0, 1, 0) device_state
|
|
|
+ t2.seq,case when t2.attribute_id is null then null when t6.id is null then 0 else 1 end is_alarm
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,if (t4.alarm_count>0, 1, 0) device_state
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,case when t4.offline_alarm_count>0 then 2 when t4.alarm_count>0 then 1 else 0 end device_state
|
|
|
+ </if>
|
|
|
from sms_device t1
|
|
|
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
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,count(1) alarm_count
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,sum(case when alarm_type='参数报警' then 1 else 0 end) alarm_count
|
|
|
+ ,sum(case when alarm_type='状态报警' then 1 else 0 end) offline_alarm_count
|
|
|
+ </if>
|
|
|
+ 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}
|
|
@@ -503,11 +546,25 @@
|
|
|
</select>
|
|
|
<!--查询管网地图图层及设备-->
|
|
|
<select id="selectPipeNetLayer" resultMap="layerMap">
|
|
|
- select t4.id scene_id,t4.scene_name,t5.scene_type_name,t6.id device_id,t6.device_code,t6.device_name,t6.point_x,t6.point_y,t6.address,if (t7.alarm_count>0, 1, 0) device_state
|
|
|
+ select t4.id scene_id,t4.scene_name,t5.scene_type_name,t6.id device_id,t6.device_code,t6.device_name,t6.point_x,t6.point_y,t6.address
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,if (t7.alarm_count>0, 1, 0) device_state
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,case when t7.offline_alarm_count>0 then 2 when t7.alarm_count>0 then 1 else 0 end device_state
|
|
|
+ </if>
|
|
|
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
|
|
|
+ <if test="flag == null or flag ==0">
|
|
|
+ ,count(1) alarm_count
|
|
|
+ </if>
|
|
|
+ <if test="flag == 1">
|
|
|
+ ,sum(case when alarm_type='参数报警' then 1 else 0 end) alarm_count
|
|
|
+ ,sum(case when alarm_type='状态报警' then 1 else 0 end) offline_alarm_count
|
|
|
+ </if>
|
|
|
+ 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>
|