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
<?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_community.dao.ComMngPopulationDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComMngPopulationDO">
        <id column="id" property="id" />
        <result column="street_id" property="streetId" />
        <result column="act_id" property="actId" />
        <result column="village_id" property="villageId" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="certificate_type" property="certificateType" />
        <result column="card_no" property="cardNo" />
        <result column="card_no_expiration_date" property="cardNoExpirationDate" />
        <result column="card_no_str" property="cardNoStr" />
        <result column="road" property="road" />
        <result column="door_no" property="doorNo" />
        <result column="floor" property="floor" />
        <result column="unit_no" property="unitNo" />
        <result column="house_no" property="houseNo" />
        <result column="political_outlook" property="politicalOutlook" />
        <result column="work_company" property="workCompany" />
        <result column="special_situation" property="specialSituation" />
        <result column="phone" property="phone" />
        <result column="out_or_local" property="outOrLocal" />
        <result column="census_register" property="censusRegister" />
        <result column="person_type" property="personType" />
        <result column="country" property="country" />
        <result column="date_of_departure" property="dateOfDeparture" />
        <result column="native_place" property="nativePlace" />
        <result column="nation_code" property="nationCode" />
        <result column="nation" property="nation" />
        <result column="is_rent" property="isRent" />
        <result column="culture_level" property="cultureLevel" />
        <result column="marriage" property="marriage" />
        <result column="healthy" property="healthy" />
        <result column="blood_type" property="bloodType" />
        <result column="religion" property="religion" />
        <result column="profession" property="profession" />
        <result column="person_status" property="personStatus" />
        <result column="death" property="death" />
        <result column="head_portrait" property="headPortrait" />
        <result column="monthly_income" property="monthlyIncome" />
        <result column="family_status" property="familyStatus" />
        <result column="birthday" property="birthday" />
        <result column="goal_in_china" property="goalInChina" />
        <result column="date_of_arrival" property="dateOfArrival" />
        <result column="label" property="label" />
        <result column="card_photo_front" property="cardPhotoFront" />
        <result column="card_photo_back" property="cardPhotoBack" />
        <result column="family_book" property="familyBook" />
        <result column="delete_flag" property="deleteFlag" />
        <result column="remark" property="remark" />
        <result column="create_at" property="createAt" />
        <result column="update_at" property="updateAt" />
        <result column="residence" property="residence" />
        <result column="address" property="address" />
        <result column="house_id" property="houseId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, street_id, act_id, village_id, name, sex, certificate_type, card_no, card_no_expiration_date, card_no_str, road, door_no, floor, unit_no, house_no, political_outlook, work_company, special_situation, phone, out_or_local, census_register, person_type, country, date_of_departure, native_place, nation_code, nation, is_rent, culture_level, marriage, healthy, blood_type, religion, profession, person_status, death, head_portrait, monthly_income, family_status, birthday, goal_in_china, date_of_arrival, label, card_photo_front, card_photo_back, family_book, delete_flag, remark, create_at, update_at, residence, address, house_id
    </sql>
 
    <update id="updateAll" parameterType="java.util.List">
        <foreach collection="populationList" item="item" index="index" separator=";">
            update com_mng_population
            <set>
                <if test="item.streetId != null">
                    `street_id` = #{item.streetId},
                </if>
                <if test="item.actId != null">
                    `act_id` = #{item.actId},
                </if>
                <if test="item.villageId != null">
                    `village_id` = #{item.villageId},
                </if>
                <if test="item.name != null and item.name !=&quot;&quot;">
                    `name` = #{item.name},
                </if>
                <if test="item.sex != null">
                    `sex` = #{item.sex},
                </if>
                <if test="item.certificateType != null and item.certificateType !=&quot;&quot;">
                    `certificate_type` = #{item.certificateType},
                </if>
                <if test="item.cardNo != null and item.cardNo !=&quot;&quot;">
                    `card_no` = #{item.cardNo},
                </if>
                <if test="item.cardNoExpirationDate != null">
                    `card_no_expiration_date` = #{item.cardNoExpirationDate},
                </if>
                <if test="item.cardNoStr != null and item.cardNoStr !=&quot;&quot;">
                    `card_no_str` = #{item.cardNoStr},
                </if>
                <if test="item.road != null and item.road !=&quot;&quot;">
                    `road` = #{item.road},
                </if>
                <if test="item.doorNo != null and item.doorNo !=&quot;&quot;">
                    `door_no` = #{item.doorNo},
                </if>
                <if test="item.floor != null and item.floor !=&quot;&quot;">
                    `floor` = #{item.floor},
                </if>
                <if test="item.unitNo != null and item.unitNo !=&quot;&quot;">
                    `unit_no` = #{item.unitNo},
                </if>
                <if test="item.houseNo != null and item.houseNo !=&quot;&quot;">
                    `house_no` = #{item.houseNo},
                </if>
                <if test="item.politicalOutlook != null">
                    `political_outlook` = #{item.politicalOutlook},
                </if>
                <if test="item.workCompany != null and item.workCompany !=&quot;&quot;">
                    `work_company` = #{item.workCompany},
                </if>
                <if test="item.specialSituation != null and item.specialSituation !=&quot;&quot;">
                    `special_situation` = #{item.specialSituation},
                </if>
                <if test="item.phone != null and item.phone !=&quot;&quot;">
                    `phone` = #{item.phone},
                </if>
                <if test="item.outOrLocal != null">
                    `out_or_local` = #{item.outOrLocal},
                </if>
                <if test="item.censusRegister != null and item.censusRegister !=&quot;&quot;">
                    `census_register` = #{item.censusRegister},
                </if>
                <if test="item.personType != null and item.personType !=&quot;&quot;">
                    `person_type` = #{item.personType},
                </if>
                <if test="item.country != null and item.country !=&quot;&quot;">
                    `country` = #{item.country},
                </if>
                <if test="item.dateOfDeparture != null">
                    `date_of_departure` = #{item.dateOfDeparture},
                </if>
                <if test="item.nativePlace != null and item.nativePlace !=&quot;&quot;">
                    `native_place` = #{item.nativePlace},
                </if>
                <if test="item.nationCode != null and item.nationCode !=&quot;&quot;">
                    `nation_code` = #{item.nationCode},
                </if>
                <if test="item.nation != null and item.nation !=&quot;&quot;">
                    `nation` = #{item.nation},
                </if>
                <if test="item.isRent != null">
                    `is_rent` = #{item.isRent},
                </if>
                <if test="item.cultureLevel != null">
                    `culture_level` = #{item.cultureLevel},
                </if>
                <if test="item.marriage != null">
                    `marriage` = #{item.marriage},
                </if>
                <if test="item.healthy != null and item.healthy !=&quot;&quot;">
                    `healthy` = #{item.healthy},
                </if>
                <if test="item.bloodType != null and item.bloodType !=&quot;&quot;">
                    `blood_type` = #{item.bloodType},
                </if>
                <if test="item.religion != null and item.religion !=&quot;&quot;">
                    `religion` = #{item.religion},
                </if>
                <if test="item.profession != null and item.profession !=&quot;&quot;">
                    `profession` = #{item.profession},
                </if>
                <if test="item.personStatus != null and item.personStatus !=&quot;&quot;">
                    `person_status` = #{item.personStatus},
                </if>
                <if test="item.death != null and item.death !=&quot;&quot;">
                    `death` = #{item.death},
                </if>
                <if test="item.headPortrait != null and item.headPortrait !=&quot;&quot;">
                    `head_portrait` = #{item.headPortrait},
                </if>
                <if test="item.monthlyIncome != null and item.monthlyIncome !=&quot;&quot;">
                    `monthly_income` = #{item.monthlyIncome},
                </if>
                <if test="item.familyStatus != null and item.familyStatus !=&quot;&quot;">
                    `family_status` = #{item.familyStatus},
                </if>
                <if test="item.birthday != null and item.birthday !=&quot;&quot;">
                    `birthday` = #{item.birthday},
                </if>
                <if test="item.goalInChina != null and item.goalInChina !=&quot;&quot;">
                    `goal_in_china` = #{item.goalInChina},
                </if>
                <if test="item.label != null and item.label !=&quot;&quot;">
                    `label` = #{item.label},
                </if>
                <if test="item.dateOfArrival != null">
                    `date_of_arrival` = #{item.dateOfArrival},
                </if>
                <if test="item.cardPhotoFront != null and item.cardPhotoFront !=&quot;&quot;">
                    `card_photo_front` = #{item.cardPhotoFront},
                </if>
                <if test="item.cardPhotoBack != null and item.cardPhotoBack !=&quot;&quot;">
                    `card_photo_back` = #{item.cardPhotoBack},
                </if>
                <if test="item.familyBook != null and item.familyBook !=&quot;&quot;">
                    `family_book` = #{item.familyBook},
                </if>
                <if test="item.deleteFlag != null">
                    `delete_flag` = #{item.deleteFlag},
                </if>
                <if test="item.remark != null and item.remark !=&quot;&quot;">
                    `remark` = #{item.remark},
                </if>
                <if test="item.residence != null and item.residence !=&quot;&quot;">
                    `residence` = #{item.residence},
                </if>
                <if test="item.address != null and item.address !=&quot;&quot;">
                    `address` = #{item.address},
                </if>
                <if test="item.houseId != null">
                    `house_id` = #{item.houseId},
                </if>
                `update_at` = NOW()
            </set>
            WHERE `id` = #{item.id}
        </foreach>
        ;
    </update>
 
    <select id="pagePopulationListApp" resultType="com.panzhihua.common.model.vos.grid.PopulationListVO">
        SELECT
        cmp.id,
        cmp.`name`,
        cmp.phone,
        cmp.card_no,
        cmpct.label,
        cmp.address,
        cmp.nation,
        cmp.political_outlook,
        cmv.lng,
        cmv.lat,
        cmp.sex
        FROM
        com_mng_population AS cmp
        LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id
        LEFT JOIN com_mng_population_community_tags AS cmpct ON cmp.id = cmpct.population_id
        WHERE
        cmpct.community_id = #{populationListDTO.communityId}
        <if test = 'populationListDTO.keyWord != null and populationListDTO.keyWord != &quot;&quot;' >
            AND (cmp.`name` LIKE concat (#{populationListDTO.keyWord},'%') or cmp.card_no_str like concat (#{populationListDTO.keyWord},'%'))
        </if>
        <if test = 'populationListDTO.label != null and populationListDTO.label != &quot;&quot;' >
            AND cmpct.label LIKE concat ('%',#{populationListDTO.label},'%')
        </if>
        <if test="populationListDTO.outOrLocal != null">
            AND cmp.out_or_local = #{populationListDTO.outOrLocal}
        </if>
    </select>
 
    <resultMap id="selectMap" type="com.panzhihua.common.model.vos.community.VillageVO">
        <result property="value" column="villageId"/>
        <result property="label" column="villageName"/>
        <collection property="children" ofType="com.panzhihua.common.model.vos.community.BuildingVO"
                    column="{village_id = village_id}"
                    javaType="java.util.ArrayList">
            <result property="value" column="id"/>
            <result property="label" column="name"/>
        </collection>
    </resultMap>
 
    <select id="getSecondHouseAddress" resultMap="selectMap">
        select t.village_id as villageId,concat(t.alley,t.house_num,'号') as villageName,t1.id,concat(t1.unit_no,'栋',t1.floor,'单元',t1.code,'号') as name  from com_mng_village t left join com_mng_population_house t1 on t.village_id = t1.village_id where t.community_id = ${communityId}
    </select>
 
    <select id="getSecondHouse" resultMap="selectMap">
        select t.village_id as villageId,concat(t.alley,t.house_num,'号') as villageName,t1.id,concat(t1.unit_no,'栋') as name  from com_mng_village t left join com_mng_population_house t1  on t.village_id = t1.village_id where t.community_id = ${communityId} GROUP BY t.village_id,t1.unit_no
    </select>
 
    <select id="selectListIds" resultType="com.panzhihua.service_community.model.dos.ComMngPopulationDO">
        SELECT id,card_no FROM com_mng_population
    </select>
<!--    SELECT id,card_no FROM com_mng_population  LIMIT 100-->
 
 
    <delete id="deletePopulaitonRelation">
        delete from com_mng_population_community_tags where population_id in
        <foreach item="item" collection="ids" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
    </delete>
 
    <select id="pagePopulation" resultType="com.panzhihua.common.model.vos.community.ComMngPopulationVO">
        SELECT   cmp.`name`,   cmp.id,   cmp.street_id,   cmp.act_id,
        cmp.village_id,   cmp.sex,   cmp.card_no,   cmp.road,   cmp.door_no,   cmp.floor,
        cmp.unit_no,   cmp.house_no,   cmp.political_outlook,   cmp.work_company,
        cmp.special_situation,   cmp.phone,   cmp.remark,   cmp.native_place,   cmp.nation,
        cmpct.label,    cmp.marriage,    cmp.culture_level,    cmp.profession,    cmp.out_or_local,
        cmp.census_register,    cmp.healthy,    cmp.birthday,    cmp.update_at,    cmp.address,
        cmp.is_rent, cmp.person_type FROM com_mng_population_community_tags as cmpct
        INNER JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
        <where>
            <if test='comMngPopulationVO.name != null and comMngPopulationVO.name != &quot;&quot;'>
                AND cmp.`name` LIKE concat(#{comMngPopulationVO.name},'%')    </if>
            <if test='comMngPopulationVO.label != null and comMngPopulationVO.label != &quot;&quot;'>
                AND cmpct.label LIKE concat('%',#{comMngPopulationVO.label},'%')    </if>
            <if test='comMngPopulationVO.actId != null'>   and cmpct.community_id = ${comMngPopulationVO.actId}
            </if>   <if test='comMngPopulationVO.outOrLocal != null'>
            and cmp.out_or_local = #{comMngPopulationVO.outOrLocal}    </if>
            <if test='comMngPopulationVO.villageId != null and comMngPopulationVO.villageId != &quot;&quot;'>
                and cmp.village_id = #{comMngPopulationVO.villageId}    </if>
            <if test='comMngPopulationVO.road != null and comMngPopulationVO.road != &quot;&quot;'>
                AND cmp.road = #{comMngPopulationVO.road}    </if>
            <if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo != &quot;&quot;'>
                AND cmp.door_no = #{comMngPopulationVO.doorNo}    </if>
            <if test='comMngPopulationVO.floor != null and comMngPopulationVO.floor != &quot;&quot;'>
                AND cmp.floor = #{comMngPopulationVO.floor}    </if>
            <if test='comMngPopulationVO.isDeath != null'>
                AND cmp.death = #{comMngPopulationVO.isDeath}    </if>
            <if test='comMngPopulationVO.unitNo != null and comMngPopulationVO.unitNo != &quot;&quot;'>
                AND cmp.unit_no = #{comMngPopulationVO.unitNo}    </if>
            <if test='comMngPopulationVO.houseNo != null and comMngPopulationVO.houseNo != &quot;&quot;'>
                AND cmp.house_no = #{comMngPopulationVO.houseNo}    </if>
            <if test='comMngPopulationVO.sex != null and comMngPopulationVO.sex != &quot;&quot;'>
                AND cmp.sex = #{comMngPopulationVO.sex}    </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageStartTime != &quot;&quot; and comMngPopulationVO.ageEndTime == null'>
                AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ <= ]]> #{comMngPopulationVO.ageStartTime}    </if>
            <if test='comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageEndTime != &quot;&quot; and comMngPopulationVO.ageStartTime == null'>
                AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ >= ]]> #{comMngPopulationVO.ageEndTime}    </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime == comMngPopulationVO.ageEndTime'>
                AND cmp.birthday BETWEEN #{comMngPopulationVO.ageStartTimeEnd} and #{comMngPopulationVO.ageEndTime}
            </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime != comMngPopulationVO.ageEndTime'>
                AND cmp.birthday BETWEEN #{comMngPopulationVO.ageEndTimeEnd} and #{comMngPopulationVO.ageStartTime}
            </if>
            <if test='comMngPopulationVO.nativePlace != null and comMngPopulationVO.nativePlace != &quot;&quot;'>
                AND cmp.native_place LIKE concat(#{comMngPopulationVO.nativePlace},'%')    </if>
            <if test='comMngPopulationVO.nation != null and comMngPopulationVO.nation != &quot;&quot;'>
                AND cmp.nation = #{comMngPopulationVO.nation}    </if>
            <if test='comMngPopulationVO.politicalOutlook != null and comMngPopulationVO.politicalOutlook != &quot;&quot;'>
                AND cmp.political_outlook = #{comMngPopulationVO.politicalOutlook}    </if>
            <if test='comMngPopulationVO.cardNo != null and comMngPopulationVO.cardNo != &quot;&quot;'>
                AND cmp.card_no = #{comMngPopulationVO.cardNo}    </if>
            <if test='comMngPopulationVO.remark != null and comMngPopulationVO.remark != &quot;&quot;'>
                AND cmp.remark = #{comMngPopulationVO.remark}    </if>
            <if test='comMngPopulationVO.keyWord != null and comMngPopulationVO.keyWord != &quot;&quot;'>
                AND (cmp.`name` like concat (#{comMngPopulationVO.keyWord},'%') or
                cmp.card_no_str = #{comMngPopulationVO.keyWord} or cmpct.label like concat ('%',#{comMngPopulationVO.keyWord},'%') or cmp.phone like concat ('%',#{comMngPopulationVO.keyWord},'%')
                )
            </if>
            <if test="comMngPopulationVO.personType != null and comMngPopulationVO.personType != &quot;&quot;">
                AND cmp.person_type = #{comMngPopulationVO.personType}
            </if>
        </where>
        order by cmp.create_at desc
    </select>
 
    <select id="exportOld" resultType="com.panzhihua.common.model.vos.community.ComMngPopulationVO">
        SELECT   cmp.`name`,   cmp.id,   cmp.street_id,   cmp.act_id,
        cmp.village_id,   cmp.sex,   cmp.card_no,   cmp.road,   cmp.door_no,   cmp.floor,
        cmp.unit_no,   cmp.house_no,   cmp.political_outlook,   cmp.work_company,
        cmp.special_situation,   cmp.phone,   cmp.remark,   cmp.native_place,   cmp.nation,
        cmpct.label,    cmp.marriage,    cmp.culture_level,    cmp.profession,    cmp.out_or_local,
        cmp.census_register,    cmp.healthy,    cmp.birthday,    cmp.update_at,    cmp.address,
        cmp.is_rent FROM com_mng_population_community_tags as cmpct
        LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
        <where>
            <if test='comMngPopulationVO.name != null and comMngPopulationVO.name != &quot;&quot;'>
                AND cmp.`name` LIKE concat(#{comMngPopulationVO.name},'%')    </if>
            <if test='comMngPopulationVO.label != null and comMngPopulationVO.label != &quot;&quot;'>
                AND cmpct.label LIKE concat('%',#{comMngPopulationVO.label},'%')    </if>
            <if test='comMngPopulationVO.actId != null'>   and cmpct.community_id = ${comMngPopulationVO.actId}
            </if>   <if test='comMngPopulationVO.outOrLocal != null'>
            and cmp.out_or_local = #{comMngPopulationVO.outOrLocal}    </if>
            <if test='comMngPopulationVO.villageId != null and comMngPopulationVO.villageId != &quot;&quot;'>
                and cmp.village_id = #{comMngPopulationVO.villageId}    </if>
            <if test='comMngPopulationVO.road != null and comMngPopulationVO.road != &quot;&quot;'>
                AND cmp.road = #{comMngPopulationVO.road}    </if>
            <if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo != &quot;&quot;'>
                AND cmp.door_no = #{comMngPopulationVO.doorNo}    </if>
            <if test='comMngPopulationVO.floor != null and comMngPopulationVO.floor != &quot;&quot;'>
                AND cmp.floor = #{comMngPopulationVO.floor}    </if>
            <if test='comMngPopulationVO.isDeath != null'>
                AND cmp.death = #{comMngPopulationVO.isDeath}    </if>
            <if test='comMngPopulationVO.unitNo != null and comMngPopulationVO.unitNo != &quot;&quot;'>
                AND cmp.unit_no = #{comMngPopulationVO.unitNo}    </if>
            <if test='comMngPopulationVO.houseNo != null and comMngPopulationVO.houseNo != &quot;&quot;'>
                AND cmp.house_no = #{comMngPopulationVO.houseNo}    </if>
            <if test='comMngPopulationVO.sex != null and comMngPopulationVO.sex != &quot;&quot;'>
                AND cmp.sex = #{comMngPopulationVO.sex}    </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageStartTime != &quot;&quot; and comMngPopulationVO.ageEndTime == null'>
                AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ <= ]]> #{comMngPopulationVO.ageStartTime}    </if>
            <if test='comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageEndTime != &quot;&quot; and comMngPopulationVO.ageStartTime == null'>
                AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ >= ]]> #{comMngPopulationVO.ageEndTime}    </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime == comMngPopulationVO.ageEndTime'>
                AND cmp.birthday BETWEEN #{comMngPopulationVO.ageStartTimeEnd} and #{comMngPopulationVO.ageEndTime}
            </if>
            <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime != comMngPopulationVO.ageEndTime'>
                AND cmp.birthday BETWEEN #{comMngPopulationVO.ageEndTimeEnd} and #{comMngPopulationVO.ageStartTime}
            </if>
            <if test='comMngPopulationVO.nativePlace != null and comMngPopulationVO.nativePlace != &quot;&quot;'>
                AND cmp.native_place LIKE concat(#{comMngPopulationVO.nativePlace},'%')    </if>
            <if test='comMngPopulationVO.nation != null and comMngPopulationVO.nation != &quot;&quot;'>
                AND cmp.nation = #{comMngPopulationVO.nation}    </if>
            <if test='comMngPopulationVO.politicalOutlook != null and comMngPopulationVO.politicalOutlook != &quot;&quot;'>
                AND cmp.political_outlook = #{comMngPopulationVO.politicalOutlook}    </if>
            <if test='comMngPopulationVO.cardNo != null and comMngPopulationVO.cardNo != &quot;&quot;'>
                AND cmp.card_no = #{comMngPopulationVO.cardNo}    </if>
            <if test='comMngPopulationVO.remark != null and comMngPopulationVO.remark != &quot;&quot;'>
                AND cmp.remark = #{comMngPopulationVO.remark}    </if>
            <if test='comMngPopulationVO.keyWord != null and comMngPopulationVO.keyWord != &quot;&quot;'>
                AND (cmp.`name` like concat (#{comMngPopulationVO.keyWord},'%') or
                cmp.card_no_str = #{comMngPopulationVO.keyWord} or cmpct.label like concat ('%',#{comMngPopulationVO.keyWord},'%') or cmp.phone like concat ('%',#{comMngPopulationVO.keyWord},'%')
                )
            </if>
        </where>
        order by cmp.create_at desc
    </select>
 
    <select id="specialInputUser" resultType="com.panzhihua.common.model.vos.user.InputUserInfoVO">
        SELECT
            cmp.id,
            cmv.`name` AS areaName,
            cmv.alley AS alley,
            cmv.house_num AS houseNum,
            cmp.`name`,
            cmp.phone,
            cmpct.label AS tags,
            cmp.create_at
        FROM
            com_mng_population_community_tags as cmpct
            LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
            LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id
        WHERE
            cmpct.community_id = ${pageInputUserDTO.communityId}
            AND (cmpct.label like '%吸毒%' or cmpct.label like '%矫正%' or cmpct.label like '%重精%' or cmpct.label like '%刑满%'
            or cmpct.label like '%上访%'   or cmpct.label like '%退役%' or cmpct.label like '%残疾%' or cmpct.label like '%低保%')
        <if test='pageInputUserDTO.name != null and pageInputUserDTO.name != &quot;&quot;'>
                AND cmp.`name` LIKE concat(#{pageInputUserDTO.name},'%')
            </if>
            <if test='pageInputUserDTO.areaName != null and pageInputUserDTO.areaName != &quot;&quot;'>
                AND cmv.`name` LIKE concat(#{pageInputUserDTO.areaName},'%')
            </if>
            <if test='pageInputUserDTO.tags != null and pageInputUserDTO.tags != &quot;&quot;'>
                AND cmpct.label like concat('%',#{pageInputUserDTO.tags},'%')
            </if>
        ORDER BY
            cmp.create_at DESC
    </select>
 
    <select id="specialInputUserExport" resultType="com.panzhihua.common.model.vos.user.InputUserInfoVO">
        SELECT
        cmp.id,
        cmv.`name` AS areaName,
        cmv.alley AS alley,
        cmv.house_num AS houseNum,
        cmp.`name`,
        cmp.phone,
        cmpct.label AS tags,
        cmp.create_at
        FROM
        com_mng_population_community_tags as cmpct
        LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
        LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id
        WHERE
        cmpct.community_id = ${pageInputUserDTO.communityId}
        AND (cmpct.label like '%吸毒%' or cmpct.label like '%矫正%' or cmpct.label like '%重精%' or cmpct.label like '%刑满%'
        or cmpct.label like '%上访%'   or cmpct.label like '%退役%' or cmpct.label like '%残疾%' or cmpct.label like '%低保%')
        <if test='pageInputUserDTO.name != null and pageInputUserDTO.name != &quot;&quot;'>
            AND cmp.`name` LIKE concat(#{pageInputUserDTO.name},'%')
        </if>
        <if test='pageInputUserDTO.areaName != null and pageInputUserDTO.areaName != &quot;&quot;'>
            AND cmv.`alley` LIKE concat(#{pageInputUserDTO.areaName},'%')
        </if>
        <if test='pageInputUserDTO.tags != null and pageInputUserDTO.tags != &quot;&quot;'>
            AND cmpct.label like concat('%',#{pageInputUserDTO.tags},'%')
        </if>
        ORDER BY
        cmp.create_at DESC
    </select>
 
    <select id="query" resultType="com.panzhihua.common.model.vos.community.ComMngPopulationNoSecretVO">
        select * from com_mng_population
        <where>
            1=1
            <if test="commonPage.name !=null and commonPage.name.trim() !=''">
                and name like concat('%',#{commonPage.name},'%')
            </if>
            <if test="commonPage.paramId !=null and commonPage.paramId !=''">
                and act_id = #{commonPage.paramId}
            </if>
        </where>
    </select>
 
    <resultMap id="selectMap2" type="com.panzhihua.common.model.vos.community.ComMngPopulationDetailVO">
        <id column="id" property="id" />
        <result column="street_id" property="streetId" />
        <result column="act_id" property="actId" />
        <result column="village_id" property="villageId" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="card_no" property="cardNo" />
        <result column="card_no_str" property="cardNoStr" />
        <result column="road" property="road" />
        <result column="door_no" property="doorNo" />
        <result column="floor" property="floor" />
        <result column="unit_no" property="unitNo" />
        <result column="phone" property="phone"/>
        <result column="house_no" property="houseNo" />
        <result column="political_outlook" property="politicalOutlook" />
        <result column="work_company" property="workCompany" />
        <result column="special_situation" property="specialSituation" />
        <result column="remark" property="remark" />
        <result column="create_at" property="createAt" />
        <result column="update_at" property="updateAt" />
        <result column="address" property="address" />
        <collection property="houseList" column="{id = id}" ofType="com.panzhihua.common.model.vos.user.ComMngHouseVo"  javaType="java.util.ArrayList">
            <result column="house_address" property="address"/>
            <result column="house_house_id" property="houseId" />
            <result column="house_residence" property="residence" />
            <result column="popul_id" property="populId"/>
            <result column="status" property="status"/>
            <result column="s_relation" property="relation"/>
            <result column="s_srelation_id" property="relationId"/>
        </collection>
    </resultMap>
 
    <select id="getById" resultMap="selectMap2">
         select t.*,t2.address as house_address,t2.house_id as house_house_id ,t2.residence as  house_residence ,t2.status,t2.relation as s_relation,t2.relation_id as s_relation_id,t2.popul_id from com_mng_population t left join ( select t.address,t1.house_id,t1.popul_id,t1.relation,t1.relation_id,t.status,t1.residence from com_mng_population_house t left join com_mng_population_house_user t1 on t.id = t1.house_id) t2 on t.id = t2.popul_id where t.id =#{id}
    </select>
 
    <select id="getPopulationDetailApp" resultType="com.panzhihua.common.model.vos.grid.PopulationDetailVO">
        SELECT
            cmp.id,
            cmp.`name`,
            cmp.phone,
            cmp.card_no,
            cmp.address,
            cmp.culture_level,
            cmp.nation,
            cmp.political_outlook,
            cmp.sex,
            cmp.birthday,
            cmp.native_place,
            cmp.healthy,
            cmp.is_rent,
            cmv.alley AS road,
            cmv.house_num AS doorNo,
            cmp.floor,
            cmp.unit_no,
            cmp.house_no,
            cmp.work_company,
            cmp.census_register,
            cmp.out_or_local,
            cmp.remark,
            cmp.marriage
        FROM
            com_mng_population AS cmp
            LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmp.village_id
        WHERE
            cmp.id = #{populationId}
    </select>
 
    <select id="getCommunityTagList" resultType="com.panzhihua.common.model.vos.community.ComMngPopulationCommunityTagsVo">
        SELECT
            cmpct.population_id,
            cmpct.community_id,
            cmpct.label,
            ca.`name` AS communityName
        FROM
            com_mng_population_community_tags AS cmpct
            LEFT JOIN com_act AS ca ON ca.community_id = cmpct.community_id
        WHERE
            cmpct.population_id = #{populationId}
    </select>
 
    <select id="getGridPopulationAdminList" resultType="com.panzhihua.common.model.vos.grid.admin.ComMngPopulationListVO">
        SELECT  cmp.id,   cmp.`name` AS userName,
        cmpct.label,   cmp.card_no,   cmp.card_no_str,   cmp.sex,   cmp.address,
        cmp.political_outlook,   cmp.census_register,   cmp.house_id,   cmp.phone,
        IFNULL(cmp.house_id,0) as isHouse,
        ( SELECT event_status FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS eventStatus,
        ( SELECT create_at FROM event_visiting_tasks WHERE event_status in (1,2,3,5) AND visiter_id = cmp.id ORDER BY create_at DESC LIMIT 1 ) AS createAt
        FROM
        com_mng_population AS cmp left join com_mng_population_community_tags as cmpct on cmp.id = cmpct.population_id where 1=1
        <if test='populationListDTO.keyWord != null and populationListDTO.keyWord != &quot;&quot;'>
            AND (cmp.name like concat (#{populationListDTO.keyWord},'%') or cmp.card_no = #{populationListDTO.cardNo} or cmp.address like concat (#{populationListDTO.keyWord},'%'))
        </if>  <if test='populationListDTO.label != null and populationListDTO.label != &quot;&quot;'>
        AND cmpct.label like concat ('%',#{populationListDTO.label},'%')  </if>
        <if test='populationListDTO.sex != null'> AND cmp.sex = #{populationListDTO.sex}  </if>
        <if test='populationListDTO.isHouse != null and populationListDTO.isHouse == 1'>
            AND cmp.house_id is not null  </if>
        <if test='populationListDTO.isHouse != null and populationListDTO.isHouse == 2'>
            AND cmp.house_id is null  </if>  <if test='populationListDTO.communityId != null'>
        AND cmpct.community_id = ${populationListDTO.communityId}  </if>
        <if test='populationListDTO.politicalOutlook != null'>
            AND cmp.political_outlook = #{populationListDTO.politicalOutlook}  </if>
    </select>
 
    <select id="getEventScreenLeftDown" resultType="com.panzhihua.common.model.vos.community.screen.event.EventLeftDownStatisticsVO">
        SELECT    count( e.id ) AS eventZATotal,    IFNULL((     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 = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 1       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e1.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e1.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventZATotal,    IFNULL((     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 = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 5       AND event_status = 2
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e2.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e2.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS eventTFTotal,    IFNULL((     SELECT      count( e3.id )      FROM      `event` AS e3
        LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id      WHERE
        egd3.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 5       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e3.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e3.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventTFTotal,    IFNULL((     SELECT      count( e4.id )      FROM
        `event` AS e4      LEFT JOIN event_grid_data AS egd4 ON egd4.id = e4.grid_id      WHERE
        egd4.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 6       AND event_status = 2
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e4.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e4.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS eventTSTotal,    IFNULL((     SELECT      count( e5.id )      FROM      `event` AS e5
        LEFT JOIN event_grid_data AS egd5 ON egd5.id = e5.grid_id      WHERE
        egd5.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 6       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e5.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e5.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventTSTotal,    IFNULL((     SELECT      count( e6.id )      FROM
        `event` AS e6      LEFT JOIN event_grid_data AS egd6 ON egd6.id = e6.grid_id      WHERE
        egd6.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 3       AND event_status = 2
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e6.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e6.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS eventMDTotal,    IFNULL((     SELECT      count( e7.id )      FROM      `event` AS e7
        LEFT JOIN event_grid_data AS egd7 ON egd7.id = e7.grid_id      WHERE
        egd7.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 3       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e7.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e7.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventMDTotal,    IFNULL((     SELECT      count( e8.id )      FROM
        `event` AS e8      LEFT JOIN event_grid_data AS egd8 ON egd8.id = e8.grid_id      WHERE
        egd8.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 4       AND event_status = 2
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e8.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e8.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS eventBWDTotal,    IFNULL((     SELECT      count( e9.id )      FROM      `event` AS e9
        LEFT JOIN event_grid_data AS egd9 ON egd9.id = e9.grid_id      WHERE
        egd9.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 4       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e9.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e9.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventBWDTotal,    IFNULL((     SELECT      count( e10.id )      FROM
        `event` AS e10      LEFT JOIN event_grid_data AS egd10 ON egd10.id = e10.grid_id      WHERE
        egd10.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 2       AND event_status = 2
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e10.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e10.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS eventGGTotal,    IFNULL((     SELECT      count( e11.id )      FROM
        `event` AS e11      LEFT JOIN event_grid_data AS egd11 ON egd11.id = e11.grid_id      WHERE
        egd11.grid_community_id = ${screenEventDTO.communityId}       AND event_category = 1
        AND event_type = 2       AND event_deal_status = 4
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e11.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND e11.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>      ),     0
        ) AS yesEventGGTotal,
        IFNULL(( SELECT count( id ) FROM com_act_easy_photo WHERE del_tag = 0  AND community_id = ${screenEventDTO.communityId}
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>   ), 0 ) AS eventSSPTotal,
        IFNULL(( SELECT count( id ) FROM com_act_easy_photo WHERE del_tag = 0 AND `status` = 4 AND community_id = ${screenEventDTO.communityId}
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
            AND create_at <![CDATA[<=]]> #{screenEventDTO.endTime}    </if>   ), 0 ) AS yesEventSSPTotal
        FROM    `event` AS e    LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id    WHERE
        egd.grid_community_id = ${screenEventDTO.communityId}     AND event_status = 2 AND event_category = 1
        AND event_type = 1
        <if test='screenEventDTO.startTime != null and screenEventDTO.startTime != &quot;&quot;'>
            AND e.create_at <![CDATA[>=]]> #{screenEventDTO.startTime}    </if>
        <if test='screenEventDTO.endTime != null and screenEventDTO.endTime != &quot;&quot;'>
        AND e.create_at <![CDATA[<=]]> #{screenEventDTO.endTime}
        </if>
    </select>
 
    <update id="updatePopulationUnit">
        update com_mng_population set unit_no = #{newUnitNo} where village_id = #{villageId} and floor = #{floor} and unit_no = #{oldUnitNo}
    </update>
 
    <select id="selectCountByVillageId" resultType="Integer">
        select count(*) from com_mng_population t LEFT JOIN com_mng_population_community_tags t1 on t.id= t1.population_id
        where t.village_id=#{villageId} and t1.label like concat('%',#{label},'%')
    </select>
 
    <select id="getCivilParty" resultType="com.panzhihua.common.model.vos.community.screen.civil.CivilPartyStatisticsVO">
        SELECT
            count( id ) as committeeNum,
            (select count(id) from com_pb_dyn where community_id = ${communityId} and `type` = 1) as dynNum,
            (select count(id) from com_pb_activity where community_id = ${communityId}) as activityNum,
            (select count(id) from com_act_micro_wish where community_id = ${communityId}) as wishNum,
            (select count(id) from com_pb_member where community_id = ${communityId} and audit_result = 1) as partyNum,
            (select count(id) from com_pb_org where community_id = ${communityId} and parent_id = 0) as organizationNum,
            (select count(id) from com_mng_volunteer_mng where community_id = ${communityId} and state = 2) as volunteerNum,
            (select count(id) from com_act_questnaire where community_id = ${communityId}) as questionnaireNum
        FROM
            com_pb_member_role
        WHERE
            community_id = ${communityId}
    </select>
 
    <select id="getCivilGovernment" resultType="com.panzhihua.common.model.vos.community.screen.civil.CivilGovernmentStatisticsVO">
        SELECT
            count( id ) as noticeNum,
            (select count(id) from com_act_discuss where community_id = ${communityId} and is_del = 2) as discussNum,
            (select count(id) from com_act_easy_photo where community_id = ${communityId} and del_tag = 0) as easyNum,
            (select count(id) from com_act_neighbor_circle where community_id = ${communityId} and is_del = 2) as neighborNum,
            (select count(id) from com_act_activity where community_id = ${communityId}) as activityNum,
            (select count(id) from com_act_dyn where community_id = ${communityId}) as dynNum,
            (select count(id) from com_act_warehouse_donates where community_id = ${communityId}) as loveNum,
            (select count(id) from com_act_message where community_id = ${communityId}) as messageNum
        FROM
            com_act_announcement
        WHERE
            community_id = ${communityId}
    </select>
 
    <select id="getCivilGrid" resultType="com.panzhihua.common.model.vos.community.screen.civil.CivilGridStatisticsVO">
        SELECT
            count( e.id ) AS tfTodayNum,
            (
            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 e1.event_type = 1
                AND e1.event_category = 1
                AND e1.create_at BETWEEN DATE_FORMAT( NOW(), '%Y-%m-%d 00:00:00' )
            AND DATE_FORMAT( NOW(), '%Y-%m-%d 23:59:59' )) AS zaTodayNum,
            (
            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_status = 2
                AND e2.event_type = 2
                AND e2.event_category = 1
                AND e2.create_at BETWEEN DATE_FORMAT( NOW(), '%Y-%m-%d 00:00:00' )
            AND DATE_FORMAT( NOW(), '%Y-%m-%d 23:59:59' )) AS msTodayNum,
            (
            SELECT
                count( e3.id )
            FROM
                `event` AS e3
                LEFT JOIN event_grid_data AS egd3 ON egd3.id = e3.grid_id
            WHERE
                egd3.grid_community_id = ${communityId}
                AND e3.event_status = 2
                AND e3.event_type = 3
                AND e3.event_category = 1
                AND e3.create_at BETWEEN DATE_FORMAT( NOW(), '%Y-%m-%d 00:00:00' )
            AND DATE_FORMAT( NOW(), '%Y-%m-%d 23:59:59' )) AS mdTodayNum,
            (
            SELECT
                count( e4.id )
            FROM
                `event` AS e4
                LEFT JOIN event_grid_data AS egd4 ON egd4.id = e4.grid_id
            WHERE
                egd4.grid_community_id = ${communityId}
                AND e4.event_status = 2
                AND e4.event_type = 6
                AND e4.event_category = 1
                AND e4.create_at BETWEEN DATE_FORMAT( NOW(), '%Y-%m-%d 00:00:00' )
            AND DATE_FORMAT( NOW(), '%Y-%m-%d 23:59:59' )) AS tsTodayNum,
            (
            SELECT
                count( e5.id )
            FROM
                `event` AS e5
                LEFT JOIN event_grid_data AS egd5 ON egd5.id = e5.grid_id
            WHERE
                egd5.grid_community_id = ${communityId}
                AND e5.event_status = 2
            ) AS eventNum,
            (
            SELECT
                count( user_id )
            FROM
                sys_user AS su
                INNER JOIN event_grid_member_relation egmr ON egmr.grid_member_id = su.user_id
            WHERE
                egmr.grid_community_id = ${communityId}
            ) AS xcNum,
            ( SELECT count( id ) FROM com_sw_patrol_record WHERE community_id = ${communityId} ) AS securityNum
        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.event_type = 5
            AND e.event_category = 1
            AND e.create_at BETWEEN DATE_FORMAT( NOW(), '%Y-%m-%d 00:00:00' )
            AND DATE_FORMAT(
            NOW(),
            '%Y-%m-%d 23:59:59')
    </select>
 
    <select id="getCivilConvenience" resultType="com.panzhihua.common.model.vos.community.screen.civil.CivilConvenienceStatisticsVO">
        SELECT
            count( id ) AS guideNum,
            (
            SELECT
                count( carr.id )
            FROM
                com_act_reserve_record AS carr
                LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
            WHERE
                car.title IN ( '返攀登记', '居家隔离', '11月24日之前居家隔离', '2021-11-4之前来攀登记' )
                AND carr.community_id = ${communityId}
            ) AS situationNum,
            ( SELECT count( id ) FROM renting_hourse_register WHERE community_id = ${communityId} ) AS leaseNum,
            (
            SELECT
                count( cpr.id )
            FROM
                com_property_repair AS cpr
                LEFT JOIN com_property AS cp ON cp.id = cpr.property_id
            WHERE
                cp.community_id = ${communityId}
            ) AS repairNum,
            ( SELECT count( id ) FROM com_pension_auth_records WHERE community_id = ${communityId} ) AS pensionNum,
            ( SELECT count( id ) FROM com_elder_auth_records WHERE community_id = ${communityId} ) AS eldersNum,
            (
            SELECT
                count( cmpct.id )
            FROM
                com_mng_population_community_tags AS cmpct
                INNER JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
            WHERE
                cmpct.label LIKE '%低保户%'
                AND cmpct.community_id = ${communityId}
            ) AS subsistenceNum,
            (
            SELECT
                count( cmpct.id )
            FROM
                com_mng_population_community_tags AS cmpct
                INNER JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
            WHERE
                cmpct.community_id = ${communityId}
                AND cmp.death = 0
                AND cmpct.label LIKE '%高龄老人%'
            ) AS allowanceNum
        FROM
            com_act_work_guide
    </select>
 
 
    <select id="westScreenStatics" resultType="com.panzhihua.common.model.vos.community.bigscreen.WestScreenStatics">
        select  ( SELECT    count(*) FROM    com_act_micro_wish AS camw  LEFT JOIN com_act t1 on camw.community_id = t1.community_id
                  where t1.area_code ='510423'  and    camw.STATUS = 6 ) microWish ,
                (select count(user_id) from sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
                 where t.type=1 and t.community_id is not null and t1.area_code ='510423') user,
                (select count(id) from com_pb_org t LEFT JOIN com_act t1 on t.community_id = t1.community_id where parent_id = 0 and t1.area_code ='510423') partyOrg,
                (select count(id) from com_pb_member t LEFT JOIN com_act t1 on t.community_id = t1.community_id where audit_result = 1 and t1.area_code ='510423') partyMember,
                (select count(id) from com_mng_volunteer_mng t LEFT JOIN com_act t1 on t.community_id = t1.community_id where  t.state = 2 and t1.area_code ='510423')  volunteer,
                (select count(id) from com_sw_patrol_record t LEFT JOIN com_act t1 on t.community_id = t1.community_id where   t1.area_code ='510423') safety,
                (select count(*) from com_act_reserve t LEFT JOIN com_act_reserve_record t1 on t.id = t1.reserve_id LEFT JOIN com_act t2 on t.community_id = t2.community_id       where (title like '%居家隔离%' or title like  '%返攀登记%' or title like  '%来攀登记%') and t2.area_code ='510423' and t1.status = 2  )  reserve,
                (select (select count(*) from com_act_activity t LEFT JOIN com_act t1 on t.community_id = t1.community_id  where status !=6 and status !=1 and  t1.area_code ='510423')+(select count(id) from com_pb_activity t LEFT JOIN com_act t1 on t.community_id = t1.community_id  where status !=6 and status !=1 and  t1.area_code ='510423')) activity,
                (select count(*) from com_act_easy_photo t LEFT JOIN com_act t1 on t.community_id = t1.community_id
                where     status in (1,2,4) and del_tag = 0 and t1.area_code ='510423') neighbor,
                (select count(*) from com_act_discuss t LEFT JOIN com_act t1 on t.community_id = t1.community_id
                where     is_del =2  and t1.area_code ='510423') discuss
        </select>
 
    <select id="getBasicsList" resultType="com.panzhihua.common.model.vos.community.screen.event.EventPopulationBasicsStatisticsVO">
        SELECT
            ca.community_id,
            ca.`name` AS communityName,
            (
            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
                cmpct.community_id = ca.community_id
            ) AS populationNum,
            ( SELECT count( village_id ) FROM com_mng_village AS cmv WHERE cmv.community_id = ca.community_id ) AS villageNum,
            (select count(id) from com_mng_population_house as cmph where cmph.community_id = ca.community_id) as houseNum
        FROM
            com_act AS ca
            LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
            <where>
                1=1
                and ca.area_code = '510423' and ca.is_screen_statistics = 1 and ca.community_id!=1552661950301868035 and ca.community_id!=11
                <if test="streetId != null and streetId != 0">
                    and cs.street_id = #{streetId}
                </if>
            </where>
        order by cs.street_id desc,populationNum desc
    </select>
 
    <select id="getPopulationSpecial" resultType="com.panzhihua.common.model.vos.community.screen.event.EventPopulationSpecialStatisticsVO">
        SELECT
            count( cmpct.id ) AS cjTotal,
            (
            SELECT
            count( cmpct1.id )
        FROM
            com_mng_population_community_tags AS cmpct1
            LEFT JOIN com_act AS ca1 ON ca1.community_id = cmpct1.community_id
            LEFT JOIN com_street AS cs1 ON cs1.street_id = ca1.street_id
        WHERE
             cmpct1.label LIKE '%低保户%' and ca1.area_code = '510423' and ca1.is_screen_statistics = 1
            <if test="streetId != null and streetId != 0">
                and cs1.street_id = #{streetId}
            </if>
            ) as dbTotal ,
            (
            SELECT
            count( cmpct3.id )
        FROM
            com_mng_population_community_tags AS cmpct3
            LEFT JOIN com_act AS ca3 ON ca3.community_id = cmpct3.community_id
            LEFT JOIN com_street AS cs3 ON cs3.street_id = ca3.street_id
        WHERE
             cmpct3.label LIKE '%特殊情况(重大病史/孕)%' and ca3.area_code = '510423' and ca3.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs3.street_id = #{streetId}
        </if>
            ) as tsTotal ,
            (
            SELECT
            count( cmpct4.id )
        FROM
            com_mng_population_community_tags AS cmpct4
            LEFT JOIN com_act AS ca4 ON ca4.community_id = cmpct4.community_id
            LEFT JOIN com_street AS cs4 ON cs4.street_id = ca4.street_id
        WHERE
            cmpct4.label LIKE '%特扶家庭%' and ca4.area_code = '510423' and ca4.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs4.street_id = #{streetId}
        </if>
            ) as tfTotal,
            (
            SELECT
            count( cmpct5.id )
        FROM
            com_mng_population_community_tags AS cmpct5
            LEFT JOIN com_act AS ca5 ON ca5.community_id = cmpct5.community_id
            LEFT JOIN com_street AS cs5 ON cs5.street_id = ca5.street_id
        WHERE
            cmpct5.label LIKE '%退役军人%' and ca5.area_code = '510423' and ca5.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs5.street_id = #{streetId}
        </if>
            ) as tyTotal,
            (
            SELECT
            count( cmpct7.id )
        FROM
            com_mng_population_community_tags AS cmpct7
            LEFT JOIN com_act AS ca7 ON ca7.community_id = cmpct7.community_id
            LEFT JOIN com_street AS cs7 ON cs7.street_id = ca7.street_id
        WHERE
            cmpct7.label LIKE '%吸毒人员%' and ca7.area_code = '510423' and ca7.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs7.street_id = #{streetId}
        </if>
            ) as xdTotal,
            (
            SELECT
            count( cmpct8.id )
        FROM
            com_mng_population_community_tags AS cmpct8
            LEFT JOIN com_act AS ca8 ON ca8.community_id = cmpct8.community_id
            LEFT JOIN com_street AS cs8 ON cs8.street_id = ca8.street_id
        WHERE
            cmpct8.label LIKE '%社区矫正%' and ca8.area_code = '510423' and ca8.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs8.street_id = #{streetId}
        </if>
            ) as jzTotal,
            (
            SELECT
            count( cmpct9.id )
        FROM
            com_mng_population_community_tags AS cmpct9
            LEFT JOIN com_act AS ca9 ON ca9.community_id = cmpct9.community_id
            LEFT JOIN com_street AS cs9 ON cs9.street_id = ca9.street_id
        WHERE
            cmpct9.label LIKE '%邪教人员%' and ca9.area_code = '510423' and ca9.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs9.street_id = #{streetId}
        </if>
            ) as xjTotal,
            (
            SELECT
            count( cmpct10.id )
        FROM
            com_mng_population_community_tags AS cmpct10
            LEFT JOIN com_act AS ca10 ON ca10.community_id = cmpct10.community_id
            LEFT JOIN com_street AS cs10 ON cs10.street_id = ca10.street_id
        WHERE
            cmpct10.label LIKE '%刑满释放%' and ca10.area_code = '510423' and ca10.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs10.street_id = #{streetId}
        </if>
            ) as xsTotal,
            (
            SELECT
            count( cmpct11.id )
        FROM
            com_mng_population_community_tags AS cmpct11
            LEFT JOIN com_act AS ca11 ON ca11.community_id = cmpct11.community_id
            LEFT JOIN com_street AS cs11 ON cs11.street_id = ca11.street_id
        WHERE
            cmpct11.label LIKE '%上访人员%' and ca11.area_code = '510423' and ca11.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs11.street_id = #{streetId}
        </if>
            ) as sfTotal,
            (
            SELECT
            count( cmpct12.id )
        FROM
            com_mng_population_community_tags AS cmpct12
            LEFT JOIN com_act AS ca12 ON ca12.community_id = cmpct12.community_id
            LEFT JOIN com_street AS cs12 ON cs12.street_id = ca12.street_id
        WHERE
            cmpct12.label LIKE '%精神障碍患者%' and ca12.area_code = '510423' and ca12.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs12.street_id = #{streetId}
        </if>
            ) as zjTotal
        FROM
            com_mng_population_community_tags AS cmpct
            LEFT JOIN com_act AS ca ON ca.community_id = cmpct.community_id
            LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
        WHERE
            cmpct.label LIKE '%残疾人%' and ca.area_code = '510423' and ca.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs.street_id = #{streetId}
        </if>
    </select>
 
    <select id="getPopulationListCardNo" resultType="string">
        SELECT
            cmp.card_no
        FROM
            com_mng_population_community_tags AS cmpct
            LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
            LEFT JOIN com_act AS ca ON ca.community_id = cmpct.community_id
            LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
        <where>
            and ca.area_code = '510423' and ca.is_screen_statistics = 1
            <if test="streetId != null and streetId != 0">
                and cs.street_id = #{streetId}
            </if>
        </where>
    </select>
 
    <select id="getPopulationAge" resultType="integer">
        select count(age) from (
            SELECT
            YEAR (now()) - YEAR (substring(cmp.card_no_str, 7, 8)) age
        FROM
            com_mng_population_community_tags AS cmpct
            LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id
            LEFT JOIN com_act AS ca ON ca.community_id = cmpct.community_id
            LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
 
        <where>
            and ca.area_code = '510423' and ca.is_screen_statistics = 1
            <if test="streetId != null and streetId != 0">
                and cs.street_id = #{streetId}
            </if>
        </where>
            having age >= #{age}
        ) as ageDual
    </select>
 
    <select id="getComprehensiveStreetList" resultType="com.panzhihua.common.model.vos.community.screen.event.EventPopulationStreetVO">
        SELECT
            street_id,
            `name`
        FROM
            com_street
        WHERE
            area_code = '510423' and app_id = 'wx0cef797390444b75'
        ORDER BY
            create_at DESC
    </select>
 
    <select id="baseInfo" resultType="com.panzhihua.common.model.vos.community.bigscreen.BaseInfo">
        select count(id) as population,
            IFNULL((select count(id) from com_mng_population_house where community_id = ${communityId}),0) as house,
            IFNULL((select count(id) from com_mng_real_company where community_id = ${communityId}),0) as company,
            IFNULL((select count(DISTINCT `name`) from com_mng_village where community_id = ${communityId}),0) as village,
            IFNULL((select count(user_id) from sys_user where community_id = ${communityId} and type=1),0) as user,
            IFNULL((select count(id) from com_pb_member where community_id = ${communityId} and audit_result =1 ),0) as partyMember,
            IFNULL((select count(id) from com_mng_volunteer_mng where community_id = ${communityId} and state=2 ),0) as volunteer,
            IFNULL((select count(id) from com_pb_org where community_id = ${communityId} and parent_id = 0),0) as partyOrg,
            IFNULL((select count(id) from com_act_dpc where community_id = ${communityId} AND is_del = 0),0) as dpcNum
        from com_mng_population_community_tags AS cmpct
        where cmpct.community_id = ${communityId}
    </select>
 
    <select id="indexDynamic" resultType="com.panzhihua.common.model.vos.community.bigscreen.IndexDynamic">
 
        SELECT    count( id ) AS microWish,
                  IFNULL(( SELECT count( id ) FROM com_act_activity WHERE community_id = ${communityId} AND volunteer_max = 0),0) AS residentActivity,
                  IFNULL(( SELECT count( id ) FROM com_act_activity WHERE community_id = ${communityId} AND volunteer_max != 0),0) AS volunteerActivity,
                  IFNULL(( SELECT count( id ) FROM com_act_easy_photo WHERE status in (1,2,4) and del_tag = 0 AND community_id = ${communityId} ),0) AS easyPhoto,
                  IFNULL(( SELECT count( id ) FROM com_pb_activity WHERE community_id = ${communityId} ),0) AS partyActivity,
                  IFNULL(( SELECT count( id ) FROM com_act_questnaire WHERE community_id = ${communityId} and is_hide=0 ),0) AS questionnaire,
                  IFNULL(( SELECT count( id ) FROM com_act_dyn WHERE community_id = ${communityId} AND STATUS = 1 ),0) AS dynamic,
                  IFNULL(( SELECT count( id ) FROM com_convenient_merchants WHERE ( community_id = ${communityId} OR community_id = 0) AND is_del = 0 ),0) AS convenient,
                  IFNULL(( SELECT count( id ) FROM com_act_neighbor_circle WHERE community_id = ${communityId} AND is_del = 2 ),0) AS neighbor
                    FROM    com_act_micro_wish AS camw    WHERE    camw.STATUS = 6
                                                AND camw.community_id = ${communityId}
    </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} AND TO_DAYS(NOW()) - TO_DAYS(e.create_at) &lt;= 30
        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) AND TO_DAYS(NOW()) - TO_DAYS(create_at) &lt;= 30
    </select>
    <select id="pageEventList"
            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 = ${pageBaseDTO.communityId}
        <if test="pageBaseDTO.param3 != null and pageBaseDTO.param3 == 1">
            AND event_deal_status = 4
        </if>
        <if test="pageBaseDTO.param3 != null and pageBaseDTO.param3 == 2">
            AND event_deal_status != 4
        </if>
        )
        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 = ${pageBaseDTO.communityId} AND `status` IN (1,2,4)
        AND del_tag = 0 AND classify_id IN (1,3,4,5,6,7,8)
        <if test="pageBaseDTO.param3 != null and pageBaseDTO.param3 == 1">
            AND `status` = 4
        </if>
        <if test="pageBaseDTO.param3 != null and pageBaseDTO.param3 == 2">
            AND `status` != 4
        </if>
        ) ORDER BY create_at DESC
    </select>
    <select id="getEventScreenSSPDateilNew"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventNewStatisticsVO">
        SELECT  id,  su.nick_name AS userName,  su.image_url,  caep.create_at,  caep.detail AS eventDes,
        caep.happen_addr AS happenAddress,  caep.lng_lat AS happentLatLng,  caep.photo_path_list,
        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 eventType,  caep.status AS eventDealStatus
        FROM  com_act_easy_photo AS caep
        LEFT JOIN sys_user AS su ON su.user_id = caep.sponsor_id
        WHERE  id = #{eventId}
    </select>
    <select id="getPopulationTotalByAdmin"
            resultType="com.panzhihua.common.model.vos.community.ComMngPopulationTotalVO">
        select count(cmpct.id) as populationTotal ,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.out_or_local = 1) as localTotal ,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.out_or_local = 2) as outTotal ,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and (cmpct.label like '%吸毒%' or cmpct.label like '%矫正%' or cmpct.label like '%重精%' or cmpct.label like '%刑满%'
            or cmpct.label like '%上访%'   or cmpct.label like '%退役%' or cmpct.label like '%残疾%' or cmpct.label like '%低保%')) as specialTotal ,
        (select count(DISTINCT `name`) from com_mng_village where community_id = ${communityId}) as villageTotal ,
        (select count(id) from com_mng_building where act_id = ${communityId}) as buildNum ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','吸毒人员','%')) as drugTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','社区矫正','%')) as correctTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','精神障碍患者','%')) as majorTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','邪教人员','%')) as cultTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','刑满释放','%')) as rehabilitationTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','重点人员','%')) as keyTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','退役军人','%')) as veteransTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','残疾人','%')) as disabilityTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','低保户','%')) as lowSecurityTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','高龄老人','%')) as elderTotal ,
        (select count(id) from com_mng_population_community_tags where community_id = ${communityId} and label LIKE CONCAT('%','养老金人员','%')) as pensionTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 1) AS houseRegTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 2) AS leftTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 3) AS outOfTownTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 4) AS overseasTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 5) AS floatingTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 6) AS permanentTotal,
        (select count(cmpct.id) from com_mng_population_community_tags cmpct INNER JOIN com_mng_population cmp on cmpct.population_id = cmp.id where cmpct.community_id = ${communityId} and cmp.person_type = 7) AS temporaryTotal
        from com_mng_population_community_tags as cmpct inner join com_mng_population as cmp on cmp.id = cmpct.population_id where community_id = ${communityId}
    </select>
 
 
    <select id="getScreenIndexByEventList" resultType="com.panzhihua.common.model.vos.community.screen.index.IndexEventListStatisticsVO" >
        SELECT  e.happen_time as createAt,  e.event_des,e.event_deal_status
        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_deal_status IN ( 1, 4 )
        ORDER BY  e.happen_time DESC
        LIMIT 8
 
    </select>
 
 
 
 
 
 
 
 
 
 
 
</mapper>