ParkingLotSMapper.xml
34.5 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
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
<?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.ParkingLotSMapper">
<resultMap id="ParkingLotAndGeoInfoResultMap" type="com.zteits.park.domain.ParkingLotAndGeoInfo">
<id column="pl_id" jdbcType="BIGINT" property="plId"/>
<association property="parkingLot" column="pl_id"
resultMap="com.zteits.park.mapper.ParkingLotMapper.BaseResultMap"/>
<collection property="parkingLotGeos" javaType="list" ofType="com.zteits.park.domain.ParkingLotGeo"
resultMap="com.zteits.park.mapper.ParkingLotGeoMapper.BaseResultMap" columnPrefix="geo_">
</collection>
</resultMap>
<resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkingLot">
<id column="pl_id" jdbcType="BIGINT" property="plId" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_out_no" jdbcType="VARCHAR" property="plOutNo" />
<result column="state" jdbcType="INTEGER" property="state" />
<result column="source_type" jdbcType="INTEGER" property="sourceType" />
<result column="pl_province_id" jdbcType="BIGINT" property="plProvinceId" />
<result column="pl_province_name" jdbcType="VARCHAR" property="plProvinceName" />
<result column="pl_city_id" jdbcType="BIGINT" property="plCityId" />
<result column="pl_city_name" jdbcType="VARCHAR" property="plCityName" />
<result column="pl_country_id" jdbcType="BIGINT" property="plCountryId" />
<result column="pl_country_name" jdbcType="VARCHAR" property="plCountryName" />
<result column="pl_address" jdbcType="VARCHAR" property="plAddress" />
<result column="pl_berth_num" jdbcType="INTEGER" property="plBerthNum" />
<result column="pl_pay_type" jdbcType="INTEGER" property="plPayType" />
<result column="pl_charge_num" jdbcType="INTEGER" property="plChargeNum" />
<result column="pl_type" jdbcType="INTEGER" property="plType" />
<result column="pl_type_prop" jdbcType="VARCHAR" property="plTypeProp" />
<result column="pl_busi_time_start" jdbcType="VARCHAR" property="plBusiTimeStart" />
<result column="pl_busi_time_end" jdbcType="VARCHAR" property="plBusiTimeEnd" />
<result column="pl_entrance_num" jdbcType="INTEGER" property="plEntranceNum" />
<result column="pl_exit_num" jdbcType="INTEGER" property="plExitNum" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<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="pl_rate" jdbcType="VARCHAR" property="plRate" />
<result column="service_tel" jdbcType="VARCHAR" property="serviceTel" />
<result column="pl_picture_path" jdbcType="VARCHAR" property="plPicturePath" />
<result column="busi_circle" jdbcType="INTEGER" property="busiCircle" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="pl_area_block_id" jdbcType="BIGINT" property="plAreaBlockId" />
<result column="pl_area_block_name" jdbcType="VARCHAR" property="plAreaBlockName" />
<result column="pl_busi_type" jdbcType="VARCHAR" property="plBusiType" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
<result column="is_special" jdbcType="INTEGER" property="isSpecial" />
<result column="area_type" jdbcType="INTEGER" property="areaType" />
<result column="area_card_limit_num" jdbcType="INTEGER" property="areaCardLimitNum" />
<result column="is_self_parking" jdbcType="INTEGER" property="isSelfParking" />
<result column="is_upload_third" jdbcType="INTEGER" property="isUploadThird" />
</resultMap>
<resultMap id="ParkingLotExtResultMap" type="com.zteits.park.domain.ParkingLotExtDO">
<id column="pl_id" jdbcType="BIGINT" property="plId"/>
<result column="pl_name" jdbcType="VARCHAR" property="plName"/>
<result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
<result column="state" jdbcType="INTEGER" property="state"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/>
<result column="pl_province_id" jdbcType="BIGINT" property="plProvinceId"/>
<result column="pl_province_name" jdbcType="VARCHAR" property="plProvinceName"/>
<result column="pl_city_id" jdbcType="BIGINT" property="plCityId"/>
<result column="pl_city_name" jdbcType="VARCHAR" property="plCityName"/>
<result column="pl_country_id" jdbcType="BIGINT" property="plCountryId"/>
<result column="pl_country_name" jdbcType="VARCHAR" property="plCountryName"/>
<result column="pl_area_block_id" jdbcType="BIGINT" property="plAreaBlockId"/>
<result column="pl_area_block_name" jdbcType="VARCHAR" property="plAreaBlockName"/>
<result column="pl_address" jdbcType="VARCHAR" property="plAddress"/>
<result column="pl_berth_num" jdbcType="INTEGER" property="plBerthNum"/>
<result column="pl_pay_type" jdbcType="INTEGER" property="plPayType"/>
<result column="pl_charge_num" jdbcType="INTEGER" property="plChargeNum"/>
<result column="pl_type" jdbcType="INTEGER" property="plType"/>
<result column="pl_type_prop" jdbcType="VARCHAR" property="plTypeProp"/>
<result column="pl_busi_time_start" jdbcType="VARCHAR" property="plBusiTimeStart"/>
<result column="pl_busi_time_end" jdbcType="VARCHAR" property="plBusiTimeEnd"/>
<result column="pl_entrance_num" jdbcType="INTEGER" property="plEntranceNum"/>
<result column="pl_exit_num" jdbcType="INTEGER" property="plExitNum"/>
<result column="data_status" jdbcType="INTEGER" property="dataStatus"/>
<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="pl_out_no" jdbcType="VARCHAR" property="plOutNo"/>
<result column="pl_rate" jdbcType="VARCHAR" property="plRate"/>
<result column="service_tel" jdbcType="VARCHAR" property="serviceTel"/>
<result column="pl_picture_path" jdbcType="VARCHAR" property="plPicturePath"/>
<result column="busi_circle" jdbcType="INTEGER" property="busiCircle"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="org_id" jdbcType="VARCHAR" property="orgId"/>
<result column="org_name" jdbcType="VARCHAR" property="orgName"/>
<result column="support_etc" jdbcType="INTEGER" property="supportEtc" />
<result column="free_berth" javaType="INTEGER" property="freeBerth"/>
<result column="park_position" jdbcType="INTEGER" property="parkPosition" />
</resultMap>
<sql id="Base_Column_List">
pl_id, pl_name, pl_no, pl_out_no, state, source_type, pl_province_id, pl_province_name,
pl_city_id, pl_city_name, pl_country_id, pl_country_name, pl_address, pl_berth_num,
pl_pay_type, pl_charge_num, pl_type, pl_type_prop, pl_busi_time_start, pl_busi_time_end,
pl_entrance_num, pl_exit_num, data_status, create_time, create_op, modify_time, modify_op,
pl_rate, service_tel, pl_picture_path, busi_circle, remark, pl_area_block_id, pl_area_block_name,
pl_busi_type, org_id, org_name, is_special,area_type,area_card_limit_num,support_etc,park_position,is_self_parking,is_upload_third
</sql>
<!-- 通过geoHash查询停车场信息 -->
<select id="queryParkingLotByGeoHash" parameterType="java.util.Set" resultMap="ParkingLotAndGeoInfoResultMap">
<foreach collection="geoHashs" item="geoHash" index="index" separator=" union all ">
SELECT
lot.*,
geo.pl_id as geo_pl_id,
geo.geo_id as geo_geo_id,
geo.lon_id as geo_lon_id,
geo.lat_id as geo_lat_id,
geo.geo_no as geo_geo_no,
geo.geo_type as geo_geo_type
FROM
parking_lot lot
JOIN parking_lot_geo geo on geo.pl_no = lot.pl_no
where lot.data_status = 1 and geo.geo_no like concat('${geoHash}','%')
</foreach>
</select>
<!-- 根据GeoHash和给定的经纬度查询符合条件的条数 -->
<select id="queryTabParkCountByDistance" parameterType="java.util.Set" resultType="java.lang.Long">
select count(1) from (
<foreach collection="geoHashs" item="geoHash" index="index" separator=" union all ">
SELECT
lot.*,
geo.lon_id as geo_lon_id,
geo.lat_id as geo_lat_id,
geo.geo_no as geo_geo_no,
geo.geo_type as geo_geo_type
FROM
parking_lot lot
LEFT JOIN parking_lot_geo geo on geo.pl_no = lot.pl_no
where lot.data_status = 1 and geo.geo_no like concat('${geoHash}','%')
</foreach>
) parkInfo
</select>
<!-- 查询停车场信息 -->
<select id="queryParkingLotAndGeo" parameterType="com.zteits.park.domain.ParkingLot"
resultMap="ParkingLotAndGeoInfoResultMap">
SELECT
lot.*,
geo.pl_id as geo_pl_id,
geo.geo_id as geo_geo_id,
geo.lon_id as geo_lon_id,
geo.lat_id as geo_lat_id,
geo.geo_no as geo_geo_no,
geo.geo_type as geo_geo_type
FROM
parking_lot lot
JOIN parking_lot_geo geo on geo.pl_no = lot.pl_no
where lot.data_status = 1
<if test="state!=null and state!=''">
AND lot.state = #{state}
</if>
</select>
<!-- 通过区县分组获取停车场统计信息 -->
<select id="statisticParkLotCountByCountry" resultType="com.zteits.park.domain.ParkingLotCountStatisticByCountryDO">
SELECT
pl_city_id as plCityId,
pl_city_name as plCityName,
pl_country_id as plCountryId,
pl_country_name as plCountryName,
count(1) as parkLotCount,
sum(pl_berth_num) as totalBerths
FROM
parking_lot
WHERE
data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test="cityId!=null and cityId!=''">
AND pl_city_id = #{cityId}
</if>
GROUP BY
pl_city_id,pl_city_name,pl_country_id,pl_country_name;
</select>
<!-- 通过城市id查询停车场信息 -->
<select id="queryParkLotByCountry" resultType="com.zteits.park.domain.ParkingLot">
SELECT pl_city_id as plCityId ,pl_name as plName , pl_no as plNo,
pl_country_id as plCountryId,pl_country_name as plCountryName
FROM
parking_lot
WHERE
data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test="cityId!=null and cityId!=''">
AND pl_city_id = #{cityId}
</if>
</select>
<!-- 通过城市id查询停车场信息 -->
<select id="queryParkLotByProvAndCity" resultType="com.zteits.park.domain.ParkingLot">
SELECT
pl_id as plId, pl_name as plName, pl_no as plNo, state as state,
source_type as sourceType, pl_province_id as plProvinceId,
pl_province_name as plProvinceName, pl_city_id as plCityId,
pl_city_name as plCityName, pl_country_id as plCountryId, pl_country_name as plCountryName,
pl_address as plAddress, pl_berth_num as plBerthNum, pl_pay_type as plPayType,
pl_charge_num as plChargeNum, pl_type as plType, pl_type_prop as plTypeProp,
pl_entrance_num as plEntranceNum,
pl_exit_num as plExitNum, data_status as dataStatus,
pl_out_no as plOutNo,
pl_rate as plRate, service_tel as serviceTel, pl_picture_path as plPicturePath,
busi_circle as busiCircle,
org_id as orgId,org_name as orgName
FROM
parking_lot
WHERE
data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test="provId!=null and provId!=''">
AND pl_province_id = #{provId}
</if>
<if test="cityId!=null and cityId!=''">
AND pl_city_id = #{cityId}
</if>
</select>
<!-- 通过城市id,区县id,停车场名称或地址查询停车场信息 -->
<select id="queryParkLotByCountryAndParkName" resultType="com.zteits.park.domain.ParkingLot">
SELECT
pl_id as plId, pl_name as plName, pl_no as plNo, state as state,
source_type as sourceType, pl_province_id as plProvinceId,
pl_province_name as plProvinceName, pl_city_id as plCityId,
pl_city_name as plCityName, pl_country_id as plCountryId, pl_country_name as plCountryName,
pl_address as plAddress, pl_berth_num as plBerthNum, pl_pay_type as plPayType,
pl_charge_num as plChargeNum, pl_type as plType, pl_type_prop as plTypeProp,
pl_entrance_num as plEntranceNum,
pl_exit_num as plExitNum, data_status as dataStatus,
pl_out_no as plOutNo,
pl_rate as plRate, service_tel as serviceTel, pl_picture_path as plPicturePath,
busi_circle as busiCircle,org_id as orgId,org_name as orgName,area_type as areaType,
area_card_limit_num as areaCardLimitNum
FROM parking_lot
WHERE
data_status = 1
<if test="plNos != null and plNos.size()>0">
and pl_no IN
<foreach collection="plNos" open="(" close=")" separator="," item="plNo">
#{plNo}
</foreach>
</if>
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test=" plTypes != null and plTypes.size()>0">
and pl_type in
<foreach collection="plTypes" open="(" close=")" separator="," item="plType">
#{plType}
</foreach>
</if>
<if test="cityId !=null and cityId !=''">
AND pl_city_id = #{cityId}
</if>
<if test="countryIds != null and countryIds.size()>0">
and pl_country_id IN
<foreach collection="countryIds" open="(" close=")" separator="," item="countryId">
#{countryId}
</foreach>
</if>
<if test="parkNameOrAddress !=null and parkNameOrAddress !=''">
AND (pl_name like concat('%',#{parkNameOrAddress},'%') OR pl_address like
concat('%',#{parkNameOrAddress},'%'))
</if>
GROUP BY pl_id
</select>
<!--查询停车场及停车场经纬度信息 -->
<select id="queryParkingLotAndGeoInfo" parameterType="com.zteits.park.domain.ParkingLotAndGeoDO"
resultType="com.zteits.park.domain.ParkinglotHeatmapHour">
SELECT
a.pl_no as plNo,
a.pl_name as plName,
a.pl_province_id as plProvinceId,
a.pl_province_name as plProvinceName,
a.pl_city_id as plCityId,
a.pl_city_name as plCityName,
a.pl_country_id as plCountryId,
a.pl_country_name as plCountryName,
b.lon_id as lon,
b.lat_id as lat
FROM
parking_lot a,
parking_lot_geo b
WHERE
a.pl_no = b.pl_no
AND a.data_status = 1
<if test="state!=null and state!=''">
AND a.state = #{state}
</if>
<if test="plProvinceId !=null and plProvinceId !=''">
AND a.pl_province_id = #{plProvinceId}
</if>
<if test="plCityId !=null and plCityId !=''">
AND a.pl_city_id = #{plCityId}
</if>
<if test="geoType !=null and geoType !=''">
AND b.geo_type = #{geoType}
</if>
<if test="lonLatType != null and lonLatType!=''">
AND b.lon_lat_type=#{lonLatType}
</if>
<if test="lonLatType == null or lonLatType ==''">
AND b.lon_lat_type=1
</if>
</select>
<select id="queryPlNoCountryAndParkNameAndAddress" resultType="java.lang.String">
SELECT pl_no FROM parking_lot
WHERE
data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test="countryIds != null and countryIds.size()>0">
and pl_country_id IN
<foreach collection="countryIds" open="(" close=")" separator="," item="countryId">
#{countryId}
</foreach>
</if>
<if test="searchText !=null and searchText !=''">
AND (pl_name like concat('%',#{searchText},'%') OR pl_address like
concat('%',#{searchText},'%'))
</if>
</select>
<select id="queryParkingLotByPark" parameterType="com.zteits.park.domain.ParkingLotQueryPageDO"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
FROM parking_lot
WHERE 1=1
and data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<!-- 系统管理查询所需字段 -->
<if test="plName != null and plName !='' ">
and pl_name like '%${plName}%'
</if>
<if test="plProvinceId !=null ">
and pl_province_id =#{plProvinceId}
</if>
<if test="plCityId !=null ">
and pl_city_id =#{plCityId}
</if>
<!-- 企业云平台需要的查询字段 -->
<if test="plAreaBlockIds != null and plAreaBlockIds.size >0">
and pl_area_block_id in
<foreach collection="plAreaBlockIds" open="(" close=")" item="plAreaBlockId" separator=",">
#{plAreaBlockId}
</foreach>
</if>
<if test="plType !=null and plType != '-1' ">
and pl_type =#{plType}
</if>
<if test="plNos != null and plNos.size >0">
and pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
GROUP BY pl_id
</select>
<!-- 通过停车场对象查出停车场信息 -->
<!--Parking information is identified through parking lot objects langlw 2017-9-11 -->
<select id="queryParkListByPark" parameterType="com.zteits.clouds.api.dto.park.param.QueryParkListByParkRequest"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
FROM parking_lot
WHERE 1=1
and data_status = 1
<if test="state!=null ">
AND state = #{state}
</if>
<if test="plType !=null ">
and pl_type = #{plType}
</if>
<if test="sourceTypes != null and sourceTypes.size >0">
and source_type in
<foreach collection="sourceTypes" open="(" close=")" item="sourceType" separator=",">
#{sourceType}
</foreach>
</if>
<if test="plProvinceIds != null and plProvinceIds.size >0">
and pl_province_id in
<foreach collection="plProvinceIds" open="(" close=")" item="plProvinceId" separator=",">
#{plProvinceId}
</foreach>
</if>
<if test="plCityIds != null and plCityIds.size >0">
and pl_city_id in
<foreach collection="plCityIds" open="(" close=")" item="plCityId" separator=",">
#{plCityId}
</foreach>
</if>
<if test="plCountryIds != null and plCountryIds.size >0">
and pl_country_id in
<foreach collection="plCountryIds" open="(" close=")" item="plCountryId" separator=",">
#{plCountryId}
</foreach>
</if>
<if test="plAreaBlockIds != null and plAreaBlockIds.size >0">
and pl_area_block_id in
<foreach collection="plAreaBlockIds" open="(" close=")" item="plAreaBlockId" separator=",">
#{plAreaBlockId}
</foreach>
</if>
<if test="isUploadThird !=null and isUploadThird!=''">
and is_upload_third = #{isUploadThird}
</if>
</select>
<select id="queryBerthNoByPlnos" parameterType="java.util.List" resultType="java.lang.Long">
SELECT
IFNULL(sum(case when pl_berth_num is null then
0
else
pl_berth_num
end),0)
FROM parking_lot WHERE pl_no in
<foreach collection="plNos" index="index" item="plNo" separator="," open="(" close=")">
#{plNo}
</foreach>
</select>
<!--通过区域块ids查询停车场列表-->
<select id="queryParkInfoByAreaBlockIds" resultType="com.zteits.park.domain.AreaTreeDO">
select
a.pl_no as plNo,
a.pl_name as areaName,
a.pl_area_block_id as parentId,
a.pl_busi_type as plBusiType
from parking_lot a
where a.data_status=1
<if test="state!=null and state!=''">
AND a.state = #{state}
</if>
and a.pl_area_block_id in
<foreach collection="areaIds" index="index" item="blockId" separator="," open="(" close=")">
#{blockId}
</foreach>
order by a.pl_name
</select>
<!-- 查询最大的plNo -->
<select id="queryMaxPlNoByPlCountryId" resultType="java.lang.String">
SELECT max(right(pl_no,length(pl_no)-1)) FROM parking_lot
WHERE pl_country_id = #{plCountryId}
</select>
<!-- 通过区县分组获取停车场统计信息区分路内路外 langlw 2017-9-6 -->
<select id="statisticParkLotCountByCountryForPlType"
resultType="com.zteits.park.domain.ParkingLotCountStatisticByCountryDO">
SELECT
pl_city_id as plCityId,
pl_city_name as plCityName,
pl_country_id as plCountryId,
pl_country_name as plCountryName,
count(1) as parkLotCount,
sum(pl_berth_num) as totalBerths,
pl_type as plType
FROM
parking_lot
WHERE
data_status = 1
<if test="state!=null and state!=''">
AND state = #{state}
</if>
<if test="cityId!=null and cityId!=''">
AND pl_city_id = #{cityId}
</if>
GROUP BY
pl_city_id,pl_city_name,pl_country_id,pl_country_name,pl_type
</select>
<!-- 根据停车场编号更新当前停车场车位数量 -->
<update id="updateParkBerthNumByPlNo" parameterType="com.zteits.park.domain.ParkingLot">
UPDATE parking_lot
SET pl_berth_num = #{plBerthNum}
WHERE pl_no = #{plNo}
</update>
<!-- 查询多有停车上编码及名称 -->
<select id="queryParkListAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from parking_lot a
where a.data_status=1
and a.state=1
</select>
<select id="queryAllPlNo" parameterType="java.lang.Integer" resultType="java.util.List">
SELECT DISTINCT pl_no
FROM parking_lot t1
WHERE 1 = 1
<if test="null != state">
AND state = #{state}
</if>
</select>
<select id="queryParkTempInfoPage" resultType="com.zteits.clouds.api.dto.pay.TdBTempParklotDTO">
SELECT
m.pl_no plNo,
m.pl_name plName,
m.pl_area_block_id blockNo,
m.pl_area_block_name blockName,
n.park_area_code berthRangeNo,
n.park_area_name berthRangeName,
m.pl_berth_num berths
FROM parking_lot m
LEFT JOIN tp_p_region_area n
ON m.data_status = 1
AND m.state = 1
AND m.pl_no = n.pl_no
AND n.data_state = 1
</select>
<!--通过服务点id查询停车场-->
<select id="queryParkingLotByAreaBlockId" parameterType="com.zteits.clouds.api.dto.park.param.QueryParkingLotByAreaBlockRequest"
resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
parking_lot
WHERE
data_status = 1
<if test="blockIds !=null and blockIds.size>0">
AND pl_area_block_id in
<foreach collection="blockIds" open="(" close=")" separator="," item="blockId">
#{blockId}
</foreach>
</if>
<if test="plNos !=null and plNos.size>0">
AND pl_no in
<foreach collection="plNos" open="(" close=")" separator="," item="parkNo">
#{parkNo}
</foreach>
</if>
<if test="parkName !=null and parkName!=''">
AND (pl_address like concat('%',#{parkName},'%') or pl_name like concat('%',#{parkName},'%'))
</if>
<if test="plNo !=null and plNo!=''">
and pl_no = #{plNo}
</if>
<if test="orgId !=null and orgId!=''">
and org_id = #{orgId}
</if>
<if test="plType !=null ">
and pl_type = #{plType}
</if>
<if test="isSpecial !=null and isSpecial!=''">
and is_special = #{isSpecial}
</if>
<if test="plBusiType !=null ">
and pl_busi_type = #{plBusiType}
</if>
order by pl_area_block_name,pl_name
</select>
<!-- 校验停车场名称唯一性 -->
<select id="checkUniqueForPlName" parameterType="com.zteits.clouds.api.dto.pay.param.CheckUniqueForPlNameRequest" resultType="java.lang.Integer">
SELECT
count(1)
FROM
parking_lot
WHERE
data_status = 1
and pl_name = #{plName}
</select>
<!--更新停车场块信息-->
<update id="updateBlockForParkLot" parameterType="com.zteits.clouds.api.dto.pay.param.ChangeBlockForParkLotRequest">
update parking_lot
<set>
<if test="plAreaBlockId != null">
pl_area_block_id = #{plAreaBlockId,jdbcType=BIGINT},
</if>
<if test="plAreaBlockName != null">
pl_area_block_name = #{plAreaBlockName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyOp != null">
modify_op = #{modifyOp,jdbcType=BIGINT}
</if>
</set>
where data_status = 1
<if test="plNos !=null and plNos.size>0">
and pl_no in
<foreach collection="plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="plAreaBlockId != null">
and pl_area_block_id = #{plAreaBlockId,jdbcType=BIGINT}
</if>
</update>
<!--停车场管理-更新停车场块信息-->
<update id="updateAreaBlockForParkLot" parameterType="com.zteits.clouds.api.dto.pay.param.ChangeBlockForParkLotRequest">
update parking_lot
<set>
<if test="plAreaBlockId != null">
pl_area_block_id = #{plAreaBlockId,jdbcType=BIGINT},
</if>
<if test="plAreaBlockName != null">
pl_area_block_name = #{plAreaBlockName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyOp != null">
modify_op = #{modifyOp,jdbcType=BIGINT}
</if>
</set>
where data_status = 1
and pl_no in
<foreach collection="plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</update>
<!--通过办事处id更新停车场块信息-->
<update id="updateParkLotBlockNameByBlockId" parameterType="com.zteits.clouds.api.dto.pay.param.ChangeBlockForParkLotRequest">
update parking_lot
<set>
<if test="plAreaBlockName != null">
pl_area_block_name = #{plAreaBlockName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyOp != null">
modify_op = #{modifyOp,jdbcType=BIGINT}
</if>
</set>
where data_status = 1
and pl_area_block_id = #{plAreaBlockId,jdbcType=BIGINT}
</update>
<select id="queryParkLotExtByState"
resultMap="ParkingLotExtResultMap">
SELECT m.*,n.free_berth
FROM parking_lot m
LEFT JOIN park_free_berth n
ON m.pl_no = n.pl_no AND m.data_status = 1 AND n.data_status = 1
WHERE 1=1 AND m.state IN
<foreach collection="states" separator="," open="(" close=")" item="state" index="index">
#{state}
</foreach>
</select>
<!-- 通过停车场外部编码查询停车场编码 -->
<select id="queryPlNoByPlOutNo" parameterType="java.lang.String" resultType="java.lang.String">
select pl_no from parking_lot where pl_out_no=#{plOutNo} limit 1
</select>
<!-- 通过停车场外部编码查询停车场总车位数 -->
<select id="queryPlBerthNumByPlOutNo" parameterType="java.lang.String" resultType="java.lang.Integer">
select pl_berth_num from parking_lot where pl_out_no=#{plOutNo} limit 1
</select>
<!-- 通过停车场外部编码查询停车场总车位数 -->
<select id="getOrgIdsByCityIds" parameterType="com.zteits.clouds.api.dto.park.param.parklot.QueryOrgIdsByCityIdsRequest" resultType="java.lang.Long">
select org_id from parking_lot
where data_status = 1
and pl_city_id in
<foreach collection="cityIds" separator="," open="(" close=")" item="cityId" index="index">
#{cityId}
</foreach>
group by org_id
</select>
<!-- 查询停车下面设备数量统计 -->
<select id="queryDeviceStatistic" parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest"
resultType="com.zteits.clouds.api.dto.park.dto.parksource.ParkDeviceStaForEveryDTO">
select 1 deviceType, 'PDA' as deviceName,ifnull(count(*),0) as num , count(case when online_flg = 0 then 1 end ) onNum,
count(case when online_flg = 1 then 1 end ) downNum,count(case when online_flg != 0 and online_flg != 1 then 1 end ) errorNum
from tp_p_pda
where data_state = 1
and org_id in
<foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
#{orgId}
</foreach>
union
select 2 deviceType, '地磁' as deviceName,ifnull(count(*),0) as num , count(case when eqp_is_online = 0 then 1 end ) onNum,
count(case when eqp_is_online = 1 then 1 end ) downNum,count(case when eqp_is_online != 0 and eqp_is_online != 1 then 1 end ) errorNum
from tp_p_eqp
where data_state = 1 and eqp_type = 1
and org_id in
<foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
#{orgId}
</foreach>
and pl_no in
<foreach collection="plNos" separator="," open="(" close=")" item="plNo" index="index">
#{plNo}
</foreach>
union
select 3 deviceType, '诱导屏' as deviceName,ifnull(count(*),0) as num, count(case when led_device_status = 1 then 1 end ) onNum,
count(case when led_device_status = 2 then 1 end ) downNum,count(case when led_device_status != 1 and led_device_status != 2 then 1 end ) errorNum
from td_g_guide_screen
where data_status = 1
and org_id in
<foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
#{orgId}
</foreach>
union
select 4 deviceType, '道闸' as deviceName,0 as num,0 onNum,0 downNum,0 errorNum
</select>
<!-- 停车场数量统计-根据组织id -->
<select id="queryParkNumStatisticByOrgIds" parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest"
resultType="java.lang.Integer">
select
count(*)
from parking_lot pl
where pl.data_status = 1 and state = 1 and pl.pl_busi_type = 1
and pl.org_id in
<foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
#{orgId}
</foreach>
</select>
<select id="queryParkDutyInfo" resultType="com.zteits.clouds.api.dto.tool.dto.ParkDutyInfoDTO">
SELECT
a.pl_area_block_id areaId,
a.pl_area_block_name areaName,
a.pl_no plNo,
a.pl_name plName,
a.pl_type plType,
b.park_area_code berthRangeId,
b.park_area_name berthRangeName
FROM parking_lot a
LEFT JOIN
tp_p_region_area b ON a.pl_no = b.pl_no AND b.data_state = 1
WHERE a.org_id = #{orgId}
AND a.data_status = 1
</select>
<select id="queryParkNumInfoStatisticByOrgIds"
resultType="com.zteits.clouds.api.dto.park.dto.ParkNumInfoDTO">
select
count(*) allNum,
sum(CASE pl_type WHEN 1 THEN 1 ELSE 0 END ) lcNum,
sum(CASE pl_type WHEN 1 THEN 0 ELSE 1 END ) fbNum
from parking_lot pl
where pl.data_status = 1 and state = 1 and pl.pl_busi_type = 1
and pl.org_id in
<foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
#{orgId}
</foreach>
</select>
<select id="queryBusiPlNameByOrgIds" resultType="java.lang.String">
SELECT pl_no
FROM parking_lot t
WHERE t.data_status = 1
AND t.pl_busi_type = 1
AND t.state = 1
AND t.org_id IN
<foreach collection="orgIds" item="orgId" separator="," open="(" close=")" >
#{orgId}
</foreach>
</select>
<!--根据车场编号查询车场名称 niueb 2019/12/12-->
<select id="queryPlNameByPlNo" parameterType="com.zteits.clouds.api.dto.park.param.QueryPlNameRequest"
resultType="com.zteits.clouds.api.dto.pay.PlNameDTO">
select
a.pl_no as plNo,
a.pl_name as plName,
a.org_id as orgId
from parking_lot a
where
a.data_status = 1
<if test="orgId != null">
and a.org_id = #{orgId,jdbcType=BIGINT}
</if>
<if test="plName != null and plName!='' ">
and a.pl_name like CONCAT('%', #{plName, jdbcType=VARCHAR},'%')
</if>
and a.pl_no in
<foreach collection="plNoList" item="plNo" separator="," open="(" close=")" >
#{plNo}
</foreach>
</select>
<!--停车场最大编码获取:以 PL 或者 TL 开头的-->
<select id="selectMaxPlNO" resultType="java.lang.String">
SELECT max(pl_no) as plNo
FROM parking_lot
WHERE 1=1
and pl_no like CONCAT(#{prefixStr, jdbcType=VARCHAR},'%')
</select>
</mapper>