<?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 !=""'>
|
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 <= concat(#{yearTime},'-12-31 59:59:59')
|
</if>
|
)
|
AS npi ON npi.classify_id = ctn.id
|
GROUP BY
|
ctn.id
|
|
</select>
|
|
|
</mapper>
|