TIncomeCalculationStaticNumSMapper.xml
15.2 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
<?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.TIncomeCalculationStaticNumSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.TIncomeCalculationStaticNum">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="static_date" jdbcType="VARCHAR" property="staticDate" />
<result column="pl_area_block_id" jdbcType="BIGINT" property="plAreaBlockId" />
<result column="pl_area_block_name" jdbcType="VARCHAR" property="plAreaBlockName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_type" jdbcType="INTEGER" property="plType" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="car_type" jdbcType="INTEGER" property="carType" />
<result column="all_num" jdbcType="BIGINT" property="allNum" />
<result column="free_num" jdbcType="INTEGER" property="freeNum" />
<result column="day_num" jdbcType="INTEGER" property="dayNum" />
<result column="night_num" jdbcType="INTEGER" property="nightNum" />
<result column="berth_num" jdbcType="INTEGER" property="berthNum" />
</resultMap>
<sql id="Base_Column_List">
id, static_date, pl_area_block_id, pl_area_block_name, pl_no, pl_type, pl_name, car_type,
all_num, free_num, day_num, night_num, berth_num
</sql>
<insert id="staticIncomeCalculationDataOfNum" statementType="STATEMENT">
INSERT INTO t_income_calculation_static_num
(static_date,
pl_area_block_id,
pl_area_block_name,
pl_no,
pl_type,
car_type,
all_num,
free_num,
day_num,
night_num)
SELECT
m.static_date,
m.pl_area_block_id,
m.pl_area_block_name,
m.pl_no,
1,
m.car_type,
count(*) allNum,
SUM(CASE WHEN m.eqpParkDuration < 15 * 60
THEN 1
ELSE 0 END) freeNum, /*停车时长小于15分钟的免费*/
SUM(CASE WHEN m.inTimeHour >= 7 AND m.inTimeHour < 19 AND m.eqpParkDuration >= 15 * 60
THEN 1
ELSE 0 END) dayNum, /* 停车时长大于15分钟,并且 进场时间大于等于7点,小于19点 白天的数据*/
SUM(CASE WHEN (m.inTimeHour < 7 OR m.inTimeHour >= 19) AND m.eqpParkDuration >= 15 * 60
THEN 1
ELSE 0 END) nightNum /* 停车时长大于15分钟,并且 进场时间小于7点,大于等于19点 夜间的数据 */
FROM (
SELECT
date_format(t.eqp_out_time, '%Y-%m-%d') static_date,
t.pl_no,
t.pl_area_block_id,
t.pl_area_block_name,
2 car_type,
IFNULL(t.eqp_parking_duration,0) eqpParkDuration,
EXTRACT(HOUR FROM t.eqp_in_time) inTimeHour,
EXTRACT(HOUR FROM t.eqp_out_time) outTimeHour,
t.eqp_in_time,
t.eqp_out_time
FROM tp_p_eqp_inout_record${monthStr} t,tp_p_eqp eqp
WHERE t.eqp_out_time >= '${staticStartDate}' AND t.eqp_out_time <= '${staticEndDate}'
AND t.eqp_no = eqp.eqp_no
AND eqp.used_type = 20
AND t.eqp_parking_duration > 1 * 60 /* 排除掉停车时长小于1分钟的数据 */
AND t.eqp_parking_duration < 12 * 60 * 60 /*排除掉停车时长大于5天的数据*/
AND t.eqp_no NOT IN (
/* 排除掉地磁每天周转次数超过50次的地磁 */
SELECT tmp.eqp_no
FROM tp_p_eqp_inout_record${monthStr} tmp
WHERE tmp.eqp_out_time >= '${staticStartDate}' AND tmp.eqp_out_time <= '${staticEndDate}'
GROUP BY tmp.eqp_no
HAVING count(0) > 50)
) m
GROUP BY m.pl_area_block_id, m.pl_area_block_name, m.pl_no, m.car_type, m.static_date;
</insert>
<!-- langlw 2018-5-15 edit -->
<!--
⚠️ 手改(非搬迁原样):本 select 原为 statementType="STATEMENT",已去掉该属性。
原因:老栈 PageHelper 5.0.0 的 MySQL 方言把分页拼成 `LIMIT 3`(字面量),STATEMENT
(MyBatis SimpleStatementHandler,不做参数绑定)照样能跑;新栈 PageHelper 6.1.1 改拼
`LIMIT ?`(见 MySqlDialect.getPageSql),STATEMENT 下这个 `?` 永远不绑定 → MySQL
`SQLSyntaxErrorException ... near '?'` → 凡走 PageHelper.startPage 且条数不为 0 的
路径一律 500。实测(2026-10-16,48099,第三十八切片):
`/order/income-calculation/static-income-by-num-for-new` 传 `baseRequest.pageSize=10`
→ 500「系统异常」;传 `pageSize=0`(不拼 LIMIT)→ code=0 出真数据;plNos 编的
(count 恒 0 → PageHelper 直接返回空集、也不拼 LIMIT)同样 code=0 —— 同一端点两种
长相,别误判成数据问题。
本 select 通篇只用 `${}` 文本替换、没有 `#{}`,去掉 STATEMENT(回到默认 PREPARED)后
SQL 文本与语义完全不变,只是 `LIMIT ?` 能被正常绑定。回归见 tools/api_smoke.py §2ah。
本文件另外三处 STATEMENT(staticIncomeByNumForNew / …ColumnChart / …LineChart)都
**没有**走 PageHelper.startPage(ColumnChart、LineChart 已实测 code=0),保持原样。
-->
<select id="queryIncomeCalculationDataByNum"
resultType="com.zteits.clouds.api.dto.park.dto.IncomeCalculationExcelDTO">
SELECT
<if test="timeType == 1">
DATE_FORMAT(t.static_date,'%Y-%m-%d') staticDate,
</if>
<if test="timeType == 2">
concat(WEEK(t.static_date), '周') staticDate,
</if>
<if test="timeType == 3">
DATE_FORMAT(t.static_date,'%Y-%m') staticDate,
</if>
<if test="timeType == 100">
1,
</if>
<if test="groupType == 1">
t.pl_no plNo,
t.pl_type plType,
t.pl_name plName,
</if>
<if test="groupType == 2">
t.pl_area_block_id areaId,
t.pl_area_block_name areaName,
</if>
<if test="groupType == 3">
t.pl_no plNo,
t.pl_type plType,
t.pl_name plName,
t.pl_area_block_id areaId,
t.pl_area_block_name areaName,
</if>
MAX(t.berth_num) berthNum,
sum(t.all_num) allNum,
sum(t.free_num) freeNum,
sum(t.day_num) dayNum,
sum(t.night_num) nightNum,
sum(t.day_num * ${dayMinAmount} + t.night_num * ${nightMinAmount}) amount
FROM t_income_calculation_static_num t
WHERE str_to_date(t.static_date,'%Y-%m-%d') >= '${beginTime}' AND str_to_date(t.static_date,'%Y-%m-%d') <=
'${endTime}'
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" index="index" separator=",">
'${plNo}'
</foreach>
GROUP BY
<if test="timeType == 1 or timeType == 2 or timeType == 3">
staticDate,
</if>
<if test="timeType == 100">
1,
</if>
<if test="groupType == 2">
t.pl_area_block_id,t.pl_area_block_name
</if>
<if test="groupType == 1">
t.pl_no,t.pl_name,t.pl_type
</if>
<if test="groupType == 3">
t.pl_no,t.pl_name,t.pl_type,t.pl_area_block_id,t.pl_area_block_name
</if>
<if test="groupType == null ">
<if test="timeType == 1 or timeType == 2 or timeType == 3">
staticDate
</if>
<if test="timeType == 100">
1
</if>
</if>
</select>
<select id="updateParkBaseInfoByProc" statementType="CALLABLE">
CALL incomeCalculationStaticFillInfo();
</select>
<select id="getAllBerthNumByCondition" resultType="java.util.HashMap">
SELECT
m.pl_area_block_id AREAID,sum(m.maxBerthNum) BERTHNUMS
FROM (
SELECT t.pl_area_block_id,t.pl_no,max(t.berth_num) maxBerthNum
FROM t_income_calculation_static_num t
WHERE
str_to_date(t.static_date,'%Y-%m-%d') >= '${startDate}'
AND str_to_date(t.static_date,'%Y-%m-%d') <='${endDate}'
AND t.pl_no IN
<foreach collection="plNos" separator="," index="index" open="(" close=")" item="plNo">
#{plNo}
</foreach>
GROUP BY t.pl_area_block_id,t.pl_no) m
GROUP BY m.pl_area_block_id
</select>
<!--批量保存按次 langlw 2018-1-9 -->
<insert id="batchSaveIncomeNum" parameterType="java.util.List" >
<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into t_income_calculation_static_num (static_date, pl_area_block_id, pl_area_block_name,
pl_no, pl_type, pl_name, car_type,
all_num, free_num, day_num, night_num, berth_num
)
values
<foreach collection="incomeNumList" item="item" separator=",">
(#{item.staticDate,jdbcType=VARCHAR}, #{item.plAreaBlockId,jdbcType=BIGINT},
#{item.plAreaBlockName,jdbcType=VARCHAR}, #{item.plNo,jdbcType=VARCHAR},
#{item.plType,jdbcType=INTEGER}, #{item.plName,jdbcType=VARCHAR},
#{item.carType,jdbcType=INTEGER}, #{item.allNum,jdbcType=BIGINT},
#{item.freeNum,jdbcType=INTEGER}, #{item.dayNum,jdbcType=INTEGER},
#{item.nightNum,jdbcType=INTEGER}, #{item.berthNum,jdbcType=INTEGER}
)
</foreach>
</insert>
<select id="staticIncomeByNumForNew" statementType="STATEMENT"
resultType="com.zteits.clouds.api.dto.order.parkorder.dto.IncomeCalculationDTO">
SELECT
<if test="timeType == 1">
DATE_FORMAT(t.static_date,'%Y-%m-%d') stringTime,
</if>
<if test="timeType == 2">
concat(WEEK(t.static_date), '周') stringTime,
</if>
<if test="timeType == 3">
DATE_FORMAT(t.static_date,'%Y-%m') stringTime,
</if>
t.pl_area_block_id plAreaBlockId,
t.pl_area_block_name plAreaBlockName,
t.pl_no plNo,
t.pl_name plName,
<if test="plType != null">
t.pl_type plType,
</if>
sum(t.day_num * ${dayMinAmount} + t.night_num * ${nightMinAmount}) amount,
max(t.berth_num) plBerthNum
FROM t_income_calculation_static_num t
WHERE str_to_date(t.static_date,'%Y-%m-%d') >= '${beginTime}' AND str_to_date(t.static_date,'%Y-%m-%d') <=
'${endTime}'
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" index="index" separator=",">
'${plNo}'
</foreach>
<if test="plType != null">
t.pl_type=#{plType}
</if>
GROUP BY
<if test="timeType !=null ">
stringTime,
</if>
<if test="plType != null">
t.pl_type,
</if>
t.pl_no,t.pl_name,t.pl_area_block_id,t.pl_area_block_name
</select>
<select id="staticIncomeByNumForNewColumnChart" statementType="STATEMENT"
resultType="com.zteits.clouds.api.dto.order.parkorder.dto.IncomeCalculationDTO">
SELECT
t.pl_area_block_id plAreaBlockId,
t.pl_area_block_name plAreaBlockName,
t.pl_type plType,
sum(t.berth_num) plBerthNum,
sum(t.day_num * ${dayMinAmount} + t.night_num * ${nightMinAmount}) amount
FROM t_income_calculation_static_num t
WHERE str_to_date(t.static_date,'%Y-%m-%d') >= '${beginTime}' AND str_to_date(t.static_date,'%Y-%m-%d') <=
'${endTime}'
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" index="index" separator=",">
'${plNo}'
</foreach>
GROUP BY
t.pl_area_block_id,t.pl_area_block_name,t.pl_type
order by amount DESC
</select>
<select id="staticIncomeByNumForNewLineChart" statementType="STATEMENT"
resultType="com.zteits.clouds.api.dto.order.parkorder.dto.IncomeCalculationDTO">
SELECT
<if test="timeType == 1">
DATE_FORMAT(t.static_date,'%Y-%m-%d') stringTime,
</if>
<if test="timeType == 2">
concat(WEEK(t.static_date), '周') stringTime,
</if>
<if test="timeType == 3">
DATE_FORMAT(t.static_date,'%Y-%m') stringTime,
</if>
t.pl_area_block_id plAreaBlockId,
t.pl_area_block_name plAreaBlockName,
sum(t.day_num * ${dayMinAmount} + t.night_num * ${nightMinAmount}) amount
FROM t_income_calculation_static_num t
WHERE str_to_date(t.static_date,'%Y-%m-%d') >= '${beginTime}' AND str_to_date(t.static_date,'%Y-%m-%d') <=
'${endTime}'
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" index="index" separator=",">
'${plNo}'
</foreach>
GROUP BY
<if test="timeType == 1">
DATE_FORMAT(t.static_date,'%Y-%m-%d'),
</if>
<if test="timeType == 2">
WEEK(t.static_date),
</if>
<if test="timeType == 3">
DATE_FORMAT(t.static_date,'%Y-%m'),
</if>
t.pl_area_block_id,t.pl_area_block_name
order by
<if test="timeType == 1">
stringTime ASC
</if>
<if test="timeType == 2">
stringTime ASC
</if>
<if test="timeType == 3">
stringTime ASC
</if>
</select>
<!-- 以合计为维度导出Excel分类型 langlw 2018-1-11 edit-->
<!--
⚠️ 手改(非搬迁原样):本 select 原为 statementType="STATEMENT",已去掉该属性。
原因与上面 `queryIncomeCalculationDataByNum` 那条完全相同(坑 25:PageHelper 5→6 的
`LIMIT 3` → `LIMIT ?`),本 select 也走 `PageHelper.startPage`(
`InComeCalculationStaticDaoImpl.exportStaticIncomeExcelByNumForAllGroupByPlType`),
是导出「收益测算汇总」那张 sheet 的取数与预取总数两个循环共同的入口。
实测(2026-10-16,48099,第三十八切片):导出 `billType=2` 全参 → **200 + 空 body**
(老代码吞异常),修前这条路径必踩。
本 select 通篇只用 `${}` 文本替换、没有 `#{}`,去掉 STATEMENT 后 SQL 文本与语义完全不变。
-->
<select id="exportStaticIncomeExcelByNumForAllGroupByPlType"
resultType="com.zteits.clouds.api.dto.park.dto.IncomeCalculationExcelDTO">
SELECT
t.pl_type plType,
MAX(t.berth_num) berthNum,
sum(t.all_num) allNum,
sum(t.free_num) freeNum,
sum(t.day_num) dayNum,
sum(t.night_num) nightNum,
sum(t.day_num * ${dayMinAmount} + t.night_num * ${nightMinAmount}) amount
FROM t_income_calculation_static_num t
WHERE str_to_date(t.static_date,'%Y-%m-%d') >= '${beginTime}' AND str_to_date(t.static_date,'%Y-%m-%d') <= '${endTime}'
AND t.pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" index="index" separator=",">
'${plNo}'
</foreach>
group by t.pl_type
</select>
</mapper>