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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?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="cn.chnmuseum.party.mapper.TBoxOperationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.chnmuseum.party.model.TBoxOperation">
<id column="id" property="id"/>
<result column="organ_id" property="organId"/>
<result column="mac" property="mac"/>
<result column="status" property="status"/>
<result column="area_id" property="areaId"/>
<result column="public_key" property="publicKey"/>
<result column="private_key" property="privateKey"/>
<result column="request_count" property="requestCount"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="organ_name" property="organName"/>
<result column="area_name" property="areaName"/>
<result column="user_name" property="userName"/>
<result column="permanent" property="permanent"/>
<result column="effective_date" property="effectiveDate"/>
<result column="exired_date" property="exiredDate"/>
<result column="num" property="num"/>
<result column="begin_date" property="beginDate"/>
<result column="end_date" property="endDate"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, organ_id, mac, status, area_id, public_key, private_key, request_count, create_time, update_time
</sql>
<select id="getList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.`user_name` organ_name
FROM t_box_operation b
left join t_user r on r.org_id = b.organ_id and r.type = '3'
where 1=1
<if test="status!= null and status != '' ">
and b.status =#{status}
</if>
<if test="areaId!= null and areaId != '' ">
and r.area_id like concat(#{areaId}, '%')
</if>
order by b.create_time desc
</select>
<select id="selectBoxPage" resultMap="BaseResultMap">
select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name
area_name,u.permanent permanent,
u.effective_date effective_date,u.exired_date exired_date,count(r.mac_addr) num
from t_box_operation b
left join t_organ o on b.organ_id = o.id
left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
left join t_area a on u.area_id = a.id
left join run_log r on r.mac_addr = b.mac
where 1=1
<if test="user.orgId!= null and user.orgId != '' ">
and b.organ_id =#{user.orgId}
</if>
<if test="user.areaId!= null and user.areaId != '' ">
and b.area_id =#{user.areaId}
</if>
<if test="user.orgCode != null and user.orgCode != '' ">
and o.code LIKE concat(#{user.orgCode}, '%')
</if>
<if test="user.areaName != null and user.areaName != '' ">
and b.area_id LIKE concat(#{user.areaName}, '%')
</if>
<if test="user.beginDate != null and user.endDate != null ">
and r.start_time between #{user.beginDate} and #{user.endDate}
</if>
group by r.mac_addr,b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name,a.full_name
,u.permanent,u.effective_date ,u.exired_date
order by b.create_time desc
</select>
<select id="selectPageList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.name organ_name ,u.user_name
FROM (t_box_operation b
left join t_organ r on r.id = b.organ_id
left join t_user u on u.org_id = b.organ_id and u.type = '2')
where 1=1
<if test="tBoxOperation.organId != null and tBoxOperation.organId != '' ">
and b.organ_id =#{tBoxOperation.organId}
</if>
<if test="tBoxOperation.status != null">
and b.status =#{tBoxOperation.status}
</if>
<if test="tBoxOperation.areaId != null and tBoxOperation.areaId != '' ">
and b.area_id = #{tBoxOperation.areaId}
</if>
<if test="tBoxOperation.areaName != null and tBoxOperation.areaName != '' ">
and b.area_id LIKE concat(#{tBoxOperation.areaName}, '%')
</if>
<if test="tBoxOperation.organCode != null and tBoxOperation.organCode != '' ">
and r.code LIKE concat(#{tBoxOperation.organCode}, '%')
</if>
order by b.create_time desc
</select>
<select id="selectBoxList" resultMap="BaseResultMap">
select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name
area_name,u.permanent permanent,
u.effective_date effective_date,u.exired_date exired_date,count(r.mac_addr) num
from t_box_operation b
left join t_organ o on b.organ_id = o.id
left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
left join t_area a on u.area_id = a.id
left join run_log r on r.mac_addr = b.mac
where 1=1
<if test="user.orgId!= null and user.orgId != '' ">
and b.organ_id =#{user.orgId}
</if>
<if test="user.areaId!= null and user.areaId != '' ">
and b.area_id =#{user.areaId}
</if>
<if test="user.orgCode != null and user.orgCode != '' ">
and o.code LIKE concat(#{user.orgCode}, '%')
</if>
<if test="user.areaName != null and user.areaName != '' ">
and b.area_id LIKE concat(#{user.areaName}, '%')
</if>
<if test="user.beginDate != null and user.endDate != null ">
and r.start_time between #{user.beginDate} and #{user.endDate}
</if>
group by r.mac_addr,b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name,a.full_name
,u.permanent,u.effective_date ,u.exired_date
order by b.create_time desc
</select>
<select id="selectListA" resultType="cn.chnmuseum.party.model.TBoxOperation">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.name organ_name ,u.user_name
FROM t_box_operation b
left join t_organ r on r.id = b.organ_id
left join t_user u on u.org_id = b.organ_id and u.type = '2'
where 1=1
<if test="tBoxOperation.organId != null and tBoxOperation.organId != '' ">
and b.organ_id =#{tBoxOperation.organId}
</if>
<if test="tBoxOperation.status != null">
and b.status =#{tBoxOperation.status}
</if>
<if test="tBoxOperation.areaId != null and tBoxOperation.areaId != '' ">
and b.area_id = #{tBoxOperation.areaId}
</if>
<if test="tBoxOperation.areaName != null and tBoxOperation.areaName != '' ">
and b.area_id LIKE concat(#{tBoxOperation.areaName}, '%')
</if>
<if test="tBoxOperation.organCode != null and tBoxOperation.organCode != '' ">
and r.code LIKE concat(#{tBoxOperation.organCode}, '%')
</if>
order by b.create_time desc
</select>
</mapper>