|
@@ -428,4 +428,95 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
+ <!--报警场景及报警设备查询-->
|
|
|
+ <select id="selectAlarmSceneAndDevice" resultType="map">
|
|
|
+ select count(1) amount,a.id,a.SCENE_NAME name,2 type
|
|
|
+ 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
|
|
|
+ <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>
|
|
|
+ and c.date_create >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and c.date_create < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and SCENE_TYPE_NAME in('水源','水厂','泵站')
|
|
|
+ </where>
|
|
|
+ group by a.SCENE_NAME, a.ID, 2
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ select count(1) amount,a.id,d.DEVICE_NAME name,1 type
|
|
|
+ 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 d on c.DEVICE_ID=d.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>
|
|
|
+ </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>
|
|
|
+ and c.date_create >= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and c.date_create < date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
|
|
|
+ and SCENE_TYPE_NAME='管网'
|
|
|
+ </where>
|
|
|
+ group by d.DEVICE_NAME, d.ID, 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|