|
@@ -471,9 +471,7 @@
|
|
|
and SCENE_TYPE_NAME in('水源','水厂','泵站')
|
|
|
</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
|
|
@@ -484,7 +482,7 @@
|
|
|
<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.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=",">
|
|
@@ -527,8 +525,41 @@
|
|
|
where a.ID = #{scene.id}
|
|
|
</if>
|
|
|
<if test="sort == 1">
|
|
|
- from sms_alarm_details c
|
|
|
- where c.device_id = #{scene.id}
|
|
|
+ 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.PARENT_SCENE_ID=0 and a.STATUS=1
|
|
|
+ and c.device_id = #{scene.id}
|
|
|
+ and b.SCENE_TYPE_NAME='管网'
|
|
|
+ <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>
|
|
|
+ </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')
|
|
@@ -543,8 +574,41 @@
|
|
|
where a.ID = #{scene.id}
|
|
|
</if>
|
|
|
<if test="sort == 1">
|
|
|
- from sms_alarm_details c
|
|
|
- where c.device_id = #{scene.id}
|
|
|
+ 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.PARENT_SCENE_ID=0 and a.STATUS=1
|
|
|
+ and c.device_id = #{scene.id}
|
|
|
+ and b.SCENE_TYPE_NAME='管网'
|
|
|
+ <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>
|
|
|
+ </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.date_create >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
and c.date_create < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|