DspResourceMapper.xml
25.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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
<?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.parking.module.park.dsp.dal.mysql.DspResourceMapper">
<!--
上级平台接收落库 SQL
约定:
1. 车场唯一性按 (source_platform_code, pl_no) 判,pl_no 被别的平台占用时拒绝,
不覆盖别人数据(设计 §8);
2. parking_lot / tp_p_berths / tp_p_region_area 都是存量表,只写接入需要的列,
其余列走库默认值;
3. 泊位按 (pl_no, berth_no) 在 data_state = 1 内唯一(存量有 232 对重复在 data_state = 0,
所以不能加唯一索引);
4. 坐标落 parking_lot_geo:geo_type = 2(入口坐标),lon_lat_type 1 百度 / 2 地球 / 3 高德。
-->
<!-- ==================== 车场 ==================== -->
<sql id="parkColumns">
pl_id, pl_no, pl_name, pl_address, pl_type, pl_type_prop,
pl_province_id, pl_province_name, pl_city_id, pl_city_name, pl_country_id, pl_country_name,
pl_berth_num, pl_charge_num, pl_entrance_num, pl_exit_num,
pl_busi_time_start, pl_busi_time_end, busi_circle, source_type, service_tel,
state, data_status, report_status, source_platform_code, source_platform_name, report_time
</sql>
<select id="selectParkByPlNo" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspParkRow">
SELECT <include refid="parkColumns"/>
FROM parking_lot
WHERE pl_no = #{plNo}
AND data_status = 1
LIMIT 1
</select>
<select id="selectParkByPlNoForUpdate" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspParkRow">
SELECT <include refid="parkColumns"/>
FROM parking_lot
WHERE pl_no = #{plNo}
AND data_status = 1
LIMIT 1
FOR UPDATE
</select>
<select id="selectParkByPlNoAndPlatform" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspParkRow">
SELECT <include refid="parkColumns"/>
FROM parking_lot
WHERE pl_no = #{plNo}
AND source_platform_code = #{platformCode}
AND data_status = 1
LIMIT 1
</select>
<insert id="insertPark" useGeneratedKeys="true" keyProperty="plId">
INSERT INTO parking_lot (
pl_no, pl_name, pl_address, pl_type, pl_type_prop,
pl_province_id, pl_province_name, pl_city_id, pl_city_name, pl_country_id, pl_country_name,
pl_berth_num, pl_charge_num, pl_entrance_num, pl_exit_num,
pl_busi_time_start, pl_busi_time_end, busi_circle, source_type, service_tel,
state, data_status, report_status, source_platform_code, source_platform_name,
report_time, create_time, modify_time
) VALUES (
#{plNo}, #{plName}, #{plAddress}, #{plType}, #{plTypeProp},
#{plProvinceId}, #{plProvinceName}, #{plCityId}, #{plCityName}, #{plCountryId}, #{plCountryName},
#{plBerthNum}, #{plChargeNum}, #{plEntranceNum}, #{plExitNum},
#{plBusiTimeStart}, #{plBusiTimeEnd}, #{busiCircle}, #{sourceType}, #{serviceTel},
#{state}, #{dataStatus}, #{reportStatus}, #{sourcePlatformCode}, #{sourcePlatformName},
#{reportTime}, #{createTime}, #{modifyTime}
)
</insert>
<update id="updatePark">
UPDATE parking_lot
SET pl_name = #{plName},
pl_address = #{plAddress},
pl_type = #{plType},
pl_type_prop = #{plTypeProp},
pl_province_id = #{plProvinceId},
pl_province_name = #{plProvinceName},
pl_city_id = #{plCityId},
pl_city_name = #{plCityName},
pl_country_id = #{plCountryId},
pl_country_name = #{plCountryName},
pl_berth_num = #{plBerthNum},
pl_charge_num = #{plChargeNum},
pl_entrance_num = #{plEntranceNum},
pl_exit_num = #{plExitNum},
pl_busi_time_start = #{plBusiTimeStart},
pl_busi_time_end = #{plBusiTimeEnd},
busi_circle = #{busiCircle},
source_type = #{sourceType},
service_tel = #{serviceTel},
report_status = #{reportStatus},
source_platform_name = #{sourcePlatformName},
report_time = #{reportTime},
modify_time = #{modifyTime}
WHERE pl_id = #{plId}
</update>
<update id="updateParkBerthNum">
UPDATE parking_lot
SET pl_berth_num = #{plBerthNum}, report_time = #{reportTime}, modify_time = #{reportTime}
WHERE pl_id = #{plId}
</update>
<update id="touchParkReport">
UPDATE parking_lot
SET report_status = #{reportStatus}, report_time = #{reportTime}, modify_time = #{reportTime}
WHERE pl_id = #{plId}
</update>
<!-- ==================== 车场扩展 ==================== -->
<sql id="lotExtColumns">
pl_id, organization_no, organization_name, maintain_department, property_owner, property_type,
property_date, build_completed_time, staff_num, open_time, service_type,
day_time_start, day_time_end, night_time_start, night_time_end,
district_code, street_name, street_code, road_name,
free_num, large_vehicle_num, light_vehicle_num,
park_place_num01, park_place_num02, park_place_num03, park_place_num04, park_place_num05,
specific_berth_num, available_berth_num, share_berth_num, deform_berth_num, new_energy_num,
charge_pile_num, quick_charge_pile_num, slow_charge_pile_num, charge_pile_operation_unit,
service_phone, contact_phone, manager_name, remark,
info_service_sn, info_service_name, charge_standard_fee_sn,
park_picture_url, picture_state, source_platform_code, report_time, create_time, modify_time
</sql>
<select id="selectLotExt" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspLotExtRow">
SELECT <include refid="lotExtColumns"/>
FROM park_lot_ext
WHERE pl_id = #{plId}
</select>
<insert id="upsertLotExt">
INSERT INTO park_lot_ext (<include refid="lotExtColumns"/>)
VALUES (
#{ext.plId}, #{ext.organizationNo}, #{ext.organizationName}, #{ext.maintainDepartment},
#{ext.propertyOwner}, #{ext.propertyType}, #{ext.propertyDate}, #{ext.buildCompletedTime},
#{ext.staffNum}, #{ext.openTime}, #{ext.serviceType},
#{ext.dayTimeStart}, #{ext.dayTimeEnd}, #{ext.nightTimeStart}, #{ext.nightTimeEnd},
#{ext.districtCode}, #{ext.streetName}, #{ext.streetCode}, #{ext.roadName},
#{ext.freeNum}, #{ext.largeVehicleNum}, #{ext.lightVehicleNum},
#{ext.parkPlaceNum01}, #{ext.parkPlaceNum02}, #{ext.parkPlaceNum03},
#{ext.parkPlaceNum04}, #{ext.parkPlaceNum05},
#{ext.specificBerthNum}, #{ext.availableBerthNum}, #{ext.shareBerthNum},
#{ext.deformBerthNum}, #{ext.newEnergyNum},
#{ext.chargePileNum}, #{ext.quickChargePileNum}, #{ext.slowChargePileNum},
#{ext.chargePileOperationUnit},
#{ext.servicePhone}, #{ext.contactPhone}, #{ext.managerName}, #{ext.remark},
#{ext.infoServiceSn}, #{ext.infoServiceName}, #{ext.chargeStandardFeeSn},
#{ext.parkPictureUrl}, #{ext.pictureState}, #{ext.sourcePlatformCode},
#{ext.reportTime}, #{ext.createTime}, #{ext.modifyTime}
)
ON DUPLICATE KEY UPDATE
organization_no = VALUES(organization_no),
organization_name = VALUES(organization_name),
maintain_department = VALUES(maintain_department),
property_owner = VALUES(property_owner),
property_type = VALUES(property_type),
property_date = VALUES(property_date),
build_completed_time = VALUES(build_completed_time),
staff_num = VALUES(staff_num),
open_time = VALUES(open_time),
service_type = VALUES(service_type),
day_time_start = VALUES(day_time_start),
day_time_end = VALUES(day_time_end),
night_time_start = VALUES(night_time_start),
night_time_end = VALUES(night_time_end),
district_code = VALUES(district_code),
street_name = VALUES(street_name),
street_code = VALUES(street_code),
road_name = VALUES(road_name),
free_num = VALUES(free_num),
large_vehicle_num = VALUES(large_vehicle_num),
light_vehicle_num = VALUES(light_vehicle_num),
park_place_num01 = VALUES(park_place_num01),
park_place_num02 = VALUES(park_place_num02),
park_place_num03 = VALUES(park_place_num03),
park_place_num04 = VALUES(park_place_num04),
park_place_num05 = VALUES(park_place_num05),
specific_berth_num = VALUES(specific_berth_num),
available_berth_num = VALUES(available_berth_num),
share_berth_num = VALUES(share_berth_num),
deform_berth_num = VALUES(deform_berth_num),
new_energy_num = VALUES(new_energy_num),
charge_pile_num = VALUES(charge_pile_num),
quick_charge_pile_num = VALUES(quick_charge_pile_num),
slow_charge_pile_num = VALUES(slow_charge_pile_num),
charge_pile_operation_unit = VALUES(charge_pile_operation_unit),
service_phone = VALUES(service_phone),
contact_phone = VALUES(contact_phone),
manager_name = VALUES(manager_name),
remark = VALUES(remark),
info_service_sn = VALUES(info_service_sn),
info_service_name = VALUES(info_service_name),
charge_standard_fee_sn = VALUES(charge_standard_fee_sn),
park_picture_url = VALUES(park_picture_url),
report_time = VALUES(report_time),
modify_time = VALUES(modify_time)
</insert>
<insert id="upsertLotExtSummary">
INSERT INTO park_lot_ext (
pl_id, park_place_num01, park_place_num02, park_place_num03, park_place_num04, park_place_num05,
available_berth_num, light_vehicle_num, large_vehicle_num, deform_berth_num, free_num,
new_energy_num, charge_pile_num, quick_charge_pile_num, slow_charge_pile_num,
charge_pile_operation_unit, source_platform_code, report_time, create_time, modify_time
) VALUES (
#{ext.plId}, #{ext.parkPlaceNum01}, #{ext.parkPlaceNum02}, #{ext.parkPlaceNum03},
#{ext.parkPlaceNum04}, #{ext.parkPlaceNum05},
#{ext.availableBerthNum}, #{ext.lightVehicleNum}, #{ext.largeVehicleNum},
#{ext.deformBerthNum}, #{ext.freeNum},
#{ext.newEnergyNum}, #{ext.chargePileNum}, #{ext.quickChargePileNum}, #{ext.slowChargePileNum},
#{ext.chargePileOperationUnit}, #{ext.sourcePlatformCode}, #{ext.reportTime},
#{ext.createTime}, #{ext.modifyTime}
)
ON DUPLICATE KEY UPDATE
park_place_num01 = VALUES(park_place_num01),
park_place_num02 = VALUES(park_place_num02),
park_place_num03 = VALUES(park_place_num03),
park_place_num04 = VALUES(park_place_num04),
park_place_num05 = VALUES(park_place_num05),
available_berth_num = VALUES(available_berth_num),
light_vehicle_num = VALUES(light_vehicle_num),
large_vehicle_num = VALUES(large_vehicle_num),
deform_berth_num = VALUES(deform_berth_num),
free_num = VALUES(free_num),
new_energy_num = VALUES(new_energy_num),
charge_pile_num = VALUES(charge_pile_num),
quick_charge_pile_num = VALUES(quick_charge_pile_num),
slow_charge_pile_num = VALUES(slow_charge_pile_num),
charge_pile_operation_unit = VALUES(charge_pile_operation_unit),
report_time = VALUES(report_time),
modify_time = VALUES(modify_time)
</insert>
<!-- ==================== 坐标 ==================== -->
<select id="selectGeoId" resultType="java.lang.Long">
SELECT geo_id FROM parking_lot_geo
WHERE pl_id = #{plId}
AND geo_type = #{geoType}
AND data_status = 1
LIMIT 1
</select>
<insert id="insertGeo" useGeneratedKeys="true" keyColumn="geo_id">
INSERT INTO parking_lot_geo (
lon_id, lat_id, lon_lat_type, geo_type, pl_id, pl_name, pl_no, data_status, create_time
) VALUES (
#{lon}, #{lat}, #{lonLatType}, 2, #{plId}, #{plName}, #{plNo}, 1, NOW()
)
</insert>
<update id="updateGeo">
UPDATE parking_lot_geo
SET lon_id = #{lon}, lat_id = #{lat}, lon_lat_type = #{lonLatType}, modify_time = NOW()
WHERE geo_id = #{geoId}
</update>
<!-- ==================== 泊位区间 ==================== -->
<select id="selectRegionAreaName" resultType="java.lang.String">
SELECT park_area_name FROM tp_p_region_area
WHERE pl_no = #{plNo}
AND park_area_code = #{areaCode}
AND data_state = 1
LIMIT 1
</select>
<select id="selectRegionAreasByName" resultType="java.util.Map">
SELECT park_area_code AS parkAreaCode, park_area_name AS parkAreaName
FROM tp_p_region_area
WHERE pl_no = #{plNo}
AND park_area_name = #{areaName}
AND data_state = 1
</select>
<insert id="insertRegionArea">
INSERT INTO tp_p_region_area (
pl_no, park_area_code, park_area_name, data_state, create_time, modify_time
) VALUES (
#{plNo}, #{areaCode}, #{areaName}, 1, NOW(), NOW()
)
</insert>
<!-- ==================== 泊位 ==================== -->
<select id="selectBerth" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspBerthRow">
SELECT id, pl_no, park_area_code, berth_no, road_position, direction, park_type,
berth_type, busi_status, remark, data_state
FROM tp_p_berths
WHERE pl_no = #{plNo}
AND berth_no = #{berthNo}
AND data_state = 1
LIMIT 1
</select>
<insert id="insertBerth" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tp_p_berths (
pl_no, park_area_code, berth_no, road_position, direction, park_type,
berth_type, busi_status, remark, data_state, is_occupy, create_time, modify_time
) VALUES (
#{plNo}, #{parkAreaCode}, #{berthNo}, #{roadPosition}, #{direction}, #{parkType},
#{berthType}, #{busiStatus}, #{remark}, 1, '2', #{createTime}, #{modifyTime}
)
</insert>
<update id="updateBerth">
UPDATE tp_p_berths
SET park_area_code = #{parkAreaCode},
road_position = #{roadPosition},
direction = #{direction},
park_type = #{parkType},
berth_type = #{berthType},
busi_status = #{busiStatus},
remark = #{remark},
modify_time = #{modifyTime}
WHERE id = #{id}
</update>
<select id="countBerths" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tp_p_berths
WHERE pl_no = #{plNo}
AND data_state = 1
</select>
<!-- ==================== 撤回级联 ==================== -->
<update id="withdrawPark">
UPDATE parking_lot
SET report_status = 2,
data_status = 0,
report_time = #{reportTime},
modify_time = #{reportTime}
WHERE pl_id = #{plId}
</update>
<update id="invalidateBerthsOfPark">
UPDATE tp_p_berths
SET data_state = 0, modify_time = NOW()
WHERE pl_no = #{plNo}
AND data_state = 1
</update>
<update id="invalidateDevicesOfPark">
UPDATE tp_p_eqp
SET data_state = 0, modify_time = NOW()
WHERE pl_no = #{plNo}
AND data_state = 1
</update>
<update id="invalidateChannelsOfPark">
UPDATE parking_lot_channel
SET data_status = 0, modfiy_date = NOW()
WHERE pl_no = #{plNo}
AND data_status = 1
</update>
<update id="unbindDeviceBerthsOfPark">
UPDATE park_device_berth_rel
SET bind_status = 0, unbind_time = NOW(), modify_time = NOW()
WHERE pl_no = #{plNo}
AND bind_status = 1
</update>
<!-- ==================== 出入口 ==================== -->
<sql id="channelColumns">
id, pl_no, cr_sn, channel_name, channel_direction, relate_road, lon_id, lat_id,
default_managed_equipment_id, picture_url, source_platform_code, report_time
</sql>
<select id="selectChannel" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspChannelRow">
SELECT <include refid="channelColumns"/>
FROM parking_lot_channel
WHERE pl_no = #{plNo}
AND cr_sn = #{crSn}
AND data_status = 1
LIMIT 1
</select>
<insert id="insertChannel" useGeneratedKeys="true" keyProperty="id">
INSERT INTO parking_lot_channel (
pl_no, cr_sn, channel_name, channel_direction, relate_road, lon_id, lat_id,
default_managed_equipment_id, picture_url, source_platform_code, report_time,
data_status, create_date, modfiy_date
) VALUES (
#{plNo}, #{crSn}, #{channelName}, #{channelDirection}, #{relateRoad}, #{lon}, #{lat},
#{defaultManagedEquipmentId}, #{pictureUrl}, #{sourcePlatformCode}, #{reportTime},
1, #{createTime}, #{modifyTime}
)
</insert>
<update id="updateChannel">
UPDATE parking_lot_channel
SET channel_name = #{channelName},
channel_direction = #{channelDirection},
relate_road = #{relateRoad},
lon_id = #{lon},
lat_id = #{lat},
default_managed_equipment_id = #{defaultManagedEquipmentId},
picture_url = #{pictureUrl},
report_time = #{reportTime},
modfiy_date = #{modifyTime}
WHERE id = #{id}
</update>
<select id="countChannels" resultType="java.lang.Integer">
SELECT COUNT(*) FROM parking_lot_channel
WHERE pl_no = #{plNo}
AND data_status = 1
</select>
<select id="selectEquipmentIdByEqpNo" resultType="java.lang.Long">
SELECT id FROM tp_p_eqp
WHERE eqp_no = #{eqpNo}
LIMIT 1
</select>
<!-- ==================== 收费标准 ==================== -->
<sql id="rateColumns">
id, pl_id, pl_no, fee_sn, fee_standard_type, billing_period, timing_unit,
small_charging_price, big_charging_price, count_charging_price, free_minutes,
cap_day, cap_once, single_pay_duration, single_pay_price,
charging_standards_detailed, charge_brand_front_url, charge_brand_opposite_url,
day_time_start, day_time_end, night_time_start, night_time_end,
source_platform_code, report_time
</sql>
<select id="selectRate" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspRateRow">
SELECT <include refid="rateColumns"/>
FROM park_rate_standard
WHERE source_platform_code = #{platformCode}
AND fee_sn = #{feeSn}
AND deleted = 0
LIMIT 1
</select>
<insert id="upsertRate">
INSERT INTO park_rate_standard (
pl_id, pl_no, fee_sn, fee_standard_type, billing_period, timing_unit,
small_charging_price, big_charging_price, count_charging_price, free_minutes,
cap_day, cap_once, single_pay_duration, single_pay_price,
charging_standards_detailed, charge_brand_front_url, charge_brand_opposite_url,
day_time_start, day_time_end, night_time_start, night_time_end,
source_platform_code, report_time, deleted, create_time, modify_time
) VALUES (
#{rate.plId}, #{rate.plNo}, #{rate.feeSn}, #{rate.feeStandardType}, #{rate.billingPeriod},
#{rate.timingUnit}, #{rate.smallChargingPrice}, #{rate.bigChargingPrice},
#{rate.countChargingPrice}, #{rate.freeMinutes}, #{rate.capDay}, #{rate.capOnce},
#{rate.singlePayDuration}, #{rate.singlePayPrice}, #{rate.chargingStandardsDetailed},
#{rate.chargeBrandFrontUrl}, #{rate.chargeBrandOppositeUrl},
#{rate.dayTimeStart}, #{rate.dayTimeEnd}, #{rate.nightTimeStart}, #{rate.nightTimeEnd},
#{rate.sourcePlatformCode}, #{rate.reportTime}, 0, #{rate.createTime}, #{rate.modifyTime}
)
ON DUPLICATE KEY UPDATE
pl_id = VALUES(pl_id),
pl_no = VALUES(pl_no),
fee_standard_type = VALUES(fee_standard_type),
billing_period = VALUES(billing_period),
timing_unit = VALUES(timing_unit),
small_charging_price = VALUES(small_charging_price),
big_charging_price = VALUES(big_charging_price),
count_charging_price = VALUES(count_charging_price),
free_minutes = VALUES(free_minutes),
cap_day = VALUES(cap_day),
cap_once = VALUES(cap_once),
single_pay_duration = VALUES(single_pay_duration),
single_pay_price = VALUES(single_pay_price),
charging_standards_detailed = VALUES(charging_standards_detailed),
charge_brand_front_url = VALUES(charge_brand_front_url),
charge_brand_opposite_url = VALUES(charge_brand_opposite_url),
day_time_start = VALUES(day_time_start),
day_time_end = VALUES(day_time_end),
night_time_start = VALUES(night_time_start),
night_time_end = VALUES(night_time_end),
report_time = VALUES(report_time),
deleted = 0,
modify_time = VALUES(modify_time)
</insert>
<!-- ==================== 设备 ==================== -->
<sql id="deviceColumns">
id, pl_no, eqp_type, eqp_no, eqp_name, vendor_name, device_model, install_position,
install_height, firmware_version, berth_no, is_bind_berth, eqp_is_online, remark,
source_platform_code, report_time
</sql>
<select id="selectDevice" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspDeviceRow">
SELECT <include refid="deviceColumns"/>
FROM tp_p_eqp
WHERE eqp_no = #{eqpNo}
LIMIT 1
</select>
<insert id="insertDevice" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tp_p_eqp (
pl_no, eqp_type, eqp_no, eqp_name, vendor_name, device_model, install_position,
install_height, firmware_version, berth_no, is_bind_berth, eqp_is_online, remark,
source_platform_code, report_time, data_state, create_time, modify_time
) VALUES (
#{plNo}, #{eqpType}, #{eqpNo}, #{eqpName}, #{vendorName}, #{deviceModel}, #{installPosition},
#{installHeight}, #{firmwareVersion}, #{berthNo}, #{isBindBerth}, #{eqpIsOnline}, #{remark},
#{sourcePlatformCode}, #{reportTime}, 1, #{createTime}, #{modifyTime}
)
</insert>
<update id="updateDevice">
UPDATE tp_p_eqp
SET pl_no = #{plNo},
eqp_type = #{eqpType},
eqp_name = #{eqpName},
vendor_name = #{vendorName},
device_model = #{deviceModel},
install_position = #{installPosition},
install_height = #{installHeight},
firmware_version = #{firmwareVersion},
berth_no = #{berthNo},
is_bind_berth = #{isBindBerth},
eqp_is_online = #{eqpIsOnline},
remark = #{remark},
report_time = #{reportTime},
data_state = 1,
modify_time = #{modifyTime}
WHERE id = #{id}
</update>
<select id="countDevices" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tp_p_eqp
WHERE pl_no = #{plNo}
AND data_state = 1
</select>
<!-- ==================== 设备-泊位关联 ==================== -->
<sql id="deviceBerthColumns">
id, pl_id, pl_no, device_sn, berth_sn, bind_status, bind_time, unbind_time,
source_platform_code, report_time
</sql>
<select id="selectDeviceBerth" resultType="com.zteits.parking.module.park.dsp.dal.dataobject.DspDeviceBerthRow">
SELECT <include refid="deviceBerthColumns"/>
FROM park_device_berth_rel
WHERE source_platform_code = #{platformCode}
AND device_sn = #{deviceSn}
AND berth_sn = #{berthSn}
LIMIT 1
</select>
<select id="selectActiveDeviceSnByBerth" resultType="java.lang.String">
SELECT device_sn FROM park_device_berth_rel
WHERE pl_no = #{plNo}
AND berth_sn = #{berthSn}
AND bind_status = 1
AND device_sn <> #{deviceSn}
LIMIT 1
</select>
<insert id="upsertDeviceBerth">
INSERT INTO park_device_berth_rel (
pl_id, pl_no, device_sn, berth_sn, bind_status, bind_time, unbind_time,
source_platform_code, report_time, create_time, modify_time
) VALUES (
#{rel.plId}, #{rel.plNo}, #{rel.deviceSn}, #{rel.berthSn}, #{rel.bindStatus},
#{rel.bindTime}, #{rel.unbindTime}, #{rel.sourcePlatformCode}, #{rel.reportTime},
#{rel.createTime}, #{rel.modifyTime}
)
ON DUPLICATE KEY UPDATE
pl_id = VALUES(pl_id),
pl_no = VALUES(pl_no),
bind_status = VALUES(bind_status),
bind_time = VALUES(bind_time),
unbind_time = VALUES(unbind_time),
report_time = VALUES(report_time),
modify_time = VALUES(modify_time)
</insert>
<update id="updateDeviceBerthBinding">
UPDATE tp_p_eqp
SET berth_no = #{berthNo},
is_bind_berth = #{isBindBerth},
modify_time = NOW()
WHERE eqp_no = #{eqpNo}
</update>
</mapper>