TpESignRecordSMapper.xml
17.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
<?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="com.zteits.park.mapper.smapper.TpESignRecordSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.TpESignRecord">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="park_code" jdbcType="VARCHAR" property="parkCode" />
<result column="device_code" jdbcType="VARCHAR" property="deviceCode" />
<result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
<result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="park_area_codes" jdbcType="VARCHAR" property="parkAreaCodes" />
<result column="park_area_names" jdbcType="VARCHAR" property="parkAreaNames" />
<result column="sign_in_time" jdbcType="TIMESTAMP" property="signInTime" />
<result column="sign_in_lonid" jdbcType="DOUBLE" property="signInLonid" />
<result column="sign_in_latid" jdbcType="DOUBLE" property="signInLatid" />
<result column="sign_in_distance" jdbcType="DOUBLE" property="signInDistance" />
<result column="sign_in_scope" jdbcType="INTEGER" property="signInScope" />
<result column="sign_in_type" jdbcType="CHAR" property="signInType" />
<result column="status" jdbcType="CHAR" property="status" />
<result column="sign_out_type" jdbcType="CHAR" property="signOutType" />
<result column="sign_out_time" jdbcType="TIMESTAMP" property="signOutTime" />
<result column="sign_out_lonid" jdbcType="DOUBLE" property="signOutLonid" />
<result column="sign_out_latid" jdbcType="DOUBLE" property="signOutLatid" />
<result column="sign_out_distance" jdbcType="DOUBLE" property="signOutDistance" />
<result column="sign_out_scope" jdbcType="INTEGER" property="signOutScope" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_op" jdbcType="BIGINT" property="createOp" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="modify_op" jdbcType="BIGINT" property="modifyOp" />
<result column="pl_area_block_id" jdbcType="BIGINT" property="plAreaBlockId" />
<result column="point_all" jdbcType="INTEGER" property="pointAll" />
<result column="radius_100" jdbcType="DOUBLE" property="radius100" />
<result column="radius_200" jdbcType="DOUBLE" property="radius200" />
<result column="radius_300" jdbcType="DOUBLE" property="radius300" />
<result column="radius_400" jdbcType="DOUBLE" property="radius400" />
<result column="radius_500" jdbcType="DOUBLE" property="radius500" />
<result column="radius_600" jdbcType="DOUBLE" property="radius600" />
<result column="radius_bak1" jdbcType="DOUBLE" property="radiusBak1" />
<result column="radius_bak2" jdbcType="DOUBLE" property="radiusBak2" />
<result column="radius_bak3" jdbcType="DOUBLE" property="radiusBak3" />
<result column="radius_bak4" jdbcType="DOUBLE" property="radiusBak4" />
<result column="radius_bak5" jdbcType="DOUBLE" property="radiusBak5" />
</resultMap>
<sql id="Base_Column_List">
id, park_code, device_code, charger_code, charger_name, pl_no, pl_name, park_area_codes,
park_area_names, sign_in_time, sign_in_lonid, sign_in_latid, sign_in_distance, sign_in_scope,
sign_in_type, status, sign_out_type, sign_out_time, sign_out_lonid, sign_out_latid,
sign_out_distance, sign_out_scope, data_status, create_time, create_op, modify_time,
modify_op, pl_area_block_id, point_all, radius_100, radius_200, radius_300, radius_400,
radius_500, radius_600, radius_bak1, radius_bak2, radius_bak3, radius_bak4, radius_bak5
</sql>
<select id="queryIndexSignRecord" resultType="com.zteits.clouds.api.dto.park.dto.IndexSignRecordDTO">
SELECT
t.park_code parkCode,
t.charger_code chargerCode,
t.modify_time modifyDate,
t.status status,
t.pl_name plName,
t.charger_name chargeName
FROM ((SELECT
t1.park_code,
t1.charger_code,
t1.modify_time,
t1.status,
t1.pl_name,
t1.charger_name
FROM tp_e_sign_record t1,
WHERE
AND t1.data_status = 1
and t1.sign_in_type = 1
AND t1.status = 0
order by t1.modify_time desc limit 10)
UNION ALL
(SELECT
t1.park_code,
t1.charger_code,
t1.modify_time,
t1.status,
t1.pl_name,
t1.charger_name
FROM tp_e_sign_record t1,
WHERE
AND t1.data_status = 1
AND t1.status = 1
and t1.sign_in_type = 1
order by t1.modify_time desc limit 10)
) t
WHERE t.park_code IN
<foreach collection="plNos" item="plNo" index="index" separator="," open="(" close=")">
#{plNo}
</foreach>
ORDER BY t.modify_time DESC
</select>
<!--根据条件查询最新的签到记录-->
<select id="queryLatestSign" parameterType="com.zteits.park.domain.TpESignRecord" resultMap="BaseResultMap">
SELECT
*
FROM
tp_e_sign_record
WHERE
id = (
SELECT max( id ) id FROM tp_e_sign_record WHERE data_status = 1
<if test="signInType != null ">
and sign_in_type =#{signInType}
</if>
<if test="deviceCode != null ">
and device_code =#{deviceCode}
</if>
<if test="plNo != null ">
and pl_no =#{plNo}
</if>
<if test="chargerCode != null ">
and charger_code =#{chargerCode}
</if>
)
</select>
<!--根据条件查询收费员签到记录-->
<select id="querySignRecordByChargerCode" parameterType="com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest" resultMap="BaseResultMap">
SELECT
*
FROM
tp_e_sign_record
WHERE data_status = 1
and sign_in_type = 1
<if test="chargerCode != null ">
and charger_code =#{chargerCode}
</if>
<if test="chargerCodes != null and chargerCodes.size>0">
and charger_code in
<foreach collection="chargerCodes" item="chargerCode" index="index" open="(" close=")" separator=",">
#{chargerCode}
</foreach>
</if>
<if test="beginTime != null and endTime != null">
and sign_in_time between #{beginTime,jdbcType=TIMESTAMP} and #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="distanceFlag != null">
<if test="distanceFlag == 0">
AND (sign_in_distance <= #{distance}) AND (sign_out_distance <= #{distance} OR sign_out_distance IS NULL)
</if>
<if test="distanceFlag == 1">
AND ((sign_in_distance > #{distance} OR sign_in_distance IS NULL)
OR (sign_out_distance > #{distance}))
</if>
</if>
order by sign_in_distance
</select>
<!--根据条件查询每个停车场收费员实际签到人数-->
<select id="querySignNumByPlNos" parameterType="com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest"
resultType="com.zteits.clouds.api.dto.park.dto.ParkinglotBasicFactsDTO">
SELECT
pl_no as plNo,
count(DISTINCT charger_code) as signInTollCollector
FROM
tp_e_sign_record
WHERE data_status = 1
and sign_in_type = 1
<if test="chargerCode != null ">
and charger_code =#{chargerCode}
</if>
<if test="plNos != null and plNos.size>0">
and pl_no in
<foreach collection="plNos" item="plNo" index="index" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="chargerCodes != null and chargerCodes.size>0">
and charger_code in
<foreach collection="chargerCodes" item="chargerCode" index="index" open="(" close=")" separator=",">
#{chargerCode}
</foreach>
</if>
<if test="beginTime != null and endTime != null">
and sign_in_time between #{beginTime,jdbcType=TIMESTAMP} and #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="distanceFlag != null">
<if test="distanceFlag == 0">
AND (sign_in_distance <= #{distance}) AND (sign_out_distance <= #{distance} OR sign_out_distance IS NULL)
</if>
<if test="distanceFlag == 1">
AND ((sign_in_distance > #{distance} OR sign_in_distance IS NULL)
OR (sign_out_distance > #{distance}))
</if>
</if>
group by pl_no
</select>
<resultMap id="signRecordMap" type="com.zteits.clouds.api.dto.park.dto.SignRecordDTO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="park_code" jdbcType="VARCHAR" property="parkCode" />
<result column="device_code" jdbcType="VARCHAR" property="deviceCode" />
<result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
<result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="park_area_codes" jdbcType="VARCHAR" property="parkAreaCodes" />
<result column="park_area_names" jdbcType="VARCHAR" property="parkAreaNames" />
<result column="sign_in_time" jdbcType="TIMESTAMP" property="signInTime" />
<result column="sign_in_lonid" jdbcType="DOUBLE" property="signInLonid" />
<result column="sign_in_latid" jdbcType="DOUBLE" property="signInLatid" />
<result column="sign_in_distance" jdbcType="DOUBLE" property="signInDistance" />
<result column="sign_in_scope" jdbcType="INTEGER" property="signInScope" />
<result column="status" jdbcType="CHAR" property="status" />
<result column="sign_out_type" jdbcType="CHAR" property="signOutType" />
<result column="sign_out_time" jdbcType="TIMESTAMP" property="signOutTime" />
<result column="sign_out_lonid" jdbcType="DOUBLE" property="signOutLonid" />
<result column="sign_out_latid" jdbcType="DOUBLE" property="signOutLatid" />
<result column="sign_out_distance" jdbcType="DOUBLE" property="signOutDistance" />
<result column="sign_out_scope" jdbcType="INTEGER" property="signOutScope" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_op" jdbcType="BIGINT" property="createOp" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="modify_op" jdbcType="BIGINT" property="modifyOp" />
<result column="pl_area_block_id" jdbcType="BIGINT" property="plAreaBlockId" />
<result column="gpsRate" jdbcType="DOUBLE" property="gpsRate" />
</resultMap>
<!--根据条件查询收费员签到记录(带GPS阈值)-->
<select id="querySignRecordAndRateByChargerCode" parameterType="com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest" resultMap="signRecordMap">
SELECT
c.*
FROM
(
SELECT
a.*, b.inNum / (b.inNum + b.outNum) gpsRate
FROM
tp_e_sign_record a
LEFT JOIN
(SELECT
t.sign_record_id,
SUM(CASE WHEN t.sign_distance <= #{distance} THEN 1 ELSE 0 END ) inNum,
SUM(CASE WHEN t.sign_distance > #{distance} THEN 1 ELSE 0 END ) outNum
FROM
tp_e_employee_tail t
WHERE
t.data_state = 1
GROUP BY t.sign_record_id)b ON a.id = b.sign_record_id
WHERE a.data_status = 1
and a.sign_in_type = 1
<if test="chargerCode != null ">
and a.charger_code =#{chargerCode}
</if>
<if test="chargerCodes != null and chargerCodes.size>0">
and a.charger_code in
<foreach collection="chargerCodes" item="chargerCode" index="index" open="(" close=")" separator=",">
#{chargerCode}
</foreach>
</if>
<if test="plNos != null and plNos.size>0">
and a.pl_no in
<foreach collection="plNos" item="plNo" index="index" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="beginTime != null and endTime != null">
and sign_in_time between #{beginTime,jdbcType=TIMESTAMP} and #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="signInBeginTime != null ">
and a.sign_in_time >= #{signInBeginTime,jdbcType=TIMESTAMP}
</if>
<if test="signInEndTime != null">
and a.sign_in_time <= #{signInEndTime,jdbcType=TIMESTAMP}
</if>
<if test="signOutBeginTime != null">
and a.sign_out_time >= #{signOutBeginTime,jdbcType=TIMESTAMP}
</if>
<if test="signOutEndTime != null">
and a.sign_out_time <= #{signOutEndTime,jdbcType=TIMESTAMP}
</if>
<if test="distanceFlag != null">
<if test="distanceFlag == 0">
AND (a.sign_in_distance <= #{distance}) AND (a.sign_out_distance <= #{distance} OR a.sign_out_distance IS NULL)
</if>
<if test="distanceFlag == 1">
AND ((a.sign_in_distance > #{distance} OR a.sign_in_distance IS NULL)
OR (a.sign_out_distance > #{distance}))
</if>
</if>
ORDER BY a.create_time DESC)c
WHERE 1=1
<if test="distanceFlag != null">
AND c.gpsRate >= #{gpsRate}
</if>
</select>
<!--根据条件查询收费员签到记录(单表带GPS阈值)-->
<select id="querySignRecordAndRateByChargerCodeNew" parameterType="com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest" resultMap="signRecordMap">
SELECT
a.*,(a.radius_${distanceCol})/100 as gpsRate
FROM
tp_e_sign_record a
WHERE a.data_status = 1
and a.sign_in_type = 1
<if test="distance != null and distanceCol != null and distanceCol != ''">
<if test ="distanceFlag == 0">
and (a.radius_${distanceCol})/100 >= #{gpsRate}
</if>
<if test ="distanceFlag == 1">
and (a.radius_${distanceCol})/100 < #{gpsRate}
and a.sign_out_time is not null
</if>
<if test ="distanceFlag == 2">
and (a.radius_${distanceCol})/100 < #{gpsRate}
and a.sign_out_time is null
</if>
<if test ="distanceFlag == null">
and (a.radius_${distanceCol})/100 >= 0
</if>
</if>
<if test="chargerCode != null ">
and a.charger_code =#{chargerCode}
</if>
<if test="chargerCodes != null and chargerCodes.size>0">
and a.charger_code in
<foreach collection="chargerCodes" item="chargerCode" index="index" open="(" close=")" separator=",">
#{chargerCode}
</foreach>
</if>
<if test="plNos != null and plNos.size>0">
and a.pl_no in
<foreach collection="plNos" item="plNo" index="index" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="beginTime != null and endTime != null">
and a.sign_in_time between #{beginTime,jdbcType=TIMESTAMP} and #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="signInBeginTime != null ">
and a.sign_in_time >= #{signInBeginTime,jdbcType=TIMESTAMP}
</if>
<if test="signInEndTime != null">
and a.sign_in_time <= #{signInEndTime,jdbcType=TIMESTAMP}
</if>
<if test="signOutBeginTime != null">
and a.sign_out_time >= #{signOutBeginTime,jdbcType=TIMESTAMP}
</if>
<if test="signOutEndTime != null">
and a.sign_out_time <= #{signOutEndTime,jdbcType=TIMESTAMP}
</if>
<if test="inBeginTime != null and inBeginTime != '' ">
and TIME(a.sign_in_time) >= #{inBeginTime}
</if>
<if test="inEndTime != null and inEndTime != '' ">
and TIME(a.sign_in_time) <= #{inEndTime}
</if>
<if test="outBeginTime != null and outBeginTime != '' ">
and TIME(a.sign_out_time) >= #{outBeginTime}
</if>
<if test="outEndTime != null and outEndTime != '' ">
and TIME(a.sign_out_time) <= #{outEndTime}
</if>
ORDER BY a.sign_in_distance
</select>
<!-- <if test="distanceFlag != null">
<if test="distanceFlag == 0">
AND (a.sign_in_distance <= #{distance}) AND (a.sign_out_distance <= #{distance} OR a.sign_out_distance IS NULL)
</if>
<if test="distanceFlag == 1">
AND ((a.sign_in_distance > #{distance} OR a.sign_in_distance IS NULL)
OR (a.sign_out_distance > #{distance})
OR (a.sign_out_distance is null)
)
</if>
</if> -->
</mapper>