上饶市公安局wvp平台
zhongrj
2023-06-27 2e98b20bea4463e4465e3c19059d0744a09aec06
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
package com.genersoft.iot.vmp.storager.dao;
 
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform;
import com.genersoft.iot.vmp.gb28181.vo.DeviceChannelVO;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.vo.PageVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
 
import java.util.List;
import java.util.Map;
 
/**
 * 用于存储设备通道信息
 */
@Mapper
@Repository
public interface DeviceChannelMapper {
 
    @Insert("INSERT INTO device_channel (coordinate,channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
            "address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
            "ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
            "longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
            "VALUES (ST_GeomFromText(${coordinate}),'${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
            "'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
            "'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, " +
            "${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, ${hasAudio}, '${createTime}', '${updateTime}', '${businessGroupId}', '${gpsTime}')")
    int add(DeviceChannel channel);
 
    @Update(value = {" <script>" +
            "UPDATE device_channel " +
            "SET updateTime='${updateTime}'" +
            "<if test='coordinate != null'>, coordinate=ST_GeomFromText(${coordinate})</if>" +
            "<if test='name != null'>, name='${name}'</if>" +
            "<if test='manufacture != null'>, manufacture='${manufacture}'</if>" +
            "<if test='model != null'>, model='${model}'</if>" +
            "<if test='owner != null'>, owner='${owner}'</if>" +
            "<if test='civilCode != null'>, civilCode='${civilCode}'</if>" +
            "<if test='block != null'>, block='${block}'</if>" +
            "<if test='address != null'>, address='${address}'</if>" +
            "<if test='parental != null'>, parental=${parental}</if>" +
            "<if test='parentId != null'>, parentId='${parentId}'</if>" +
            "<if test='safetyWay != null'>, safetyWay=${safetyWay}</if>" +
            "<if test='registerWay != null'>, registerWay=${registerWay}</if>" +
            "<if test='certNum != null'>, certNum='${certNum}'</if>" +
            "<if test='certifiable != null'>, certifiable=${certifiable}</if>" +
            "<if test='errCode != null'>, errCode=${errCode}</if>" +
            "<if test='secrecy != null'>, secrecy='${secrecy}'</if>" +
            "<if test='ipAddress != null'>, ipAddress='${ipAddress}'</if>" +
            "<if test='port != null'>, port=${port}</if>" +
            "<if test='password != null'>, password='${password}'</if>" +
            "<if test='PTZType != null'>, PTZType=${PTZType}</if>" +
            "<if test='status != null'>, status='${status}'</if>" +
            "<if test='streamId != null'>, streamId='${streamId}'</if>" +
            "<if test='hasAudio != null'>, hasAudio=${hasAudio}</if>" +
            "<if test='longitude != null'>, longitude=${longitude}</if>" +
            "<if test='latitude != null'>, latitude=${latitude}</if>" +
            "<if test='longitudeGcj02 != null'>, longitudeGcj02=${longitudeGcj02}</if>" +
            "<if test='latitudeGcj02 != null'>, latitudeGcj02=${latitudeGcj02}</if>" +
            "<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
            "<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
            "<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
            "<if test='gpsTime != null'>, gpsTime=#{gpsTime}</if>" +
            "WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
            " </script>"})
    int update(DeviceChannel channel);
 
