TpPEqpLogSMapper.xml
12.8 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
<?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.TpPEqpLogSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.TpPEqpLog">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="eqp_no" jdbcType="VARCHAR" property="eqpNo" />
<result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
<result column="event_type" jdbcType="VARCHAR" property="eventType" />
<result column="factory_no" jdbcType="VARCHAR" property="factoryNo" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<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="berth_state" jdbcType="CHAR" property="berthState" />
<result column="electricity" jdbcType="VARCHAR" property="electricity" />
<result column="voltag" jdbcType="VARCHAR" property="voltag" />
<result column="eqp_type" jdbcType="INTEGER" property="eqpType" />
<result column="eqp_is_online" jdbcType="CHAR" property="eqpIsOnline" />
</resultMap>
<sql id="Base_Column_List">
id, pl_no, eqp_no, berth_no, event_type, factory_no, remark, data_state, create_time,
create_op, modify_time, modify_op, berth_state, electricity, voltag,eqp_type,eqp_is_online
</sql>
<!-- 统计泊位周转率 按小时-->
<select id="queryBerthTurnOverByHour" parameterType="com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest"
resultType="com.zteits.park.domain.BerthTurnOverCountDO">
SELECT DATE_FORMAT(create_time,'%Y-%m-%d %H') as turnDayTime,
<!-- pl_no AS plNo, -->
count(1) AS turnCount
FROM
${tableName} a
where 1=1
<if test="beginTime != null and endTime != null">
and a.create_time between #{beginTime} and #{endTime}
</if>
<if test="eventType != null">
and a.event_type = #{eventType}
</if>
<if test="eqpType != null">
and a.eqp_type = #{eqpType,jdbcType=INTEGER}
</if>
<if test="plNos != null and plNos.size >0">
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
and a.data_state=1
GROUP BY
<!-- pl_no, -->
DATE_FORMAT(create_time,'%Y-%m-%d %H')
</select>
<!-- 统计泊位周转率 按天-->
<select id="queryBerthTurnOverByDay" parameterType="com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest"
resultType="com.zteits.park.domain.BerthTurnOverCountDO">
SELECT DATE_FORMAT(create_time,'%Y-%m-%d') as turnDayTime,
<!-- pl_no AS plNo, -->
count(1) AS turnCount
FROM
${tableName} a
where 1=1
<if test="beginTime != null and endTime != null">
and a.create_time between #{beginTime} and #{endTime}
</if>
<if test="eventType != null">
and a.event_type = #{eventType}
</if>
<if test="eqpType != null">
and a.eqp_type = #{eqpType,jdbcType=INTEGER}
</if>
<if test="plNos != null and plNos.size >0">
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
and a.data_state=1
GROUP BY
<!-- pl_no, -->
DATE_FORMAT(create_time,'%Y-%m-%d')
</select>
<!-- 统计泊位周转率 详细-->
<select id="queryBerthTurnOverDetail" parameterType="com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest"
resultType="com.zteits.park.domain.BerthTurnOverCountDO">
SELECT DATE_FORMAT(create_time,'%Y-%m-%d') as turnDayTime,
pl_no AS plNo,
count(1) AS turnCount
FROM
${tableName} a
where 1=1
<if test="beginTime != null and endTime != null">
and a.create_time between #{beginTime} and #{endTime}
</if>
<if test="eventType != null">
and a.event_type = #{eventType}
</if>
<if test="eqpType != null">
and a.eqp_type = #{eqpType,jdbcType=INTEGER}
</if>
<if test="plNos != null and plNos.size >0">
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
and a.data_state=1
GROUP BY
pl_no,
DATE_FORMAT(create_time,'%Y-%m-%d')
</select>
<!-- 统计泊位周转率 详细-按小时-->
<select id="queryBerthTurnOverDetailForHour" parameterType="com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest"
resultType="com.zteits.park.domain.BerthTurnOverCountDO">
SELECT DATE_FORMAT(create_time,'%Y-%m-%d %H') as turnDayTime,
pl_no AS plNo,
count(1) AS turnCount
FROM
${tableName} a
where 1=1
<if test="beginTime != null and endTime != null">
and a.create_time between #{beginTime} and #{endTime}
</if>
<if test="eventType != null">
and a.event_type = #{eventType}
</if>
<if test="eqpType != null">
and a.eqp_type = #{eqpType,jdbcType=INTEGER}
</if>
<if test="plNos != null and plNos.size >0">
and a.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
and a.data_state=1
GROUP BY
pl_no,
DATE_FORMAT(create_time,'%Y-%m-%d %H')
</select>
<!-- 分组查询停车场占用率 langlw 2017-8-18 -->
<!-- query park cooupancy rate group by park -->
<select id="queryParkOccupancyRate" resultType="com.zteits.clouds.api.dto.park.dto.ParkOccupancyRateDTO">
select t.plNo,
count(t.useBerth)/COUNT(id) as occupancyRate
from
(SELECT
create_time as createTime,
pl_no as plNo,
CASE berth_state
WHEN 1 THEN
id
END AS useBerth,
id
FROM
${tableName}
WHERE
data_state = 1
)t
<if test="plNos != null and plNos.size >0">
and t.pl_no IN
<foreach collection="plNos" open="(" close=")" separator="," item="plNo">
#{plNo}
</foreach>
</if>
group by plNo
</select>
<!-- 插入日志 -->
<insert id="insertSelective" parameterType="com.zteits.park.domain.TpPEqpLogSplitTable">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="plNo != null">
pl_no,
</if>
<if test="eqpNo != null">
eqp_no,
</if>
<if test="berthNo != null">
berth_no,
</if>
<if test="eventType != null">
event_type,
</if>
<if test="factoryNo != null">
factory_no,
</if>
<if test="remark != null">
remark,
</if>
<if test="dataState != null">
data_state,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createOp != null">
create_op,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="modifyOp != null">
modify_op,
</if>
<if test="berthState != null">
berth_state,
</if>
<if test="electricity != null">
electricity,
</if>
<if test="voltag != null">
voltag,
</if>
<if test="eqpType != null">
eqp_type,
</if>
<if test="eqpIsOnline != null">
eqp_is_online,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="plNo != null">
#{plNo,jdbcType=VARCHAR},
</if>
<if test="eqpNo != null">
#{eqpNo,jdbcType=VARCHAR},
</if>
<if test="berthNo != null">
#{berthNo,jdbcType=VARCHAR},
</if>
<if test="eventType != null">
#{eventType,jdbcType=VARCHAR},
</if>
<if test="factoryNo != null">
#{factoryNo,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="dataState != null">
#{dataState,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createOp != null">
#{createOp,jdbcType=BIGINT},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyOp != null">
#{modifyOp,jdbcType=BIGINT},
</if>
<if test="berthState != null">
#{berthState,jdbcType=CHAR},
</if>
<if test="electricity != null">
#{electricity,jdbcType=VARCHAR},
</if>
<if test="voltag != null">
#{voltag,jdbcType=VARCHAR},
</if>
<if test="eqpType != null">
#{eqpType,jdbcType=INTEGER},
</if>
<if test="eqpIsOnline != null">
#{eqpIsOnline,jdbcType=CHAR},
</if>
</trim>
</insert>
<!-- 分页查询停车场设备编号信息 xiejp 2017-12-13 -->
<!-- query park eqp for page -->
<select id="queryParkEqpForPageByPlNo" resultType="com.zteits.clouds.api.dto.park.dto.TpPEqpLogDTO"
parameterType="com.zteits.clouds.api.dto.clouds.param.EqpLogQueryRequest">
select pl.pl_no as plNo,
pl.pl_name as plName,
tp.factory_no as factoryNo,
tp.factory_name as factoryName,
A.eqp_no as eqpNo,
A.berth_no as berthNo,
A.event_type as eventType,
A.create_time as createTime,
A.eqp_type as eqpType,
A.modify_time as modifyTime
from
(select *
from ${tableName}
where 1=1
<if test="plNos != null and plNos.size >0">
AND pl_no in
<foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">
#{plNo}
</foreach>
</if>
<if test="eqpNo != null and eqpNo != ''">
AND eqp_no = #{eqpNo}
</if>
<if test="berthNo != null and berthNo != ''">
AND berth_no like concat('%',#{berthNo},'%')
</if>
<if test="factoryNos != null and factoryNos.size >0">
AND factory_no in
<foreach collection="factoryNos" index="index" item="factoryNo" open="(" separator="," close=")">
#{factoryNo}
</foreach>
</if>
<if test="eventTypes != null and eventTypes.size >0">
AND event_type in
<foreach collection="eventTypes" index="index" item="eventType" open="(" separator="," close=")">
#{eventType}
</foreach>
</if>
<if test="eqpType != null">
AND eqp_type = #{eqpType}
</if>
<if test="modifyOp != null">
AND modify_op = #{modifyOp}
</if>
<if test="createTimeStart != null">
and create_time >=#{createTimeStart}
</if>
<if test="createTimeEnd != null">
and create_time <= #{createTimeEnd}
</if>
<if test="createTime != null">
and DATE(create_time) = DATE(#{createTime})
</if>
)A
LEFT JOIN parking_lot pl on A.pl_no = pl.pl_no
LEFT JOIN tp_p_factory_info tp on A.factory_no = tp.factory_no
ORDER BY A.create_time DESC
</select>
<!--心跳上报日志记录-->
<select id="insertHeartBeatData">
INSERT INTO ${eqpLogTableName}
( pl_no, eqp_no, berth_no, event_type, factory_no, data_state, create_time, modify_time, eqp_type, eqp_is_online )
SELECT
pl_no,
eqp_no,
berth_no,
#{eventType},
factory_no,
1,
heartbeat_time,
heartbeat_time,
eqp_type,
#{eqpIsOnline}
FROM
tp_p_eqp
WHERE
eqp_no IN
<foreach collection="eqpNos" index="index" item="eqpNo" open="(" separator="," close=")">
#{eqpNo}
</foreach>
</select>
<!-- 获取最新一条信息 -->
<select id="queryLastEqpLogByEqpNo" parameterType="com.zteits.clouds.api.dto.clouds.param.EqpLogQueryRequest"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ${tableName}
where 1=1
<if test="eqpNo != null and eqpNo != ''">
AND eqp_no = #{eqpNo}
</if>
<if test="berthNo != null and berthNo != ''">
AND berth_no like concat('%',#{berthNo},'%')
</if>
<if test="eventTypes != null and eventTypes.size >0">
AND event_type in
<foreach collection="eventTypes" index="index" item="eventType" open="(" separator="," close=")">
#{eventType}
</foreach>
</if>
<if test="eqpType != null">
AND eqp_type = #{eqpType}
</if>
<if test="createTimeStart != null">
and create_time >=#{createTimeStart}
</if>
<if test="createTimeEnd != null">
and create_time <= #{createTimeEnd}
</if>
order by create_time desc
limit 1
</select>
</mapper>