mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
<?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.panzhihua.service_grid.dao.EventMapper">
 
     <resultMap id="baseResult" type="com.panzhihua.service_grid.model.dos.EventDO">
        <result property="id" column="id"/>
        <result property="orderSn" column="order_sn"/>
        <result property="eventCategory" column="event_category"/>
        <result property="gridMemberStreet" column="grid_member_street"/>
        <result property="gridMemberCommunity" column="grid_member_community"/>
        <result property="gridId" column="grid_id"/>
        <result property="gridMemberId" column="grid_member_id"/>
        <result property="gridMemberName" column="grid_member_name"/>
        <result property="gridMemberTelephone" column="grid_member_telephone"/>
        <result property="eventTitle" column="event_title"/>
        <result property="propagandaType" column="propaganda_type"/>
        <result property="propagandaTime" column="propaganda_time"/>
        <result property="eventType" column="event_type"/>
        <result property="eventDes" column="event_des"/>
        <result property="propagandaObject" column="propaganda_object"/>
        <result property="propagandaNum" column="propaganda_num"/>
        <result property="communityProcess" column="community_process"/>
        <result property="happenTime" column="happen_time"/>
        <result property="happentAddress" column="happent_address"/>
        <result property="happenAddress" column="happen_address"/>
        <result property="happentLatLng" column="happent_lat_lng"/>
        <result property="eventStatus" column="event_status"/>
        <result property="eventProcessStatus" column="event_process_status"/>
        <result property="processType" column="process_type"/>
        <result property="processUserId" column="process_user_id"/>
        <result property="processUserName" column="process_user_name"/>
        <result property="processDate" column="process_date"/>
        <result property="processDesc" column="process_desc"/>
        <result property="eventResource" column="event_resource"/>
        <result property="dangerLevel" column="danger_level"/>
        <result property="redCard" column="red_card"/>
        <result property="yellowCard" column="yellow_card"/>
        <result property="invalid" column="invalid"/>
        <result property="major" column="major"/>
        <result property="deathsNumber" column="deaths_number"/>
        <result property="injuriesNumber" column="injuries_number"/>
        <result property="difficult" column="difficult"/>
        <result property="urgent" column="urgent"/>
        <result property="urgentDell" column="urgent_dell"/>
        <result property="submitDate" column="submit_date"/>
        <result property="createBy" column="create_by"/>
        <result property="createAt" column="create_at"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateAt" column="update_at"/>
        <result property="eventClazz" column="event_clazz"/>
        <result property="eventDealStatus" column="event_deal_status"/>
    </resultMap>
 
    <sql id="columns">
    <![CDATA[
        id,order_sn,event_category,grid_member_street,happen_address,grid_member_community,event_clazz,grid_id,grid_member_id,grid_member_name,grid_member_telephone,
        event_title,propaganda_type,propaganda_time,event_type,event_des,propaganda_object,propaganda_num,community_process,happen_time,happent_address,happent_lat_lng,
        event_status,event_process_status,process_type,process_user_id,process_user_name,process_date,process_desc,event_resource,danger_level,red_card,yellow_card,invalid,
        major,deaths_number,injuries_number,difficult,urgent,urgent_dell,submit_date,create_by,create_at,update_by,update_at,event_deal_status
    ]]>
    </sql>
 
 
    <select id="findByPage" resultType="com.panzhihua.common.model.vos.grid.EventVO"
        parameterType="com.panzhihua.common.model.dtos.grid.PageEventDTO">
        SELECT <include refid="columns" />
        FROM event
        <where>
            event_status != 3 AND event_category = 1
            <if test="pageEventDTO.eventDealStatus!=null">
                AND event_deal_status = #{pageEventDTO.eventDealStatus}
            </if>
            <if test="pageEventDTO.isAll!=null and pageEventDTO.isAll == 1">
                AND event_deal_status in (1,2,4)
            </if>
            <if test="pageEventDTO.revokeType!=null">
                AND ( revoke_type = #{pageEventDTO.revokeType} OR revoke_type is null )
            </if>
           <if test="pageEventDTO.id!=null">
                AND id = #{pageEventDTO.id}
            </if>
           <if test="pageEventDTO.orderSn!=null">
                AND order_sn = #{pageEventDTO.orderSn}
            </if>
           <if test="pageEventDTO.eventCategory!=null">
                AND event_category = #{pageEventDTO.eventCategory}
            </if>
           <if test="pageEventDTO.gridMemberStreet!=null">
                AND grid_member_street = #{pageEventDTO.gridMemberStreet}
            </if>
           <if test="pageEventDTO.gridMemberCommunity!=null">
                AND grid_member_community = #{pageEventDTO.gridMemberCommunity}
            </if>
           <if test="pageEventDTO.gridId!=null">
                AND grid_id = #{pageEventDTO.gridId}
            </if>
           <if test="pageEventDTO.gridMemberId!=null">
                AND grid_member_id = #{pageEventDTO.gridMemberId}
            </if>
           <if test="pageEventDTO.gridMemberName!=null">
                AND grid_member_name = #{pageEventDTO.gridMemberName}
            </if>
           <if test="pageEventDTO.gridMemberTelephone!=null">
                AND grid_member_telephone = #{pageEventDTO.gridMemberTelephone}
            </if>
           <if test="pageEventDTO.eventTitle!=null">
                AND event_title = #{pageEventDTO.eventTitle}
            </if>
           <if test="pageEventDTO.propagandaType!=null">
                AND propaganda_type = #{pageEventDTO.propagandaType}
            </if>
           <if test="pageEventDTO.propagandaTimeBegin!=null">
                AND propaganda_time <![CDATA[>=]]> #{pageEventDTO.propagandaTimeBegin}
           </if>
           <if test="pageEventDTO.propagandaTimeEnd!=null">
                AND propaganda_time <![CDATA[<=]]> #{pageEventDTO.propagandaTimeEnd}
           </if>
           <if test="pageEventDTO.eventType!=null">
                AND event_type = #{pageEventDTO.eventType}
            </if>
           <if test="pageEventDTO.eventDes!=null">
                AND event_des = #{pageEventDTO.eventDes}
            </if>
            <if test="pageEventDTO.eventClazz!=null">
                AND event_clazz like concat(#{pageEventDTO.eventClazz},'%')
            </if>
           <if test="pageEventDTO.propagandaObject!=null">
                AND propaganda_object = #{pageEventDTO.propagandaObject}
            </if>
           <if test="pageEventDTO.propagandaNum!=null">
                AND propaganda_num = #{pageEventDTO.propagandaNum}
            </if>
           <if test="pageEventDTO.communityProcess!=null">
                AND community_process = #{pageEventDTO.communityProcess}
            </if>
           <if test="pageEventDTO.happenTimeBegin!=null">
                AND happen_time <![CDATA[>=]]> #{pageEventDTO.happenTimeBegin}
           </if>
           <if test="pageEventDTO.happenTimeEnd!=null">
                AND happen_time <![CDATA[<=]]> #{pageEventDTO.happenTimeEnd}
           </if>
           <if test="pageEventDTO.happentAddress!=null">
                AND happent_address = #{pageEventDTO.happentAddress}
            </if>
           <if test="pageEventDTO.happentLatLng!=null">
                AND happent_lat_lng = #{pageEventDTO.happentLatLng}
            </if>
           <if test="pageEventDTO.eventStatus!=null">
                AND event_status = #{pageEventDTO.eventStatus}
            </if>
           <if test="pageEventDTO.eventProcessStatus!=null">
                AND event_process_status = #{pageEventDTO.eventProcessStatus}
            </if>
           <if test="pageEventDTO.processType!=null">
                AND process_type = #{pageEventDTO.processType}
            </if>
           <if test="pageEventDTO.processUserId!=null">
                AND process_user_id = #{pageEventDTO.processUserId}
            </if>
           <if test="pageEventDTO.processUserName!=null">
                AND process_user_name = #{pageEventDTO.processUserName}
            </if>
           <if test="pageEventDTO.processDateBegin!=null">
                AND process_date <![CDATA[>=]]> #{pageEventDTO.processDateBegin}
           </if>
           <if test="pageEventDTO.processDateEnd!=null">
                AND process_date <![CDATA[<=]]> #{pageEventDTO.processDateEnd}
           </if>
           <if test="pageEventDTO.processDesc!=null">
                AND process_desc = #{pageEventDTO.processDesc}
            </if>
           <if test="pageEventDTO.eventResource!=null">
                AND event_resource = #{pageEventDTO.eventResource}
            </if>
           <if test="pageEventDTO.dangerLevel!=null">
                AND danger_level = #{pageEventDTO.dangerLevel}
            </if>
           <if test="pageEventDTO.redCard!=null">
                AND red_card = #{pageEventDTO.redCard}
            </if>
           <if test="pageEventDTO.yellowCard!=null">
                AND yellow_card = #{pageEventDTO.yellowCard}
            </if>
           <if test="pageEventDTO.invalid!=null">
                AND invalid = #{pageEventDTO.invalid}
            </if>
           <if test="pageEventDTO.major!=null">
                AND major = #{pageEventDTO.major}
            </if>
           <if test="pageEventDTO.deathsNumber!=null">
                AND deaths_number = #{pageEventDTO.deathsNumber}
            </if>
           <if test="pageEventDTO.injuriesNumber!=null">
                AND injuries_number = #{pageEventDTO.injuriesNumber}
            </if>
           <if test="pageEventDTO.difficult!=null">
                AND difficult = #{pageEventDTO.difficult}
            </if>
           <if test="pageEventDTO.urgent!=null">
                AND urgent = #{pageEventDTO.urgent}
            </if>
           <if test="pageEventDTO.urgentDell!=null">
                AND urgent_dell = #{pageEventDTO.urgentDell}
            </if>
           <if test="pageEventDTO.submitDateBegin!=null">
                AND submit_date <![CDATA[>=]]> #{pageEventDTO.submitDateBegin}
           </if>
           <if test="pageEventDTO.submitDateEnd!=null">
                AND submit_date <![CDATA[<=]]> #{pageEventDTO.submitDateEnd}
           </if>
           <if test="pageEventDTO.createBy!=null">
                AND create_by = #{pageEventDTO.createBy}
            </if>
           <if test="pageEventDTO.createAtBegin!=null">
                AND create_at  <![CDATA[>=]]> #{pageEventDTO.createAtBegin}
           </if>
           <if test="pageEventDTO.createAtEnd!=null">
                AND create_at <![CDATA[<=]]> #{pageEventDTO.createAtEnd}
           </if>
           <if test="pageEventDTO.updateBy!=null">
                AND update_by = #{pageEventDTO.updateBy}
            </if>
           <if test="pageEventDTO.updateAtBegin!=null">
                AND update_at <![CDATA[>=]]> #{pageEventDTO.updateAtBegin}
           </if>
           <if test="pageEventDTO.updateAtEnd!=null">
                AND update_at <![CDATA[<=]]> #{pageEventDTO.updateAtEnd}
           </if>
        </where>
        order by event_deal_status asc,create_at desc
    </select>
    <select id="findPublicityByPage" resultType="com.panzhihua.common.model.vos.grid.EventVO"
            parameterType="com.panzhihua.common.model.dtos.grid.PagePublicityEventDTO">
        SELECT
            e.id,e.order_sn,e.event_category,e.grid_member_street,e.happen_address,e.grid_member_community,e.event_clazz,e.grid_id,e.grid_member_id,e.grid_member_name,e.grid_member_telephone,
            e.event_title,e.propaganda_type,e.propaganda_time,e.event_type,e.event_des,e.propaganda_object,e.propaganda_num,e.community_process,e.happen_time,e.happent_address,e.happent_lat_lng,
            e.event_status,e.event_process_status,e.process_type,e.process_user_id,e.process_user_name,e.process_date,e.process_desc,e.event_resource,e.danger_level,e.red_card,e.yellow_card,e.invalid,
            e.major,e.deaths_number,e.injuries_number,e.difficult,e.urgent,e.urgent_dell,e.submit_date,e.create_by,e.create_at,e.update_by,e.update_at,e.event_deal_status
        FROM
            event e left join event_grid_data egd on e.grid_id = egd.id
        <where>
            e.event_status != 3 AND e.event_category = 2
            <if test="pagePublicityEventDTO.communityId!=null">
                AND egd.grid_community_id = ${pagePublicityEventDTO.communityId}
            </if>
 
            <if test="pagePublicityEventDTO.revokeType!=null">
                AND ( e.revoke_type = #{pagePublicityEventDTO.revokeType} OR e.revoke_type is null )
            </if>
            <if test="pagePublicityEventDTO.eventDealStatus!=null">
                AND e.event_deal_status = #{pagePublicityEventDTO.eventDealStatus}
            </if>
            <if test="pagePublicityEventDTO.id!=null">
                AND e.id = #{pagePublicityEventDTO.id}
            </if>
            <if test="pagePublicityEventDTO.orderSn!=null">
                AND e.order_sn = #{pagePublicityEventDTO.orderSn}
            </if>
            <if test="pagePublicityEventDTO.eventCategory!=null">
                AND e.event_category = #{pagePublicityEventDTO.eventCategory}
            </if>
            <if test="pagePublicityEventDTO.gridMemberStreet!=null">
                AND e.grid_member_street = #{pagePublicityEventDTO.gridMemberStreet}
            </if>
            <if test="pagePublicityEventDTO.gridMemberCommunity!=null">
                AND e.grid_member_community = #{pagePublicityEventDTO.gridMemberCommunity}
            </if>
            <if test="pagePublicityEventDTO.gridId!=null">
                AND e.grid_id = #{pagePublicityEventDTO.gridId}
            </if>
            <if test="pagePublicityEventDTO.gridMemberId!=null">
                AND e.grid_member_id = #{pagePublicityEventDTO.gridMemberId}
            </if>
            <if test="pagePublicityEventDTO.gridMemberName!=null">
                AND e.grid_member_name = #{pagePublicityEventDTO.gridMemberName}
            </if>
            <if test="pagePublicityEventDTO.gridMemberTelephone!=null">
                AND e.grid_member_telephone = #{pagePublicityEventDTO.gridMemberTelephone}
            </if>
            <if test="pagePublicityEventDTO.eventTitle!=null">
                AND e.event_title = #{pagePublicityEventDTO.eventTitle}
            </if>
            <if test="pagePublicityEventDTO.propagandaType!=null">
                AND e.propaganda_type = #{pagePublicityEventDTO.propagandaType}
            </if>
            <if test="pagePublicityEventDTO.propagandaTimeBegin!=null">
                AND e.propaganda_time <![CDATA[>=]]> #{pagePublicityEventDTO.propagandaTimeBegin}
            </if>
            <if test="pagePublicityEventDTO.propagandaTimeEnd!=null">
                AND e.propaganda_time <![CDATA[<=]]> #{pagePublicityEventDTO.propagandaTimeEnd}
            </if>
            <if test="pagePublicityEventDTO.eventDes!=null">
                AND e.event_des = #{pagePublicityEventDTO.eventDes}
            </if>
            <if test="pagePublicityEventDTO.propagandaObject!=null">
                AND e.propaganda_object = #{pagePublicityEventDTO.propagandaObject}
            </if>
            <if test="pagePublicityEventDTO.propagandaNum!=null">
                AND e.propaganda_num = #{pagePublicityEventDTO.propagandaNum}
            </if>
            <if test="pagePublicityEventDTO.communityProcess!=null">
                AND e.community_process = #{pagePublicityEventDTO.communityProcess}
            </if>
            <if test="pagePublicityEventDTO.happenTimeBegin!=null">
                AND e.happen_time <![CDATA[>=]]> #{pagePublicityEventDTO.happenTimeBegin}
            </if>
            <if test="pagePublicityEventDTO.happenTimeEnd!=null">
                AND e.happen_time <![CDATA[<=]]> #{pagePublicityEventDTO.happenTimeEnd}
            </if>
            <if test="pagePublicityEventDTO.happentAddress!=null">
                AND e.happent_address = #{pagePublicityEventDTO.happentAddress}
            </if>
            <if test="pagePublicityEventDTO.happentLatLng!=null">
                AND e.happent_lat_lng = #{pagePublicityEventDTO.happentLatLng}
            </if>
            <if test="pagePublicityEventDTO.eventStatus!=null">
                AND e.event_status = #{pagePublicityEventDTO.eventStatus}
            </if>
            <if test="pagePublicityEventDTO.eventProcessStatus!=null">
                AND e.event_process_status = #{pagePublicityEventDTO.eventProcessStatus}
            </if>
            <if test="pagePublicityEventDTO.processType!=null">
                AND e.process_type = #{pagePublicityEventDTO.processType}
            </if>
            <if test="pagePublicityEventDTO.processUserId!=null">
                AND e.process_user_id = #{pagePublicityEventDTO.processUserId}
            </if>
            <if test="pagePublicityEventDTO.processUserName!=null">
                AND e.process_user_name = #{pagePublicityEventDTO.processUserName}
            </if>
            <if test="pagePublicityEventDTO.processDateBegin!=null">
                AND e.process_date <![CDATA[>=]]> #{pagePublicityEventDTO.processDateBegin}
            </if>
            <if test="pagePublicityEventDTO.processDateEnd!=null">
                AND e.process_date <![CDATA[<=]]> #{pagePublicityEventDTO.processDateEnd}
            </if>
            <if test="pagePublicityEventDTO.processDesc!=null">
                AND e.process_desc = #{pagePublicityEventDTO.processDesc}
            </if>
            <if test="pagePublicityEventDTO.eventResource!=null">
                AND e.event_resource = #{pagePublicityEventDTO.eventResource}
            </if>
            <if test="pagePublicityEventDTO.dangerLevel!=null">
                AND e.danger_level = #{pagePublicityEventDTO.dangerLevel}
            </if>
            <if test="pagePublicityEventDTO.redCard!=null">
                AND e.red_card = #{pagePublicityEventDTO.redCard}
            </if>
            <if test="pagePublicityEventDTO.yellowCard!=null">
                AND e.yellow_card = #{pagePublicityEventDTO.yellowCard}
            </if>
            <if test="pagePublicityEventDTO.invalid!=null">
                AND e.invalid = #{pagePublicityEventDTO.invalid}
            </if>
            <if test="pagePublicityEventDTO.major!=null">
                AND e.major = #{pagePublicityEventDTO.major}
            </if>
            <if test="pagePublicityEventDTO.deathsNumber!=null">
                AND e.deaths_number = #{pagePublicityEventDTO.deathsNumber}
            </if>
            <if test="pagePublicityEventDTO.injuriesNumber!=null">
                AND e.injuries_number = #{pagePublicityEventDTO.injuriesNumber}
            </if>
            <if test="pagePublicityEventDTO.difficult!=null">
                AND e.difficult = #{pagePublicityEventDTO.difficult}
            </if>
            <if test="pagePublicityEventDTO.urgent!=null">
                AND e.urgent = #{pagePublicityEventDTO.urgent}
            </if>
            <if test="pagePublicityEventDTO.urgentDell!=null">
                AND e.urgent_dell = #{pagePublicityEventDTO.urgentDell}
            </if>
            <if test="pagePublicityEventDTO.submitDateBegin!=null">
                AND e.submit_date <![CDATA[>=]]> #{pagePublicityEventDTO.submitDateBegin}
            </if>
            <if test="pagePublicityEventDTO.submitDateEnd!=null">
                AND e.submit_date <![CDATA[<=]]> #{pagePublicityEventDTO.submitDateEnd}
            </if>
            <if test="pagePublicityEventDTO.createBy!=null">
                AND e.create_by = #{pagePublicityEventDTO.createBy}
            </if>
            <if test="pagePublicityEventDTO.createAtBegin!=null">
                AND e.create_at  <![CDATA[>=]]> #{pagePublicityEventDTO.createAtBegin}
            </if>
            <if test="pagePublicityEventDTO.createAtEnd!=null">
                AND e.create_at <![CDATA[<=]]> #{pagePublicityEventDTO.createAtEnd}
            </if>
            <if test="pagePublicityEventDTO.updateBy!=null">
                AND e.update_by = #{pagePublicityEventDTO.updateBy}
            </if>
            <if test="pagePublicityEventDTO.updateAtBegin!=null">
                AND e.update_at <![CDATA[>=]]> #{pagePublicityEventDTO.updateAtBegin}
            </if>
            <if test="pagePublicityEventDTO.updateAtEnd!=null">
                AND e.update_at <![CDATA[<=]]> #{pagePublicityEventDTO.updateAtEnd}
            </if>
        </where>
        <if test="pagePublicityEventDTO.sortColumns!=null">
            ORDER BY e.${pagePublicityEventDTO.sortColumns} ${pagePublicityEventDTO.sortType}
        </if>
    </select>
 
    <select id="getEventByGridId" resultType="com.panzhihua.common.model.vos.grid.ComMapGridEventVO">
        SELECT
            id,
            event_type AS type,
            event_des AS eventTitle,
            happent_address AS happentAddress,
            happen_address AS happenAddress,
            happent_lat_lng AS happentLatLng
        FROM
            `event`
        WHERE
            ( event_category = 1 OR event_category = 2 )
            AND event_process_status = 1
            AND event_status = 2
            AND grid_id = #{gridId}
            AND process_type = 1 UNION ALL
        SELECT
            id,
            IFNULL( NULL, 7 ) AS type,
            event_des AS eventTitle,
            happent_address AS happentAddress,
            happen_address AS happenAddress,
            happent_lat_lng AS happentLatLng
        FROM
            event_visiting_tasks
        WHERE
            event_status = 1
            AND dell_type = 1
            AND grid_id = #{gridId}
    </select>
 
    <select id="getGridMemberImageUrl" resultType="Map">
        select image_url,nick_name from sys_user where user_id = #{gridMemberId}
    </select>
    <select id="findToManageByPage" resultType="com.panzhihua.common.model.vos.grid.EventVO"
            parameterType="com.panzhihua.common.model.dtos.grid.PageEventManageDTO">
        SELECT
            e.id,e.order_sn,e.event_category,e.grid_member_street,e.happen_address,e.grid_member_community,e.event_clazz,e.grid_id,e.grid_member_id,e.grid_member_name,e.grid_member_telephone,
            e.event_title,e.propaganda_type,e.propaganda_time,e.event_type,e.event_des,e.propaganda_object,e.propaganda_num,e.community_process,e.happen_time,e.happent_address,e.happent_lat_lng,
            e.event_status,e.event_process_status,e.process_type,e.process_user_id,e.process_user_name,e.process_date,e.process_desc,e.event_resource,e.danger_level,e.red_card,e.yellow_card,e.invalid,
            e.major,e.deaths_number,e.injuries_number,e.difficult,e.urgent,e.urgent_dell,e.submit_date,e.create_by,e.create_at,e.update_by,e.update_at,e.event_deal_status,egd.grid_name
        FROM
            event e left join event_grid_data egd on e.grid_id = egd.id
        <where>
            e.event_status != 3 AND e.event_category = 1
            <if test="pageEventManageDTO.communityId!=null">
                AND egd.grid_community_id = ${pageEventManageDTO.communityId}
            </if>
            <if test='pageEventManageDTO.keyWord != null and pageEventManageDTO.keyWord != &quot;&quot;'>
                AND (
                e.grid_member_name like concat('%', #{pageEventManageDTO.keyWord},'%') OR
                e.event_title like concat('%', #{pageEventManageDTO.keyWord},'%') OR
                e.happen_address like concat('%', #{pageEventManageDTO.keyWord},'%') OR
                e.order_sn like concat('%', #{pageEventManageDTO.keyWord},'%') OR
                e.event_clazz like concat('%', #{pageEventManageDTO.keyWord},'%') OR
                e.event_des like concat('%', #{pageEventManageDTO.keyWord},'%')
                )
             </if>
            <if test="pageEventManageDTO.revokeType!=null">
                AND ( e.revoke_type = #{pageEventManageDTO.revokeType} OR e.revoke_type is null )
            </if>
            <if test="pageEventManageDTO.eventDealStatus!=null">
                AND e.event_deal_status = #{pageEventManageDTO.eventDealStatus}
            </if>
            <if test="pageEventManageDTO.communityProcess!=null">
                AND e.community_process = #{pageEventManageDTO.communityProcess}
            </if>
            <if test="pageEventManageDTO.eventType!=null">
                AND e.event_type = #{pageEventManageDTO.eventType}
            </if>
            <if test="pageEventManageDTO.dangerLevel!=null">
                AND e.danger_level = #{pageEventManageDTO.dangerLevel}
            </if>
            <if test="pageEventManageDTO.redCard!=null">
                AND e.red_card = #{pageEventManageDTO.redCard}
            </if>
            <if test="pageEventManageDTO.yellowCard!=null">
                AND e.yellow_card = #{pageEventManageDTO.yellowCard}
            </if>
            <if test="pageEventManageDTO.eventClazz != null and pageEventManageDTO.eventClazz != &quot;&quot;">
                AND e.event_clazz like concat('%',#{pageEventDTO.eventClazz},'%')
            </if>
            <if test="pageEventManageDTO.urgent!=null">
                AND e.urgent = #{pageEventManageDTO.urgent}
            </if>
            <if test="pageEventManageDTO.major!=null">
                AND e.major = #{pageEventManageDTO.major}
            </if>
            <if test="pageEventManageDTO.invalid!=null">
                AND e.invalid = #{pageEventManageDTO.invalid}
            </if>
        </where>
        <if test="pageEventManageDTO.sortColumns!=null">
            ORDER BY e.${pageEventManageDTO.sortColumns} ${pageEventManageDTO.sortType}
        </if>
    </select>
 
    <select id="findCommunityPublicityByPage" resultType="com.panzhihua.common.model.vos.grid.EventVO"
            parameterType="com.panzhihua.common.model.dtos.grid.PagePublicityEventCommunityDTO">
        SELECT
            e.id,e.order_sn,e.event_category,e.grid_member_street,e.happen_address,e.grid_member_community,e.event_clazz,e.grid_id,e.grid_member_id,e.grid_member_name,e.grid_member_telephone,
            e.event_title,e.propaganda_type,e.propaganda_time,e.event_type,e.event_des,e.propaganda_object,e.propaganda_num,e.community_process,e.happen_time,e.happent_address,e.happent_lat_lng,
            e.event_status,e.event_process_status,e.process_type,e.process_user_id,e.process_user_name,e.process_date,e.process_desc,e.event_resource,e.danger_level,e.red_card,e.yellow_card,e.invalid,
            e.major,e.deaths_number,e.injuries_number,e.difficult,e.urgent,e.urgent_dell,e.submit_date,e.create_by,e.create_at,e.update_by,e.update_at,e.event_deal_status, egd.grid_name
        FROM
            event e left join event_grid_data egd on e.grid_id = egd.id
        <where>
            e.event_status != 3 AND e.event_category = 2
            <if test='pagePublicityEventCommunityDTO.keyWord != null and pagePublicityEventCommunityDTO.keyWord != &quot;&quot;'>
                AND (
                e.grid_member_name like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%') OR
                e.event_title like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%') OR
                e.happen_address like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%') OR
                e.order_sn like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%') OR
                e.propaganda_type like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%') OR
                egd.grid_name like concat('%', #{pagePublicityEventCommunityDTO.keyWord},'%')
                )
            </if>
            <if test="pagePublicityEventCommunityDTO.revokeType!=null">
                AND ( e.revoke_type = #{pagePublicityEventCommunityDTO.revokeType} OR e.revoke_type is null )
            </if>
            <if test="pagePublicityEventCommunityDTO.communityId!=null">
                AND egd.grid_community_id = ${pagePublicityEventCommunityDTO.communityId}
            </if>
            <if test="pagePublicityEventCommunityDTO.eventDealStatus!=null">
                AND e.event_deal_status = #{pagePublicityEventCommunityDTO.eventDealStatus}
            </if>
        </where>
        <if test="pagePublicityEventCommunityDTO.sortColumns!=null">
            ORDER BY e.${pagePublicityEventCommunityDTO.sortColumns} ${pagePublicityEventCommunityDTO.sortType}
        </if>
    </select>
    <select id="eventStatistics" resultType="com.panzhihua.common.model.vos.grid.EventStatisticsAllAdminVO">
        SELECT
            count( e.id ) AS eventTotal,(
            SELECT
                count( e.id )
            FROM
                `event` AS e
                LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
            WHERE
                e.event_status = 2
                AND e.event_process_status = 2
            ) AS handleEventTotal,
            (
            SELECT
                count( e.id )
            FROM
                `event` AS e
                LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
            WHERE
                e.event_category = 2
                AND e.event_status = 2
            ) AS propagandaEducationTotal,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE handle_status = 2  ) AS easyPhotoTotal
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
            e.event_status = 2
    </select>
 
    <select id="getEventCountByGridIds" resultType="Integer">
        select count(id) from event where grid_id in
        <foreach item="item" collection="ids" separator="," open="(" close=")" index="">
        #{item}
        </foreach>
    </select>
 
    <select id="getGridEventStatisticsByApp" resultType="com.panzhihua.common.model.vos.grid.GridEventStatisticsVO">
        SELECT
            count( id ) AS todayNum,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_process_status = 2
                AND process_date BETWEEN DATE_FORMAT( DATE_ADD( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY ), '%Y-%m-%d %H:%i:%s' )
            AND NOW()
            <if test="gridId!=null">
                 AND grid_id = #{gridId}
            </if>
            ) AS monthNum,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 2
                AND event_status = 2
                AND process_date BETWEEN DATE_FORMAT( CURDATE(), '%Y-%m-%d %H:%i:%s' )
            AND NOW()
            <if test="gridId!=null">
                AND grid_id = #{gridId}
            </if>
            ) AS todayEducationNum,
            ( SELECT count( id ) FROM `event` WHERE event_category = 2 AND event_status = 2
                <if test="gridId!=null">
                    AND grid_id = #{gridId}
                </if>) AS educationNum,
            (
            SELECT
                count( cmph.id )
            FROM
                com_mng_population_house AS cmph
            LEFT JOIN event_grid_data AS egd ON egd.grid_community_id = cmph.community_id
            WHERE
                <if test="gridId!=null">
                    egd.id = #{gridId}
                </if>
            ) AS houseTotal,
            (
        SELECT
        count( id )
        FROM
        event_visiting_tasks
        WHERE
        event_status = 2 AND submit_date BETWEEN DATE_FORMAT( CURDATE(), '%Y-%m-%d %H:%i:%s' )
        AND DATE_SUB( DATE_ADD(CURDATE(), INTERVAL 1 DAY),INTERVAL 1 SECOND)
        <if test="gridId!=null">
            AND grid_id = #{gridId}
        </if>
        ) as zfTodayNum,
        (
        SELECT
        count( id )
        FROM
        event_visiting_tasks
        WHERE
        event_status = 2 AND submit_date BETWEEN DATE_FORMAT( DATE_ADD( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY ), '%Y-%m-%d %H:%i:%s' )
        AND NOW()
        <if test="gridId!=null">
            AND grid_id = #{gridId}
        </if>
        ) as zfMonthNum,(
        SELECT
            count( caep.id )
        FROM
            com_act_easy_photo as caep
            left join event_grid_data as egd on egd.grid_community_id = caep.community_id
        WHERE
            handle_status = 2
            AND feedback_at BETWEEN DATE_FORMAT( CURDATE(), '%Y-%m-%d %H:%i:%s' )
            AND DATE_SUB(DATE_ADD( CURDATE(), INTERVAL 1 DAY ),INTERVAL 1 SECOND)
            <if test="gridId!=null">
                AND egd.id = #{gridId}
            </if>
        ) as sspTodayNum,
        (
        SELECT
            count( caep.id )
        FROM
            com_act_easy_photo as caep
            left join event_grid_data as egd on egd.grid_community_id = caep.community_id
        WHERE
            handle_status = 2
            AND feedback_at BETWEEN DATE_FORMAT( DATE_ADD( curdate(), INTERVAL - DAY ( curdate())+ 1 DAY ), '%Y-%m-%d %H:%i:%s' ) AND NOW()
            <if test="gridId!=null">
                AND egd.id = #{gridId}
            </if>
        ) as sspMonthNum
        FROM
            `event`
        WHERE
            event_category = 1
            AND event_process_status = 2
            AND process_date BETWEEN DATE_FORMAT( CURDATE(), '%Y-%m-%d %H:%i:%s' )
            AND NOW()
            <if test="gridId!=null">
                AND grid_id = #{gridId}
            </if>
    </select>
 
    <select id="getGridEventDetailStatisticsByApp" parameterType="com.panzhihua.common.model.dtos.grid.GridEventStatisticsDTO"
            resultType="com.panzhihua.common.model.vos.grid.GridEventStatisticsDetailVO">
        SELECT
            count( e.id ) AS eventTFTotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 5
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventTFTotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 1 AND event_type = 3 AND event_process_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventMDTotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 3
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventMDTotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 1 AND event_type = 1 AND event_process_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventZATotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 1
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventZATotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 1 AND event_type = 4 AND event_process_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventBWDTotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 4
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventBWDTotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 1 AND event_type = 6 AND event_process_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventTSTotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 6
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventTSTotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 1 AND event_type = 2 AND event_process_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventGGTotal,
            (
            SELECT
                count( id )
            FROM
                `event`
            WHERE
                event_category = 1
                AND event_type = 2
                AND event_process_status IN ( 1, 3 )
                AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS noEventGGTotal,
            ( SELECT count( id ) FROM `event` WHERE event_category = 2 AND event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventXCTotal,
            ( SELECT count( id ) FROM event_visiting_tasks WHERE event_status = 2
                <if test="statisticsDTO.gridId!=null">
                    AND grid_id = #{statisticsDTO.gridId}
                </if>
                <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                    AND submit_date <![CDATA[ >= ]]> #{statisticsDTO.startTime}
                </if>
                <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                    AND submit_date <![CDATA[ <= ]]> #{statisticsDTO.endTime}
                </if>
            ) AS eventZFTotal,
            (
            SELECT
                count( id )
            FROM
                event_visiting_tasks
            WHERE
            event_status IN ( 1, 3 )
            <if test="statisticsDTO.gridId!=null">
                AND grid_id = #{statisticsDTO.gridId}
            </if>
            <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
            </if>
            <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
            </if>
            ) AS noEventZFTotal,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE handle_status = 2 AND community_id = egd.grid_community_id
            <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
            </if>
            <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
            </if>
            ) AS eventSSPTotal,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE handle_status = 1 AND community_id = egd.grid_community_id
            <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                AND create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
            </if>
            <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                AND create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
            </if>
            ) AS noEventSSPTotal
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
            e.event_category = 1
            AND e.event_type = 5
            AND e.event_process_status = 2
            <if test="statisticsDTO.gridId!=null">
                AND e.grid_id = #{statisticsDTO.gridId}
            </if>
            <if test='statisticsDTO.startTime != null and statisticsDTO.startTime != &quot;&quot;'>
                AND e.create_at <![CDATA[ >= ]]> #{statisticsDTO.startTime}
            </if>
            <if test='statisticsDTO.endTime != null and statisticsDTO.endTime != &quot;&quot;'>
                AND e.create_at <![CDATA[ <= ]]> #{statisticsDTO.endTime}
            </if>
    </select>
 
    <select id="getUserBaseInfo" parameterType="java.lang.Long" resultType="java.util.Map">
        select nick_name,image_url from sys_user where user_id = #{gridMemberId}
    </select>
 
    <select id="getScreenEventList" parameterType="com.panzhihua.common.model.dtos.community.bigscreen.event.ScreenEventListDTO"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventListVO">
        SELECT
            e.id,
            e.grid_member_id,
            su.image_url,
            su.nick_name AS userName,
            e.happen_time as createAt,
            e.urgent,
            e.danger_level,
            e.major,
            e.process_desc,
            e.event_des,
            e.event_category,
            e.event_type,
            e.event_clazz,
            e.happen_address,
            e.happent_lat_lng,
            e.happent_address,
            e.event_deal_status,
            egd.grid_name
        FROM
            `event` AS e
            LEFT JOIN sys_user AS su ON su.user_id = e.grid_member_id
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
            <where>
                event_status = 2
                <if test='eventListDTO.communityId != null'>
                    and egd.grid_community_id = ${eventListDTO.communityId}
                </if>
 
                <if test='eventListDTO.startTime != null and eventListDTO.startTime != &quot;&quot;'>
                    and e.create_at <![CDATA[>=]]> #{eventListDTO.startTime}
                </if>
 
                <if test='eventListDTO.endTime != null and eventListDTO.endTime != &quot;&quot;'>
                    and e.create_at <![CDATA[<=]]> #{eventListDTO.endTime}
                </if>
 
                <if test='eventListDTO.gridIds != null and eventListDTO.gridIds.size > 0'>
                    and e.grid_id in
                    <foreach collection='eventListDTO.gridIds' item='id' index='index' open='(' close=')' separator=',' >
                    #{id}
                    </foreach>
                </if>
 
                <if test='eventListDTO.eventCategory != null'>
                    and e.event_category = #{eventListDTO.eventCategory}
                </if>
 
                <if test='eventListDTO.eventTypes != null and eventListDTO.eventTypes.size > 0'>
                    and e.event_type in
                    <foreach collection='eventListDTO.eventTypes' item='id' index='index' open='(' close=')' separator=',' >
                        #{id}
                    </foreach>
                </if>
 
                <if test='eventListDTO.eventDealStatus != null'>
                    and e.event_deal_status = #{eventListDTO.eventDealStatus}
                </if>
 
                <if test='eventListDTO.urgent != null and eventListDTO.urgent != &quot;&quot;'>
                    and e.urgent = #{eventListDTO.urgent}
                </if>
 
                <if test='eventListDTO.major != null and eventListDTO.major != &quot;&quot;'>
                    and e.major = #{eventListDTO.major}
                </if>
            </where>
            order by e.create_at desc
    </select>
 
    <select id="specialPopulationList" resultType="com.panzhihua.common.model.vos.grid.EventSpecialPopulationVO"
            parameterType="com.panzhihua.common.model.dtos.grid.PageEventSpecialPopulationDTO">
        SELECT
            cmp.id,
            cmp.`name`,
            cmp.card_no as idCard,
            cmpct.label,
            cmp.sex,
            cmp.phone,
            cmp.address,
            cmp.political_outlook
        FROM
            com_mng_population AS cmp
            left join com_mng_population_community_tags AS cmpct on cmp.id = cmpct.population_id
            <where>
                and cmpct.label IS NOT NULL
                <if test='specialPopulationDTO.communityId != null'>
                    and cmpct.community_id = ${specialPopulationDTO.communityId}
                </if>
                <if test="specialPopulationDTO.keyWord!=null and specialPopulationDTO.keyWord!= &quot;&quot;">
                    AND (cmp.name like concat(#{specialPopulationDTO.keyWord},'%') or cmp.card_no_str like concat(#{specialPopulationDTO.keyWord},'%'))
                </if>
            </where>
        ORDER BY
            cmp.create_at DESC
    </select>
 
    <select id="countByCommunityId" resultType="Map">
        SELECT
            count( e.id ) AS resolvedNum,
            (
            SELECT
                count( e1.id )
            FROM
                `event` AS e1
                LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
            WHERE
                egd1.grid_community_id = ${communityId}
                AND e1.event_category = 1
                AND e1.event_process_status = 1
                AND e1.event_status = 2
                AND e1.event_deal_status = 1
            ) AS pendingNum,
            (
            SELECT
                count( e2.id )
            FROM
                `event` AS e2
                LEFT JOIN event_grid_data AS egd2 ON egd2.id = e2.grid_id
            WHERE
                egd2.grid_community_id = ${communityId}
                AND e2.event_category = 2
                AND e2.event_status = 2
            ) AS propagandaNum,
            (
            SELECT
                count( e3.id )
            FROM
                `event` AS e3
                LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id
            WHERE
                e3.event_status = 2
                AND e3.create_at LIKE CONCAT(#{nowDate},'%')) as currentNum,
                (select count(id) from com_act_easy_photo where community_id = ${communityId} and del_tag = 0 and create_at LIKE CONCAT(#{nowDate},'%')) as sspCurrentNum
 
                FROM
                    `event` AS e
                    LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
                WHERE
                    egd.grid_community_id = ${communityId}
                    AND e.event_category = 1
                AND e.event_process_status = 2
            AND e.event_deal_status = 4
    </select>
 
    <select id="countByAvgCommunityId" resultType="com.panzhihua.common.model.vos.screen.DateScreenVO">
        SELECT
            e.create_at AS startTime,(
            SELECT
                e1.create_at
            FROM
                `event` AS e1
                LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
            WHERE
                egd1.grid_community_id = ${communityId}
                AND e1.event_process_status = 2
            ORDER BY
                e1.create_at DESC
                LIMIT 1
            ) AS endTime
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
            egd.grid_community_id = ${communityId}
            AND e.event_process_status = 2
        ORDER BY
            e.create_at ASC
            LIMIT 1
    </select>
 
    <select id="getWorkScreenEventList" resultType="com.panzhihua.common.model.vos.screen.EventDetailWorkVO">
        SELECT
            e.id,
            su.nick_name AS userName,
            su.image_url,
            e.create_at,
            e.event_type,
            e.event_process_status,
            e.event_deal_status,
            e.major,
            e.red_card,
            e.yellow_card,
            e.urgent,
            e.danger_level,
            e.event_des,
            e.happen_address,
            e.happent_address,
            e.happent_lat_lng
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
            LEFT JOIN sys_user AS su ON su.user_id = e.grid_member_id
        WHERE
            egd.grid_community_id = ${communityId}
            AND e.event_status = 2
            AND e.event_deal_status in (1,2,3,4,6,8)
        ORDER BY
            e.create_at DESC
            LIMIT 10
    </select>
 
    <select id="countByTime" resultType="com.panzhihua.common.model.vos.screen.EventWorkVO">
        SELECT
        (
        SELECT
        COUNT( e.id )
        FROM
        `event` AS e
        LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
        egd.grid_community_id = ${communityId} and e.event_status = 2 AND e.create_at <![CDATA[<=]]> #{end}) AS eventTotal,
        (select count(id) from com_act_easy_photo where community_id = ${communityId} and del_tag = 0 and create_at <![CDATA[<=]]> #{end}) as sspTotal,
        (select count(id) from com_act_easy_photo where community_id = ${communityId} and del_tag = 0 and #{start} <![CDATA[<=]]> create_at AND create_at <![CDATA[<=]]> #{end}) as sspAdd,
        (select count(id) from com_act_easy_photo where community_id = ${communityId} and handle_status = 2 and del_tag = 0 and #{start} <![CDATA[<=]]> create_at AND create_at <![CDATA[<=]]> #{end}) as sspSolve,
        (
        SELECT
        COUNT( e1.id )
        FROM
        `event` AS e1
        LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
        WHERE
        egd1.grid_community_id = ${communityId} and e1.event_status = 2 AND #{start} <![CDATA[<=]]> e1.create_at AND e1.create_at <![CDATA[<=]]> #{end}) AS eventAdd,
        (
        SELECT
        COUNT( e2.id )
        FROM
        `event` AS e2
        LEFT JOIN event_grid_data AS egd2 ON egd2.id = e2.grid_id
        WHERE
        egd2.grid_community_id = ${communityId} and e2.event_process_status = 2 AND #{start} <![CDATA[<=]]> e2.create_at AND e2.create_at <![CDATA[<=]]> #{end}) AS eventSolve
        FROM
        DUAL
    </select>
 
    <select id="getComplete" resultType="com.panzhihua.common.model.vos.screen.EventTypeWorkVO">
        SELECT
            count( e.id ) AS zaTotal,(
            SELECT
                count( e1.id )
            FROM
                `event` AS e1
                LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
            WHERE
                e1.event_category = 1
                AND e1.event_process_status = 2
                AND e1.event_type = 2
                AND egd1.grid_community_id = ${communityId}
                ) AS ggTotal,(
            SELECT
                count( e2.id )
            FROM
                `event` AS e2
                LEFT JOIN event_grid_data AS egd2 ON egd2.id = e2.grid_id
            WHERE
                e2.event_category = 1
                AND e2.event_process_status = 2
                AND e2.event_type = 3
                AND egd2.grid_community_id = ${communityId}
                ) AS mdTotal,(
            SELECT
                count( e3.id )
            FROM
                `event` AS e3
                LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id
            WHERE
                e3.event_category = 1
                AND e3.event_process_status = 2
                AND e3.event_type = 4
                AND egd3.grid_community_id = ${communityId}
                ) AS bwdTotal,(
            SELECT
                count( e4.id )
            FROM
                `event` AS e4
                LEFT JOIN event_grid_data AS egd4 ON egd4.id = e4.grid_id
            WHERE
                e4.event_category = 1
                AND e4.event_process_status = 2
                AND e4.event_type = 5
                AND egd4.grid_community_id = ${communityId}
                ) AS tfTotal,(
            SELECT
                count( e5.id )
            FROM
                `event` AS e5
                LEFT JOIN event_grid_data AS egd5 ON egd5.id = e5.grid_id
            WHERE
                e5.event_category = 1
                AND e5.event_process_status = 2
                AND e5.event_type = 6
                AND egd5.grid_community_id = ${communityId}
            ) AS tsTotal,
            (select count(id) from com_act_easy_photo as caep where community_id = ${communityId} and del_tag = 0 and status = 4) as sspTotal
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
            e.event_category = 1
            AND e.event_process_status = 2
            AND e.event_type = 1
            AND egd.grid_community_id = ${communityId}
    </select>
 
    <select id="getNoComplete" resultType="com.panzhihua.common.model.vos.screen.EventTypeWorkVO">
        SELECT
            count( e.id ) AS zaTotal,(
            SELECT
                count( e1.id )
            FROM
                `event` AS e1
                LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
            WHERE
                e1.event_category = 1
                AND e1.event_process_status = 1
                AND e1.event_status = 2
                AND e1.event_type = 2
                AND egd1.grid_community_id = ${communityId}
                ) AS ggTotal,(
            SELECT
                count( e2.id )
            FROM
                `event` AS e2
                LEFT JOIN event_grid_data AS egd2 ON egd2.id = e2.grid_id
            WHERE
                e2.event_category = 1
                AND e2.event_process_status = 1
                AND e2.event_status = 2
                AND e2.event_type = 3
                AND egd2.grid_community_id = ${communityId}
                ) AS mdTotal,(
            SELECT
                count( e3.id )
            FROM
                `event` AS e3
                LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id
            WHERE
                e3.event_category = 1
                AND e3.event_process_status = 1
                AND e3.event_status = 2
                AND e3.event_type = 4
                AND egd3.grid_community_id = ${communityId}
                ) AS bwdTotal,(
            SELECT
                count( e4.id )
            FROM
                `event` AS e4
                LEFT JOIN event_grid_data AS egd4 ON egd4.id = e4.grid_id
            WHERE
                e4.event_category = 1
                AND e4.event_process_status = 1
                AND e4.event_status = 2
                AND e4.event_type = 5
                AND egd4.grid_community_id = ${communityId}
                ) AS tfTotal,(
            SELECT
                count( e5.id )
            FROM
                `event` AS e5
                LEFT JOIN event_grid_data AS egd5 ON egd5.id = e5.grid_id
            WHERE
                e5.event_category = 1
                AND e5.event_process_status = 1
                AND e5.event_status = 2
                AND e5.event_type = 6
                AND egd5.grid_community_id = ${communityId}
            ) AS tsTotal,
            (select count(id) from com_act_easy_photo as caep where community_id = ${communityId} and del_tag = 0 and status in (1,2)) as sspTotal
        FROM
            `event` AS e
            LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE
            e.event_category = 1
            AND e.event_process_status = 1
            AND e.event_status = 2
            AND e.event_type = 1
            AND egd.grid_community_id = ${communityId}
    </select>
 
    <select id="getSSPEventTotal" resultType="Map">
        SELECT
            count( id ) as noEventSSPTotal,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE handle_status = 2 and del_tag = 0 AND community_id = ${communityId} ) AS eventSSPTotal
        FROM
            com_act_easy_photo
        WHERE
            handle_status = 1 and del_tag = 0
            AND community_id = ${communityId}
    </select>
 
    <select id="getEventListByCommunityId" parameterType="Long"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventGridIncidentStatisticsVO">
        SELECT
            e.id,
            e.event_type AS type,
            e.happent_lat_lng AS latLng,
            e.event_deal_status as status
        FROM
            `event` AS e
            left join event_grid_data as egd on egd.id = e.grid_id
        WHERE
            e.event_category = 1
            AND e.event_status = 2
            AND egd.grid_community_id = ${communityId}
            AND e.event_deal_status IN (1,2,3,4)
            union all
            select id,7 as type,lng_lat as latLng,handle_status as status from com_act_easy_photo as caep where community_id = ${communityId} and lng_lat is not null
    </select>
 
    <select id="getCivilScreenVillageList" parameterType="Long"  resultType="com.panzhihua.common.model.vos.community.screen.civil.CivilVillageStatisticsVO">
        SELECT `NAME`,  user_sum,  lng,  lat,  village_images,  village_id  FROM  com_mng_village AS cmv  WHERE  community_id = ${communityId}
    </select>
 
    <select id="getVillagePopulationTotal" parameterType="Long" resultType="com.panzhihua.common.model.vos.screen.ScreenDrawEventPopulationTotalVO">
        SELECT
            count( id ) as populationTotal,
            (select count(id) from com_mng_population where village_id = #{villageId} and out_or_local = 1) as localTotal,
            (select count(id) from com_mng_population where village_id = #{villageId} and out_or_local = 2) as outTotal,
            (select count(cmp.id) from com_mng_population_community_tags as cmpct left join com_mng_population as cmp on cmpct.population_id = cmp.id where cmp.village_id = #{villageId} and cmpct.label is not null) as specialTotal,
            (select count(id) from com_mng_building where village_id = #{villageId}) as buildTotal
        FROM
            com_mng_population AS cmp
        WHERE
            village_id = #{villageId}
    </select>
 
    <select id="getMemberBuildName" resultType="Map">
        SELECT
            cmb.`name`,egmbr.village_id
        FROM
            event_grid_member_building_relation AS egmbr
            LEFT JOIN com_mng_building AS cmb ON cmb.id = egmbr.building_id
        WHERE
            egmbr.grid_member_id = #{userId}
    </select>
 
    <select id="getPopulationByLabelCount" resultType="Integer">
        select count(cmpct.id) from com_mng_population_community_tags AS cmpct
              left join com_mng_population AS cmp on cmp.id = cmpct.population_id
        where cmtct.label is not null and cmp.village_id = #{villageId} and floor = #{floor}
    </select>
    <select id="selectComprehensiveGovernanceStatics"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventComprehensiveGovernanceStatisticsVO">
        SELECT
        (SELECT COUNT( e.id ) FROM `event` AS e
        LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        LEFT JOIN com_act AS a ON egd.grid_community_id = a.community_id
        WHERE e.event_category = 1 AND e.event_type = 5 AND e.event_deal_status = 4 AND a.area_code = 510423) AS eventTFTotal,
 
        (SELECT COUNT( e1.id ) FROM `event` AS e1
        LEFT JOIN event_grid_data AS egd1 ON egd1.id = e1.grid_id
        LEFT JOIN com_act AS a1 ON egd1.grid_community_id = a1.community_id
        WHERE event_category = 1 AND event_type = 1 AND e1.event_deal_status = 4 AND a1.area_code = 510423) AS eventZATotal,
 
        (SELECT COUNT( e2.id ) FROM `event` AS e2
        LEFT JOIN event_grid_data AS egd2 ON egd2.id = e2.grid_id
        LEFT JOIN com_act AS a2 ON egd2.grid_community_id = a2.community_id
        WHERE event_category = 1 AND event_type = 3 AND e2.event_deal_status = 4 AND a2.area_code = 510423) AS eventMDTotal,
 
        (SELECT COUNT( e3.id ) FROM `event` AS e3
        LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id
        LEFT JOIN com_act AS a3 ON egd3.grid_community_id = a3.community_id
        WHERE event_category = 1 AND event_type = 6 AND e3.event_deal_status = 4 AND a3.area_code = 510423) AS eventTSTotal,
 
        (SELECT COUNT( e5.id ) FROM `event` AS e5
        LEFT JOIN event_grid_data AS egd5 ON egd5.id = e5.grid_id
        LEFT JOIN com_act AS a5 ON egd5.grid_community_id = a5.community_id
        WHERE event_category = 1 AND event_type = 2 AND e5.event_deal_status = 4 AND a5.area_code = 510423) AS eventMSTotal,
 
        (SELECT COUNT(p.id) FROM com_act_easy_photo p
        LEFT JOIN com_act AS a ON p.community_id = a.community_id
        WHERE p.`status` = 4 AND p.del_tag = 0 AND a.area_code = 510423) AS eventSSPTotal
    </select>
    <select id="getGridsGovernanceEventList"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventGridIncidentStatisticsVO">
        SELECT event_type AS type, IFNULL( NULL, 1 ) AS eventType, e.id AS eventId, happent_lat_lng AS latLng, event_des AS content,
        (SELECT url FROM event_resource WHERE ref_id = e.id AND classification = 1 AND `type` = 1 LIMIT 1) AS cover, e.create_at,
        CASE
        WHEN event_deal_status = 4 THEN 1
        ELSE 2 END `status`
        FROM `event` AS e
        LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
        WHERE e.event_category = 1 AND e.event_type IN ( 1, 2, 3, 5, 6 ) AND e.event_status = 2 AND egd.grid_community_id = ${communityId}
        UNION ALL SELECT
        CASE
        WHEN classify_id = 4 THEN 1
        WHEN classify_id = 6 THEN 2
        WHEN classify_id = 5 THEN 3
        WHEN classify_id = 7 THEN 5
        WHEN classify_id = 3 THEN 6
        WHEN classify_id = 8 THEN 9
        WHEN classify_id = 1 THEN 10
        END type, IFNULL( NULL, 2 ) AS eventType, id AS eventId, lng_lat AS latLng, detail AS content, substring_index(photo_path_list, ',', 1) AS cover, create_at,
        CASE
        WHEN `status` = 4 THEN 1
        ELSE 2 END `status`
        FROM com_act_easy_photo WHERE community_id = ${communityId} AND `status` IN (1,2,4) AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8)
    </select>
    <select id="getVillagePopulationTotalNew"
            resultType="com.panzhihua.common.model.vos.screen.ScreenDrawEventPopulationTotalVO">
        SELECT
        (SELECT count(id) FROM com_mng_population WHERE village_id = #{villageId}) as populationTotal,
        (SELECT count(id) from com_mng_building where village_id = #{villageId}) as buildTotal,
        (SELECT count(id) FROM com_mng_population_house WHERE village_id = #{villageId}) as houseTotal,
        (select count(id) from com_mng_population where village_id = #{villageId} and out_or_local = 1) as localTotal,
        (select count(id) from com_mng_population where village_id = #{villageId} and out_or_local = 2) as outTotal,
        (SELECT COUNT(t1.id) FROM com_disability_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}) as disabilityTotal,
        (SELECT COUNT(t1.id) FROM com_low_security_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}) as lowSecurityTotal,
        (SELECT COUNT(id) FROM com_mng_population WHERE village_id = #{villageId} AND TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) > 80) as elderTotal,
        (SELECT COUNT(t1.id) FROM com_mng_population t1 LEFT JOIN com_mng_population_community_tags t2 ON t1.id = t2.population_id WHERE t1.village_id = #{villageId} AND t2.label LIKE '%特殊情况%') as specialSituationTotal,
        (SELECT COUNT(id) FROM
        (SELECT t1.id FROM com_drug_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        UNION ALL
        SELECT t1.id FROM com_correct_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        UNION ALL
        SELECT t1.id FROM com_cult_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        UNION ALL
        SELECT t1.id FROM com_rehabilitation_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        UNION ALL
        SELECT t1.id FROM com_key_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        UNION ALL
        SELECT t1.id FROM com_major_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}
        ) temp) as otherTotal,
        (SELECT COUNT(t1.id) FROM com_mng_population t1 LEFT JOIN com_mng_population_community_tags t2 ON t1.id = t2.population_id WHERE t1.village_id = #{villageId} AND t2.label LIKE '%特扶家庭%') as specialHelpTotal,
        (SELECT COUNT(t1.id) FROM com_veterans_population t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}) as veteransTotal,
        (SELECT COUNT(id) FROM com_mng_population WHERE village_id = #{villageId} AND TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) > 60) as oldTotal,
        (SELECT COUNT(t1.id) FROM com_pension_auth_pensioners t1 LEFT JOIN com_mng_population t2 ON t1.population_id = t2.id WHERE t2.village_id = #{villageId}) as pensionTotal,
        (SELECT COUNT(id) FROM renting_hourse_register WHERE village_id = #{villageId} AND auth_status = 2) as rentingHouseTotal,
        (SELECT COUNT(id) FROM com_mng_population t1 LEFT JOIN sys_user t2 ON t1.card_no_str = t2.id_card WHERE t1.village_id = #{villageId} AND t2.is_volunteer = 1) as volunteerTotal,
        (SELECT ROUND(AVG(TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()))) FROM com_mng_population) as averageAge
    </select>
    <select id="selectStatisticsForAge" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT filed, COUNT(filed) AS num FROM (
            SELECT
            CASE
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 0 AND 18 THEN '0-18岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 19 AND 30 THEN '19-30岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 31 AND 40 THEN '31-40岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 41 AND 50 THEN '41-50岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 51 AND 60 THEN '51-60岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 61 AND 79 THEN '61-79岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) BETWEEN 80 AND 89 THEN '80-89岁'
            WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(card_no_str, 7, 8), NOW()) > 89 THEN '89岁以上'
            END filed
            FROM com_mng_population WHERE village_id IN
            <foreach collection="villageIds" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
            ) temp WHERE filed is not null GROUP BY filed
            UNION ALL
            (SELECT '0-18岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '19-30岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '31-40岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '41-50岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '51-60岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '61-79岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '80-89岁' AS filed, 0 AS num)
            UNION ALL
            (SELECT '89岁以上' AS filed, 0 AS num)
        ) t GROUP BY filed
    </select>
    <select id="getById" resultType="com.panzhihua.common.model.vos.grid.EventDetailsVO">
        SELECT t1.*,
        CASE
        t1.revoke_type
        WHEN 1 THEN
        t2.`name`
        WHEN 2 THEN
        t3.`name`
        ELSE
        NULL
        END AS `revoke`
        FROM event t1
        LEFT JOIN sys_user t2 ON t1.revoke_id = t2.user_id
        LEFT JOIN com_act t3 ON t1.revoke_id = t3.community_id
        WHERE t1.id = #{id}
    </select>
 
</mapper>