You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
326 lines
13 KiB
326 lines
13 KiB
<?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.elink.esua.epdc.dao.VolunteerInfoDao">
|
|
|
|
<resultMap type="com.elink.esua.epdc.entity.VolunteerInfoEntity" id="volunteerInfoMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="userId" column="USER_ID"/>
|
|
<result property="realName" column="REAL_NAME"/>
|
|
<result property="sex" column="SEX"/>
|
|
<result property="birthday" column="BIRTHDAY"/>
|
|
<result property="mobile" column="MOBILE"/>
|
|
<result property="identityNo" column="IDENTITY_NO"/>
|
|
<result property="kindnessTime" column="KINDNESS_TIME"/>
|
|
<result property="participationNum" column="PARTICIPATION_NUM"/>
|
|
<result property="points" column="POINTS"/>
|
|
<result property="gridId" column="GRID_ID"/>
|
|
<result property="parentDeptIds" column="PARENT_DEPT_IDS"/>
|
|
<result property="parentDeptNames" column="PARENT_DEPT_NAMES"/>
|
|
<result property="allDeptIds" column="ALL_DEPT_IDS"/>
|
|
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
|
|
<result property="road" column="ROAD"/>
|
|
<result property="villageName" column="VILLAGE_NAME"/>
|
|
<result property="dwellingPlace" column="DWELLING_PLACE"/>
|
|
<result property="address" column="ADDRESS"/>
|
|
<result property="introduce" column="INTRODUCE"/>
|
|
<result property="registTime" column="REGIST_TIME"/>
|
|
<result property="auditStatus" column="AUDIT_STATUS"/>
|
|
<result property="failureReason" column="FAILURE_REASON"/>
|
|
<result property="auditTime" column="AUDIT_TIME"/>
|
|
<result property="auditor" column="AUDITOR"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
<result property="volunteerNickname" column="VOLUNTEER_NICKNAME"/>
|
|
<result property="volunteerFaceImg" column="VOLUNTEER_FACE_IMG"/>
|
|
<result property="volunteerSignature" column="VOLUNTEER_SIGNATURE"/>
|
|
</resultMap>
|
|
|
|
<!--根据查询条件,返回首页 志愿者信息列表-->
|
|
<select id="volunteerInfoList" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
SELECT
|
|
v.ID id,
|
|
v.USER_ID userId,
|
|
v.REAL_NAME realName,
|
|
v.VOLUNTEER_NICKNAME volunteerNickname,
|
|
v.SEX sex,
|
|
v.BIRTHDAY birthday,
|
|
date_format(v.BIRTHDAY,'%Y.%m.%d') birthdayString,
|
|
v.MOBILE mobile,
|
|
v.IDENTITY_NO identityNo,
|
|
v.KINDNESS_TIME kindnessTime,
|
|
u.POINTS points,
|
|
date_format(v.REGIST_TIME,'%Y-%m-%d %H:%i:%S') registTimeString,
|
|
v.REGIST_TIME registTime,
|
|
v.AUDIT_STATUS auditStatus,
|
|
v.VOLUNTEER_ORDER volunteerOrder
|
|
FROM
|
|
epdc_volunteer_info v
|
|
left join epdc_user u on v.USER_ID = u.ID and u.del_flag = '0'
|
|
where v.del_flag = '0' and u.id is not null
|
|
<if test="realName !='' and realName.trim() != null">
|
|
and v.REAL_NAME LIKE CONCAT( '%', trim(#{realName}), '%' )
|
|
</if>
|
|
<if test="volunteerNickname !='' and volunteerNickname.trim() != null">
|
|
and v.VOLUNTEER_NICKNAME LIKE CONCAT( '%', trim(#{volunteerNickname}), '%' )
|
|
</if>
|
|
<if test="mobile !='' and mobile.trim() != null">
|
|
and v.MOBILE LIKE CONCAT( '%', trim(#{mobile}), '%' )
|
|
</if>
|
|
<if test="deptId !='' and deptId != null">
|
|
and v.ALL_DEPT_IDS like concat('%',#{deptId},'%')
|
|
</if>
|
|
ORDER BY v.KINDNESS_TIME desc,u.POINTS DESC
|
|
</select>
|
|
|
|
<select id="volunteerInfoCount" resultType="int">
|
|
SELECT
|
|
count(1)
|
|
FROM
|
|
epdc_volunteer_info v left join epdc_user u on v.USER_ID = u.ID
|
|
where 1=1
|
|
<if test="realName !='' and realName != null">
|
|
and v.REAL_NAME = #{realName}
|
|
</if>
|
|
<if test="mobile !='' and mobile != null">
|
|
and v.MOBILE = #{mobile}
|
|
</if>
|
|
<if test="allDeptIds !='' and allDeptIds != null">
|
|
and v.ALL_DEPT_IDS like concat('%',#{allDeptIds},'%')
|
|
</if>
|
|
</select>
|
|
|
|
<!--根据志愿者id,查询志愿者 单条详情-->
|
|
<select id="getVolunteerDetail" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
SELECT
|
|
v.ID id,
|
|
v.USER_ID userId,
|
|
v.REAL_NAME realName,
|
|
v.VOLUNTEER_NICKNAME volunteerNickname,
|
|
v.SEX sex,
|
|
v.BIRTHDAY birthday,
|
|
date_format(v.BIRTHDAY,'%Y.%m.%d') birthdayString,
|
|
v.MOBILE mobile,
|
|
v.IDENTITY_NO identityNo,
|
|
v.ADDRESS address,
|
|
v.INTRODUCE introduce,
|
|
u.POINTS points,
|
|
date_format(v.REGIST_TIME,'%Y.%m.%d %H.%i') registTimeString,
|
|
v.REGIST_TIME registTime,
|
|
v.VOLUNTEER_ORDER volunteerOrder,
|
|
vt.TAG_ID
|
|
FROM
|
|
epdc_volunteer_info v left join epdc_user u on v.USER_ID = u.ID
|
|
left join epdc_volunteer_tag_relation vt on vt.VOLUNTEER_ID = v.ID and vt.DEL_FLAG = '0'
|
|
where v.ID = #{id}
|
|
</select>
|
|
|
|
<select id="getVolunteerUserDefaultValue" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
SELECT
|
|
eu.ID userId,
|
|
eu.REAL_NAME realName,
|
|
eu.MOBILE mobile,
|
|
eu.IDENTITY_NO identityNo,
|
|
eugr.GRID_ID gridId,
|
|
eu.PARENT_DEPT_IDS parentDeptIds,
|
|
eu.PARENT_DEPT_NAMES parentDeptNames,
|
|
eu.ALL_DEPT_IDS allDeptIds,
|
|
eu.ALL_DEPT_NAMES allDeptNames,
|
|
eu.ROAD road,
|
|
eu.VILLAGE_NAME villageName,
|
|
eu.DWELLING_PLACE dwellingPlace,
|
|
eu.ADDRESS address
|
|
FROM
|
|
epdc_user eu
|
|
Left Join (select * from epdc_user_grid_relation where USER_ID = #{id} order by UPDATED_TIME desc limit 0,1) eugr
|
|
on(eu.id=eugr.USER_ID)
|
|
WHERE
|
|
eu.ID = #{id}
|
|
</select>
|
|
|
|
<select id="volunteerTagQuery" resultType="com.elink.esua.epdc.dto.UserTagDTO">
|
|
select t.id,t.tag_name,t.tag_code
|
|
from epdc_user_tag t
|
|
where tag_code = #{tagCode} and del_flag = 0
|
|
</select>
|
|
|
|
<update id="updateVolunteerInfo" parameterType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
UPDATE epdc_volunteer_info
|
|
SET
|
|
UPDATED_BY = #{updatedBy}
|
|
,UPDATED_TIME = #{updatedTime}
|
|
,AUDIT_STATUS = #{auditStatus}
|
|
,FAILURE_REASON = #{failureReason}
|
|
,AUDIT_TIME = #{auditTime}
|
|
,AUDITOR = #{auditor}
|
|
WHERE ID = #{id}
|
|
</update>
|
|
|
|
<select id="getVolunteerCountById" resultType="Integer">
|
|
SELECT count(*) countNum FROM `epdc_volunteer_info` where del_flag = '0' and USER_ID = #{userId} and AUDIT_STATUS in ('1','0')
|
|
</select>
|
|
|
|
<select id="selectAdjustVolunteerPointsDTO" parameterType="java.lang.String" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO">
|
|
SELECT
|
|
m.id,
|
|
m.USER_ID as userId,
|
|
m.REAL_NAME as realName,
|
|
m.SEX,
|
|
DATE_FORMAT(m.BIRTHDAY,'%Y-%m-%d') as birthday,
|
|
m.MOBILE,
|
|
eu.POINTS,
|
|
eu.NICKNAME,
|
|
eu.FACE_IMG
|
|
FROM
|
|
epdc_volunteer_info m
|
|
LEFT JOIN epdc_user eu ON ( m.USER_ID = eu.ID )
|
|
WHERE
|
|
m.DEL_FLAG = '0'
|
|
AND m.ID = #{id}
|
|
</select>
|
|
|
|
<select id="getRankingList" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO">
|
|
select volunteerInfo.* from (
|
|
select (@i:=@i+1) sort, info.*
|
|
from (select
|
|
'1' show_flag,
|
|
DATE_FORMAT(NOW(),'%Y-%m-%d') generate_date,
|
|
vi.ID volunteer_id,
|
|
vi.USER_ID,
|
|
vi.VOLUNTEER_FACE_IMG as FACE_IMG,
|
|
vi.VOLUNTEER_NICKNAME as NICKNAME,
|
|
eu.PARTY_FLAG,
|
|
vi.KINDNESS_TIME,
|
|
vi.PARTICIPATION_NUM
|
|
from epdc_volunteer_info vi
|
|
left join epdc_user eu on eu.id = vi.USER_ID
|
|
WHERE vi.DEL_FLAG = '0' AND vi.AUDIT_STATUS IN ('0', '1')
|
|
order by vi.KINDNESS_TIME desc,vi.PARTICIPATION_NUM desc,vi.REGIST_TIME ) as info, (select @i:=0) j ) volunteerInfo
|
|
</select>
|
|
<!-- 根据用户id查询志愿者信息 -->
|
|
<select id="selectOneVolunteerInfoDTO" parameterType="java.lang.String"
|
|
resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
select m.*,
|
|
vt.tag_id
|
|
from epdc_volunteer_info m
|
|
left join epdc_volunteer_tag_relation vt on vt.VOLUNTEER_ID = m.id and vt.del_flag = '0'
|
|
where m.DEL_FLAG='0'
|
|
and m.USER_ID=#{userId}
|
|
</select>
|
|
|
|
<update id="updateVolunteerKindnessTime">
|
|
UPDATE epdc_volunteer_info
|
|
SET KINDNESS_TIME = ( KINDNESS_TIME + #{kindnessTime} ),
|
|
PARTICIPATION_NUM = ( PARTICIPATION_NUM + 1 )
|
|
WHERE
|
|
USER_ID = #{userId}
|
|
AND DEL_FLAG = '0'
|
|
</update>
|
|
|
|
<select id="selectListVolunteer" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAppVolunteerListResultDTO">
|
|
SELECT
|
|
v.ID id,
|
|
v.VOLUNTEER_NICKNAME nickname,
|
|
v.VOLUNTEER_FACE_IMG faceImg,
|
|
v.VOLUNTEER_SIGNATURE volunteerSignature,
|
|
u.party_flag
|
|
FROM
|
|
epdc_volunteer_info v
|
|
LEFT JOIN epdc_volunteer_tag_relation vt ON vt.VOLUNTEER_ID = v.ID
|
|
LEFT JOIN epdc_user u on u.id = v.user_id
|
|
AND vt.DEL_FLAG = '0'
|
|
WHERE
|
|
v.DEL_FLAG = 0
|
|
AND v.AUDIT_STATUS != 2
|
|
<if test="nickname != null and nickname != '' ">
|
|
AND v.VOLUNTEER_NICKNAME like concat('%', #{nickname}, '%')
|
|
</if>
|
|
<if test="volunteerTagId != null and volunteerTagId != '' ">
|
|
AND vt.TAG_ID = #{volunteerTagId}
|
|
</if>
|
|
ORDER BY v.VOLUNTEER_ORDER ASC ,CONVERT(v.VOLUNTEER_NICKNAME USING gbk)
|
|
LIMIT #{pageIndex},#{pageSize}
|
|
</select>
|
|
|
|
<select id="selectListVolunteerCount" resultType="Integer">
|
|
SELECT
|
|
count(*) AS volunteerCount
|
|
FROM
|
|
epdc_volunteer_info v
|
|
WHERE
|
|
v.DEL_FLAG = 0
|
|
AND v.AUDIT_STATUS != 2
|
|
</select>
|
|
|
|
<update id="updateVolunteerAauthentication" parameterType="com.elink.esua.epdc.dto.epdc.form.v2.EpdcCompleteVolunteerInfoV2FormDTO">
|
|
UPDATE epdc_volunteer_info
|
|
SET
|
|
<if test="realName != null and realName != '' ">
|
|
REAL_NAME = #{realName},
|
|
</if>
|
|
<if test="mobile != null and mobile != '' ">
|
|
MOBILE = #{mobile},
|
|
</if>
|
|
<if test="identityNo != null and identityNo != '' ">
|
|
IDENTITY_NO = #{identityNo},
|
|
</if>
|
|
<if test="road != null and road != '' ">
|
|
ROAD = #{road},
|
|
</if>
|
|
<if test="villageName != null and villageName != '' ">
|
|
VILLAGE_NAME = #{villageName},
|
|
</if>
|
|
<if test="dwellingPlace != null and dwellingPlace != '' ">
|
|
DWELLING_PLACE = #{dwellingPlace},
|
|
</if>
|
|
<if test="gridId != null and gridId != '' ">
|
|
GRID_ID = #{gridId},
|
|
</if>
|
|
<if test="introduce != null and introduce != '' ">
|
|
INTRODUCE = #{introduce},
|
|
</if>
|
|
<if test="birthday != null and birthday != '' ">
|
|
BIRTHDAY = #{birthday},
|
|
</if>
|
|
<if test="sex != null and sex != '' ">
|
|
SEX = #{sex},
|
|
</if>
|
|
<if test="volunteerNickname != null and volunteerNickname != '' ">
|
|
VOLUNTEER_NICKNAME = #{volunteerNickname},
|
|
</if>
|
|
<if test="volunteerFaceImg != null and volunteerFaceImg != '' ">
|
|
VOLUNTEER_FACE_IMG = #{volunteerFaceImg},
|
|
</if>
|
|
<if test="volunteerSignature != null and volunteerSignature != '' ">
|
|
VOLUNTEER_SIGNATURE = #{volunteerSignature}
|
|
</if>
|
|
WHERE
|
|
USER_ID = #{userId}
|
|
AND DEL_FLAG = '0'
|
|
</update>
|
|
<update id="updateKindnessTime">
|
|
UPDATE epdc_volunteer_info
|
|
SET KINDNESS_TIME = ( KINDNESS_TIME + #{kindnessTime} )
|
|
WHERE
|
|
USER_ID in
|
|
<foreach collection="userIds" index="index" item="userId" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
AND DEL_FLAG = '0'
|
|
</update>
|
|
<select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.VolunteerInfoDTO">
|
|
SELECT
|
|
ID,
|
|
PARENT_DEPT_IDS,
|
|
PARENT_DEPT_NAMES,
|
|
ALL_DEPT_IDS,
|
|
ALL_DEPT_NAMES
|
|
FROM
|
|
epdc_volunteer_info
|
|
WHERE
|
|
FIND_IN_SET( #{deptId}, ALL_DEPT_IDS )
|
|
</select>
|
|
</mapper>
|
|
|