    /**
     * 查询设备列表信息
     * @param deviceId
     * @param parentChannelId
     * @param query
     * @param type
     * @param hasSubChannel
     * @param dwbh
     * @param online
     * @return
     */
    @Select(value = {" <script>" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "dc.manufacture,\n" +
            "dc.model,\n" +
            "dc.`owner`,\n" +
            "dc.civilCode,\n" +
            "dc.block,\n" +
            "dc.address,\n" +
            "dc.parentId,\n" +
            "dc.safetyWay,\n" +
            "dc.registerWay,\n" +
            "dc.certNum,\n" +
            "dc.certifiable,\n" +
            "dc.errCode,\n" +
            "dc.endTime,\n" +
            "dc.secrecy,\n" +
            "ST_ASTEXT (coordinate) as coordinate," +
            "dc.ipAddress,dc.`port`,dc.`password`,dc.PTZType,dc.`status`,dc.streamId,dc.deviceId,\n" +
            "dc.parental,dc.hasAudio,dc.createTime,dc.updateTime,dc.subCount," +
            "dc.latitude," +
            "dc.longitude " +
            "from " +
            "device_channel dc " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "   inner join device_channel_dept dcd on dc.id = dcd.device_channel_id \n " +
            " </if> " +
            "WHERE " +
            "dc.deviceId = #{deviceId}" +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "     and dcd.dept_id = #{dwbh}\n " +
            " </if> " +
            " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
            " <if test='type == 0' > AND dc.name like '%信州%' AND dc.name like '%赣E%'</if>" +
            " <if test='type == 1' > AND dc.name LIKE '02%' AND dc.name not like '%赣E%' and dc.ipAddress is not null and dc.ipAddress != '' </if>" +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            " <if test='hasSubChannel == true' >  AND dc.subCount > 0 </if>" +
            " <if test='hasSubChannel == false' >  AND dc.subCount = 0 </if>" +
            " order by dc.`status` desc,dc.channelId desc" +
            " </script>"})
    List<DeviceChannelVO> queryChannelsCar(String deviceId,
                                           String parentChannelId,
                                           String query,
                                           String type,
                                           Boolean hasSubChannel,
                                           String dwbh,
                                           Boolean online);
 
    @Select(value = {" <script>" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "dc.manufacture,\n" +
            "dc.model,\n" +
            "dc.`owner`,\n" +
            "dc.civilCode,\n" +
            "dc.block,\n" +
            "dc.address,\n" +
            "dc.parentId,\n" +
            "dc.safetyWay,\n" +
            "dc.registerWay,\n" +
            "dc.certNum,\n" +
            "dc.certifiable,\n" +
            "dc.errCode,\n" +
            "dc.endTime,\n" +
            "dc.secrecy,\n" +
            "dc.ipAddress,dc.`port`,dc.`password`,dc.PTZType,dc.`status`,dc.streamId,dc.deviceId,\n" +
            "dc.parental,dc.hasAudio,dc.createTime,dc.updateTime,dc.subCount," +
            "any_value ( CASE WHEN dc.latitude = 0 THEN dmp.latitude ELSE dc.latitude END ) AS latitude," +
            "any_value ( CASE WHEN dc.longitude = 0 THEN dmp.longitude ELSE dc.longitude END ) AS longitude, " +
            "ST_AsGeoJSON ( dc.coordinate ) AS coordinates " +
            "from " +
            "device_channel dc " +
            "LEFT JOIN ( SELECT " +
            "deviceId,ANY_VALUE(longitude)as longitude,ANY_VALUE(latitude) as latitude,ANY_VALUE(time) as time " +
            "FROM" +
            "( SELECT * FROM device_mobile_position ORDER BY time DESC LIMIT 1000 ) t " +
            "GROUP BY" +
            " deviceId ) dmp ON dc.deviceId = dmp.deviceId " +
            "WHERE  1=1 " +
            "and ST_CONTAINS ( ST_POLYGONFROMTEXT ( 'POLYGON((${range}))' ), dc.coordinate )" +
            " <if test='query!=null ' > AND dc.name LIKE '%${query}%'</if>" +
            " </script>"})
    List<DeviceChannel> SpatialQueryList(String range, String query);
 
