|
@@ -472,49 +472,53 @@
|
|
|
</where>
|
|
|
group by a.scene_name, a.id, sort
|
|
|
union all
|
|
|
- select count(1) amount, d.id,c.scene_id, d.device_name name,1 sort
|
|
|
- from sms_alarm_details c
|
|
|
- INNER JOIN sms_device d on c.DEVICE_ID=d.ID
|
|
|
- INNER JOIN sms_scene a on c.PARENT_SCENE_ID=a.ID
|
|
|
- INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
- <where>
|
|
|
- a.PARENT_SCENE_ID=0 and a.STATUS=1
|
|
|
- <if test="scene.tenantId != null and scene.tenantId != ''">
|
|
|
- and a.tenant_id = #{scene.tenantId}
|
|
|
- </if>
|
|
|
- <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
- <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
- and ( a.DEPT_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- or
|
|
|
- a.COMPANY_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- )
|
|
|
- </if>
|
|
|
- <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
- and a.DEPT_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
+
|
|
|
+ select sum(amount) amount, id, GROUP_CONCAT(scene_id SEPARATOR ',') scene_id, name, sort
|
|
|
+ from(
|
|
|
+ select count(1) amount, d.id,c.PARENT_SCENE_ID scene_id, d.device_name name,1 sort
|
|
|
+ from sms_alarm_details c
|
|
|
+ INNER JOIN sms_device d on c.DEVICE_ID=d.ID
|
|
|
+ INNER JOIN sms_scene a on c.PARENT_SCENE_ID=a.ID
|
|
|
+ INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
|
|
|
+ <where>
|
|
|
+ a.PARENT_SCENE_ID=0 and a.STATUS=1
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">
|
|
|
+ and a.tenant_id = #{scene.tenantId}
|
|
|
</if>
|
|
|
- <if test="scene.permissonType == 1">
|
|
|
- and a.COMPANY_ORG_ID in
|
|
|
- <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
- #{item.orgId}
|
|
|
- </foreach>
|
|
|
- and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
</if>
|
|
|
- </if>
|
|
|
- and c.alarm_start_time >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
- and c.alarm_start_time < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
- and SCENE_TYPE_NAME='管网'
|
|
|
- </where>
|
|
|
- group by d.device_name, d.id, c.scene_id, sort) t
|
|
|
- order by amount desc
|
|
|
+ and c.alarm_start_time >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and c.alarm_start_time < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and SCENE_TYPE_NAME='管网'
|
|
|
+ </where>
|
|
|
+ group by d.device_name, d.id, c.scene_id, sort)
|
|
|
+ ) t
|
|
|
+ order by amount desc
|
|
|
</select>
|
|
|
|
|
|
<select id="selectMonthAlarmTimes" resultType="map">
|