YtAlarmMapper.xml
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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="org.thingsboard.server.dao.yunteng.mapper.YtAlarmMapper">
<resultMap type="org.thingsboard.server.dao.yunteng.entities.YtAlarmEntity" id="alarmInfo">
<result property="id" column="id" typeHandler="org.thingsboard.server.dao.yunteng.mapper.UUIDTypeHandler"/>
<result property="tenantId" column="tenant_id" typeHandler="org.thingsboard.server.dao.yunteng.mapper.UUIDTypeHandler"/>
<result property="deviceName" column="device_name"/>
<result property="customerId" column="customer_id" typeHandler="org.thingsboard.server.dao.yunteng.mapper.UUIDTypeHandler"/>
<result property="type" column="type"/>
<result property="deviceId" column="device_id" />
<result property="originatorType" column="originator_type"/>
<result property="tbDeviceId" column="originator_Id" typeHandler="org.thingsboard.server.dao.yunteng.mapper.UUIDTypeHandler"/>
<result property="severity" column="severity" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
<result property="status" column="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
<result property="startTs" column="start_ts"/>
<result property="endTs" column="end_ts"/>
<result property="ackTs" column="ack_ts"/>
<result property="clearTs" column="clear_ts"/>
<result property="details" column="details" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
<result property="propagate" column="propagate"/>
</resultMap>
<resultMap type="org.thingsboard.server.dao.yunteng.entities.SysDict" id="alarmType">
<result property="dictName" column="dict_name"/>
<result property="dictCode" column="dict_code"/>
</resultMap>
<select id="alarmPage" resultMap="alarmInfo">
SELECT d.name AS device_name,d.id device_id,m.*
FROM alarm m LEFT JOIN iotfs_device d ON m.originator_id = d.tb_device_id::uuid
<where>
m.tenant_id = #{tenantId}
<if test="alarmType!=null">
AND type LIKE CONCAT('%',#{alarmType},'%')
</if>
<if test="startTime!=null">
AND created_time >= #{startTime}
</if>
<if test="endTime!=null">
AND created_time <= #{endTime}
</if>
<if test="status!=null">
AND status = #{status.name}
</if>
<if test="deviceId!=null">
AND d.id = #{deviceId}
</if>
<if test="originatorType!=null">
AND originator_type = #{originatorType.ordinal}
</if>
<if test="organizationId!=null">
AND d.organization_id IN
<foreach collection="organizationId" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
<select id="alarmType" resultMap="alarmType">
SELECT DISTINCT m.type AS dict_name,m.type AS dict_code
FROM alarm m
<where>
m.tenant_id = #{tenantId}
</where>
</select>
</mapper>