南昌市物联网技防平台-后台
zengh
2021-07-26 bf673eb643fd990ae44a953c5302b18dfa52510a
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
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
<?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="org.springblade.jfpt.alarm.mapper.AlarmMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="alarmResultMap" type="org.springblade.jfpt.alarm.vo.AlarmVO">
        <id column="id" property="id"/>
        <result column="alarmType" property="alarmType"/>
        <result column="alarmPeople" property="alarmPeople"/>
        <result column="alarmTime" property="alarmTime"/>
        <result column="galarmPeople" property="galarmPeople"/>
        <result column="sex" property="sex"/>
        <result column="phoneNumber" property="phoneNumber"/>
        <result column="place" property="place"/>
        <result column="content" property="content"/>
        <result column="waringType" property="waringType"/>
        <result column="deviceNumber" property="deviceNumber"/>
        <result column="region" property="region"/>
        <result column="district" property="district"/>
        <result column="alarmId" property="alarmId"/>
        <result column="level" property="level"/>
        <!--<result column="coordinate" property="coordinate"/>-->
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="jtype" property="jtype"/>
        <result column="rname" property="rname"/>
        <result column="serialNumber" property="serialNumber"/>
        <result column="stype" property="stype"/>
        <result column="channelNumber" property="channelNumber"/>
        <result column="czTime" property="czTime"/>
        <result column="bz" property="bz"/>
        <result column="name" property="name"/>
        <result column="cid" property="cid"/>
        <result column="vaddress" property="vaddress"/>
        <result column="aaddress" property="aaddress"/>
        <result column="uids" property="uids"/>
        <result column="securityArr" property="securityArr"/>
        <result column="securityId" property="securityId"/>
        <result column="baname" property="baname"/>
        <result column="baid" property="baid"/>
        <result column="deviceName" property="deviceName"/>
        <result column="baphone" property="baphone"/>
        <result column="manufacturers" property="manufacturers"/>
        <result column="alarmlb" property="alarmlb"/>
        <result column="alarmbs" property="alarmbs"/>
    </resultMap>
 
    <!-- 通用查询映射结果 -->
    <resultMap id="alarmonline" type="org.springblade.jfpt.alarm.vo.AlarmVO">
        <id column="alarmPeople" property="alarmPeople"/>
        <result column="alarmId" property="alarmId"/>
        <result column="phoneNumber" property="phoneNumber"/>
    </resultMap>
 
    <!-- 通用查询映射结果 -->
    <resultMap id="userResultMap" type="org.springblade.system.user.entity.User">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="phone" property="phone"/>
        <result column="online_status" property="online_status"/>
        <result column="work_status" property="work_status"/>
    </resultMap>
 
    <sql id="alarmCondition">
        <if test="alarm.id!=null">
            and a.id = #{alarm.id}
        </if>
        <if test="alarm.alarmbs!=null">
            and a.alarmbs = #{alarm.alarmbs}
        </if>
        <if test="alarm.jtype!=null">
            and a.jtype like concat('%',#{alarm.jtype},'%')
        </if>
        <if test="alarm.deviceNumber!=null">
            and a.deviceNumber like concat('%',#{alarm.deviceNumber},'%')
        </if>
        <if test="alarm.galarmPeople!=null">
            and a.galarmPeople like concat('%',#{alarm.galarmPeople},'%')
        </if>
        <if test="alarm.district!=null">
            and e.district like concat('%',#{alarm.district},'%')
        </if>
        <if test="alarm.province!=null">
            and e.province like concat('%',#{alarm.province},'%')
        </if>
        <if test="alarm.city!=null">
            and e.city like concat('%',#{alarm.city},'%')
        </if>
        <if test="alarm.level!=null">
            and a.level like concat('%',#{alarm.level},'%')
        </if>
        <if test="alarm.waringType!=null and alarm.waringType!='undefined'">
            and a.waringType like concat('%',#{alarm.waringType},'%')
        </if>
        <if test="alarm.beginTime!=null and alarm.beginTime!='' and alarm.beginTime!='undefined'">
            and a.alarmTime&gt;=#{alarm.beginTime}
        </if>
        <if test="alarm.endTime!=null and alarm.endTime!='' and alarm.endTime!='undefined'">
            and a.alarmTime&lt;=#{alarm.endTime}
        </if>
        <if test="alarm.timeDesc!=null and alarm.timeDesc!='' and alarm.timeDesc!='undefined'">
            <if test="alarm.timeDesc=='30分钟以上'">
                and czTime-alarmTime>1800
            </if>
            <if test="alarm.timeDesc=='10-30分钟'">
                and czTime-alarmTime>600 and czTime-alarmTime &lt;1800
            </if>
            <if test="alarm.timeDesc=='5-10分钟'">
                and czTime-alarmTime>300 and czTime-alarmTime &lt;600
            </if>
            <if test="alarm.timeDesc=='小于5分钟'">
                and czTime-alarmTime>0 and czTime-alarmTime &lt;300
            </if>
            <if test="alarm.timeDesc=='0-2'">
                and hour(alarmTime)>=0 and hour(alarmTime) &lt;2
            </if>
            <if test="alarm.timeDesc=='2-4'">
                and hour(alarmTime)>=2 and hour(alarmTime) &lt;4
            </if>
            <if test="alarm.timeDesc=='4-6'">
                and hour(alarmTime)>=4 and hour(alarmTime) &lt;6
            </if>
            <if test="alarm.timeDesc=='6-8'">
                and hour(alarmTime)>=6 and hour(alarmTime) &lt;8
            </if>
            <if test="alarm.timeDesc=='8-10'">
                and hour(alarmTime)>=8 and hour(alarmTime) &lt;10
            </if>
            <if test="alarm.timeDesc=='10-12'">
                and hour(alarmTime)>=10 and hour(alarmTime) &lt;12
            </if>
            <if test="alarm.timeDesc=='12-14'">
                and hour(alarmTime)>=12 and hour(alarmTime) &lt;14
            </if>
            <if test="alarm.timeDesc=='14-16'">
                and hour(alarmTime)>=14 and hour(alarmTime) &lt;16
            </if>
            <if test="alarm.timeDesc=='16-18'">
                and hour(alarmTime)>=16 and hour(alarmTime) &lt;18
            </if>
            <if test="alarm.timeDesc=='18-20'">
                and hour(alarmTime)>=18 and hour(alarmTime) &lt;20
            </if>
            <if test="alarm.timeDesc=='20-22'">
                and hour(alarmTime)>=20 and hour(alarmTime) &lt;22
            </if>
            <if test="alarm.timeDesc=='22-24'">
                and hour(alarmTime)>=22 and hour(alarmTime) &lt;24
            </if>
        </if>
    </sql>
    <sql id="alarmConditionPie">
        <if test="alarm.beginTime!=null and alarm.beginTime!=''">
            and DATE_FORMAT(a.alarmTime,'%Y-%m-%d')&gt;=#{alarm.beginTime}
        </if>
        <if test="alarm.endTime!=null and alarm.endTime!=''">
            and DATE_FORMAT(a.alarmTime,'%Y-%m-%d')&lt;=#{alarm.endTime}
        </if>
        <if test="alarm.timeDesc!=null and alarm.timeDesc!=''">
            <if test="alarm.timeDesc=='30分钟以上'">
                and czTime-alarmTime>1800
            </if>
            <if test="alarm.timeDesc=='10-30分钟'">
                and czTime-alarmTime>600 and czTime-alarmTime &lt;1800
            </if>
            <if test="alarm.timeDesc=='5-10分钟'">
                and czTime-alarmTime>300 and czTime-alarmTime &lt;600
            </if>
            <if test="alarm.timeDesc=='小于5分钟'">
                and czTime-alarmTime>0 and czTime-alarmTime &lt;300
            </if>
            <if test="alarm.timeDesc=='0-2'">
                and hour(alarmTime)>=0 and hour(alarmTime) &lt;2
            </if>
            <if test="alarm.timeDesc=='2-4'">
                and hour(alarmTime)>=2 and hour(alarmTime) &lt;4
            </if>
            <if test="alarm.timeDesc=='4-6'">
                and hour(alarmTime)>=4 and hour(alarmTime) &lt;6
            </if>
            <if test="alarm.timeDesc=='6-8'">
                and hour(alarmTime)>=6 and hour(alarmTime) &lt;8
            </if>
            <if test="alarm.timeDesc=='8-10'">
                and hour(alarmTime)>=8 and hour(alarmTime) &lt;10
            </if>
            <if test="alarm.timeDesc=='10-12'">
                and hour(alarmTime)>=10 and hour(alarmTime) &lt;12
            </if>
            <if test="alarm.timeDesc=='12-14'">
                and hour(alarmTime)>=12 and hour(alarmTime) &lt;14
            </if>
            <if test="alarm.timeDesc=='14-16'">
                and hour(alarmTime)>=14 and hour(alarmTime) &lt;16
            </if>
            <if test="alarm.timeDesc=='16-18'">
                and hour(alarmTime)>=16 and hour(alarmTime) &lt;18
            </if>
            <if test="alarm.timeDesc=='18-20'">
                and hour(alarmTime)>=18 and hour(alarmTime) &lt;20
            </if>
            <if test="alarm.timeDesc=='20-22'">
                and hour(alarmTime)>=20 and hour(alarmTime) &lt;22
            </if>
            <if test="alarm.timeDesc=='22-24'">
                and hour(alarmTime)>=22 and hour(alarmTime) &lt;24
            </if>
        </if>
    </sql>
 
 
    <select id="selectAlarmPage" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,a.alarmlb,a.alarmbs,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deptId,
        e.manufacturers,
        e.street as place,
        e.channelNumber,
        u.name as baname,
        u.id as baid,
        u.phone as baphone
        from sys_alarm a
        LEFT JOIN
        sys_equipment e on e.deviceNumber=a.deviceNumber
        LEFT JOIN jfpth.blade_user u ON u.id = a.securityId
        where 1=1
        <include refid="alarmCondition"></include>
        and a.waringType IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
 
    <select id="selectazPage" resultMap="alarmResultMap">
        SELECT
        *
        FROM
            sys_alarm
        WHERE
            1 = 1
            <if test="alarm.district!=null">
                and district like concat('%',#{alarm.district},'%')
            </if>
            <if test="alarm.province!=null">
                and province like concat('%',#{alarm.province},'%')
            </if>
            <if test="alarm.city!=null">
                and city like concat('%',#{alarm.city},'%')
            </if>
            <if test="alarm.alarmPeople!=null">
                and alarmPeople like concat('%',#{alarm.alarmPeople},'%')
            </if>
            <if test="alarm.jtype!=null">
                and jtype = #{alarm.jtype}
            </if>
            AND waringType IN ( "安装任务" )
        ORDER BY
            jtype ASC,
            alarmTime DESC
    </select>
 
    <select id="getChartData" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS value,
            "未安装" as name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND jtype = 0
            AND waringType IN ( "安装任务" ) UNION ALL
        SELECT
            COUNT( * ) AS value,
            "已安装" as name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND jtype = 2
            AND waringType IN ( "安装任务" )
    </select>
    <select id="getChartDataAlarm" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS
        value
            ,
            "未处理" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND jtype = 0
            AND waringType IN ( "紧急求救" ) UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "处理中" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND jtype = 1
            AND waringType IN ( "紧急求救" )
            UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "已处理" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND jtype = 2
            AND waringType IN ( "紧急求救" )
    </select>
    <select id="getChartDataAlarmBs" resultType="java.util.Map">
        SELECT
            COUNT( * ) AS
        value
            ,
            "一般警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND alarmbs = 0
            AND waringType IN ( "紧急求救" ) UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "误报警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND alarmbs = 1
            AND waringType IN ( "紧急求救" )
            UNION ALL
        SELECT
            COUNT( * ) AS
        value
            ,
            "严重警情" AS name
        FROM
            sys_alarm
        WHERE
            1 = 1
            AND alarmbs = 2
            AND waringType IN ( "紧急求救" )
    </select>
 
    <select id="listAll" resultMap="alarmResultMap">
       select a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,
        a.deviceNumber,a.region,e.district, a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,a.vaddress
         from sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
 
    </select>
 
    <select id="selectList" resultMap="alarmResultMap">
        SELECT
        a.id,
        a.alarmType,
        a.alarmPeople,
        a.alarmTime,
        a.galarmPeople,
        a.sex,
        a.phoneNumber,
        a.place,
        a.content,
        a.waringType,
        a.deviceNumber,
        a.vaddress,
        a.region,
        e.district,
        a.alarmId,
        a.czTime,
        a.bz,
        a.LEVEL,
        a.jd,
        a.wd,
        a.jtype,
        a.cid,
        a.rname,
        jfpth.blade_region.name as addvnm,
        e.serialNumber,
        e.stype,
        e.channelNumber
        FROM
        sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber LEFT JOIN jfpth.blade_region on
        jfpth.blade_region.`code`=a.district where 1=1
        <if test="jtype!=null and jtype!=''">
            and a.jtype=#{jtype}
        </if>
        <if test="district!=null and district!=''">
            and a.district=#{district}
        </if>
        <if test="waringType!=null and waringType!=''">
            and a.waringType=#{waringType}
        </if>
        <if test="beginTime!=null and beginTime!=''">
            and a.alarmTime&gt;=#{beginTime}
        </if>
        <if test="endTime!=null and endTime!=''">
            and a.alarmTime&lt;=#{endTime}
        </if>
        ORDER BY id ASC
    </select>
 
    <select id="getLimit" resultMap="alarmResultMap">
       select a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.vaddress,
        a.deviceNumber,a.region,a.district, a.alarmId,a.LEVEL,a.jd,a.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid from sys_alarm a ORDER BY id DESC LIMIT 1
    </select>
 
    <select id="selectInfo" resultMap="alarmResultMap">
        SELECT
        a.id,
        a.alarmType,
        a.alarmPeople,
        a.alarmTime,
        a.galarmPeople,
        a.sex,
        a.phoneNumber,
        a.place,
        a.czTime,
        a.bz,
        a.content,
        a.waringType,
        a.deviceNumber,
        a.region,
        a.district,
        a.alarmId,
        a.vaddress,
        a.rname,
        a.LEVEL,
        a.cid,
        a.jd,
        a.wd,
        a.jtype,
        d.addvnm
        FROM
        sys_alarm a LEFT JOIN sys_district d on d.addvcds=a.district where 1=1
        <if test="id!=null and id!=''">
            and a.id=#{id}
        </if>
    </select>
 
    <!--实时提醒-->
    <select id="selecttx" resultMap="alarmResultMap">
        SELECT
        a.id,
        a.alarmType,
        a.alarmPeople,
        a.alarmTime,
        a.galarmPeople,
        a.sex,
        a.phoneNumber,
        a.place,
        a.content,
        a.waringType,
        a.deviceNumber,
        a.region,
        e.district,
        e.province,
        e.city,
        a.alarmId,
        a.rname,
        a.LEVEL,
        a.cid,
        a.jd,
        a.wd,
        a.jtype,
        d.addvnm,
        e.serialNumber,
        e.stype,
        e.channelNumber,
        e.oneContacts,
        e.ThreeContacts,
        e.twoContacts,
        e.onePhone,
        e.twoPhone,
        e.ThreePhone
        FROM
        sys_alarm a LEFT JOIN sys_district d on d.addvcds=a.district LEFT JOIN sys_equipment e on
        e.deviceNumber=a.deviceNumber where 1=1
        <if test="id!=null and id!=''">
            and a.id &gt;#{id}
        </if>
    </select>
 
    <delete id="deletejj">
        delete  from sys_alarm where id=#{id}
    </delete>
 
    <!--新增-->
    <insert id="s" parameterType="org.springblade.jfpt.alarm.entity.Alarm" useGeneratedKeys="true" keyProperty="id">
       INSERT INTO sys_alarm (alarmType,jjTime,alarmPeople,alarmTime,galarmPeople,sex,phoneNumber,place,content,waringType,deviceNumber,
       region,district,alarmId,level,rname,coordinate,jd,wd,jtype,province,city,cid) VALUES
        (#{alarmType},#{jjTime},#{alarmPeople},#{alarmTime},#{galarmPeople},#{sex},#{phoneNumber},#{place},#{content},#{waringType},
        #{deviceNumber},#{region},#{district},#{alarmId},#{level},#{rname},POINT(#{jd},#{wd}),
        #{jd},#{wd},#{jtype},#{province},#{city},#{cid})
    </insert>
 
    <update id="updateOne" parameterType="org.springblade.jfpt.alarm.entity.Alarm">
    update sys_alarm SET alarmType=#{alarmType},alarmPeople=#{alarmPeople},alarmTime=#{alarmTime},
    galarmPeople=#{galarmPeople},sex=#{sex},phoneNumber=#{phoneNumber},place=#{place},
    content=#{content},waringType=#{waringType},deviceNumber=#{deviceNumber},region=#{region},district=#{district},alarmId=#{alarmId},level=#{level},rname=#{rname},jd=#{jd},wd=#{wd},
    coordinate=POINT(#{jd},#{wd}),jtype=#{jtype},province=#{province},city=#{city},cid=#{cid} where id=#{id}
</update>
 
 
    <select id="selectScount" resultType="java.util.HashMap">
        SELECT COUNT(*) as cou,waringType FROM `sys_alarm` WHERE alarmTime like concat(concat('%', #{time}), '%') GROUP BY waringType
    </select>
 
 
    <select id="selectListSe" resultMap="alarmResultMap">
        SELECT
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,"一键求助" as waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deptId,
        a.alarmlb,
        e.manufacturers,
        e.channelNumber,
        jfpth.blade_region.`name` as addvnm
        FROM
        sys_alarm a
        LEFT JOIN sys_equipment e
        on
        e.deviceNumber=a.deviceNumber
        LEFT JOIN
        jfpth.blade_region
        on
        jfpth.blade_region.`code`=a.district
        where
        DATE_FORMAT(alarmTime,'%Y-%m-%d') &gt;=#{beginTime}
        and DATE_FORMAT(alarmTime,'%Y-%m-%d') &lt;=#{endTime}
        and a.waringType  IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
 
 
    <update id="updateJtype">
        update sys_alarm SET jtype=#{jtype}
 
        <if test="bz!=null and bz!=''">
            ,bz=#{bz}
        </if>
 
        <if test="securityArr!=null and securityArr!=''">
            ,securityArr =#{securityArr}
        </if>
 
        <if test="bs!=null and bs!=''">
            ,alarmbs =#{bs}
        </if>
 
        where id=#{id}
    </update>
 
    <update id="updatePoliceStatus">
        update jfpth.blade_user SET work_status=#{status} where id=#{id}
    </update>
 
    <!--查询当天警情总数-->
    <select id="selectAlarmCount" resultType="java.lang.Integer">
        SELECT count(*) FROM `sys_alarm`
        where
        waringType = '紧急求救'
        <if test="conditionVo.status==0">
            and to_days(alarmTime) = to_days(curdate())
        </if>
        <if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
            and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
        </if>
    </select>
 
 
    <!--查询警情7天内每天的数据-->
    <select id="selectAlarmData" resultType="java.lang.Integer">
        select ifnull(b.count,0) as count from
        (
        SELECT DATE_FORMAT(date_sub(curdate(), interval 6 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(date_sub(curdate(), interval 5 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(date_sub(curdate(), interval 4 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(date_sub(curdate(), interval 3 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(date_sub(curdate(), interval 2 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(date_sub(curdate(), interval 1 day),'%Y-%m-%d') as click_date
            union all
        SELECT DATE_FORMAT(curdate(),'%Y-%m-%d')  as click_date
        ) a
        left join
        (
        select DATE_FORMAT(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            where waringType = '紧急求救'
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
        ) b
         on
         a.click_date = b.datetime
         order by a.click_date asc
    </select>
 
    <!--    &lt;!&ndash;查询本日,本周,本月 主动报警的数量&ndash;&gt;-->
    <!--    <select id="selectAlarmSum" resultType="java.util.HashMap">-->
    <!--        select sa.alarmType name,IFNULL(sb.count, 0) value from (select alarmType from sys_alarm GROUP BY alarmType) sa-->
    <!--        left join-->
    <!--        ( select alarmType,count(*) count from sys_alarm-->
    <!--        where 1=1-->
    <!--        <if test="conditionVo.status==0">-->
    <!--            and to_days(alarmTime) = to_days(now())-->
    <!--        </if>-->
    <!--        <if test="conditionVo.status==1">-->
    <!--            and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)-->
    <!--        </if>-->
    <!--        <if test="conditionVo.status==2">-->
    <!--            and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')-->
    <!--        </if>-->
    <!--        group by alarmType-->
    <!--        ) sb-->
    <!--        on-->
    <!--        sa.alarmType = sb.alarmType-->
    <!--    </select>-->
 
    <!--查询本日,本周,本月 主动报警的数量-->
    <select id="selectAlarmSum" resultType="java.util.HashMap">
        select '一键求助' name,ifnull(count(*),0 ) value from sys_alarm
        where waringType = '紧急求救'
        <if test="conditionVo.status==0">
            and to_days(alarmTime) = to_days(now())
        </if>
        <if test="conditionVo.status==1">
            and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
        </if>
        <if test="conditionVo.status==2">
            and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')
        </if>
        union all
        select '电话报警' name,ifnull(count(*),0 ) value from sys_alarm
        where waringType = '电话报警'
        <if test="conditionVo.status==0">
            and to_days(alarmTime) = to_days(now())
        </if>
        <if test="conditionVo.status==1">
            and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
        </if>
        <if test="conditionVo.status==2">
            and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')
        </if>
 
    </select>
 
    <select id="queryPolice" resultMap="userResultMap">
        SELECT * FROM jfpth.blade_user WHERE is_deleted != '1' and role_id ="1372092102682521602"
    </select>
 
 
    <select id="queryPoliceTime" resultMap="alarmonline">
 
        SELECT
        a.alarmPeople,
        a.alarmId,
        a.phoneNumber,
        max( a.jjTime ) AS jjTime
        FROM
        sys_alarm a
        WHERE
        1 =1
 
        <if test="policeIdArr!=null and policeIdArr.size>0">
            and alarmId in
            <foreach collection="policeIdArr" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY
        a.alarmPeople,
        a.alarmId,
        a.phoneNumber
        ORDER BY
        jjTime
        LIMIT 1
 
    </select>
 
    <select id="queryBa" resultType="java.util.HashMap">
    SELECT
        s.id,
        s.CODE,
        s.NAME,
        s.real_name,
        s.phone,
        p.jd,
        p.wd,
        ST_ASTEXT ( e.coordinate )
    FROM
        jfpth.blade_user s
        LEFT JOIN sys_position p ON p.snumber = s.
        CODE LEFT JOIN sys_enclosure e ON e.anumber = s.CODE
    WHERE
        is_deleted != '1'
        AND role_id = "1370562810882502657"
    </select>
 
    <select id="getAlarm" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.deviceName,
        e.threeId,
        e.deptId,
        e.street as place,
        e.channelNumber
        FROM
        sys_alarm a
        LEFT JOIN sys_equipment e ON e.deviceNumber = a.deviceNumber
        WHERE
 
        <if test="alarm.securityArr!=null and alarm.securityArr!=''">
            securityId = "" or securityId IS NULL
            AND securityArr LIKE concat('%',#{alarm.securityArr},'%')
        </if>
 
        <if test="alarm.id!=null and alarm.id!=''">
            a.id = #{alarm.id}
        </if>
 
 
    </select>
 
    <select id="getAlarming" resultMap="alarmResultMap">
        select
        a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,a.cid,
        a.securityArr,a.securityId,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
        e.stype,
        e.oneId,
        e.twoId,
        e.threeId,
        e.deviceName,
        e.deptId,
        e.street as place,
        e.channelNumber
        FROM
            sys_alarm a
            LEFT JOIN sys_equipment e ON e.deviceNumber = a.deviceNumber
        WHERE
            securityId =#{alarm.securityId} and jtype != 2
 
    </select>
 
    <update id="setAlarm">
        update sys_alarm SET securityId=#{alarm.securityId} where id=#{alarm.id}
    </update>
 
    <update id="updateVaddress">
        update sys_alarm SET vaddress=#{vaddress} where id=#{jid}
    </update>
 
    <update id="updateAaddress">
        update sys_alarm SET aaddress=#{aaddress} where id=#{jid}
    </update>
 
 
    <select id="selectEq" resultType="java.util.HashMap">
        SELECT COUNT(deviceNumber) as cou,deviceNumber  FROM `sys_alarm` WHERE alarmTime like concat(concat('%', #{time}), '%') and waringType NOT IN("系统测试","主机重新上电") group by deviceNumber
    </select>
 
    <select id="selAlarmTimeCount" resultType="java.lang.Integer">
        select count(*) from sys_alarm
        where waringType = '紧急求救'
        <if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
            and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
        </if>
    </select>
 
    <!--查询当前时间段内一键求助报警的数据集合-->
    <select id="selectAlarmList" resultType="org.springblade.jfpt.alarm.entity.Alarm">
        SELECT waringType,alarmTime,alarmId,alarmPeople,jtype,czTime FROM `sys_alarm`
        where waringType='紧急求救'
        and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
    </select>
 
    <!--统计时间段内一键求助警情数量数据-->
    <select id="selectAlarmTimeData" resultType="java.lang.Integer">
        select ifnull(count,0) count from
        (
            SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) days FROM
            (
                SELECT @date := DATE_ADD( #{conditionVo.startTime}, INTERVAL - 1 DAY ) FROM sys_date
            ) time
                WHERE to_days( @date ) &lt; to_days( #{conditionVo.endTime} )
        ) a
        left join
        (
            select DATE_FORMAT(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
            where waringType = '紧急求救'
            group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
        ) b
        on
        a.days = b.datetime
        order by days
    </select>
 
 
    <!--查询本年所有月份的预警数量-->
    <select id="queryYearAlarm" resultType="java.util.HashMap">
 
        <if test="childList!=null and childList.size>0">
 
            <foreach collection="childList" index="index" item="item" open="" separator="union all" close="">
                SELECT
                #{item} as month,count(ce.id) as count
                FROM
                sys_alarm as ce
                WHERE
                YEAR ( alarmTime ) = date_format(now(),'%Y%')
                AND MONTH ( alarmTime ) = #{item}
 
                AND waringType = "紧急求救"
                AND deviceNumber = #{deviceNumber}
 
            </foreach>
        </if>
 
    </select>
 
    <!--查询符合条件的数据并导出-->
    <select id="exportAlarm" resultType="org.springblade.common.entity.AlarmExcel">
        select
        a.id, "一键求助" as
        alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz,
        a.deviceNumber,a.region,e.district,a.vaddress,a.aaddress,
        a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,e.province,e.city,
        e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone
        from sys_alarm a
        LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
        where 1=1
        <include refid="alarmCondition"></include>
        and a.waringType IN("紧急求救")
        ORDER BY
        a.jtype ASC,
        a.alarmTime DESC
    </select>
 
    <!--获取实时警情图表统计数据-->
    <select id="getAlarmPie" resultType="org.springblade.common.entity.ReportReturnData">
        select if(1=1,"一键求助",0) type,ifnull(count(*),0) count from sys_alarm
        where waringType="紧急求救"
        <include refid="alarmConditionPie"></include>
    </select>
 
    <!--查询未处理及处理中的警情总数量-->
    <select id="selectEqCount" resultType="Integer">
        SELECT ifnull(count(*),0) count  FROM `sys_alarm`
        where deviceNumber = #{deviceNumber}
        and jtype!=2
    </select>
 
</mapper>