    @Select(value = {" <script>" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "dc.manufacture,\n" +
            "dc.model,\n" +
            "dc.`owner`,\n" +
            "dc.civilCode,\n" +
            "dc.block,\n" +
            "dc.address,\n" +
            "dc.parentId,\n" +
            "dc.safetyWay,\n" +
            "dc.registerWay,\n" +
            "dc.certNum,\n" +
            "dc.certifiable,\n" +
            "dc.errCode,\n" +
            "dc.endTime,\n" +
            "dc.secrecy,\n" +
            "ST_ASTEXT (coordinate) as coordinate," +
            "dc.ipAddress,dc.`port`,dc.`password`,dc.PTZType,dc.`status`,dc.streamId,dc.deviceId,\n" +
            "dc.parental,dc.hasAudio,dc.createTime,dc.updateTime,dc.subCount," +
            "any_value ( CASE WHEN dc.latitude = 0 THEN dmp.latitude ELSE dc.latitude END ) AS latitude," +
            "any_value ( CASE WHEN dc.longitude = 0 THEN dmp.longitude ELSE dc.longitude END ) AS longitude " +
            "from " +
            "device_channel dc " +
            "LEFT JOIN (SELECT * FROM device_mobile_position WHERE deviceId = #{deviceId} ORDER BY time desc limit 1) dmp ON dc.channelId = dmp.deviceId " +
            "WHERE " +
            "dc.deviceId = #{deviceId} " +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            " <if test='hasSubChannel == true' >  AND dc.subCount > 0 </if>" +
            " <if test='hasSubChannel == false' >  AND dc.subCount = 0 </if>" +
            "order by dc.status desc " +
            " </script>"})
    List<DeviceChannel> queryChannels(String deviceId,
                                      String parentChannelId,
                                      String query,
                                      Boolean hasSubChannel,
                                      Boolean online,
                                      String deptId);
 
    @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
    DeviceChannel queryChannel(String deviceId, String channelId);
 
