<?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.ComMngVolunteerMngDAO">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComMngVolunteerMngDO">
|
<id column="id" property="id" />
|
<result column="create_at" property="createAt" />
|
<result column="state" property="state" />
|
<result column="name" property="name" />
|
<result column="phone" property="phone" />
|
<result column="photo_path" property="photoPath" />
|
<result column="political_face" property="politicalFace" />
|
<result column="reject_reson" property="rejectReson" />
|
<result column="apply_reson" property="applyReson" />
|
<result column="address" property="address" />
|
<result column="age" property="age" />
|
<result column="job" property="job" />
|
<result column="integral" property="integral" />
|
<result column="community_id" property="communityId" />
|
<result column="submit_user_id" property="submitUserId" />
|
<result column="id_card" property="idCard" />
|
<result column="org_id" property="orgId" />
|
<result column="team_id" property="teamId" />
|
<result column="skill_id" property="skillId" />
|
<result column="love_integral" property="loveIntegral" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, create_at, state, name, phone, photo_path, political_face, reject_reson, apply_reson, address, age,
|
job, integral, community_id, submit_user_id, id_card, org_id, team_id, skill_id,love_integral
|
</sql>
|
|
<select id="pageVolunteer" resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT
|
cmvm.id,
|
cmvm.`name`,
|
cmvm.photo_path,
|
cmvm.phone,
|
cmvm.integral,
|
cmvm.id_card,
|
cmvm.skill_id,
|
cmvm.org_id,
|
cmvm.team_id,
|
cmvm.is_university,
|
IF(cmvm.is_university = 1,cmvm.university_name,null) AS university_name,
|
cmvot.`name` as orgName,
|
cmvot1.`name` as teamName,
|
cmvot1.`service_type_id`,
|
cmvst.`name` as serviceTypeName,
|
cmvs.`name` as skillName,
|
cmvm.create_at,
|
cmvm.love_integral,
|
t.name as communityName
|
FROM
|
com_mng_volunteer_mng as cmvm
|
left join com_mng_volunteer_org_team as cmvot on cmvot.id = cmvm.org_id
|
left join com_mng_volunteer_org_team as cmvot1 on cmvot1.id = cmvm.team_id
|
left join com_mng_volunteer_skill as cmvs on cmvs.id = cmvm.skill_id
|
left join com_mng_volunteer_service_type as cmvst on cmvst.id = cmvot1.service_type_id
|
left join com_act t on cmvm.community_id = t.community_id
|
WHERE
|
cmvm.state = 2
|
<if test="comMngVolunteerMngVO.communityId !=null">
|
and cmvm.community_id = #{comMngVolunteerMngVO.communityId}
|
</if>
|
<if test="comMngVolunteerMngVO.streetId !=null">
|
and t.street_id = #{comMngVolunteerMngVO.streetId}
|
</if>
|
<if test='comMngVolunteerMngVO.name != null and comMngVolunteerMngVO.name != ""'>
|
and cmvm.name like concat(#{comMngVolunteerMngVO.name},'%')
|
</if>
|
<if test='comMngVolunteerMngVO.keyWord != null and comMngVolunteerMngVO.keyWord != ""'>
|
and (
|
cmvm.name like concat(#{comMngVolunteerMngVO.keyWord},'%') or
|
cmvm.phone like concat(#{comMngVolunteerMngVO.keyWord},'%') or
|
cmvm.id_card = #{comMngVolunteerMngVO.keyWord} or
|
cmvm.university_name like concat(#{comMngVolunteerMngVO.keyWord},'%') or
|
TIMESTAMPDIFF(YEAR, SUBSTRING(cmvm.id_card, 7, 8), NOW()) = #{comMngVolunteerMngVO.keyWord}
|
)
|
</if>
|
<if test="comMngVolunteerMngVO.orgId != null">
|
and cmvm.org_id = #{comMngVolunteerMngVO.orgId}
|
</if>
|
<if test="comMngVolunteerMngVO.teamId != null">
|
and cmvm.team_id = #{comMngVolunteerMngVO.teamId}
|
</if>
|
<if test="comMngVolunteerMngVO.isUniversity != null">
|
and cmvm.is_university = #{comMngVolunteerMngVO.isUniversity}
|
</if>
|
<if test="comMngVolunteerMngVO.skillId != null">
|
and cmvm.skill_id = #{comMngVolunteerMngVO.skillId}
|
</if>
|
<if test="comMngVolunteerMngVO.serviceTypeId != null">
|
and cmvot1.service_type_id = #{comMngVolunteerMngVO.serviceTypeId}
|
</if>
|
<if test='comMngVolunteerMngVO.phone != null and comMngVolunteerMngVO.phone != ""'>
|
AND cmvm.phone like concat(#{comMngVolunteerMngVO.phone},'%')
|
</if>
|
<if test="comMngVolunteerMngVO.propertyId != null and comMngVolunteerMngVO.propertyId != ''">
|
AND cmvm.property_id=#{comMngVolunteerMngVO.propertyId}
|
</if>
|
ORDER BY
|
integral DESC,
|
cmvm.create_at DESC
|
</select>
|
<select id="retrieveVolunteerOrgHistogram"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT
|
t2.`name` AS filed,
|
COUNT( 1 ) AS num
|
FROM
|
com_mng_volunteer_mng t1
|
JOIN com_mng_volunteer_org_team t2 ON t1.org_id = t2.id
|
WHERE
|
t1.community_id = #{communityId} AND t1.state = 2
|
GROUP BY
|
filed
|
</select>
|
<select id="getVolunteerBaseData"
|
resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenVolunteerStatisticsInfo">
|
SELECT
|
(SELECT COUNT(id) FROM com_mng_volunteer_mng WHERE community_id = #{communityId} AND state = 2) AS volunteerNum,
|
(SELECT COUNT(id) FROM com_mng_volunteer_org_team WHERE community_id = #{communityId} AND parent_id = 0) AS volunteerOrgNum,
|
(SELECT COUNT(id) FROM com_mng_volunteer_org_team WHERE community_id = #{communityId} AND parent_id != 0) AS volunteerTeamNum
|
</select>
|
<select id="retrieveVolunteerServiceTypeCircleData"
|
resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT t1.id, t3.`name` AS serviceTypeName
|
FROM com_mng_volunteer_mng t1
|
JOIN com_mng_volunteer_org_team t2 ON t1.team_id = t2.id
|
LEFT JOIN com_mng_volunteer_service_type t3 ON t2.service_type_id = t3.id
|
WHERE t1.community_id = #{communityId} AND t1.state = 2
|
</select>
|
<select id="retrieveVolunteerAgeCircleData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT filed, COUNT(filed) AS num FROM (
|
SELECT
|
CASE
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 0 AND 18 THEN '0-18岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 19 AND 30 THEN '19-30岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 31 AND 40 THEN '31-40岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 41 AND 50 THEN '41-50岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 51 AND 60 THEN '51-60岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 61 AND 79 THEN '61-79岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) BETWEEN 80 AND 89 THEN '80-89岁'
|
WHEN TIMESTAMPDIFF(YEAR, SUBSTRING(id_card, 7, 8), NOW()) > 89 THEN '89岁以上'
|
END filed
|
FROM com_mng_volunteer_mng WHERE community_id = #{communityId} AND state = 2
|
) temp WHERE filed is not null GROUP BY filed
|
UNION ALL
|
(SELECT '0-18岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '19-30岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '31-40岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '41-50岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '51-60岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '61-79岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '80-89岁' AS filed, 0 AS num)
|
UNION ALL
|
(SELECT '89岁以上' AS filed, 0 AS num)
|
) t GROUP BY filed
|
</select>
|
<select id="retrieveVolunteerSkillCircleData"
|
resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT t1.id, t2.`name` AS skillName
|
FROM com_mng_volunteer_mng t1
|
JOIN com_mng_volunteer_skill t2 ON t1.skill_id = t2.id
|
WHERE t1.community_id = #{communityId} AND t1.state = 2
|
</select>
|
<select id="selectVolunteerByCommunityId"
|
resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT t1.id, t1.`name`,t1.phone,t1.id_card,t1.is_university,
|
t1.photo_path,
|
(select name from com_mng_volunteer_skill where id=t1.skill_id) as skillName,
|
t2.`name` AS teamName, t3.`name` AS orgName
|
FROM com_mng_volunteer_mng t1
|
INNER JOIN com_mng_volunteer_org_team t2 ON t1.team_id = t2.id
|
INNER JOIN com_mng_volunteer_org_team t3 ON t1.org_id = t3.id
|
WHERE t1.community_id = #{communityId} AND t1.state = 2
|
</select>
|
<select id="pageVolunteerExamine"
|
resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT
|
t.id,
|
t.`name`,
|
t.state,
|
t.phone,
|
t.apply_reson,
|
t.create_at,
|
t.submit_user_id,
|
t.is_university
|
FROM
|
com_mng_volunteer_mng t
|
RIGHT JOIN ( SELECT submit_user_id, MAX( create_at ) create_at FROM com_mng_volunteer_mng WHERE state IN ( 1, 3 ) GROUP BY submit_user_id ) tmp ON t.create_at = tmp.create_at
|
AND t.submit_user_id = tmp.submit_user_id
|
WHERE
|
state IN ( 1, 3 )
|
AND community_id = #{comMngVolunteerMngVO.communityId}
|
<if test = 'comMngVolunteerMngVO.name != null and comMngVolunteerMngVO.name.trim() != ""' >
|
AND t.NAME LIKE concat(#{comMngVolunteerMngVO.name},'%')
|
</if>
|
<if test = 'comMngVolunteerMngVO.phone != null and comMngVolunteerMngVO.phone.trim() != ""' >
|
AND t.phone LIKE concat(#{comMngVolunteerMngVO.phone},'%')
|
</if>
|
<if test = 'comMngVolunteerMngVO.state != null and comMngVolunteerMngVO.state != 0' >
|
AND t.state = #{comMngVolunteerMngVO.state}
|
</if>
|
<if test="comMngVolunteerMngVO.isUniversity != null">
|
and t.is_university = #{comMngVolunteerMngVO.isUniversity}
|
</if>
|
ORDER BY
|
t.state ASC
|
</select>
|
<select id="detailVolunteerExamine"
|
resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
SELECT t1.*, t2.`name` AS orgName, t3.`name` AS teamName, t4.`name` AS skillName
|
FROM com_mng_volunteer_mng t1
|
LEFT JOIN com_mng_volunteer_org_team t2 ON t1.org_id = t2.id
|
LEFT JOIN com_mng_volunteer_org_team t3 On t1.team_id = t3.id
|
LEFT JOIN com_mng_volunteer_skill t4 ON t1.skill_id = t4.id
|
WHERE t1.id = #{id}
|
</select>
|
|
</mapper>
|