|
@@ -0,0 +1,138 @@
|
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
+<mapper namespace="com.huaxu.dao.OnlineMonitorMapper">
|
|
|
|
+ <!-- 结果集 -->
|
|
|
|
+ <resultMap type="com.huaxu.dto.MonitorDataCollectDto" id="monitorDataMap">
|
|
|
|
+ <result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
|
|
|
|
+ <result property="sceneName" column="scene_name" jdbcType="VARCHAR"/>
|
|
|
|
+ <result property="pointX" column="point_x" jdbcType="VARCHAR"/>
|
|
|
|
+ <result property="pointY" column="point_y" jdbcType="VARCHAR"/>
|
|
|
|
+ <result property="address" column="address" jdbcType="VARCHAR"/>
|
|
|
|
+ <collection property="MonitorDataEntities" ofType="com.huaxu.dto.MonitorDataDto" javaType="list">
|
|
|
|
+ <result property="attributeId" column="attribute_id" jdbcType="INTEGER"/>
|
|
|
|
+ <result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
|
|
|
|
+ <result property="unit" column="unit" jdbcType="VARCHAR"/>
|
|
|
|
+ <result property="isAlarm" column="is_Alarm" jdbcType="VARCHAR"/>
|
|
|
|
+ </collection>
|
|
|
|
+ </resultMap>
|
|
|
|
+
|
|
|
|
+ <!--查询实时报警信息-->
|
|
|
|
+ <select id="selectAlarmDetails" resultType="com.huaxu.dto.AlarmDetailsDto">
|
|
|
|
+ select
|
|
|
|
+ t3.scene_name as "sceneName",
|
|
|
|
+ t1.alarm_content as "alarmContent",
|
|
|
|
+ t1.alarm_start_time as "alarmStartTime"
|
|
|
|
+ from sms_alarm_details t1
|
|
|
|
+ inner join sms_device t2 on t1.device_id=t2.id and t2.`status`=1
|
|
|
|
+ inner join (
|
|
|
|
+ select a.id,a.scene_name,b.id c_id,b.scene_name c_scene_name
|
|
|
|
+ from sms_scene a
|
|
|
|
+ inner join sms_scene b on find_in_set(a.id, b.parent_scene_ids ) and b.status=1
|
|
|
|
+ inner join sms_scene_type s on s.id =a.scene_type_id and s.status=1
|
|
|
|
+ where a.parent_scene_id=0 and a.status=1 and s.scene_type_name=#{sceneTypeName}
|
|
|
|
+ <if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
|
+ and b.id in
|
|
|
|
+ <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sceneName != null and sceneName != ''">
|
|
|
|
+ and a.scene_name like concat('%',#{sceneName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ )t3 on t2.scene_id=t3.c_id
|
|
|
|
+ where t1.`status`=1 and t1.state=1
|
|
|
|
+ order by t3.scene_name
|
|
|
|
+ </select>
|
|
|
|
+ <!--查询实时报警数量-->
|
|
|
|
+ <select id="selectAlarmCount" resultType="java.util.Map">
|
|
|
|
+ select
|
|
|
|
+ t3.scene_name as "sceneName",
|
|
|
|
+ count(1) as "alalmCount"
|
|
|
|
+ from sms_alarm_details t1
|
|
|
|
+ inner join sms_device t2 on t1.device_id=t2.id and t2.`status`=1
|
|
|
|
+ inner join (
|
|
|
|
+ select a.id,a.scene_name,b.id c_id,b.scene_name c_scene_name
|
|
|
|
+ from sms_scene a
|
|
|
|
+ inner join sms_scene b on find_in_set(a.id, b.parent_scene_ids ) and b.status=1
|
|
|
|
+ inner join sms_scene_type s on s.id =a.scene_type_id and s.status=1
|
|
|
|
+ where a.parent_scene_id=0 and a.status=1 and s.scene_type_name=#{sceneTypeName}
|
|
|
|
+ <if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
|
+ and b.id in
|
|
|
|
+ <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ <if test="sceneName != null and sceneName != ''">
|
|
|
|
+ and a.scene_name like concat('%',#{sceneName},'%')
|
|
|
|
+ </if>
|
|
|
|
+ )t3 on t2.scene_id=t3.c_id
|
|
|
|
+ where t1.`status`=1 and t1.state=1
|
|
|
|
+ group by t3.scene_name
|
|
|
|
+ order by count(1) desc
|
|
|
|
+ </select>
|
|
|
|
+ <!--查询地图悬浮数据-->
|
|
|
|
+ <select id="selectMapSuspension" resultMap="monitorDataMap">
|
|
|
|
+ select
|
|
|
|
+ t4.id scene_Id,
|
|
|
|
+ t4.scene_name ,
|
|
|
|
+ t4.point_x ,
|
|
|
|
+ t4.point_y,
|
|
|
|
+ t4.address ,
|
|
|
|
+ t3.attribute_id ,
|
|
|
|
+ ifnull(t3.remark, t2.`name`) attribute_Name,
|
|
|
|
+ t2.unit ,
|
|
|
|
+ if (t5.id is null, 0, 1) is_Alarm
|
|
|
|
+ from sms_device t1
|
|
|
|
+ inner join sms_device_attribute t2 on t1.device_type_id = t2.device_type_id and t2.`status` = 1
|
|
|
|
+ inner join sms_device_parm t3 on t1.id = t3.device_id and t3.attribute_id = t2.id and t3.`status` = 1
|
|
|
|
+ inner join (
|
|
|
|
+ select a.id,a.scene_name,a.point_x,a.point_y,a.address,b.id c_id,b.scene_name c_scene_name
|
|
|
|
+ from sms_scene a
|
|
|
|
+ inner join sms_scene b on find_in_set(a.id, b.parent_scene_ids) and b. status = 1
|
|
|
|
+ inner join sms_scene_type s on s.id = a.scene_type_id and s. status = 1
|
|
|
|
+ where a.parent_scene_id = 0 and a. status = 1 and s.scene_type_name = #{sceneTypeName}
|
|
|
|
+ <if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
|
+ and b.id in
|
|
|
|
+ <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ ) t4 on t1.scene_id = t4.c_id
|
|
|
|
+ left join sms_alarm_details t5 on t5.device_id = t1.id and t5.attribute_id = t3.attribute_id and t5.state = 1
|
|
|
|
+ where t1.`status` = 1 and t3.is_suspension = 1
|
|
|
|
+ order by t4.scene_name,t3.seq
|
|
|
|
+ </select>
|
|
|
|
+ <!--查询地图参数数据-->
|
|
|
|
+ <select id="selectMapParam" resultMap="monitorDataMap">
|
|
|
|
+ select
|
|
|
|
+ t4.id scene_Id,
|
|
|
|
+ t4.scene_name ,
|
|
|
|
+ t4.point_x ,
|
|
|
|
+ t4.point_y,
|
|
|
|
+ t4.address ,
|
|
|
|
+ t3.attribute_id ,
|
|
|
|
+ ifnull(t3.remark, t2.`name`) attribute_Name,
|
|
|
|
+ t2.unit ,
|
|
|
|
+ if (t5.id is null, 0, 1) is_Alarm
|
|
|
|
+ from sms_device t1
|
|
|
|
+ inner join sms_device_attribute t2 on t1.device_type_id = t2.device_type_id and t2.`status` = 1
|
|
|
|
+ inner join sms_device_parm t3 on t1.id = t3.device_id and t3.attribute_id = t2.id and t3.`status` = 1
|
|
|
|
+ inner join (
|
|
|
|
+ select a.id,a.scene_name,a.point_x,a.point_y,a.address,b.id c_id,b.scene_name c_scene_name
|
|
|
|
+ from sms_scene a
|
|
|
|
+ inner join sms_scene b on find_in_set(a.id, b.parent_scene_ids) and b. status = 1
|
|
|
|
+ inner join sms_scene_type s on s.id = a.scene_type_id and s. status = 1
|
|
|
|
+ where a.parent_scene_id = 0 and a. status = 1 and a.id = #{sceneId}
|
|
|
|
+ <if test="sceneIds != null and sceneIds.size() > 0">
|
|
|
|
+ and b.id in
|
|
|
|
+ <foreach collection="sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </if>
|
|
|
|
+ ) t4 on t1.scene_id = t4.c_id
|
|
|
|
+ left join sms_alarm_details t5 on t5.device_id = t1.id and t5.attribute_id = t3.attribute_id and t5.state = 1
|
|
|
|
+ where t1.`status` = 1 and t3.is_map = 1
|
|
|
|
+ order by t4.scene_name,t3.seq
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+</mapper>
|