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
<?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.ComActDAO">
 
 
 
 
 
 
 
    <select id="getCommunityListByName" resultType="com.panzhihua.common.model.vos.community.switchs.CommunitySwitchAllAppletsVO">
        select ca.`name`,ca.street_id,ca.community_id,cs.`name` as streetName
        from com_act as ca
        left join com_street as cs on cs.street_id = ca.street_id
        where ca.state = 0 and ca.name like concat('%',#{name},'%')
        <if test='appId !=null and appId !=&quot;&quot;'>
          and cs.app_id = #{appId}
        </if>
    </select>
 
 
 
 
 
 
 
 
 
    <select id="oneTagThreeReal" resultType="com.panzhihua.common.model.vos.area.StreetAndBuildVO">
        select ca.name name,ca.community_id as communityId,
               (select
                     count( cmpct.id )
                from com_mng_population_community_tags cmpct left join com_mng_population cmp on cmp.id = cmpct.population_id where cmpct.community_id = ca.community_id )peopleNum,
               (select count(cmv.village_id) from com_mng_village cmv where cmv.community_id = ca.community_id) villageNum,
               (select count(id) from com_mng_population_house as cmph where cmph.community_id = ca.community_id) buildNum
        from com_act ca where ca.street_id = #{streetId}
    </select>
 
    <select id="getScreenStatics"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.ScreenStatics">
        select
               (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) user,
               (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)  volunteer,
               (select count(*) from  com_act_micro_wish AS camw  left join com_act t1 on camw.community_id = t1.community_id
                  where camw.status = 6 ) microWish,
               (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 )
               + (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 )) 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 ) neighbor,
               (select count(id) from com_pb_org t left join com_act t1 on t.community_id = t1.community_id where parent_id = 0) 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) partyMember,
               (select count(*) from com_property t left join  com_act t1 on t.community_id = t1.community_id where t.is_red = 1) red,
               (select count( id ) from com_act_easy_photo t left join com_act t1 on t.community_id = t1.community_id where `status` = 5 and del_tag = 0 ) grid,
               (select count(*) from com_act_discuss t left join com_act t1 on t.community_id = t1.community_id where t.is_del =2 ) discuss,
               (select count(*) from new_fight_community_construction t left join com_act t1 on t.construction_community_id = t1.community_id) agreement,
               (select count(m.id) from com_pb_member m left join com_pb_check_unit as cpcu on m.check_unit_id = cpcu.id where m.audit_result = 1) arrivePartyMember,
 
               ( SELECT count(*) from automessage_transaction_event ) as transactionEvent,
                (SELECT count(*) from com_convenient_merchants as cm INNER JOIN com_act as ca on  ca.community_id = cm.community_id ) as merchantsCount ,
                (
                    SELECT count(*) FROM com_convenient_consultation_statistics ccs inner JOIN
                    ( SELECT cm.id from com_convenient_merchants as cm INNER JOIN com_act as ca on  ca.community_id = cm.community_id
                        )  as mc on mc.id = ccs.merchant_id
                ) as consultationStatistics,
 
                ( SELECT count(*) FROM event_grid_member_relation as mr INNER JOIN com_act as ca  on ca.community_id  = mr.grid_community_id
                       ) as gridMember,
                (SELECT Round( (
                        (select count(*) from com_act_easy_photo as ep INNER JOIN com_act as ca on ca.community_id = ep.community_id WHERE `status` in ('4','5') )
                                        /
                        ( select count(*) from com_act_easy_photo as ep INNER JOIN com_act as ca on ca.community_id = ep.community_id )
                ) * 100 , 2)  )  as easyPhotoPercentage ,
                (SELECT Round( (
                    (select count(*) from com_act_micro_wish as ep INNER JOIN com_act as ca on ca.community_id = ep.community_id WHERE `status` in ('6','5') )
                        /
                    ( select count(*) from com_act_micro_wish as ep INNER JOIN com_act as ca on ca.community_id = ep.community_id )
                ) * 100 , 2) ) as microWishPercentage ,
        (SELECT
            Round(
                        (
                                (  SELECT count(1) FROM (
                                    SELECT
                                        count( 1 )
                                    FROM
                                        com_act_discuss AS ad
                                            INNER JOIN com_act AS ca ON ca.community_id = ad.community_id
                                            INNER JOIN com_act_discuss_option_user AS ou ON ou.discuss_id = ad.id GROUP BY ad.id  ) as ddd
                                ) / (
                                    SELECT
                                        count( 1 )
                                    FROM
                                        com_act_discuss AS ad
                                            INNER JOIN com_act AS ca ON ca.community_id = ad.community_id
                                )
                            ) * 100,
                        2
                ) )as discussPercentage,
            ( SELECT count(*) from com_act as ca INNER JOIN com_mng_volunteer_org_team as vm on ca.community_id = vm.community_id
                where vm.parent_id != '0'
            )  AS volunteerTeam ,
            (  SELECT count(*) from com_act as ca INNER JOIN com_mng_volunteer_org_team as vm on ca.community_id = vm.community_id
                where vm.parent_id != '0'
             ) as volunteerOrg ,
            (   SELECT count(1) fROM com_act_discuss AS ad
                    INNER JOIN com_act AS ca ON ca.community_id = ad.community_id
                    INNER JOIN com_act_discuss_option_user as ado on ado.discuss_id = ad.id
                ) as discussCount,
        (SELECT count(*) from com_act as ca INNER JOIN com_act_questnaire as aq  on ca.community_id = aq.community_id ) as questnaireCount
 
 
    </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.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.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.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.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.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.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.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.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.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.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.is_screen_statistics = 1
        <if test="streetId != null and streetId != 0">
            and cs.street_id = #{streetId}
        </if>
    </select>
    <select id="getPopulationAge" resultType="java.lang.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.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="institutionalUnitServiceAnalysis" resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
        select cpcu.belong_to unitName,sum(canc.real_service_time) as serviceTime
        from com_act_neighbor_circle canc left join com_pb_check_unit cpcu on canc.solve_unit_id = cpcu.id
        <where>
            <if test="beginTime != null">
                and canc.order_time between #{beginTime} and #{endTime}
            </if>
                and cpcu.belong_to != ''
        </where>
        GROUP BY cpcu.belong_to
 
        SELECT  cpcu.belong_to unitName,sum(caa.duration) as serviceTime
        FROM com_act_activity as caa
        left join com_pb_check_unit as cpcu on caa.check_unit_id=cpcu.id
        <where>
            <if test="beginTime != null">
                and caa.publish_at between #{beginTime} and #{endTime}
            </if>
                and cpcu.belong_to != ''
        </where>
        GROUP BY cpcu.belong_to
    </select>
 
    <select id="institutionalUnitActivityAnalysis"
            resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
 
    </select>
    <select id="sumAreaStreet" resultType="com.panzhihua.common.model.dtos.community.large.SumAreaStreetResp">
        SELECT
            ( select count(*) FROM (
                SELECT cs.street_id,cs.area_code FROM ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY street_id   )   as ca INNER  JOIN com_street cs on cs.street_id = ca.street_id
                GROUP BY area_code) as gr    ) as areaCount ,
 
            ( SELECT count(*) FROM ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY street_id )  as dd  )as streetCount ,
 
            ( SELECT count(*) FROM ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY community_id ) as adfd )as actCount ,
 
            ( SELECT count(*) from `com_mng_population` cmp RIGHT JOIN ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY street_id) cs on cs.street_id = cmp.street_id where cmp.death = '0' ) as populationCount ,
 
            ( SELECT count(*) from `com_mng_village` cmv RIGHT JOIN ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY street_id) cs on cs.street_id = cmv.street_id  ) as villageCount ,
 
            ( SELECT count(*) from `com_mng_population_house` cmph RIGHT JOIN ( SELECT street_id from com_act where app_id = 'wx118de8a734d269f0' GROUP BY street_id) cs on cmph.street_id = cs.street_id  ) as houseCount
    </select>
    <select id="selectVillage" resultType="com.panzhihua.common.model.dtos.community.large.AreaStreetDetailResp">
        select
               <if test="type = '1'.toString() " >
                   ( SELECT count(*) from (SELECT 1 from com_act WHERE community_id in (
                   <foreach collection="ids" item="id" separator=",">
                       #{id}
                   </foreach>
                   ) GROUP BY street_id ) as countAS ) as streetCount  ,
               </if>
        <if test="type = '2'.toString() or type = '1'.toString()" >
            ( SELECT  count(*) from com_act WHERE community_id in (
            <foreach collection="ids" item="id" separator=",">
                #{id}
            </foreach>
            ) ) as actCount ,
        </if>
            ( SELECT count(*) FROM com_mng_population WHERE act_id in(
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        ) and death = '0' ) as populationCount ,
 
            ( SELECT count( * ) FROM  com_mng_village  WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        ) ) AS villageCount,
 
            ( SELECT count( * ) FROM  com_mng_village  WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        ) and type = '1' ) as cityVillageCount,
 
            ( SELECT count( * ) FROM  com_mng_village  WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        ) and type = '2' ) as countryVillageCount
 
 
    </select>
    <select id="selectEvent" resultType="com.panzhihua.common.model.vos.community.screen.event.EventPopulationSpecialStatisticsVO">
        SELECT
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
                )  and label like concat('%','残疾','%')  ) as cjTotal,
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )  and label like concat('%','低保','%')  ) as dbTotal,
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )  and label like concat('%','养老金','%')  ) as lnTotal,
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )  and label like concat('%','高龄','%')  ) as glTotal,
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )  and label like concat('%','退役','%')  ) as tyTotal,
            ( SELECT count(*) FROM com_mng_population_community_tags WHERE  community_id IN (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )  and label like concat('%','留守','%')  ) as lsTotal
    </select>
 
    <select id="qryReport" resultType="com.panzhihua.common.model.dtos.partybuilding.QryReportResp">
        SELECT
        ctn.id as categoryId,
        sum( IF(npi.id is null,0,1) ) as sum,
        ctn.`name` as categoryName
        FROM
        com_act_neighbor_circle_topic_new AS ctn
        LEFT JOIN (
        SELECT new_fight_need_problem_inventory.* from new_fight_need_problem_inventory  inner join (
            SELECT community_id from com_act
        ) as ca on  ca.community_id = new_fight_need_problem_inventory.community_id
        <if test="yearTime != null and yearTime != '' ">
            WHERE  creation_time &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        )
        AS npi ON npi.classify_id = ctn.id
        GROUP BY
            ctn.id
 
    </select>
 
 
</mapper>