DeviceActionDetailMapper.xml
13.6 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?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.com.glsx.openplatform.mapper.DeviceActionDetailMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.openplatform.model.DeviceActionDetail">
<!--@mbg.generated-->
<!--@Table t_device_action_detail-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="device_sn" jdbcType="VARCHAR" property="deviceSn"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, device_sn, `type`, create_time
</sql>
<select id="selectBeforeTime" resultMap="BaseResultMap">
select id, device_sn, type, create_time
from t_device_action_detail
where create_time < #{time,jdbcType=TIMESTAMP}
order by id
</select>
<insert id="insertInto">
insert into
<choose>
<when test="month != null and month != ''">
t_device_action_detail_${month}
</when>
<otherwise>
t_device_action_detail
</otherwise>
</choose>
(id, device_sn, `type`, create_time)
values
(#{record.id,jdbcType=INTEGER}, #{record.deviceSn,jdbcType=VARCHAR},
#{record.type,jdbcType=VARCHAR}, #{record.createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="batchInsertInto">
insert into
<choose>
<when test="month != null and month != ''">
t_device_action_detail_${month}
</when>
<otherwise>
t_device_action_detail
</otherwise>
</choose>
(id, device_sn, `type`, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=INTEGER}, #{item.deviceSn,jdbcType=VARCHAR},
#{item.type,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<delete id="deleteBeforeTime">
delete from t_device_action_detail
where create_time < #{time,jdbcType=TIMESTAMP}
</delete>
<delete id="deleteByIds">
delete from t_device_action_detail
where id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item,jdbcType=INTEGER}
</foreach>
</delete>
<!--<select id="selectDeviceType" resultType="java.lang.String">-->
<!-- select distinct device_type-->
<!-- from t_platform_device-->
<!-- where device_type != '通信模组'-->
<!--</select>-->
<!--<select id="countByDate" resultType="int">-->
<!-- select count(1)-->
<!-- from t_platform_device-->
<!-- <where>-->
<!-- <if test="startDate != null">-->
<!-- and activat_time >= #{startDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- <if test="endDate != null">-->
<!-- and activat_time < #{endDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- <if test="type != null and type != ''">-->
<!-- and device_type = #{type,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- </where>-->
<!--</select>-->
<!--<select id="selectByDate" resultType="cn.com.glsx.openplatform.model.PlatformDevice">-->
<!-- select id, device_sn deviceSn, device_type deviceType, customer_id customerId,-->
<!-- user_id userId, activat_time activatTime, status, create_time createTime,-->
<!-- update_time updateTime, create_by createBy, update_by updateBy, remark-->
<!-- from t_platform_device-->
<!-- <where>-->
<!-- <if test="startDate != null">-->
<!-- and activat_time >= #{startDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- <if test="endDate != null">-->
<!-- and activat_time < #{endDate,jdbcType=TIMESTAMP}-->
<!-- </if>-->
<!-- <if test="type != null and type != ''">-->
<!-- and device_type = #{type,jdbcType=VARCHAR}-->
<!-- </if>-->
<!-- </where>-->
<!-- order by rand()-->
<!-- <if test="count != null">-->
<!-- limit #{count,jdbcType=INTEGER}-->
<!-- </if>-->
<!--</select>-->
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from t_device_action_detail
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete
from t_device_action_detail
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
useGeneratedKeys="true">
<!--@mbg.generated-->
<selectKey order="AFTER" keyProperty="id" resultType="integer">
select LAST_INSERT_ID()
</selectKey>
insert into t_device_action_detail (device_sn, `type`, create_time)
values (#{deviceSn,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
useGeneratedKeys="true">
<!--@mbg.generated-->
<selectKey order="AFTER" keyProperty="id" resultType="integer">
select LAST_INSERT_ID()
</selectKey>
insert into t_device_action_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceSn != null and deviceSn != ''">
device_sn,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceSn != null and deviceSn != ''">
#{deviceSn,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail">
<!--@mbg.generated-->
update t_device_action_detail
<set>
<if test="deviceSn != null and deviceSn != ''">
device_sn = #{deviceSn,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail">
<!--@mbg.generated-->
update t_device_action_detail
set device_sn = #{deviceSn,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update t_device_action_detail
<trim prefix="set" suffixOverrides=",">
<trim prefix="device_sn = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.deviceSn,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`type` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.type,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="create_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update t_device_action_detail
<trim prefix="set" suffixOverrides=",">
<trim prefix="device_sn = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.deviceSn != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.deviceSn,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="`type` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.type != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.type,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="create_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createTime != null">
when id = #{item.id,jdbcType=INTEGER}
then #{item.createTime,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into t_device_action_detail
(device_sn, `type`, create_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.deviceSn,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into t_device_action_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
device_sn,
`type`,
create_time,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{deviceSn,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
device_sn = #{deviceSn,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into t_device_action_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="deviceSn != null and deviceSn != ''">
device_sn,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="deviceSn != null and deviceSn != ''">
#{deviceSn,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="deviceSn != null and deviceSn != ''">
device_sn = #{deviceSn,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
</mapper>