CustomerActionStatisticsMapper.xml
18.3 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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<?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.CustomerActionStatisticsMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.openplatform.model.CustomerActionStatistics">
<!--@mbg.generated-->
<!--@Table t_customer_action_statistics-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="customer_id" jdbcType="INTEGER" property="customerId"/>
<result column="customer_name" jdbcType="VARCHAR" property="customerName"/>
<result column="device_type" jdbcType="VARCHAR" property="deviceType"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="statistics_time" jdbcType="VARCHAR" property="statisticsTime"/>
<result column="number" jdbcType="INTEGER" property="number"/>
<result column="online_number" jdbcType="INTEGER" property="onlineNumber"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, customer_id, customer_name, device_type, `type`, statistics_time, number, online_number
</sql>
<select id="selectMonthList" resultType="java.lang.String">
select distinct statistics_time
from t_customer_action_statistics
where statistics_time >= '2020-07'
order by statistics_time
</select>
<select id="selectTypeCountMap" resultType="java.util.Map">
select type, number
from t_customer_action_statistics
<where>
<if test="statistics.customerId != null">
and customer_id = #{statistics.customerId,jdbcType=INTEGER}
</if>
<if test="statistics.deviceType != null and statistics.deviceType != ''">
and device_type = #{statistics.deviceType,jdbcType=VARCHAR}
</if>
<if test="statistics.statisticsTime != null and statistics.statisticsTime != ''">
and statistics_time = #{statistics.statisticsTime,jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="countPlatformDevice" resultType="int">
select count(1)
from t_platform_device
<where>
<if test="statistics.customerId != null">
and customer_id = #{statistics.customerId,jdbcType=INTEGER}
</if>
<if test="statistics.deviceType != null and statistics.deviceType != ''">
and device_type = #{statistics.deviceType,jdbcType=VARCHAR}
</if>
<if test="endDate != null">
and activat_time < #{endDate,jdbcType=TIMESTAMP}
</if>
</where>
</select>
<select id="selectPlatformDevice" resultType="cn.com.glsx.openplatform.model.PlatformDevice">
select id, device_sn deviceSn, device_type deviceType, version, customer_id customerId,
user_id, activat_time activatTime, status, create_time createTime
from t_platform_device
<where>
<if test="statistics.customerId != null">
and customer_id = #{statistics.customerId,jdbcType=INTEGER}
</if>
<if test="statistics.deviceType != null and statistics.deviceType != ''">
and device_type = #{statistics.deviceType,jdbcType=VARCHAR}
</if>
<if test="endDate != null">
and activat_time < #{endDate,jdbcType=TIMESTAMP}
</if>
</where>
order by rand()
</select>
<select id="selectDeviceFromDeviceNetworkDetail"
resultType="cn.com.glsx.openplatform.model.DeviceNetworkDetail">
select dnd.device_sn deviceSn, dnd.create_time creatreTime
from t_device_network_detail dnd
left join t_platform_device pd on pd.device_sn = dnd.device_sn
<where>
<if test="customerId != null">
pd.customer_id = #{customerId,jdbcType=INTEGER}
</if>
<if test="endDate != null">
and dnd.create_time < #{endDate,jdbcType=TIMESTAMP}
</if>
</where>
order by rand()
</select>
<select id="selectByMonth" resultMap="BaseResultMap">
select id, customer_id, customer_name, device_type, type, statistics_time, number,
online_number
from t_customer_action_statistics
<where>
<if test="month != null and month != ''">
and statistics_time = #{month,jdbcType=VARCHAR}
</if>
</where>
order by customer_id
</select>
<select id="selectOnlineNumber" resultType="java.lang.Integer">
select sum(online_number)
from t_customer_device_statistics_new_doing_copy2
<where>
<if test="customerId != null">
and customer_id = #{customerId,jdbcType=INTEGER}
</if>
<if test="statisticsTime != null and statisticsTime != ''">
and statistics_time = #{statisticsTime,jdbcType=VARCHAR}
</if>
</where>
group by customer_id, statistics_time
</select>
<select id="selectDeviceList"
resultType="cn.com.glsx.openplatform.model.PlatformDevice">
select id, device_sn deviceSn, device_type deviceType
from t_platform_device
where customer_id = #{actionStatistics.customerId,jdbcType=INTEGER}
and device_type = #{actionStatistics.deviceType,jdbcType=VARCHAR}
and create_time < #{endDate,jdbcType=TIMESTAMP}
order by rand()
limit #{count,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from t_customer_action_statistics
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete
from t_customer_action_statistics
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics"
useGeneratedKeys="true">
<!--@mbg.generated-->
<selectKey order="AFTER" keyProperty="id" resultType="integer">
select LAST_INSERT_ID()
</selectKey>
insert into t_customer_action_statistics (customer_id, customer_name, `type`,
statistics_time, number)
values (#{customerId,jdbcType=INTEGER}, #{customerName,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{statisticsTime,jdbcType=VARCHAR}, #{number,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics"
useGeneratedKeys="true">
<!--@mbg.generated-->
<selectKey order="AFTER" keyProperty="id" resultType="integer">
select LAST_INSERT_ID()
</selectKey>
insert into t_customer_action_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">
customer_id,
</if>
<if test="customerName != null and customerName != ''">
customer_name,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="statisticsTime != null and statisticsTime != ''">
statistics_time,
</if>
<if test="number != null">
number,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null">
#{customerId,jdbcType=INTEGER},
</if>
<if test="customerName != null and customerName != ''">
#{customerName,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="statisticsTime != null and statisticsTime != ''">
#{statisticsTime,jdbcType=VARCHAR},
</if>
<if test="number != null">
#{number,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics">
<!--@mbg.generated-->
update t_customer_action_statistics
<set>
<if test="customerId != null">
customer_id = #{customerId,jdbcType=INTEGER},
</if>
<if test="customerName != null and customerName != ''">
customer_name = #{customerName,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="statisticsTime != null and statisticsTime != ''">
statistics_time = #{statisticsTime,jdbcType=VARCHAR},
</if>
<if test="number != null">
number = #{number,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics">
<!--@mbg.generated-->
update t_customer_action_statistics
set customer_id = #{customerId,jdbcType=INTEGER},
customer_name = #{customerName,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
statistics_time = #{statisticsTime,jdbcType=VARCHAR},
number = #{number,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update t_customer_action_statistics
<trim prefix="set" suffixOverrides=",">
<trim prefix="customer_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.customerId,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="customer_name = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.customerName,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="statistics_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER}
then #{item.statisticsTime,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="number = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.number,jdbcType=INTEGER}
</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_customer_action_statistics
<trim prefix="set" suffixOverrides=",">
<trim prefix="customer_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.customerId != null">
when id = #{item.id,jdbcType=INTEGER}
then #{item.customerId,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="customer_name = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.customerName != null">
when id = #{item.id,jdbcType=INTEGER}
then #{item.customerName,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="statistics_time = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.statisticsTime != null">
when id = #{item.id,jdbcType=INTEGER}
then #{item.statisticsTime,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="number = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.number != null">
when id = #{item.id,jdbcType=INTEGER}
then #{item.number,jdbcType=INTEGER}
</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_customer_action_statistics
(customer_id, customer_name, `type`, statistics_time, number)
values
<foreach collection="list" item="item" separator=",">
(#{item.customerId,jdbcType=INTEGER}, #{item.customerName,jdbcType=VARCHAR},
#{item.type,jdbcType=VARCHAR},
#{item.statisticsTime,jdbcType=VARCHAR}, #{item.number,jdbcType=INTEGER})
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into t_customer_action_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
customer_id,
customer_name,
`type`,
statistics_time,
number,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{customerId,jdbcType=INTEGER},
#{customerName,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{statisticsTime,jdbcType=VARCHAR},
#{number,jdbcType=INTEGER},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
customer_id = #{customerId,jdbcType=INTEGER},
customer_name = #{customerName,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
statistics_time = #{statisticsTime,jdbcType=VARCHAR},
number = #{number,jdbcType=INTEGER},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
parameterType="cn.com.glsx.openplatform.model.CustomerActionStatistics"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into t_customer_action_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="customerId != null">
customer_id,
</if>
<if test="customerName != null and customerName != ''">
customer_name,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="statisticsTime != null and statisticsTime != ''">
statistics_time,
</if>
<if test="number != null">
number,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="customerId != null">
#{customerId,jdbcType=INTEGER},
</if>
<if test="customerName != null and customerName != ''">
#{customerName,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="statisticsTime != null and statisticsTime != ''">
#{statisticsTime,jdbcType=VARCHAR},
</if>
<if test="number != null">
#{number,jdbcType=INTEGER},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
<if test="customerId != null">
customer_id = #{customerId,jdbcType=INTEGER},
</if>
<if test="customerName != null and customerName != ''">
customer_name = #{customerName,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="statisticsTime != null and statisticsTime != ''">
statistics_time = #{statisticsTime,jdbcType=VARCHAR},
</if>
<if test="number != null">
number = #{number,jdbcType=INTEGER},
</if>
</trim>
</insert>
</mapper>