| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <?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.xunmei.iot.mapper.IotAlarmDataMapper">
- <select id="selectPageList" resultType="com.xunmei.iot.vo.alarm.IotAlarmDataVo">
- SELECT
- a.*,
- b.affiliated_area AS city,
- b.affiliated_bank AS bank,
- b.short_name AS org_name
- FROM
- iot_alarm_data a
- LEFT JOIN sys_org b ON a.org_id = b.id
- LEFT JOIN iot_device_info d ON a.device_id = d.id
- where 1=1 and d.deleted = 0
- <if test="param.deviceName != null and param.deviceName != ''">
- and a.device_name like concat('%',#{param.deviceName},'%')
- </if>
- <if test="param.orgId != null and param.orgId != ''">
- and a.org_id = #{param.orgId}
- </if>
- <if test="param.orgPath != null and param.orgPath != ''">
- and b.path like concat(#{param.orgPath},'%')
- </if>
- <if test="param.dataType != null">
- and a.data_type = #{param.dataType}
- </if>
- <if test=" deviceTypeList!= null and deviceTypeList.size() > 0">
- and a.source_type in
- <foreach collection="deviceTypeList" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="param.params.alarmStartTime != null">
- and a.time >= #{param.params.alarmStartTime}
- </if>
- <if test="param.params.alarmEndTime != null">
- and a.time <= #{param.params.alarmEndTime}
- </if>
- <if test="param.params.endAlarmStartTime != null">
- and a.end_time >= #{param.params.endAlarmStartTime}
- </if>
- <if test="param.params.endAlarmEndTime != null">
- and a.end_time <= #{param.params.endAlarmEndTime}
- </if>
- <if test="param.params.dealAlarmStartTime != null">
- and a.do_time >= #{param.params.dealAlarmStartTime}
- </if>
- <if test="param.params.dealAlarmEndTime != null">
- and a.do_time <= #{param.params.dealAlarmEndTime}
- </if>
- <if test="param.isDo != null and param.isDo != ''">
- and a.is_do = #{param.isDo}
- </if>
- <if test="param.isDo == 0">
- and a.is_do is null
- </if>
- order by a.end_time ,a.time desc
- </select>
- <select id="selectAppPageList" resultType="com.xunmei.iot.vo.alarmData.AppAlarmDataPageVo">
- SELECT
- a.id,
- a.device_name,
- a.source_type,
- a.source_type_des,
- a.time as start_time,
- a.end_time,
- a.do_time,
- a.do_type,
- a.do_by_user,
- a.do_content,
- b.short_name AS org_name
- FROM
- iot_alarm_data a
- LEFT JOIN sys_org b ON a.org_id = b.id
- LEFT JOIN iot_device_info d ON a.device_id = d.id
- where 1=1 and d.deleted = 0
- <if test="param.deviceName != null and param.deviceName != ''">
- and a.device_name like concat('%',#{param.deviceName},'%')
- </if>
- <if test="param.orgId != null and param.orgId != ''">
- and a.org_id = #{param.orgId}
- </if>
- <if test="param.orgPath != null and param.orgPath != ''">
- and b.path like concat(#{param.orgPath},'%')
- </if>
- <if test="param.alarmType != null and param.alarmType != ''">
- and a.source_type = #{param.alarmType}
- </if>
- <if test="param.state==0">
- and a.end_time is not null
- </if>
- <if test="param.state==1">
- and a.end_time is null
- </if>
- <if test="param.params != null and param.params.alarmStartTime != null">
- and a.time >= #{param.params.alarmStartTime}
- </if>
- <if test="param.params != null and param.params.alarmEndTime != null">
- and a.time <= #{param.params.alarmEndTime}
- </if>
- <if test="param.isDo != null and param.isDo != ''">
- and a.is_do = #{param.isDo}
- </if>
- <if test="param.isDo == 0">
- and a.is_do is null
- </if>
- order by a.end_time ,a.time desc
- </select>
- <select id="detail" resultType="com.xunmei.iot.vo.alarm.IotAlarmDataVo">
- SELECT a.*,
- b.affiliated_area AS city,
- b.affiliated_bank AS bank,
- b.short_name AS org_name
- FROM iot_alarm_data a
- LEFT JOIN sys_org b ON a.org_id = b.id
- where a.id = #{id}
- </select>
- <select id="appBadge" resultType="java.lang.Integer">
- SELECT count(0)
- FROM iot_alarm_data a
- where a.org_id = #{orgId}
- and a.end_time is null
- </select>
- <select id="selectAlarmDataListByOrgPath" resultType="com.xunmei.common.core.domain.mediator.domain.IotAlarmData">
- SELECT
- d.*
- FROM
- iot_alarm_data d
- INNER JOIN sys_org o ON d.org_id = o.id
- LEFT JOIN iot_device_info i ON d.device_id = i.id
- where
- o.path like concat(#{orgPath},'%')
- and o.deleted = 0
- and i.deleted = 0
- <if test="dataType != null">
- and d.data_type = #{dataType}
- </if>
- </select>
- <select id="selectDeviceTypeCount" resultType="com.xunmei.iot.vo.alarmData.DeviceTypeCountVo">
- SELECT a.id,
- a.device_type as deviceType,
- count(1) as deviceTypeCount,
- t.alarmNums as deviceTypeAlarmCount
- FROM iot_device_info a
- left JOIN (
- SELECT s.device_id as deviceId,
- COUNT(1) as alarmNums
- from iot_device_info i
- INNER join iot_device_status s on i.id = s.device_id and i.iot_token = s.iot_token and i.deleted = 0
- WHERE s.state=1
- group by s.device_id
- ) t on t.deviceId= a.id
- WHERE a.deleted = 0
- <if test=" query.checkSub != null and query.checkSub == true">
- and a.org_path like concat(concat('%',#{query.orgPath}),'%')
- </if>
- <if test=" query.checkSub != null and query.checkSub == false">
- and a.org_id = #{query.orgId}
- </if>
- GROUP BY a.id
- union all
- SELECT a.id,
- a.sensor_type as deviceType,
- count(1) as deviceTypeCount,
- t.alarmNums as deviceTypeAlarmCount
- FROM iot_alarm_defence_area a
- left JOIN (
- SELECT a.id as deviceId,
- sum(IF(a.state='alarm',1,0)) as alarmNums FROM iot_alarm_defence_area a where a.deleted=0 GROUP BY a.id
- ) t on a.id=t.deviceId WHERE a.deleted = 0
- <if test=" query.checkSub != null and query.checkSub == true">
- and a.org_path like concat(concat('%',#{query.orgPath}),'%')
- </if>
- <if test=" query.checkSub != null and query.checkSub == false">
- and a.org_id = #{query.orgId}
- </if>
- GROUP BY a.id;
- </select>
- <select id="selectSensorAlarmPageList" resultType="com.xunmei.iot.vo.alarm.IotAlarmDataVo">
- SELECT
- a.*,
- b.affiliated_area AS city,
- b.affiliated_bank AS bank,
- b.short_name AS org_name
- FROM
- iot_alarm_data a
- LEFT JOIN iot_sensor s ON a.device_id = s.device_code AND a.org_id = s.org_id
- LEFT JOIN sys_org b ON a.org_id = b.id
- WHERE
- 1=1
- <if test="param.sensorId != null">
- and s.id = #{param.sensorId}
- </if>
- <if test="param.deviceName != null and param.deviceName != ''">
- and s.device_name like concat('%',#{param.deviceName},'%')
- </if>
- ORDER BY
- a.`time` DESC,
- a.end_time DESC
- </select>
- <select id="selectAlarmCount" resultType="java.util.Map">
- select CAST(d.source_type as CHAR) deviceType, CAST(SUM(1) AS CHAR) as nums
- from iot_alarm_data d
- inner join sys_org o on o.id = d.org_id
- where o.deleted = 0
- and data_type = 0
- and (
- (
- #{beginTime} <![CDATA[<=]]> d.time
- and now() <![CDATA[>=]]> d.time
- )
- or
- (
- #{beginTime} <![CDATA[<=]]> d.end_time
- and now() <![CDATA[>=]]> d.end_time
- )
- or (
- #{beginTime} <![CDATA[>=]]> d.time
- and now() <![CDATA[<=]]> d.end_time
- )
- )
- and o.path like concat(#{orgPath}, '%')
- and d.source_type is not null
- group by d.source_type
- </select>
- <select id="selectAlarmTypeList" resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
- select product_type as value,
- replace(product_name,'传感器','') as label
- from iot_alarm_system_field
- where product_type not in
- <foreach item="name" collection="excludeTypes" separator="," open="(" close=")">
- #{name}
- </foreach>
- <choose>
- <when test=" category == null or category =='' ">
- and (product_type like 'FSU_%' or product_type like 'AlarmHostInput_%')
- </when>
- <when test=" category == '0' ">
- and product_type like 'FSU_%'
- </when>
- <when test=" category == '2'">
- and (product_type like 'AlarmHostInput_%' or product_type in
- <foreach item="name" collection="mixTypes" separator="," open="(" close=")">
- #{name}
- </foreach>
- )
- </when>
- <otherwise>
- </otherwise>
- </choose>
- group by product_type
- </select>
- <select id="selectUpsAlarmCount" resultType="java.lang.Integer">
- select CAST(SUM(1) AS CHAR) as nums
- from iot_alarm_data d
- inner join sys_org o on o.id = d.org_id
- where o.deleted = 0
- and data_type = 0
- and (
- (
- #{beginTime} <![CDATA[<=]]> d.time
- and now() <![CDATA[>=]]> d.time
- )
- or
- (
- #{beginTime} <![CDATA[<=]]> d.end_time
- and now() <![CDATA[>=]]> d.end_time
- )
- or (
- #{beginTime} <![CDATA[>=]]> d.time
- and now() <![CDATA[<=]]> d.end_time
- )
- )
- and o.path like concat(#{orgPath}, '%')
- and d.source_type = 'FSU_Ups'
- </select>
- <select id="getByProductTypesAndOrgId"
- resultType="com.xunmei.common.core.domain.mediator.domain.IotAlarmData">
- SELECT
- d.*
- FROM
- iot_alarm_data d
- INNER JOIN sys_org o ON d.org_id = o.id
- WHERE
- o.id = #{orgId}
- AND o.deleted = 0
- <if test="dataType != null">
- and d.data_type = #{dataType}
- </if>
- <if test="productTypes !=null and productTypes.size()>0">
- and d.source_type in
- <foreach collection="productTypes" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|