<?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_dangjian.dao.ComPbMemberDAO">
|
|
<resultMap type="com.panzhihua.service_dangjian.model.dos.ComPbMemberDO" id="ComPbMemberMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="orgId" column="org_id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="idCard" column="id_card" jdbcType="VARCHAR"/>
|
<result property="photoPath" column="photo_path" jdbcType="VARCHAR"/>
|
<result property="joinTime" column="join_time" jdbcType="TIMESTAMP"/>
|
<result property="employmentTime" column="employment_time" jdbcType="TIMESTAMP"/>
|
<result property="auditResult" column="audit_result" jdbcType="INTEGER"/>
|
<result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
|
<result property="updateAt" column="update_at" jdbcType="TIMESTAMP"/>
|
<result property="communityId" column="community_id" jdbcType="INTEGER"/>
|
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
<result property="refuseReason" column="refuse_reason" jdbcType="VARCHAR"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="type" column="type" jdbcType="INTEGER"/>
|
<result property="position" column="position" jdbcType="VARCHAR"/>
|
<result property="checkUnitId" column="check_unit_id" jdbcType="INTEGER"/>
|
<result property="function" column="function" jdbcType="VARCHAR"/>
|
<result property="specialtyCategory" column="specialty_category" jdbcType="INTEGER"/>
|
<result property="specialtyName" column="specialty_name" jdbcType="VARCHAR"/>
|
<result property="positionTwo" column="position_two" jdbcType="VARCHAR"/>
|
<result property="otherRemark" column="other_remark" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, o.`name` orgName,cpcu.name as checkUnitName,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge,
|
CASE
|
|
WHEN u.id_card IS NULL THEN
|
'未注册' ELSE '已注册'
|
END status
|
from com_pb_member as m
|
LEFT JOIN sys_user u ON m.id_card = u.id_card
|
LEFT JOIN com_pb_org o ON m.org_id = o.id
|
LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id
|
where m.id = #{id}
|
</select>
|
|
<!--查询指定行数据-->
|
<select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, m.org_name,cpcu.name as checkUnitName,t2.partyTime,t2.partyInterval,cmv.name as villageName,ca.name as communityName,cpcu.belong_to,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge,
|
su.nick_name
|
from com_pb_member as m
|
LEFT JOIN com_pb_org o ON m.org_id = o.id
|
LEFT JOIN sys_user su ON m.user_id = su.user_id
|
LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id
|
LEFT JOIN com_mng_village cmv on m.village_id = cmv.village_id
|
LEFT JOIN com_act ca on m.community_id = ca.community_id
|
LEFT JOIN (select t1.user_id,sum(t.duration) as partyTime,sum(t1.award) as partyInterval from com_act_activity t LEFT JOIN com_act_act_regist t1 on t.id = t1.activity_id where t1.sign_identity = 2
|
<if test="dto.startTime !=null">
|
and t.begin_at between #{dto.startTime} and #{dto.endTime}
|
</if>
|
GROUP BY t1.user_id ) t2 on m.user_id = t2.user_id
|
<where>
|
and m.audit_result = 1
|
<if test='dto.orgName != null and dto.orgName != ""'>
|
and cpcu.org_name like concat(#{dto.orgName},'%')
|
</if>
|
<if test='dto.orgId != null'>
|
and o.id = #{dto.orgId}
|
</if>
|
<if test='dto.account != null and dto.account != ""'>
|
and su.account like concat (#{dto.account},'%')
|
</if>
|
<if test="dto.ids != null and dto.ids.length != 0">
|
and cpcu.id IN
|
<foreach collection="dto.ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test='dto.name != null and dto.name != ""'>
|
and m.name like concat (#{dto.name},'%')
|
</if>
|
<if test="dto.orgId != null">
|
and m.org_id = #{dto.orgId}
|
</if>
|
<if test="dto.communityIds != null and dto.communityIds.size() >0">
|
and m.community_id IN
|
<foreach collection="dto.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (m.name like concat ('%',#{dto.keyWord},'%') or
|
m.phone like concat ('%',#{dto.keyWord},'%') or
|
cpcu.name like concat ('%',#{dto.keyWord},'%') or ca.name like concat ('%',#{dto.keyWord},'%')
|
)
|
</if>
|
<if test="dto.type != null">
|
and m.type = #{dto.type}
|
</if>
|
<if test="dto.checkUnitId != null">
|
and m.check_unit_id = #{dto.checkUnitId}
|
</if>
|
<if test="dto.specialtyName != null and dto.specialtyName !=''">
|
and m.specialty_name like concat('%',#{dto.specialtyName},'%')
|
</if>
|
<if test="dto.belongTo !=null and dto.belongTo !=''">
|
and cpcu.belong_to = #{dto.belongTo}
|
</if>
|
<if test="dto.natureName !=null and dto.natureName !=''">
|
and cpcu.nature_name = #{dto.natureName}
|
</if>
|
<if test="dto.isRegister !=null">
|
<if test="dto.isRegister == 1">
|
and m.user_id IS NOT NULL
|
</if>
|
<if test="dto.isRegister == 0">
|
and m.user_id IS NULL
|
</if>
|
</if>
|
</where>
|
order by m.create_at desc
|
</select>
|
|
<select id="exportPartyMemberList" resultType="com.panzhihua.common.model.vos.PartyMemberListExcelVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, m.org_name,cpcu.name as checkUnitName,t2.partyTime,t2.partyInterval,cmv.name as villageName,
|
ca.name as communityName,cpcu.belong_to,cpcu.help_community_name,m.phone,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge
|
from com_pb_member as m
|
LEFT JOIN com_pb_org o ON m.org_id = o.id
|
LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id
|
LEFT JOIN com_mng_village cmv on m.village_id = cmv.village_id
|
LEFT JOIN com_act ca on m.community_id = ca.community_id
|
LEFT JOIN (select t1.user_id,sum(t.duration) as partyTime,sum(t1.award) as partyInterval from com_act_activity t LEFT JOIN com_act_act_regist t1 on t.id = t1.activity_id where t1.sign_identity = 2
|
<if test="dto.startTime !=null">
|
and t.begin_at between #{dto.startTime} and #{dto.endTime}
|
</if>
|
GROUP BY t1.user_id ) t2 on m.user_id = t2.user_id
|
<where>
|
and m.audit_result = 1
|
<if test='dto.orgName != null and dto.orgName != ""'>
|
and o.name like concat(#{dto.orgName},'%')
|
</if>
|
<if test='dto.orgId != null'>
|
and o.id = #{dto.orgId}
|
</if>
|
<if test='dto.account != null and dto.account != ""'>
|
and m.phone like concat (#{dto.account},'%')
|
</if>
|
<if test='dto.name != null and dto.name != ""'>
|
and m.name like concat (#{dto.name},'%')
|
</if>
|
<if test="dto.orgId != null">
|
and m.org_id = #{dto.orgId}
|
</if>
|
<if test="dto.communityId != null and dto.communityId !=0">
|
and m.community_id = ${dto.communityId}
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord != ''">
|
and (m.name like concat ('%',#{dto.keyWord},'%') or
|
m.phone like concat ('%',#{dto.keyWord},'%') or
|
cpcu.name like concat ('%',#{dto.keyWord},'%') or ca.name like concat ('%',#{dto.keyWord},'%')
|
)
|
</if>
|
<if test="dto.type != null">
|
and m.type = #{dto.type}
|
</if>
|
<if test="dto.checkUnitId != null">
|
and m.check_unit_id = #{dto.checkUnitId}
|
</if>
|
<if test="dto.specialtyName != null and dto.specialtyName !=''">
|
and m.specialty_name like concat('%',#{dto.specialtyName},'%')
|
</if>
|
<if test="dto.belongTo !=null and dto.belongTo !=''">
|
and cpcu.belong_to = #{dto.belongTo}
|
</if>
|
</where>
|
order by m.create_at desc
|
</select>
|
|
<select id="pagePartyBuildingMembersVO" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, o.`name` orgName,cpcu.name as checkUnitName,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge,
|
CASE
|
|
WHEN u.id_card IS NULL THEN
|
'未注册' ELSE '已注册'
|
END status
|
from com_pb_member as m
|
LEFT JOIN sys_user u ON m.id_card = u.id_card AND u.`type` = 1 and m.community_id =u.community_id
|
LEFT JOIN com_pb_org o ON m.org_id = o.id
|
LEFT JOIN com_pb_check_unit as cpcu on cpcu.id = m.check_unit_id
|
WHERE
|
m.audit_result IN ( 0, 3 )
|
<if test='pagePartyBuildingMemberVO.phone != null and pagePartyBuildingMemberVO.phone != ""'>
|
and u.phone LIKE CONCAT('%',#{pagePartyBuildingMemberVO.phone},'%')
|
</if>
|
<if test='pagePartyBuildingMemberVO.name != null and pagePartyBuildingMemberVO.name != ""'>
|
and u.name like concat ('%',#{pagePartyBuildingMemberVO.name},'%')
|
</if>
|
<if test='pagePartyBuildingMemberVO.auditStatus != null'>
|
and m.audit_result = #{pagePartyBuildingMemberVO.auditStatus}
|
</if>
|
<if test='pagePartyBuildingMemberVO.communityId != null'>
|
and m.community_id = ${pagePartyBuildingMemberVO.communityId}
|
</if>
|
</select>
|
|
<select id="pageDataStatisticsMember" resultType="com.panzhihua.common.model.vos.partybuilding.ComDataStatisticsMemberVo">
|
SELECT
|
cpm.id,
|
cpm.`name`,
|
cpm.photo_path,
|
cpm.type,
|
cpm.`function`,
|
cpm.specialty_category,
|
cpm.specialty_name,
|
cpm.position,
|
cpm.position_two,
|
cpm.id_card,
|
cpm.phone,
|
cpm.check_unit_id,
|
t1.user_id,
|
cpcu.`name` AS checkUnitName,
|
cpm.org_id,
|
cpm.community_id,
|
cpo.`name` AS orgName,
|
YEAR (
|
from_days(
|
datediff( now( ), cpm.join_time ))) AS partyAge,
|
(select count(id) from com_pb_member_role where id_card = cpm.id_card) as isRole
|
FROM
|
com_pb_member AS cpm
|
LEFT JOIN com_pb_check_unit AS cpcu ON cpcu.id = cpm.check_unit_id
|
LEFT JOIN com_pb_org AS cpo ON cpo.id = cpm.org_id
|
LEFT JOIN sys_user t1 on cpm.id_card = t1.id_card and t1.type=1
|
<where>
|
and cpm.audit_result = 1
|
<if test="dto.communityId != null">
|
and cpm.community_id = #{dto.communityId}
|
</if>
|
|
<if test="dto.keyWord != null and dto.keyWord !=''">
|
and (
|
cpm.`name` like concat (#{dto.keyWord},'%') or
|
cpm.`id_card` = #{dto.keyWord} or
|
cpm.`phone` like concat (#{dto.keyWord},'%') or
|
cpcu.`name` like concat (#{dto.keyWord},'%') or
|
cpo.`name` like concat (#{dto.keyWord},'%')
|
)
|
</if>
|
<if test="dto.month !=null and dto.month !=''">
|
and (cpm.create_at >= DATE_FORMAT( CONCAT(#{dto.month},'-00-00'), '%Y-00-00 00:00:00') and DATE_FORMAT( CONCAT(#{dto.month},'-12-31'), '%Y-12-31 23:59:59') >= cpm.create_at)
|
</if>
|
</where>
|
order by cpm.create_at desc
|
</select>
|
|
<select id="getMemberStatistics" resultType="com.panzhihua.common.model.vos.partybuilding.ComDataStatisticsMemberVo">
|
SELECT
|
count( cpam.id ) AS partyActivityCount,
|
IFNULL(( SELECT integral_available_party FROM com_act_integral_user WHERE user_id = #{userId} AND community_id = #{communityId} ), 0 ) AS partyActivityIntegral,
|
IFNULL(( SELECT integral_available_volunteer FROM com_act_integral_user WHERE user_id = #{userId} AND community_id = #{communityId} ), 0 ) AS volunteerActivityIntegral,
|
( SELECT count( caas.id ) FROM com_act_act_regist AS caas
|
LEFT JOIN com_act_activity AS caa ON caa.id = caas.activity_id
|
WHERE caas.user_id = #{userId} and caas.type = 1 and caa.type = 1 and caa.community_id = #{communityId}
|
) AS volunteerActivityCount,
|
IFNULL((
|
SELECT
|
sum( caa.duration )
|
FROM
|
com_act_act_regist AS caas
|
LEFT JOIN com_act_activity AS caa ON caa.id = caas.activity_id
|
WHERE
|
caas.user_id = #{userId} and caas.type = 1 and caa.type = 1 and caa.community_id = #{communityId}
|
),
|
0
|
) AS volunteerActivityDuration,
|
IFNULL((
|
SELECT
|
sum( caa.duration )
|
FROM
|
com_act_act_regist AS caas
|
LEFT JOIN com_act_activity AS caa ON caa.id = caas.activity_id
|
WHERE
|
caas.user_id = #{userId} and caas.type = 3 and caas.end_time is not null and caa.type = 3 and caa.community_id = #{communityId}
|
),
|
0
|
) AS partyActivityDuration,
|
( SELECT count( id ) FROM com_act_micro_wish WHERE sponsor_id = #{userId} AND `status` = 6 AND community_id = #{communityId} ) AS wishCount,
|
( SELECT count( id ) FROM com_act_easy_photo WHERE sponsor_id = #{userId} AND `status` = 4 AND community_id = #{communityId} ) AS easyCount
|
FROM
|
com_act_act_regist AS cpam
|
LEFT JOIN com_act_activity AS caa ON caa.id = cpam.activity_id
|
WHERE
|
cpam.user_id = #{userId} and caa.type = 3 and cpam.end_time is not null
|
</select>
|
|
<select id="getOrgDataStatistics" resultType="com.panzhihua.common.model.vos.partybuilding.ComDataStatisticsOrgVo">
|
SELECT
|
count( id ) AS tyNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND specialty_category = 2
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS wdNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND specialty_category = 3
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS yyNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND specialty_category = 4
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS msNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND specialty_category = 5
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS qtNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND specialty_category IS NULL
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS wuNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND type = 1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS preparePartyMemberNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId} AND type = 2
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS formalPartyMemberNum,
|
( SELECT count( id ) FROM com_pb_member WHERE audit_result = 1 AND community_id = #{communityId}
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) AS partyMemberNum
|
FROM
|
com_pb_member
|
WHERE
|
audit_result = 1
|
AND community_id = #{communityId}
|
AND specialty_category = 1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getOrgDataStatisticsLeftDown" resultType="com.panzhihua.common.model.vos.partybuilding.ComDataStatisticsOrgVo">
|
SELECT
|
count( caas1.id ) AS participateVolunteerActivityNum,
|
(
|
SELECT
|
IFNULL( sum( caa.duration ), 0 )
|
FROM
|
com_act_act_sign AS caas
|
LEFT JOIN com_act_activity AS caa ON caa.id = caas.activity_id
|
WHERE
|
caas.`status` = 1
|
AND caa.type = 1
|
AND caas.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
) AS participateVolunteerActivityDuration,
|
(
|
SELECT
|
IFNULL( sum( caa3.duration ), 0 )
|
FROM
|
com_act_act_sign AS caas3
|
LEFT JOIN com_act_activity AS caa3 ON caa3.id = caas3.activity_id
|
WHERE
|
caas3.`status` = 1
|
AND caa3.type = 3
|
AND caas3.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas3.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
) AS participatePartyActivityDuration,
|
(
|
SELECT
|
IFNULL( sum( caa4.duration ), 0 )
|
FROM
|
com_act_act_sign AS caas4
|
LEFT JOIN com_act_activity AS caa4 ON caa4.id = caas4.activity_id
|
WHERE
|
caas4.`status` = 1 and (caa4.type = 1 or caa4.type = 3)
|
AND caas4.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas4.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
) AS participateActivityDuration,
|
(
|
SELECT
|
count( caas2.id )
|
FROM
|
com_act_act_sign as caas2
|
left join com_act_activity as caa2 on caa2.id = caas2.activity_id
|
WHERE
|
caas2.`status` = 1 and caa2.type = 3
|
AND caas2.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas2.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
) AS participatePartyActivityNum,
|
(
|
SELECT
|
count( caas5.id )
|
FROM
|
com_act_act_sign as caas5
|
left join com_act_activity as caa5 on caa5.id = caas5.activity_id
|
WHERE
|
caas5.`status` = 1 and (caa5.type = 1 or caa5.type = 3)
|
AND caas5.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas5.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
) AS participateActivityNum
|
FROM
|
com_act_act_sign as caas1
|
left join com_act_activity as caa1 on caa1.id = caas1.activity_id
|
WHERE
|
caas1.`status` = 1 and caa1.type = 1
|
AND caas1.user_id IN ( SELECT t1.user_id FROM com_pb_member t left join sys_user t1 on t.id_card=t1.id_card WHERE audit_result = 1 AND t.community_id = #{communityId} AND t1.type=1
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
AND caas1.create_at BETWEEN #{startTime}
|
AND #{endTime}
|
</select>
|
|
<select id="getOrgDataStatisticsMember" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, o.`name` orgName,cpcu.name as checkUnitName,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge,
|
CASE
|
|
WHEN u.id_card IS NULL THEN
|
'未注册' ELSE '已注册'
|
END status
|
from com_pb_member as m
|
LEFT JOIN sys_user u ON m.id_card = u.id_card
|
LEFT JOIN com_pb_org o ON m.org_id = o.id
|
LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id
|
<where>
|
and m.audit_result = 1
|
and m.community_id = #{communityId}
|
<if test="orgIds != null and orgIds.size > 0">
|
AND m.org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
|
<select id="getOrgDataStatisticsRightDown" resultType="map">
|
SELECT
|
count( camw.id ) AS completeWishNum,(
|
SELECT
|
count( camw.id )
|
FROM
|
com_act_micro_wish AS camw
|
WHERE
|
camw.community_id = #{communityId}
|
AND camw.`status` = 6
|
AND camw.evaluate_at <![CDATA[ <= ]]> #{endDate}
|
AND sponsor_id IN (
|
SELECT
|
user_id
|
FROM
|
com_pb_member
|
WHERE
|
community_id = #{communityId}
|
AND audit_result = 1
|
AND user_id IS NOT NULL
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)) AS cumulativeWishNum,
|
(SELECT
|
count( caep.id )
|
FROM
|
com_act_easy_photo AS caep
|
WHERE
|
caep.community_id = #{communityId}
|
AND caep.`status` >= 4
|
AND caep.feedback_at <![CDATA[ <= ]]> #{endDate}
|
AND caep.feedback_at <![CDATA[ >= ]]> #{startDate}
|
AND caep.sponsor_id IN (
|
SELECT
|
user_id
|
FROM
|
com_pb_member
|
WHERE
|
community_id = #{communityId}
|
AND audit_result = 1
|
AND user_id IS NOT NULL
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) ) as completeEasyNum,
|
(SELECT
|
count( caep.id )
|
FROM
|
com_act_easy_photo AS caep
|
WHERE
|
caep.community_id = #{communityId}
|
AND caep.`status` >= 4
|
AND caep.feedback_at <![CDATA[ <= ]]> #{endDate}
|
AND caep.sponsor_id IN (
|
SELECT
|
user_id
|
FROM
|
com_pb_member
|
WHERE
|
community_id = #{communityId}
|
AND audit_result = 1
|
AND user_id IS NOT NULL
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) ) as cumulativeEasyNum
|
FROM
|
com_act_micro_wish AS camw
|
WHERE
|
camw.community_id = #{communityId}
|
AND camw.`status` = 6
|
AND camw.evaluate_at <![CDATA[ <= ]]> #{endDate}
|
AND camw.evaluate_at <![CDATA[ >= ]]> #{startDate}
|
AND sponsor_id IN (
|
SELECT
|
user_id
|
FROM
|
com_pb_member
|
WHERE
|
community_id = #{communityId}
|
AND audit_result = 1
|
AND user_id IS NOT NULL
|
<if test="orgIds != null and orgIds.size > 0">
|
AND org_id in
|
<foreach collection="orgIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
</select>
|
|
<select id="getHeaderOrgDataStatistics" resultType="com.panzhihua.common.model.vos.partybuilding.ComDataStatisticsHeaderOrgVo">
|
SELECT
|
count( id ) AS orgNum,
|
( SELECT count( distinct area_id ) FROM com_pb_org WHERE community_id = #{communityId} AND area_id IS NOT NULL ) AS areaNum,
|
(select count(village_id) from com_mng_village where community_id = #{communityId}) as villageNum
|
FROM
|
com_pb_org
|
WHERE
|
community_id = #{communityId}
|
</select>
|
|
<select id="exportDataStatisticsMember" resultType="com.panzhihua.common.model.vos.partybuilding.excel.ComDataStatisticsMemberExcelVo">
|
SELECT
|
cpm.id,
|
cpm.`name`,
|
cpm.photo_path,
|
cpm.type,
|
cpm.`function`,
|
cpm.specialty_category,
|
cpm.specialty_name,
|
cpm.position,
|
cpm.position_two,
|
cpm.id_card,
|
cpm.phone,
|
cpm.check_unit_id,
|
cpm.user_id,
|
cpcu.`name` AS checkUnitName,
|
cpm.org_id,
|
cpm.community_id,
|
cpo.`name` AS orgName,
|
YEAR (
|
from_days(
|
datediff( now( ), cpm.join_time ))) AS partyAge,
|
(select count(id) from com_pb_member_role where id_card = cpm.id_card) as isRole
|
FROM
|
com_pb_member AS cpm
|
LEFT JOIN com_pb_check_unit AS cpcu ON cpcu.id = cpm.check_unit_id
|
LEFT JOIN com_pb_org AS cpo ON cpo.id = cpm.org_id
|
<where>
|
and cpm.audit_result = 1
|
<if test="dto.communityId != null">
|
and cpm.community_id = #{dto.communityId}
|
</if>
|
|
<if test="dto.keyWord != null and dto.keyWord !=''">
|
and (
|
cpm.`name` like concat (#{dto.keyWord},'%') or
|
cpm.`id_card` = #{dto.keyWord} or
|
cpm.`phone` like concat (#{dto.keyWord},'%') or
|
cpcu.`name` like concat (#{dto.keyWord},'%') or
|
cpo.`name` like concat (#{dto.keyWord},'%')
|
)
|
</if>
|
</where>
|
order by cpm.create_at desc
|
</select>
|
|
<select id="getPbMemberByApplets" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select
|
m.id, m.org_id, m.name, m.id_card, m.photo_path, m.join_time, m.employment_time, m.audit_result, m.create_at, m.update_at,
|
m.community_id, m.user_id, m.refuse_reason, m.phone, m.type, m.position, m.check_unit_id, m.function, m.specialty_category,
|
m.specialty_name, m.position_two, IFNULL(m.org_Name,cpo.`name`) as orgName,cpcu.name as checkUnitName,t2.partyTime,t2.partyInterval,
|
TIMESTAMPDIFF(
|
YEAR,
|
m.employment_time,
|
DATE_FORMAT( NOW(), '%Y-%m-%d' )) as partyAge
|
from com_pb_member as m
|
LEFT JOIN (select user_id,phone from sys_user where type = 1 and app_id = "wx118de8a734d269f0") u ON m.phone = u.phone
|
LEFT JOIN com_pb_org as cpo on cpo.id = m.org_id
|
LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id
|
LEFT JOIN (select t1.user_id,sum(t.duration) as partyTime,sum(t1.award) as partyInterval from com_act_activity t LEFT JOIN com_act_act_regist t1 on t.id = t1.activity_id where t1.sign_identity = 2
|
GROUP BY t1.user_id ) t2 on u.user_id = t2.user_id
|
where m.audit_result = 1
|
<if test="dto.checkUnitId != null">
|
and m.check_unit_id = #{dto.checkUnitId}
|
</if>
|
<if test="dto.specialtyCategory != null">
|
and m.specialty_category = #{dto.specialtyCategory}
|
</if>
|
<if test="dto.specialtyName != null and dto.specialtyName != ''">
|
and m.specialty_name = #{dto.specialtyName}
|
</if>
|
<if test="dto.name != null">
|
and m.name like concat('%',#{dto.name},'%')
|
</if>
|
<if test="dto.communityId != null">
|
and m.community_id =#{dto.communityId}
|
</if>
|
order by m.create_at desc
|
</select>
|
|
<select id="selectDetail" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select t.*,
|
t1.contacts as contactsName,
|
t1.phone as contacts,
|
t1.admin_phone as adminPhone,
|
t1.name as checkUnitName,
|
t2.name as villageName,
|
t1.contacts as helpCommunityContactsName,
|
t1.phone as helpCommunityContacts,
|
t4.name as communityName,
|
t1.address,
|
t1.village_name as unitVillageName,
|
t1.belong_to
|
from com_pb_member t
|
left join com_pb_check_unit t1 on t.check_unit_id = t1.id
|
left join com_mng_village t2 on t.village_id = t2.village_id
|
left join com_act t4 on t.community_id = t4.community_id
|
where t.phone = #{phone}
|
and t.type = #{type} limit 1
|
</select>
|
<select id="getDetailByApp" resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
select t.*,
|
t1.contacts as contactsName,
|
t1.phone as contacts,
|
t1.name as checkUnitName,
|
t2.name as villageName,
|
t1.contacts as helpCommunityContactsName,
|
t1.phone as helpCommunityContacts,
|
t4.name as communityName,
|
t1.address,
|
t1.village_name as unitVillageName,
|
t1.belong_to,
|
su.nick_name
|
from com_pb_member t
|
LEFT JOIN sys_user su ON t.user_id = su.user_id
|
left join com_pb_check_unit t1 on t.check_unit_id = t1.id
|
left join com_mng_village t2 on t.village_id = t2.village_id
|
left join com_act t4 on t.community_id = t4.community_id where t.id = #{id}
|
</select>
|
<select id="pageRegisterMember"
|
resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO">
|
SELECT m.`name`, m.phone, u.user_id
|
FROM com_pb_member m
|
INNER JOIN sys_user u ON m.phone = u.phone AND u.type = 1 AND u.app_id = #{dto.appid}
|
LEFT JOIN com_act_activity_invite caai ON m.user_id = caai.user_id AND caai.activity_id = #{dto.activityId}
|
WHERE caai.id IS NULL
|
<if test="dto.checkUnitId != null">
|
AND m.check_unit_id = #{dto.checkUnitId}
|
</if>
|
</select>
|
</mapper>
|