    @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}")
    int cleanChannelsByDeviceId(String deviceId);
 
    @Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
    int del(String deviceId, String channelId);
 
    @Update(value = {"UPDATE device_channel SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
    void stopPlay(String deviceId, String channelId);
 
    @Update(value = {"UPDATE device_channel SET streamId=#{streamId} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
    void startPlay(String deviceId, String channelId, String streamId);
 
    @Select(value = {" <script>" +
            "SELECT " +
            "    dc.id,\n" +
            "    dc.channelId,\n" +
            "    dc.deviceId,\n" +
            "    dc.name,\n" +
            "    de.manufacture,\n" +
            "    de.hostAddress,\n" +
            "    dc.subCount,\n" +
            "    pgc.platformId as platformId,\n" +
            "    pgc.catalogId as catalogId " +
            " FROM device_channel dc " +
            "LEFT JOIN device de ON dc.deviceId = de.deviceId " +
            "LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
            " WHERE 1=1 " +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test='online == true' > AND dc.status=1</if> " +
            " <if test='online == false' > AND dc.status=0</if> " +
            " <if test='hasSubChannel!= null and hasSubChannel == true' >  AND dc.subCount > 0</if> " +
            " <if test='hasSubChannel!= null and hasSubChannel == false' >  AND dc.subCount = 0</if> " +
            " <if test='catalogId == null ' >  AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " +
            " <if test='catalogId != null ' >  AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " +
            " ORDER BY dc.deviceId, dc.channelId ASC" +
            " </script>"})
    List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId);
 
    @Select(value = {" <script>" +
            "SELECT " +
            "    dc.*,\n" +
            "    pgc.platformId as platformId,\n" +
            "    pgc.catalogId as catalogId " +
            " FROM device_channel dc " +
            " LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
            " WHERE pgc.platformId = #{platformId} " +
            " ORDER BY dc.deviceId, dc.channelId ASC" +
            " </script>"})
    List<DeviceChannelInPlatform> queryChannelByPlatformId(String platformId);
 
 
    @Select("SELECT * FROM device_channel WHERE channelId=#{channelId}")
    List<DeviceChannel> queryChannelByChannelId( String channelId);
 
    @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
    void offline(String deviceId,  String channelId);
 
    @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId}"})
    void offlineByDeviceId(String deviceId);
 
    @Insert("<script> " +
            "insert into device_channel " +
            "(coordinate,channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " +
            "  address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
            "  ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
            "  longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " +
            "values " +
            "<foreach collection='addChannels' index='index' item='item' separator=','> " +
            "(ST_GeomFromText(${item.coordinate}),'${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
            "'${item.owner}', '${item.civilCode}', '${item.block}',${item.subCount}," +
            "'${item.address}', ${item.parental}, '${item.parentId}', ${item.safetyWay}, ${item.registerWay}, " +
            "'${item.certNum}', ${item.certifiable}, ${item.errCode}, '${item.secrecy}', " +
            "'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
            "'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
            "${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84}, ${item.hasAudio},'${item.createTime}', '${item.updateTime}', " +
            "'${item.businessGroupId}', '${item.gpsTime}') " +
            "</foreach> " +
            "ON DUPLICATE KEY UPDATE " +
            "updateTime=VALUES(updateTime), " +
            "name=VALUES(name), " +
            "manufacture=VALUES(manufacture), " +
            "model=VALUES(model), " +
            "owner=VALUES(owner), " +
            "civilCode=VALUES(civilCode), " +
            "block=VALUES(block), " +
            "subCount=VALUES(subCount), " +
            "address=VALUES(address), " +
            "parental=VALUES(parental), " +
            "parentId=VALUES(parentId), " +
            "safetyWay=VALUES(safetyWay), " +
            "registerWay=VALUES(registerWay), " +
            "certNum=VALUES(certNum), " +
            "certifiable=VALUES(certifiable), " +
            "errCode=VALUES(errCode), " +
            "secrecy=VALUES(secrecy), " +
            "ipAddress=VALUES(ipAddress), " +
            "port=VALUES(port), " +
            "password=VALUES(password), " +
            "PTZType=VALUES(PTZType), " +
            "status=VALUES(status), " +
            "streamId=VALUES(streamId), " +
            "longitude=VALUES(longitude), " +
            "latitude=VALUES(latitude), " +
            "longitudeGcj02=VALUES(longitudeGcj02), " +
            "latitudeGcj02=VALUES(latitudeGcj02), " +
            "longitudeWgs84=VALUES(longitudeWgs84), " +
            "latitudeWgs84=VALUES(latitudeWgs84), " +
            "hasAudio=VALUES(hasAudio), " +
            "businessGroupId=VALUES(businessGroupId), " +
            "gpsTime=VALUES(gpsTime)" +
            "</script>")
    int batchAdd(List<DeviceChannel> addChannels);
 
    @Update(value = {"UPDATE device_channel SET status=1 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
    void online(String deviceId,  String channelId);
 
    @Update({"<script>" +
            "<foreach collection='updateChannels' item='item' separator=';'>" +
            " UPDATE" +
            " device_channel" +
            " SET updateTime='${item.updateTime}'" +
            "<if test='item.coordinate != null'>, coordinate=ST_GeomFromText(${item.coordinate})</if>" +
            "<if test='item.name != null'>, name='${item.name}'</if>" +
            "<if test='item.manufacture != null'>, manufacture='${item.manufacture}'</if>" +
            "<if test='item.model != null'>, model='${item.model}'</if>" +
            "<if test='item.owner != null'>, owner='${item.owner}'</if>" +
            "<if test='item.civilCode != null'>, civilCode='${item.civilCode}'</if>" +
            "<if test='item.block != null'>, block='${item.block}'</if>" +
            "<if test='item.subCount != null'>, block=${item.subCount}</if>" +
            "<if test='item.address != null'>, address='${item.address}'</if>" +
            "<if test='item.parental != null'>, parental=${item.parental}</if>" +
            "<if test='item.parentId != null'>, parentId='${item.parentId}'</if>" +
            "<if test='item.safetyWay != null'>, safetyWay=${item.safetyWay}</if>" +
            "<if test='item.registerWay != null'>, registerWay=${item.registerWay}</if>" +
            "<if test='item.certNum != null'>, certNum='${item.certNum}'</if>" +
            "<if test='item.certifiable != null'>, certifiable=${item.certifiable}</if>" +
            "<if test='item.errCode != null'>, errCode=${item.errCode}</if>" +
            "<if test='item.secrecy != null'>, secrecy='${item.secrecy}'</if>" +
            "<if test='item.ipAddress != null'>, ipAddress='${item.ipAddress}'</if>" +
            "<if test='item.port != null'>, port=${item.port}</if>" +
            "<if test='item.password != null'>, password='${item.password}'</if>" +
            "<if test='item.PTZType != null'>, PTZType=${item.PTZType}</if>" +
            "<if test='item.status != null'>, status='${item.status}'</if>" +
            "<if test='item.streamId != null'>, streamId='${item.streamId}'</if>" +
            "<if test='item.hasAudio != null'>, hasAudio=${item.hasAudio}</if>" +
            "<if test='item.longitude != null'>, longitude=${item.longitude}</if>" +
            "<if test='item.latitude != null'>, latitude=${item.latitude}</if>" +
            "<if test='item.longitudeGcj02 != null'>, longitudeGcj02=${item.longitudeGcj02}</if>" +
            "<if test='item.latitudeGcj02 != null'>, latitudeGcj02=${item.latitudeGcj02}</if>" +
            "<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
            "<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
            "<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" +
            "<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" +
            "WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
            "</foreach>" +
            "</script>"})
    int batchUpdate(List<DeviceChannel> updateChannels);
 
 
    @Select(value = {" <script>" +
            "SELECT " +
            "dc1.* " +
            "from " +
            "device_channel dc1 " +
            "WHERE " +
            "dc1.deviceId = #{deviceId} " +
            " <if test='query != null'> AND (dc1.channelId LIKE '%${query}%' OR dc1.name LIKE '%${query}%' OR dc1.name LIKE '%${query}%')</if> " +
            " <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
            " <if test='online == true' > AND dc1.status=1</if>" +
            " <if test='online == false' > AND dc1.status=0</if>" +
            " <if test='hasSubChannel == true' >  AND dc1.subCount >0</if>" +
            " <if test='hasSubChannel == false' >  AND dc1.subCount=0</if>" +
            "ORDER BY dc1.channelId ASC " +
            "Limit #{limit} OFFSET #{start}" +
            " </script>"})
    List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
                                                                 Boolean hasSubChannel, Boolean online, int start, int limit);
 
    @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
    List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
 
    @Delete(value = {" <script>" +
            "DELETE " +
            "from " +
            "device_channel " +
            "WHERE " +
            "deviceId = #{deviceId} " +
            " AND channelId NOT IN " +
            "<foreach collection='channels'  item='item'  open='(' separator=',' close=')' > #{item.channelId}</foreach>" +
            " </script>"})
    int cleanChannelsNotInList(String deviceId, List<DeviceChannel> channels);
 
    @Update(" update device_channel" +
            " set subCount = (select *" +
            "                from (select count(0)" +
            "                      from device_channel" +
            "                      where deviceId = #{deviceId} and parentId = #{channelId}) as temp)" +
            " where deviceId = #{deviceId} " +
            " and channelId = #{channelId}")
    int updateChannelSubCount(String deviceId, String channelId);
 
    @Update(value = {" <script>" +
            "UPDATE device_channel " +
            "SET " +
            "latitude=${latitude}, " +
            "longitude=${longitude}, " +
            "longitudeGcj02=${longitudeGcj02}, " +
            "latitudeGcj02=${latitudeGcj02}, " +
            "longitudeWgs84=${longitudeWgs84}, " +
            "latitudeWgs84=${latitudeWgs84}, " +
            "coordinate=ST_GeomFromText(${coordinate}), " +
            "gpsTime='${gpsTime}' " +
            "WHERE deviceId=#{deviceId} " +
            " <if test='channelId != null' >  AND channelId=#{channelId}</if>" +
            " </script>"})
    void updatePosition(DeviceChannel deviceChannel);
 
    @Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0")
    List<DeviceChannel> getAllChannelInPlay();
 
    @Select("select * from device_channel where longitude*latitude > 0 and deviceId = #{deviceId}")
    List<DeviceChannel> getAllChannelWithCoordinate(String deviceId);
 
 
    @Select(value = {" <script>" +
            "select * " +
            "from device_channel " +
            "where deviceId=#{deviceId}" +
            " <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} </if>" +
            " <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=${length} </if>" +
            " <if test='parentId == null and length == null' > and parentId = #{parentId} </if>" +
            " <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} </if>" +
            " </script>"})
    List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);
 
    @Select(value = {" <script>" +
            "select * " +
            "from device_channel " +
            "where deviceId=#{deviceId} and length(channelId)>14 and civilCode=#{parentId}" +
            " </script>"})
    List<DeviceChannel> getChannelsByCivilCode(String deviceId, String parentId);
 
    @Select("select min(length(channelId)) as minLength " +
            "from device_channel " +
            "where deviceId=#{deviceId}")
    Integer getChannelMinLength(String deviceId);
 
    @Select("select * from device_channel where deviceId=#{deviceId} and civilCode not in " +
            "(select civilCode from device_channel where deviceId=#{deviceId} group by civilCode)")
    List<DeviceChannel> getChannelWithoutCiviCode(String deviceId);
 
    @Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
    List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
 
    @Select("select dc.id, dc.channelId, dc.deviceId, dc.name, dc.manufacture,dc.model,dc.owner, pc.civilCode,dc.block, " +
            " dc.address, '0' as parental,'0' as channelType, pc.id as parentId, dc.safetyWay, dc.registerWay,dc.certNum, dc.certifiable,  " +
            " dc.errCode,dc.endTime, dc.secrecy,   dc.ipAddress,  dc.port,  dc.PTZType,  dc.password, dc.status, " +
            " dc.longitudeWgs84 as longitude, dc.latitudeWgs84 as latitude,  pc.businessGroupId " +
            " from device_channel dc" +
            " left join platform_gb_channel pgc on  dc.id = pgc.deviceChannelId" +
            " left join platform_catalog pc on pgc.catalogId = pc.id and pgc.platformId = pc.platformId" +
            " where pgc.platformId=#{serverGBId}")
    List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
 
    @Select("select * from device_channel where deviceId = #{deviceId}")
    List<DeviceChannel> queryAllChannels(String deviceId);
 
    /**
     * 获取辖区名称
     * @param dwbh
     * @return
     */
    @Select("select dept_name from srjw.blade_dept where id = #{dwbh}")
    String getDeptNameByDwbh(@Param("dwbh") String dwbh);
 
    /**
     * 查询当前辖区对应的设备通道ids
     * @param deptName 辖区名称
     * @return
     */
    @Select("select channelId from wvp.device_channel where name like concat(concat('%',#{deptName}),'%')")
    List<String> getIdsListByDeptName(@Param("deptName") String deptName);
 
 
    /**
     * 查询所有
     * @param deviceId
     * @param parentChannelId
     * @param query
     * @param hasSubChannel
     * @param dwbh
     * @param online
     * @return
     */
    @Select(value = {" <script>" +
            "(SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "0 as type," +
            "dc.status," +
            "dc.latitude," +
            "dc.longitude " +
            "from " +
            "device_channel dc " +
            "JOIN device_channel_dept dcd ON dc.id = dcd.device_channel_id " +
            "WHERE " +
            "dc.deviceId = #{deviceId} AND dc.name like '%信州%' AND dc.name like '%赣E%' "+
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "            and dcd.dept_id = #{dwbh}\n" +
            "        </if> " +
            " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            " <if test='hasSubChannel == true' >  AND dc.subCount > 0 </if>" +
            " <if test='hasSubChannel == false' >  AND dc.subCount = 0 </if>" +
            " order by dc.channelId desc " +
            ")  union all (" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "1 as type," +
            "dc.status," +
            "dc.latitude," +
            "dc.longitude " +
            "from " +
            "device_channel dc " +
            "JOIN device_channel_dept dcd ON dc.id = dcd.device_channel_id " +
            "WHERE " +
            "dc.deviceId = #{deviceId} AND dc.name LIKE '02%' AND dc.name not like '%赣E%' and dc.ipAddress is not null and dc.ipAddress != '' " +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "            and dcd.dept_id = #{dwbh}\n" +
            "        </if> " +
            " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            " <if test='hasSubChannel == true' >  AND dc.subCount > 0 </if>" +
            " <if test='hasSubChannel == false' >  AND dc.subCount = 0 </if>" +
            " order by dc.channelId desc " +
            ") union all (" +
            "SELECT " +
            "dc.id,\n" +
            "dc.terminal_number as channelId,\n" +
            "dcd.`name`,\n" +
            "2 as type," +
            "dc.status," +
            "dc.latitude,\n" +
            "dc.longitude \n" +
            "from " +
            "sys_talk_back_equipment dc " +
            "JOIN sys_talk_back_equipment_info dcd ON dc.terminal_number like concat('%',dcd.terminal_number,'%')" +
            "WHERE " +
            "1=1" +
            " <if test='query != null'> AND (dcd.name LIKE '%${query}%' OR dcd.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "            and dcd.dept_id = #{dwbh}\n" +
            "        </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            "ORDER BY dc.receive_time " +
            ") union all (" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "3 as type," +
            "dc.status," +
            "dc.latitude," +
            "dc.longitude " +
            "from " +
            "device_channel_police_camera dc " +
            "JOIN device_channel_dept_police_camera dcd ON dc.id = dcd.device_channel_police_camera_id " +
            "WHERE " +
            "1=1" +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "            and dcd.dept_id = #{dwbh}\n" +
            "        </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            " order by dc.channelId desc " +
            ") " +
            " </script>"})
    List<DeviceChannelVO> queryChannelsAllByOnline(String deviceId,
                                                   String parentChannelId,
                                                   String query,
                                                   Boolean hasSubChannel,
                                                   String dwbh,
                                                   Boolean online);
 
    /**
     * 查询巡逻路线数据
     * @param id
     * @return
     */
    @Select("select ST_ASTEXT(positions) from srjw.sys_range where id = #{id}")
    String getRangeInfoById(@Param("id") String id);
 
    /**
     * 判断该点在哪个派出所
     * @param point 点
     * @return
     */
    @Select("SELECT police_station_id FROM srjw.police_station_info WHERE ST_Intersects(geom,ST_GeomFromText(${point},4326))")
    List<Long> getPoliceStationInfo(@Param("point") String point);
 
 
    /**
     * 查询是否存在绑定关系数据
     * @param id
     * @param deptId
     * @return
     */
    @Select("select count(*) from wvp.device_channel_dept where device_channel_id = #{id} and dept_id = #{deptId}")
    int queryExistByDeptIdAndDeviceChannelId(@Param("id") Integer id,@Param("deptId")  String deptId);
 
 
    /**
     * 更新绑定
     * @param deviceChannelId
     * @param deptId
     */
    @Insert("insert into wvp.device_channel_dept(device_channel_id,dept_id) values(#{deviceChannelId},#{deptId})")
    void saveHandleBindPosition(@Param("deviceChannelId") Integer deviceChannelId,@Param("deptId") String deptId);
 
 
    /**
     * 更新绑定
     * @param deviceChannelId
     * @param deptId
     */
    @Update("update wvp.device_channel_dept set dept_id = #{deptId} where device_channel_id = #{deviceChannelId}")
    void updateHandleBindPosition(@Param("deviceChannelId") Integer deviceChannelId,@Param("deptId") String deptId);
 
    /**
     * 查询手台列表数据
     * @param deviceId
     * @param o
     * @param query
     * @param hasSubChannel
     * @param dwbh 单位编号
     * @param online 是否在线
     * @return
     */
    @Select(value = {" <script>" +
            "SELECT " +
            "dc.id,\n" +
            "dc.terminal_number as channelId,\n" +
            "dcd.`name`,\n" +
            "dc.status," +
            "2 as type," +
            "dc.latitude,\n" +
            "dc.longitude\n" +
            "from " +
            "sys_talk_back_equipment dc " +
            "JOIN sys_talk_back_equipment_info dcd ON dc.terminal_number like concat('%',dcd.terminal_number,'%')" +
            "WHERE " +
            "1=1" +
            " <if test='query != null'> AND (dcd.name LIKE '%${query}%' OR dcd.terminal_number LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "     and dcd.dept_id = #{dwbh}\n" +
            " </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            "ORDER BY dc.receive_time " +
            " </script>"})
    List<DeviceChannelVO> queryTalkBackEquipment(String deviceId, Object o, String query, Boolean hasSubChannel, String dwbh, Boolean online);
 
    /**
     * 查询执法记录仪列表数据
     * @param deviceId
     * @param o
     * @param query
     * @param hasSubChannel
     * @param dwbh 单位编号
     * @param online 是否在线
     * @return
     */
    @Select(value = {" <script>" +
            "SELECT " +
            "dc.id,\n" +
            "dc.channelId,\n" +
            "dc.`name`,\n" +
            "dc.status," +
            "3 as type," +
            "dc.latitude," +
            "dc.longitude " +
            "from " +
            "device_channel_police_camera dc " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "    JOIN device_channel_dept_police_camera dcd ON dc.id = dcd.device_channel_police_camera_id " +
            " </if> " +
            "WHERE " +
            "1=1" +
            " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
            " <if test=\"dwbh!=null and dwbh!='' and dwbh!='1123598813738675201'\">\n" +
            "            and dcd.dept_id = #{dwbh}\n" +
            " </if> " +
            " <if test='online == true' > AND dc.status=1</if>" +
            " <if test='online == false' > AND dc.status=0</if>" +
            "ORDER BY dc.channelId " +
            " </script>"})
    List<DeviceChannelVO> queryChannelsPoliceCamera(String deviceId, Object o, String query, Boolean hasSubChannel, String dwbh, Boolean online);
 
    /**
     * 查询派出所名称--摄像头,警车
     * @param id 设备id
     * @return
     */
    @Select("select bd.dept_name from device_channel_dept dcd join srjw.blade_dept bd on bd.id = dcd.dept_id where device_channel_id = #{id}")
    String getDeptNameByDeviceChannelId(@Param("id") int id);
 
    /**
     * 查询派出所名称 -- 手台
     * @param id 手台编号
     * @return
     */
    @Select("select bd.dept_name from sys_talk_back_equipment_info dcd join srjw.blade_dept bd on bd.id = dcd.dept_id where terminal_number = #{id}")
    String getDeptNameByTalkBackEquipmentId(@Param("id")String id);
 
 
    /**
     * 查询派出所名称--执法记录仪
     * @param id 设备id
     * @return
     */
    @Select("select bd.dept_name from device_channel_dept_police_camera dcd join srjw.blade_dept bd on bd.id = dcd.dept_id where device_channel_police_camera_id = #{id}")
    String getDeptNameByDeviceChannelPoloiceCameraId(@Param("id")int id);
}