ParkingRunningStatisticSMapper.xml
12 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
<?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.ParkingRunningStatisticSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkingRunningStatistic">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
<result column="pl_name" jdbcType="VARCHAR" property="plName"/>
<result column="top_org_id" jdbcType="BIGINT" property="topOrgId"/>
<result column="pl_type" jdbcType="INTEGER" property="plType"/>
<result column="berth_num" jdbcType="INTEGER" property="berthNum"/>
<result column="free_berth_num" jdbcType="INTEGER" property="freeBerthNum"/>
<result column="data_source" jdbcType="INTEGER" property="dataSource"/>
<result column="time_cycle" jdbcType="INTEGER" property="timeCycle"/>
<result column="free_ratio" jdbcType="DOUBLE" property="freeRatio"/>
<result column="occupy_ratio" jdbcType="DOUBLE" property="occupyRatio"/>
<result column="unit_turnover_ratio" jdbcType="DOUBLE" property="unitTurnoverRatio"/>
<result column="turnover_ratio" jdbcType="DOUBLE" property="turnoverRatio"/>
<result column="park_in_count" jdbcType="INTEGER" property="parkInCount"/>
<result column="unit_park_in_count" jdbcType="INTEGER" property="unitParkInCount"/>
<result column="vip_in_count" jdbcType="INTEGER" property="vipInCount"/>
<result column="unit_vip_in_count" jdbcType="INTEGER" property="unitVipInCount"/>
<result column="park_out_count" jdbcType="INTEGER" property="parkOutCount"/>
<result column="unit_park_out_count" jdbcType="INTEGER" property="unitParkOutCount"/>
<result column="vip_out_count" jdbcType="INTEGER" property="vipOutCount"/>
<result column="unit_vip_out_count" jdbcType="INTEGER" property="unitVipOutCount"/>
<result column="statistic_begin_time" jdbcType="TIMESTAMP" property="statisticBeginTime"/>
<result column="statistic_end_time" jdbcType="TIMESTAMP" property="statisticEndTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="data_status" jdbcType="INTEGER" property="dataStatus"/>
</resultMap>
<sql id="Base_Column_List">
id, pl_no, pl_name, top_org_id, pl_type, berth_num, free_berth_num, data_source,
time_cycle, free_ratio, occupy_ratio, unit_turnover_ratio, turnover_ratio, park_in_count,
unit_park_in_count, vip_in_count, unit_vip_in_count, park_out_count, unit_park_out_count,
vip_out_count, unit_vip_out_count, statistic_begin_time, statistic_end_time, create_time,
data_status
</sql>
<!-- 按日/月查询车流量图表数据 -->
<select id="queryCarFlowChartByDayOrMonth"
parameterType="com.zteits.clouds.api.dto.park.param.ParkingRunningStatisticForPageRequest"
resultType="com.zteits.clouds.api.dto.park.dto.ParkingRunningStatisticDTO">
SELECT
<if test="timeType == 1">
DATE_FORMAT(statistic_end_time, '%Y-%m-%d') staticTimeStr,
</if>
<if test="timeType == 2">
DATE_FORMAT(statistic_end_time, '%Y-%m') staticTimeStr,
</if>
<if test="timeType == 4">
DATE_FORMAT (statistic_end_time, '%H:%i') as staticTimeStr,
</if>
sum(unit_park_in_count) vehicleFlow,
sum(unit_vip_in_count) fixVehicleFlow,
sum(unit_park_out_count) outParkCount,
avg(free_ratio) freeRatio,
avg(turnover_ratio) turnoverRatio,
avg(unit_turnover_ratio) unitTurnoverRatio
FROM parking_running_statistic
WHERE data_status = 1
And data_source = 10
<choose>
<when test="timeType == 4">
And time_cycle = 40
</when>
<otherwise>
And time_cycle = 50
</otherwise>
</choose>
<if test="beginTime != null and endTime !=null">
and statistic_end_time between #{beginTime} and #{endTime}
</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>
GROUP BY staticTimeStr
ORDER BY staticTimeStr
</select>
<!-- 按天查询车流量列表详情 2018-5-18 langlw edit -->
<select id="queryCarFlowByTimeTypeForList"
parameterType="com.zteits.clouds.api.dto.park.param.ParkingRunningStatisticForPageRequest"
resultType="com.zteits.clouds.api.dto.park.dto.ParkingRunningStatisticDTO">
SELECT
<if test="timeType == 1">
DATE_FORMAT(statistic_end_time, '%Y-%m-%d') as staticTimeStr,
</if>
<if test="timeType == 2">
DATE_FORMAT(statistic_end_time, '%Y-%m') as staticTimeStr,
</if>
<if test="timeType == 3">
1 as staticTimeStr,
</if>
<if test="timeType == 4">
DATE_FORMAT(statistic_end_time, '%Y-%m-%d %H:%i') as staticTimeStr,
</if>
pl_no plNo,
pl_name plName,
pl_type as plType,
max(berth_num) as totalBerths,
sum(unit_park_in_count) vehicleFlow,
sum(unit_vip_in_count) fixVehicleFlow,
sum(unit_park_in_count) as inParkCount,
sum(unit_park_out_count) outParkCount,
avg(free_ratio) freeRatio,
avg(turnover_ratio) turnoverRatio,
avg(unit_turnover_ratio) unitTurnoverRatio
FROM parking_running_statistic
WHERE
data_status = 1
<choose>
<when test="timeType == 4">
And time_cycle = 40
</when>
<otherwise>
And time_cycle = 50
</otherwise>
</choose>
AND data_source = 10
<if test="beginTime != null and endTime !=null">
and statistic_end_time between #{beginTime} and #{endTime}
</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>
GROUP BY
staticTimeStr,
pl_no,pl_name,pl_type
<choose>
<when test="baseRequest != null and baseRequest.sortName != null and baseRequest.sortOrder != null
and baseRequest.sortName != '' and baseRequest.sortOrder != ''">
ORDER BY ${baseRequest.sortName} ${baseRequest.sortOrder}
</when>
<otherwise>
ORDER BY staticTimeStr ASC, inParkCount desc ,outParkCount desc
</otherwise>
</choose>
</select>
<!-- 查询周转率新的图表 langlw 2018-3-19-->
<select id="queryTurnoverRatioChart" resultType="com.zteits.clouds.api.dto.clouds.dto.TurnoverRatioDTO"
parameterType="com.zteits.clouds.api.dto.park.param.ParkingRunningStatisticForPageRequest">
SELECT
<if test="timeType == 1">
DATE_FORMAT(statistic_end_time,'%Y-%m-%d') as statisticTime,
</if>
<if test="timeType == 2">
DATE_FORMAT(statistic_end_time,'%Y-%m') as statisticTime,
</if>
pl_type as plType,
max(turnover_ratio) as maxTurnoverRatio,
min(turnover_ratio) as minTurnoverRatio,
avg(turnover_ratio) as avgTurnoverRatio
from parking_running_statistic
where data_status = 1
And data_source = 10
and time_cycle=50
<if test="beginTime != null and endTime !=null">
and statistic_end_time between #{beginTime} and #{endTime}
</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>
group by statisticTime,pl_type
ORDER BY statisticTime DESC
</select>
<!-- 查询周转率新的 langlw 2018-3-19-->
<select id="queryTurnoverRatioForTable" resultType="com.zteits.clouds.api.dto.clouds.dto.TurnoverRatioDTO"
parameterType="com.zteits.clouds.api.dto.park.param.ParkingRunningStatisticForPageRequest">
SELECT
<if test="timeType == 1">
DATE_FORMAT(statistic_end_time,'%Y-%m-%d') as statisticTime,
</if>
<if test="timeType == 2">
DATE_FORMAT(statistic_end_time,'%Y-%m') as statisticTime,
</if>
pl_name as plName,pl_no as plNo,
pl_type as plType,
max(turnover_ratio) as maxTurnoverRatio,
min(turnover_ratio) as minTurnoverRatio,
avg(turnover_ratio) as avgTurnoverRatio
from parking_running_statistic
where data_status = 1
And data_source = 10
and time_cycle=50
<if test="beginTime != null and endTime !=null">
and statistic_end_time between #{beginTime} and #{endTime}
</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>
group by statisticTime,plName,plNo,plType
ORDER BY statisticTime DESC
</select>
<!-- 首页根据停车场编号查询 当前时间的进出场车流量、周转率、占用率 -->
<select id="queryTodayVehicleFlowOccupyRateAndTurnOver"
resultType="com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO">
SELECT
sum(unit_park_in_count) inCount,
AVG(unit_turnover_ratio) avgTurnoverRate,
AVG((1 - t.free_ratio)) avgOccupyRate,
sum(unit_park_out_count) outCount,
HOUR (t.statistic_end_time) HOUR
FROM
parking_running_statistic t
WHERE t.data_status = 1
AND t.data_source = 10
AND t.time_cycle = #{timeCycle}
AND t.statistic_end_time >= #{beginTime}
AND t.statistic_end_time <= #{endTime}
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" separator="," index="index">
#{plNo}
</foreach>
GROUP BY t.statistic_end_time
ORDER BY t.statistic_end_time ASC;
</select>
<!-- 首页按停车场类型查询当前停车场的占用率、周转次数 -->
<select id="queryCurrentOccupyRateAndTurnOver"
resultType="com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO">
SELECT
COUNT( a.pl_no ) plNum,
a.pl_type plType,
AVG( 1 - a.free_ratio ) avgOccupyRate,
AVG( a.turnover_ratio ) avgTurnoverRate,
SUM( a.park_in_count ) inCount
FROM
parking_running_statistic a
WHERE
a.data_status = 1
AND a.data_source = 10
AND a.time_cycle = 10
AND a.statistic_end_time >= #{beginTime}
AND a.statistic_end_time <= #{endTime}
AND a.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" separator="," index="index">
#{plNo}
</foreach>
GROUP BY a.pl_type
</select>
<select id="queryAvgOccUpyRatio" resultType="java.lang.Double">
SELECT
avg(occupy_ratio)
FROM parking_running_statistic
WHERE
data_status = 1
AND data_source = 10
AND time_cycle = #{timeCycle}
AND pl_no = #{plNo}
AND statistic_end_time BETWEEN #{startTime} AND #{endTime}
</select>
<select id="queryRecentParkingStatisticData" resultType="com.zteits.park.domain.ParkingRunningStatistic">
SELECT
<include refid="Base_Column_List"/>
FROM parking_running_statistic
WHERE
id = (
SELECT max(id) from parking_running_statistic
WHERE data_status = 1
AND data_source = #{dataSource}
AND time_cycle = #{timeCycle}
AND pl_no = #{plNo}
)
</select>
</mapper>