ParkInOutRecordSMapper.xml
15.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
<?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.ParkInOutRecordSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkInOutRecord">
<id column="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="record_id" jdbcType="VARCHAR" property="recordId" />
<result column="park_order_type" jdbcType="INTEGER" property="parkOrderType" />
<result column="park_detail_type" jdbcType="INTEGER" property="parkDetailType" />
<result column="park_state" jdbcType="INTEGER" property="parkState" />
<result column="order_state" jdbcType="INTEGER" property="orderState" />
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource" />
<result column="source_type" jdbcType="INTEGER" property="sourceType" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="order_dicount_fee" jdbcType="BIGINT" property="orderDicountFee" />
<result column="order_act_fee" jdbcType="BIGINT" property="orderActFee" />
<result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee" />
<result column="top_org_id" jdbcType="BIGINT" property="topOrgId" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="pl_type" jdbcType="INTEGER" property="plType" />
<result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo" />
<result column="berth_range_name" jdbcType="VARCHAR" property="berthRangeName" />
<result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
<result column="car_number" jdbcType="VARCHAR" property="carNumber" />
<result column="car_type" jdbcType="INTEGER" property="carType" />
<result column="car_number_color" jdbcType="VARCHAR" property="carNumberColor" />
<result column="park_in_time" jdbcType="TIMESTAMP" property="parkInTime" />
<result column="park_out_time" jdbcType="TIMESTAMP" property="parkOutTime" />
<result column="parking_duration" jdbcType="BIGINT" property="parkingDuration" />
<result column="park_in_source_code" jdbcType="VARCHAR" property="parkInSourceCode" />
<result column="park_in_source_name" jdbcType="VARCHAR" property="parkInSourceName" />
<result column="park_out_source_code" jdbcType="VARCHAR" property="parkOutSourceCode" />
<result column="park_out_source_name" jdbcType="VARCHAR" property="parkOutSourceName" />
<result column="in_free_berths" jdbcType="INTEGER" property="inFreeBerths" />
<result column="out_free_berths" jdbcType="INTEGER" property="outFreeBerths" />
<result column="pl_berth_num" jdbcType="INTEGER" property="plBerthNum" />
<result column="cust_type" jdbcType="INTEGER" property="custType" />
<result column="cust_id" jdbcType="VARCHAR" property="custId" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
order_id, record_id, park_order_type, park_detail_type, park_state, order_state,
terminal_source, source_type, pl_no, order_dicount_fee, order_act_fee, order_total_fee,
top_org_id, pl_name, pl_type, berth_range_no, berth_range_name, berth_no, car_number,
car_type, car_number_color, park_in_time, park_out_time, parking_duration, park_in_source_code,
park_in_source_name, park_out_source_code, park_out_source_name, in_free_berths,
out_free_berths, pl_berth_num, cust_type, cust_id, data_state, create_date
</sql>
<select id="queryCarInOutNum" resultType="com.zteits.park.domain.ParkingRunningStatistic">
SELECT
inInfo.pl_no plNo,
IFNULL(inInfo.park_in_count,0) parkInCount,
IFNULL(inInfo.vip_in_count,0) vipInCount,
IFNULL(outInfo.vip_out_count,0) vipOutCount,
IFNULL(outInfo.park_out_count,0) parkOutCount,
IFNULL(outInfo.parking_duration,0) allParkingDuration
FROM (
SELECT
t.pl_no,
sum(CASE park_order_type
WHEN 300
THEN 1
WHEN 500
THEN 1
ELSE 0 END) vip_in_count,
count(*) park_in_count
FROM park_in_out_record t
WHERE
t.data_state = 1
AND t.pl_no = #{plNo}
AND t.park_in_time > #{startTime}
AND t.park_in_time <= #{endTime}) inInfo,
(
SELECT
t.pl_no,
sum(CASE park_order_type
WHEN 300
THEN 1
WHEN 500
THEN 1
ELSE 0 END) vip_out_count,
count(*) park_out_count,
sum(t.parking_duration) parking_duration
FROM park_in_out_record t
WHERE
t.data_state = 1
AND t.pl_no = #{plNo}
AND t.park_state = 20
AND t.park_out_time > #{startTime}
AND t.park_out_time <= #{endTime}) outInfo
WHERE inInfo.pl_no = outInfo.pl_no;
</select>
<select id="queryCarInInfo" resultType="com.zteits.park.domain.ParkingRunningStatistic">
SELECT
inInfo.pl_no AS plNo,
IFNULL(inInfo.vip_in_count, 0) AS vipInCount,
IFNULL(inInfo.park_in_count, 0) AS parkInCount
FROM (
SELECT
t.pl_no,
SUM(CASE WHEN t.park_order_type IN (300, 500) THEN 1 ELSE 0 END) AS vip_in_count,
COUNT(*) AS park_in_count
FROM park_in_out_record t
WHERE
t.data_state = 1
AND t.pl_no = #{plNo}
AND t.park_in_time BETWEEN #{startTime} AND #{endTime}
GROUP BY t.pl_no
) inInfo
</select>
<select id="queryCarOutInfo" resultType="com.zteits.park.domain.ParkingRunningStatistic">
SELECT outInfo.pl_no AS plNo,
IFNULL(outInfo.vip_out_count, 0) AS vipOutCount,
IFNULL(outInfo.park_out_count, 0) AS parkOutCount,
IFNULL(outInfo.parking_duration, 0) AS allParkingDuration
FROM (SELECT pl_no,
SUM(CASE WHEN park_order_type IN (300, 500) THEN 1 ELSE 0 END) AS vip_out_count,
COUNT(*) AS park_out_count,
SUM(parking_duration) AS parking_duration
FROM park_in_out_record
WHERE data_state = 1
AND pl_no = #{plNo}
AND park_state = 20
AND park_out_time BETWEEN #{startTime} AND #{endTime}
GROUP BY pl_no) outInfo
</select>
<select id="queryFreeBerthsRencentTime" resultType="java.lang.Integer">
SELECT tmp.freeBerth,
tmp.parkTime
FROM (
select *
from (
SELECT in_free_berths freeBerth,
park_in_time parkTime
FROM park_in_out_record
WHERE data_state = 1
AND park_in_time <= #{endTime}
AND pl_no = #{plNo}
ORDER BY order_id DESC
LIMIT 1) a
UNION ALL
select *
from (
SELECT out_free_berths freeBerth,
park_out_time parkTime
FROM park_in_out_record
WHERE data_state = 1
AND park_out_time <= #{endTime}
AND pl_no = #{plNo}
ORDER BY order_id DESC
LIMIT 1) b
) tmp
ORDER BY tmp.parkTime DESC
LIMIT 1
</select>
<!-- 违法车辆停车场记录 -->
<select id="queryPageIllegalCarParkOrder" resultMap="BaseResultMap">
SELECT
p.order_id,
p.car_number,
p.park_state,
p.pl_no,
p.pl_name,
p.park_in_time,
p.park_out_time,
p.parking_duration
FROM
illegal_car_info i
JOIN park_in_out_record p ON i.car_number = p.car_number
where i.data_state=1 and p.data_state=1
<if test="carNumber!=null and carNumber!=''">
AND i.car_number like CONCAT("%",#{carNumber},"%")
</if>
<if test="parkState!=null and parkState!=''">
AND p.park_state = #{parkState}
</if>
<if test="beginInTime!=null">
AND p.park_in_time between #{beginInTime} and #{endInTime}
</if>
<if test="beginOutTime!=null">
AND p.park_out_time between #{beginOutTime} and #{endOutTime}
</if>
ORDER BY p.park_in_time desc ,p.park_out_time desc
</select>
<select id="queryParkInsideCarNum" resultType="com.zteits.park.domain.bean.ParkInsideCarNumBean">
SELECT
t.pl_no plNo,
sum(CASE park_order_type
WHEN 300
THEN 1
WHEN 500
THEN 1
ELSE 0 END) insideVipCarNum,
count(*) insideCarNum
FROM park_in_out_record t
WHERE t.pl_no = #{plNo}
AND t.park_state = 10
AND t.park_in_time >= #{startTime}
AND t.park_in_time <= #{endTime}
GROUP BY pl_no;
</select>
<!-- 通过记录第三方订单id(主键)和车牌号,查询订单id -->
<select id="queryOrderIdByRecordIdAndCarNumber" resultType="java.lang.String">
select
order_id
from
park_in_out_record
where
record_id=#{recordId} and car_number=#{carNumber} limit 1
</select>
<select id="statisticParkInOutRecord"
resultType="com.zteits.clouds.api.dto.park.dto.ParkInOutRecordStatisticDTO">
select t.park_order_type parkOrderType,
count(*) num,
sum(ifnull(t.order_total_fee, 0)) sumTotalFee,
sum(ifnull(t.parking_duration, 0)) sumParkDuration
from park_in_out_record t
where t.data_state = 1
<if test="req.plNos !=null and req.plNos.size > 0 ">
and t.pl_no in
<foreach collection="req.plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="req.parkOrderTypes != null and req.parkOrderTypes.size > 0">
and t.park_order_type in
<foreach collection="req.parkOrderTypes" item="parkOrderType" open="(" close=")" separator=",">
#{parkOrderType}
</foreach>
</if>
<if test="req.parkState != null">
and t.park_state = #{req.parkState}
</if>
<if test="req.parkOutTimeStart != null">
and t.park_out_time >= #{req.parkOutTimeStart}
</if>
<if test="req.parkOutTimeEnd != null">
and t.park_out_time <= #{req.parkOutTimeEnd}
</if>
<if test="req.topOrgId != null ">
and t.top_org_id = #{req.topOrgId}
</if>
group by t.park_order_type
</select>
<select id="pageQueryParkInOutRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from park_in_out_record t
where t.data_state = 1
<if test="req.plNos !=null and req.plNos.size > 0 ">
and t.pl_no in
<foreach collection="req.plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="req.parkOrderTypes != null and req.parkOrderTypes.size > 0">
and t.park_order_type in
<foreach collection="req.parkOrderTypes" item="parkOrderType" open="(" close=")" separator=",">
#{parkOrderType}
</foreach>
</if>
<if test="req.parkState != null">
and t.park_state = #{req.parkState}
</if>
<if test="req.parkOutTimeStart != null">
and t.park_out_time >= #{req.parkOutTimeStart}
</if>
<if test="req.parkOutTimeEnd != null">
and t.park_out_time <= #{req.parkOutTimeEnd}
</if>
<if test="req.topOrgId != null ">
and t.top_org_id = #{req.topOrgId}
</if>
order by t.park_out_time desc
</select>
</mapper>