TkRpcRecordMapper.xml
4.38 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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.TkRpcRecordMapper">
<resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkRpcRecordDTO" id="dataMap">
<result property="id" column="id"/>
<result property="deviceName" column="device_name"/>
<result property="tbDeviceId" column="tb_device_id"/>
<result property="deviceId" column="device_id"/>
<result property="deviceType" column="device_type" typeHandler="org.apache.ibatis.type.EnumTypeHandler" />
<result property="deviceSn" column="sn"/>
<result property="createTime" column="create_time"/>
<result property="expirationTime" column="expiration_time"/>
<result property="request" column="request"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="response" column="response"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="additionalInfo" column="additional_info"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="status" column="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/>
<result property="organizationId" column="organization_id"/>
<result property="organizationName" column="organization_name"/>
<result column="tenant_name" property="tenantName"/>
<result column="tenant_id" property="tenantId"/>
<!-- <association property="request" javaType="org.thingsboard.server.common.data.yunteng.dto.YtRpcRequestDTO">-->
<!-- <result column="deviceId" property="deviceId" typeHandler="org.thingsboard.server.dao.yunteng.mapper.UUIDTypeHandler"/>-->
<!-- <result column="oneway" property="oneway"/>-->
<!-- <result column="tenant_enabled" property="retries"/>-->
<!-- <result column="tenant_expire_time" property="body" />-->
<!-- </association>-->
</resultMap>
<sql id="basicColumns">
base.id,base.created_time AS create_time,base.expiration_time,base.request,base.response,base.additional_info,base.status
</sql>
<sql id="detailColumns">
<include refid="basicColumns"/>
,org.id AS organization_id,org.name AS organization_name
,dev.name AS device_name,dev.tb_device_id,dev.device_type,dev.sn,dev.tenant_id,dev.id AS device_id
,ten.title AS tenant_name
</sql>
<select id="getPageDatas" resultMap="dataMap">
SELECT <include refid="detailColumns"/>
FROM rpc base
LEFT JOIN tk_device dev ON base.device_id =dev.tb_device_id::uuid
LEFT JOIN tk_organization org ON dev.organization_id = org.id
LEFT JOIN tenant ten ON base.tenant_id = ten.id
<where>
1=1
<if test="tenantId !=null and tenantId !=''">
AND base.tenant_id = #{tenantId}::uuid
</if>
<if test="tbDeviceId !=null ">
AND base.device_id = #{tbDeviceId}::uuid
</if>
<if test="name !=null and name !=''">
AND (
dev.name LIKE concat('%',#{name}::TEXT,'%')
OR
org.name LIKE concat('%',#{name}::TEXT,'%')
OR
ten.title LIKE concat('%',#{name}::TEXT,'%')
OR
base.request LIKE concat('%',#{name}::TEXT,'%')
)
</if>
<if test="oneway !=null and name !=''">
AND base.request LIKE concat('%',#{oneway}::TEXT,'%')
</if>
<if test="status !=null">
AND base.status
<if test="status.toString() == 'SUCCESSFUL'">
= #{status}
</if>
<if test="status.toString() != 'SUCCESSFUL'">
!= 'SUCCESSFUL'
</if>
</if>
<if test="organization !=null">
AND dev.organization_id IN
<foreach collection="organization" item="organizationId" open="(" separator="," close=")">
#{organizationId}
</foreach>
</if>
</where>
</select>
</mapper>