|
@@ -554,25 +554,44 @@
|
|
|
<select id="selectAlarmLable" resultType="map">
|
|
|
select amount 数量, label 标签 from
|
|
|
(
|
|
|
- select count(1) amount, label from
|
|
|
+ select count(1) amount, concat(label,op) label from
|
|
|
(
|
|
|
- select if(d.REMARK is null,e.NAME,d.REMARK) label
|
|
|
+ select if(d.REMARK is null,e.NAME,d.REMARK) label,CASE WHEN ALARM_CONDITION='>' OR ALARM_CONDITION='>=' then '高' WHEN ALARM_CONDITION='<' OR ALARM_CONDITION='<=' then '低' end op
|
|
|
<if test="sort == 2">
|
|
|
from sms_scene a INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
INNER JOIN sms_alarm_details c on c.PARENT_SCENE_ID=a.ID
|
|
|
INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
|
|
|
LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
|
|
|
+ INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
|
|
|
where a.ID = #{scene.id}
|
|
|
</if>
|
|
|
<if test="sort == 1">
|
|
|
from sms_alarm_details c
|
|
|
INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
|
|
|
LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
|
|
|
+ INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
|
|
|
where c.device_id = #{scene.id}
|
|
|
</if>
|
|
|
and c.date_create >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
and c.date_create < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
) t1
|
|
|
+ group by concat(label,op)
|
|
|
+ union all
|
|
|
+ select count(1) amount, label from
|
|
|
+ (
|
|
|
+ select '离线' label
|
|
|
+ <if test="sort == 2">
|
|
|
+ from sms_scene a INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
+ INNER JOIN sms_alarm_details c on c.PARENT_SCENE_ID=a.ID
|
|
|
+ where a.ID = #{scene.id} and alarm_type='状态报警'
|
|
|
+ </if>
|
|
|
+ <if test="sort == 1">
|
|
|
+ from sms_alarm_details c
|
|
|
+ where c.device_id = #{scene.id} and alarm_type='状态报警'
|
|
|
+ </if>
|
|
|
+ and c.date_create >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and c.date_create < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ ) t1
|
|
|
group by label
|
|
|
) t2
|
|
|
order by amount desc
|