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.
945 lines
36 KiB
945 lines
36 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.UserDao">
|
|
|
|
<delete id="deleteAuditFailureByOpenId">
|
|
DELETE FROM epdc_user WHERE WX_OPEN_ID = #{wxOpenId} AND STATE = '2'
|
|
</delete>
|
|
|
|
<select id="selectOneInfoById" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcUserInfoResultDTO">
|
|
SELECT
|
|
eu.ID AS id,
|
|
eu.NICKNAME AS nickname,
|
|
eu.FACE_IMG AS faceImg,
|
|
eu.MOBILE AS mobile,
|
|
CASE SUM(IFNULL(eu.IDENTITY_NO,0))
|
|
WHEN 0 THEN v.IDENTITY_NO
|
|
ELSE eu.IDENTITY_NO
|
|
END AS identityNo,
|
|
eugr.ALL_DEPT_NAMES AS deptName,
|
|
eu.REAL_NAME AS realName,
|
|
eu.ROAD AS road,
|
|
eu.VILLAGE_NAME AS villageName,
|
|
eu.DWELLING_PLACE AS dwellingPlace,
|
|
eu.PARTY_FLAG AS partyFlag,
|
|
eu.POINTS as points,
|
|
CASE
|
|
WHEN IFNULL(eu.POINTS_TOTLE,0) <= 0 THEN 0
|
|
ELSE
|
|
IFNULL(FLOOR(IFNULL(eu.POINTS_TOTLE,0) / IFNULL(g.POINTS,0) * IFNULL(g.GRADE,0)),0)
|
|
END grade,
|
|
CASE
|
|
COUNT( ui.ID )
|
|
WHEN 0 THEN
|
|
'0' ELSE '1'
|
|
END AS showIdentityFlag
|
|
FROM
|
|
epdc_user eu
|
|
LEFT JOIN ( SELECT gr.ALL_DEPT_NAMES, gr.USER_ID FROM epdc_user_grid_relation gr WHERE gr.DEL_FLAG = '0' AND gr.USER_ID = #{id} ORDER BY gr.UPDATED_TIME DESC LIMIT 0, 1 ) eugr ON ( eu.id = eugr.USER_ID )
|
|
LEFT JOIN epdc_user_info ui ON eu.ID = ui.USER_ID
|
|
AND ui.DEL_FLAG = '0'
|
|
left join epdc_points_grade g ON 1=1 AND g.DEL_FLAG = 0
|
|
LEFT JOIN epdc_volunteer_info v ON eu.ID = v.USER_ID
|
|
WHERE
|
|
eu.ID = #{id}
|
|
AND eu.DEL_FLAG = '0'
|
|
</select>
|
|
<select id="deleteByUnionId">
|
|
DELETE
|
|
FROM
|
|
epdc_user
|
|
WHERE
|
|
WX_UNION_ID = #{wxUnionId}
|
|
AND STATE = '2'
|
|
</select>
|
|
|
|
<select id="getUserRegisterAuditResult"
|
|
resultType="com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterAuditMsgResultDTO">
|
|
SELECT
|
|
u.ID,
|
|
u.MOBILE,
|
|
u.REMARK,
|
|
u.REAL_NAME,
|
|
DATE_FORMAT( u.CREATED_TIME, '%Y-%m-%d %H:%i:%s' ) AS CREATED_TIME,
|
|
DATE_FORMAT( u.REGISTER_TIME, '%Y-%m-%d %H:%i:%s' ) AS REGISTER_TIME,
|
|
u.WX_OPEN_ID,
|
|
u.STATE,
|
|
f.ID AS wxFormIdId,
|
|
f.WX_FORM_ID
|
|
FROM
|
|
epdc_user u
|
|
LEFT JOIN epdc_user_wx_form_id f ON u.WX_OPEN_ID = f.WX_OPEN_ID
|
|
AND f.DEL_FLAG = '0'
|
|
WHERE
|
|
u.DEL_FLAG = '0' AND u.ID = #{userId}
|
|
ORDER BY f.CREATED_TIME DESC
|
|
LIMIT 1
|
|
</select>
|
|
<select id="selectListUserDto" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT * FROM (
|
|
SELECT
|
|
u.id,
|
|
u.REAL_NAME,
|
|
u.NICKNAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
u.CREATED_TIME,
|
|
u.UPDATED_TIME,
|
|
IDENTITY_NO,
|
|
ADDRESS,
|
|
STATE,
|
|
PARTY_FLAG,
|
|
ug.GRID_ID,
|
|
ug.ALL_DEPT_IDS,
|
|
ug.PARENT_DEPT_IDS,
|
|
ug.ALL_DEPT_NAMES,
|
|
u.FACE_IMG
|
|
FROM
|
|
epdc_user u
|
|
LEFT JOIN ( SELECT * from epdc_user_grid_relation ORDER BY CREATED_TIME ASC ) ug ON u.ID = ug.USER_ID
|
|
where
|
|
u.del_flag = '0'
|
|
and (u.IDENTITY_NO is null or u.IDENTITY_NO = '')
|
|
<if test="startTime != '' and endTime != ''">and u.CREATED_TIME between #{startTime} and #{endTime}</if>
|
|
<if test="state != '' and state != null">and u.state = #{state}</if>
|
|
<if test="realName != '' and realName != null">and u.real_name like '%${realName}%'</if>
|
|
<if test="nickname != '' and nickname != null">and u.NICKNAME like '%${nickname}%'</if>
|
|
<if test="mobile != '' and mobile != null">and u.mobile like '%${mobile}%'</if>
|
|
<if test="identityNo != '' and identityNo != null">and u.identity_no like '%${identityNo}%'</if>
|
|
<if test="partyFlag != '' and partyFlag != null">and u.party_flag = #{partyFlag}</if>
|
|
GROUP BY
|
|
u.ID
|
|
ORDER BY
|
|
u.register_time DESC
|
|
) t
|
|
WHERE 1=1
|
|
<if test="streetId != '' and streetId != null">
|
|
AND (find_in_set(#{streetId},t.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{streetId},t.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="communityId != '' and communityId != null">
|
|
AND (find_in_set(#{communityId},t.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{communityId},t.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="gridId != '' and gridId != null">
|
|
and (t.grid_id = #{gridId}
|
|
OR find_in_set(#{gridId},t.ALL_DEPT_IDS))
|
|
</if>
|
|
</select>
|
|
<select id="selectListUserDtos" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT *
|
|
FROM (
|
|
SELECT *
|
|
FROM (
|
|
SELECT t.*,
|
|
ug.ALL_DEPT_NAMES,
|
|
ug.CREATED_TIME,
|
|
ug.GRID_ID,
|
|
ug.ALL_DEPT_IDS
|
|
FROM (
|
|
SELECT u.id,
|
|
u.NICKNAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
u.UPDATED_TIME,
|
|
u.ADDRESS,
|
|
u.STATE,
|
|
u.PARTY_FLAG,
|
|
u.FACE_IMG
|
|
FROM epdc_user u
|
|
WHERE u.del_flag = '0'
|
|
AND (
|
|
u.IDENTITY_NO IS NULL
|
|
OR u.IDENTITY_NO = ''
|
|
)
|
|
AND u.state = 0
|
|
AND u.party_flag = 0
|
|
<if test="startTime != '' and endTime != ''">and u.CREATED_TIME between #{startTime} and #{endTime}</if>
|
|
<if test="state != '' and state != null">and u.state = #{state}</if>
|
|
<if test="realName != '' and realName != null">and u.real_name like '%${realName}%'</if>
|
|
<if test="nickname != '' and nickname != null">and u.NICKNAME like '%${nickname}%'</if>
|
|
<if test="mobile != '' and mobile != null">and u.mobile like '%${mobile}%'</if>
|
|
<if test="identityNo != '' and identityNo != null">and u.identity_no like '%${identityNo}%'</if>
|
|
<if test="partyFlag != '' and partyFlag != null">and u.party_flag = #{partyFlag}</if>
|
|
) t
|
|
INNER JOIN epdc_user_grid_relation ug ON t.ID = ug.USER_ID
|
|
AND ug.DEL_FLAG = '0'
|
|
ORDER BY ug.CREATED_TIME ASC,
|
|
t.REGISTER_TIME DESC
|
|
) temp
|
|
WHERE 1=1
|
|
GROUP BY temp.id
|
|
) t2
|
|
WHERE 1 = 1
|
|
<if test="deptId != '' and deptId != null">and t2.ALL_DEPT_IDS LIKE '%${deptId}%'</if>
|
|
</select>
|
|
<select id="selectListOfWaitPartyUserDto" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT
|
|
u.id,
|
|
u.REAL_NAME,
|
|
u.NICKNAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
u.CREATED_TIME,
|
|
u.UPDATED_TIME,
|
|
u.IDENTITY_NO,
|
|
u.ADDRESS,
|
|
u.STATE,
|
|
u.PARTY_FLAG,
|
|
u.ALL_DEPT_NAMES
|
|
FROM
|
|
epdc_user u
|
|
where
|
|
u.del_flag = '0'
|
|
and u.IDENTITY_NO is not null
|
|
and u.state = '1'
|
|
<![CDATA[ AND u.IDENTITY_NO != '' ]]>
|
|
<if test="startTime != '' and endTime != ''">and u.CREATED_TIME between #{startTime} and #{endTime}</if>
|
|
<if test="realName != '' and realName != null">and u.real_name like '%${realName}%'</if>
|
|
<if test="mobile != '' and mobile != null">and u.mobile like '%${mobile}%'</if>
|
|
<if test="streetId != '' and streetId != null">
|
|
AND (find_in_set(#{streetId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{streetId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="communityId != '' and communityId != null">
|
|
AND (find_in_set(#{communityId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{communityId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="gridId != '' and gridId != null">
|
|
and find_in_set(#{gridId},u.ALL_DEPT_IDS)
|
|
</if>
|
|
ORDER BY
|
|
u.register_time desc
|
|
</select>
|
|
<!-- 根据userId获取居民详情(已认证或待认证(提交信息待审核)的居民用户) -->
|
|
<resultMap id="EpdcResidentDetailResultDtoMap"
|
|
type="com.elink.esua.epdc.dto.epdc.result.EpdcResidentDetailResultDTO">
|
|
<id column="id" property="userId"/>
|
|
<result column="REAL_NAME" property="realName"/>
|
|
<result column="IDENTITY_NO" property="identityNo"/>
|
|
<result column="VILLAGE_NAME" property="villageName"/>
|
|
<result column="ROAD" property="road"/>
|
|
<result column="DWELLING_PLACE" property="dwellingPlace"/>
|
|
<result column="PARTY_FLAG" property="partyFlag"/>
|
|
<result column="state" property="state"/>
|
|
<result column="mobile" property="mobile"/>
|
|
<collection property="gridList" ofType="com.elink.esua.epdc.dto.epdc.result.EpdcResidentDetailGridResultDTO">
|
|
<result column="completeName" property="completeName"/>
|
|
<result column="leaderFlag" property="leaderFlag"/>
|
|
</collection>
|
|
</resultMap>
|
|
<!--获取居民详情-->
|
|
<select id="residentDetailByUserId" resultMap="EpdcResidentDetailResultDtoMap">
|
|
SELECT
|
|
eu.id,
|
|
eu.REAL_NAME,
|
|
eu.IDENTITY_NO,
|
|
eu.VILLAGE_NAME,
|
|
eu.ROAD,
|
|
eu.DWELLING_PLACE,
|
|
eu.PARTY_FLAG ,
|
|
eu.state,
|
|
eu.mobile,
|
|
eugr.ALL_DEPT_NAMES as completeName,
|
|
eugr.LEADER_FLAG as leaderFlag
|
|
FROM
|
|
epdc_user eu
|
|
left join (select * from epdc_user_grid_relation where USER_ID = #{userId} and DEL_FLAG = '0') eugr
|
|
on(eu.id=eugr.USER_ID)
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
AND eu.id =#{userId}
|
|
</select>
|
|
|
|
<select id="selectListOfInviteUsers" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcUserGroupInviteResultDTO">
|
|
SELECT
|
|
u.ID AS userId,
|
|
u.NICKNAME,
|
|
u.FACE_IMG AS userAvatar,
|
|
u.PARTY_FLAG AS partyMember,
|
|
u.MOBILE
|
|
FROM
|
|
epdc_user_grid_relation gr
|
|
LEFT JOIN epdc_user u ON u.ID = gr.USER_ID
|
|
AND u.DEL_FLAG = '0'
|
|
WHERE
|
|
gr.DEL_FLAG = '0'
|
|
AND gr.GRID_ID = #{gridId}
|
|
AND u.ID IS NOT NULL
|
|
AND gr.USER_ID NOT IN
|
|
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
<if test="mobile != null and mobile != ''">
|
|
and u.MOBILE like concat('%', #{mobile}, '%')
|
|
</if>
|
|
<if test="road != null and road != ''">
|
|
and u.ROAD like concat('%', #{road}, '%')
|
|
</if>
|
|
<if test="lastName != null and lastName != ''">
|
|
and u.LAST_NAME like concat('%', #{lastName}, '%')
|
|
</if>
|
|
ORDER BY
|
|
CONVERT ( u.NICKNAME USING gbk ) ASC,
|
|
u.REGISTER_TIME
|
|
</select>
|
|
|
|
<resultMap id="partMemberDetail" type="com.elink.esua.epdc.dto.epdc.result.EpdcPartyMemberDetailDto">
|
|
<id column="userId" property="userId"/>
|
|
<result column="realName" property="realName"/>
|
|
<result column="identityNo" property="identityNo"/>
|
|
<result column="road" property="road"/>
|
|
<result column="villageName" property="villageName"/>
|
|
<result column="dwellingPlace" property="dwellingPlace"/>
|
|
<result column="authenticatedFlag" property="authenticatedFlag"/>
|
|
<result column="streetName" property="streetName"/>
|
|
<result column="communityName" property="communityName"/>
|
|
<result column="gridName" property="gridName"/>
|
|
<result column="partyFlag" property="partyFlag"/>
|
|
<result column="cadreFlag" property="cadreFlag"/>
|
|
<collection property="gridList" ofType="com.elink.esua.epdc.dto.epdc.result.EpdcResidentDetailGridResultDTO">
|
|
<result column="completeName" property="completeName"/>
|
|
<result column="leaderFlag" property="leaderFlag"/>
|
|
</collection>
|
|
<collection property="tagNameList" ofType="java.lang.String">
|
|
<result column="tagName"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<!-- 获取党员详情(已认证或未认证的党员用户) -->
|
|
<select id="partyMemberDetailByUserId" resultMap="partMemberDetail">
|
|
SELECT
|
|
eu.ID AS userId,
|
|
eu.REAL_NAME AS realName,
|
|
eu.IDENTITY_NO AS identityNo,
|
|
eu.ROAD AS road,
|
|
eu.MOBILE as mobile,
|
|
eu.VILLAGE_NAME AS villageName,
|
|
eu.DWELLING_PLACE as dwellingPlace,
|
|
'1' as authenticatedFlag,
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(epm.ALL_DEPT_NAMES,'-',-3),'-',1) as streetName,
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(epm.ALL_DEPT_NAMES,'-',-2),'-',1)as communityName,
|
|
SUBSTRING_INDEX(epm.ALL_DEPT_NAMES,'-',-1) as gridName,
|
|
eu.PARTY_FLAG as partyFlag,
|
|
epm.CADRE_FLAG as cadreFlag,
|
|
eugr.ALL_DEPT_NAMES as completeName,
|
|
eugr.LEADER_FLAG as leaderFlag,
|
|
eut.TAG_NAME as tagName
|
|
FROM
|
|
epdc_party_members epm
|
|
LEFT JOIN epdc_user eu ON eu.IDENTITY_NO = epm.IDENTITY_NO
|
|
LEFT JOIN epdc_party_tag_relation eptr ON eptr.PARTY_ID = epm.ID
|
|
LEFT JOIN epdc_user_tag eut ON eut.ID = eptr.TAG_ID
|
|
AND eut.DEL_FLAG = '0'
|
|
LEFT JOIN epdc_user_grid_relation eugr on eugr.USER_ID = eu.ID
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
AND epm.DEL_FLAG = '0'
|
|
AND eu.ID = #{userId}
|
|
</select>
|
|
<!--党员认证失败-->
|
|
<select id="partyMemberDetailFaild" resultMap="partMemberDetail">
|
|
SELECT
|
|
eu.ID AS userId,
|
|
eu.REAL_NAME AS realName,
|
|
eu.IDENTITY_NO AS identityNo,
|
|
eu.ROAD AS road,
|
|
eu.VILLAGE_NAME AS villageName,
|
|
eu.DWELLING_PLACE AS dwellingPlace,
|
|
'0' AS authenticatedFlag,
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(epaf.ALL_DEPT_NAMES,'-',-3),'-',1) as streetName,
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(epaf.ALL_DEPT_NAMES,'-',-2),'-',1)as communityName,
|
|
SUBSTRING_INDEX(epaf.ALL_DEPT_NAMES,'-',-1) as gridName,
|
|
eu.PARTY_FLAG AS partyFlag,
|
|
epaf.CADRE_FLAG AS cadreFlag,
|
|
eugr.ALL_DEPT_NAMES AS completeName,
|
|
eugr.LEADER_FLAG AS leaderFlag,
|
|
eut.TAG_NAME AS tagName
|
|
FROM
|
|
epdc_party_authentication_failed epaf
|
|
LEFT JOIN epdc_user eu ON eu.ID = epaf.USER_ID
|
|
LEFT JOIN epdc_user_tag_relation eutr ON eutr.USER_ID = eu.ID
|
|
LEFT JOIN epdc_user_tag eut ON eut.ID = eutr.TAG_ID
|
|
AND eut.DEL_FLAG = '0'
|
|
LEFT JOIN epdc_user_grid_relation eugr ON eugr.USER_ID = eu.ID
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
AND epaf.DEL_FLAG = '0'
|
|
AND eu.ID = #{userId}
|
|
</select>
|
|
|
|
<!-- 通过用户ID获取党员身份证号 -->
|
|
<select id="getPartyMemberIdNoByUserID" resultType="java.lang.String">
|
|
SELECT
|
|
eu.IDENTITY_NO
|
|
FROM
|
|
epdc_user eu
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
AND eu.id = #{userId}
|
|
</select>
|
|
|
|
<!--查询待认证用户数量-->
|
|
<select id="selectCountUnauthorizedAmount" resultType="Integer">
|
|
SELECT
|
|
COUNT(u.ID)
|
|
FROM
|
|
epdc_user u
|
|
WHERE
|
|
u.PARTY_FLAG = '0' AND u.DEL_FLAG = '0' AND u.STATE = '1'
|
|
and (u.IDENTITY_NO is null or u.IDENTITY_NO = '')
|
|
<choose>
|
|
<when test="gridId != null and gridId > 0">AND u.DEPT_ID = #{gridId}</when>
|
|
<otherwise>
|
|
AND u.DEPT_ID in
|
|
<foreach collection="gridIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<!-- 获取用户列表:党员认证失败 -->
|
|
<select id="selectPartyAuthenticationFailedList"
|
|
parameterType="com.elink.esua.epdc.dto.epdc.form.EpdcWorkUserFromDTO"
|
|
resultType="com.elink.esua.epdc.dto.epdc.result.EpdcWorkUserResultDTO">
|
|
SELECT
|
|
u.ID as userId,
|
|
u.NICKNAME as nickname,
|
|
u.REGISTER_TIME as registerTime,
|
|
u.FACE_IMG as faceImg
|
|
FROM
|
|
epdc_user_grid_relation ug
|
|
LEFT JOIN epdc_user u ON ug.USER_ID = u.ID
|
|
WHERE u.DEL_FLAG = '0'
|
|
AND ug.DEL_FLAG = '0'
|
|
and u.PARTY_FLAG = '0'
|
|
<if test="partyFlag ='0' and authenticatedFlag ='1'">
|
|
and EXISTS(select m.USER_ID
|
|
from epdc_party_authentication_failed m
|
|
where m.USER_ID=u.id)
|
|
</if>
|
|
<choose>
|
|
<when test="gridId != null and gridId > 0">AND ug.GRID_ID = #{gridId}</when>
|
|
<otherwise>
|
|
<if test="gridIdList!=null and gridIdList.size()>0">
|
|
AND ug.GRID_ID in
|
|
<foreach collection="gridIdList" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</otherwise>
|
|
</choose>
|
|
GROUP BY
|
|
u.ID
|
|
ORDER BY u.CREATED_TIME DESC
|
|
LIMIT #{pageIndex},#{pageSize}
|
|
</select>
|
|
|
|
<!-- 根据网格id查询网格下所有的用户 -->
|
|
<select id="selectListGridUserResultDTO" parameterType="map"
|
|
resultType="com.elink.esua.epdc.dto.epdc.result.EpdcGridUserResultDTO">
|
|
SELECT
|
|
eu.id AS userId,
|
|
eu.NICKNAME,
|
|
eu.FACE_IMG AS userAvatar,
|
|
eu.MOBILE,
|
|
r.LEADER_FLAG AS lordFlag,
|
|
eu.PARTY_FLAG AS partyMember,
|
|
10 as STATE,
|
|
NULL AS auditOpinion,
|
|
r.GRID_ID AS gridId
|
|
FROM
|
|
epdc_user_grid_relation r
|
|
LEFT JOIN epdc_user eu ON r.USER_ID = eu.ID
|
|
WHERE
|
|
r.DEL_FLAG = '0'
|
|
AND eu.DEL_FLAG = '0'
|
|
and (eu.PARTY_FLAG='1' or r.LEADER_FLAG='1')
|
|
<if test="gridIdList!=null and gridIdList.size()>0">
|
|
AND r.GRID_ID in
|
|
<foreach collection="gridIdList" index="index" item="gridId" open="(" separator="," close=")">
|
|
#{gridId}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectListUserByWxForLogin" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT
|
|
u.ID, u.NICKNAME, u.FACE_IMG, u.MOBILE, u.PARTY_FLAG, u.REAL_NAME, u.SEX, u.STATE, ur.GRID_ID, ur.GRID
|
|
FROM
|
|
epdc_user u
|
|
LEFT JOIN epdc_user_grid_relation ur ON u.ID = ur.USER_ID AND ur.DEL_FLAG = '0'
|
|
WHERE
|
|
u.DEL_FLAG = '0'
|
|
<if test="wxOpenId != null and wxOpenId !=''">AND u.WX_OPEN_ID = #{wxOpenId}</if>
|
|
<if test="wxUnionId != null and wxUnionId !=''">AND u.WX_UNION_ID = #{wxUnionId}</if>
|
|
ORDER BY
|
|
ur.SWITCHED_TIME DESC
|
|
</select>
|
|
|
|
<resultMap id="CachingUserInfoDTOMap" type="com.elink.esua.epdc.dto.CachingUserInfoDTO">
|
|
<result property="userId" column="ID"/>
|
|
<result property="nickname" column="NICKNAME"/>
|
|
<result property="mobile" column="MOBILE"/>
|
|
<result property="faceImg" column="FACE_IMG"/>
|
|
<result property="sex" column="SEX"/>
|
|
<result property="realName" column="REAL_NAME"/>
|
|
<result property="state" column="STATE"/>
|
|
<result property="remark" column="REMARK"/>
|
|
<result property="gridId" column="gridId"/>
|
|
<result property="grid" column="grid"/>
|
|
<collection property="userTagInfos" select="com.elink.esua.epdc.dao.UserTagDao.selectByUserId"
|
|
column="id">
|
|
</collection>
|
|
</resultMap>
|
|
<!-- 获取用户缓存信息 -->
|
|
<select id="selectCachingUserInfoDTO" parameterType="map" resultMap="CachingUserInfoDTOMap">
|
|
SELECT
|
|
eu.ID,
|
|
eu.NICKNAME,
|
|
eu.MOBILE,
|
|
eu.FACE_IMG,
|
|
eu.SEX,
|
|
eu.REAL_NAME,
|
|
eu.STATE,
|
|
eu.REMARK,
|
|
(select r.GRID_ID
|
|
from epdc_user_grid_relation r
|
|
where r.USER_ID=eu.ID
|
|
and r.DEL_FLAG='0'
|
|
order by r.SWITCHED_TIME desc
|
|
limit 1
|
|
)as gridId,
|
|
(
|
|
select r.GRID
|
|
from epdc_user_grid_relation r
|
|
where r.USER_ID=eu.ID
|
|
and r.DEL_FLAG='0'
|
|
order by r.SWITCHED_TIME desc
|
|
limit 1
|
|
)as grid
|
|
FROM
|
|
epdc_user eu
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
<if test="openId!=null and openId!=''">
|
|
and eu.WX_OPEN_ID=#{openId}
|
|
</if>
|
|
<if test="unionId!=null and unionId!=''">
|
|
and eu.WX_UNION_ID=#{unionId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 根据用户id查询CachingUserInfoDTO -->
|
|
<select id="selectCachingUserInfoDTOByUserId" parameterType="java.lang.String" resultMap="CachingUserInfoDTOMap">
|
|
SELECT
|
|
eu.ID,
|
|
eu.NICKNAME,
|
|
eu.MOBILE,
|
|
eu.FACE_IMG,
|
|
eu.SEX,
|
|
eu.REAL_NAME,
|
|
eu.STATE,
|
|
eu.REMARK,
|
|
(select r.GRID_ID
|
|
from epdc_user_grid_relation r
|
|
where r.USER_ID=eu.ID
|
|
and r.DEL_FLAG='0'
|
|
order by r.SWITCHED_TIME desc
|
|
limit 1
|
|
)as gridId,
|
|
(
|
|
select r.GRID
|
|
from epdc_user_grid_relation r
|
|
where r.USER_ID=eu.ID
|
|
and r.DEL_FLAG='0'
|
|
order by r.SWITCHED_TIME desc
|
|
limit 1
|
|
)as grid
|
|
FROM
|
|
epdc_user eu
|
|
WHERE
|
|
eu.DEL_FLAG = '0'
|
|
and eu.id=#{userId}
|
|
</select>
|
|
<select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT
|
|
ID,
|
|
PARENT_DEPT_IDS,
|
|
PARENT_DEPT_NAMES,
|
|
ALL_DEPT_IDS,
|
|
ALL_DEPT_NAMES
|
|
FROM
|
|
epdc_user
|
|
WHERE
|
|
FIND_IN_SET( #{deptId}, ALL_DEPT_IDS )
|
|
</select>
|
|
|
|
|
|
<select id="selectAuthenticatedListUserDto" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT
|
|
u.id,
|
|
u.REAL_NAME,
|
|
u.NICKNAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
u.CREATED_TIME,
|
|
IDENTITY_NO,
|
|
ADDRESS,
|
|
STATE,
|
|
PARTY_FLAG,
|
|
u.ALL_DEPT_NAMES,
|
|
u.FACE_IMG
|
|
FROM
|
|
epdc_user u
|
|
where
|
|
u.del_flag = '0'
|
|
<if test="startTime != '' and endTime != ''">and u.CREATED_TIME between #{startTime} and #{endTime}</if>
|
|
<if test="state != '' and state != null">and u.state = #{state}</if>
|
|
<if test="realName != '' and realName != null">and u.real_name like '%${realName}%'</if>
|
|
<if test="nickname != '' and nickname != null">and u.NICKNAME like '%${nickname}%'</if>
|
|
<if test="mobile != '' and mobile != null">and u.mobile like '%${mobile}%'</if>
|
|
<if test="identityNo != '' and identityNo != null">and u.identity_no like '%${identityNo}%'</if>
|
|
<if test="partyFlag != '' and partyFlag != null">and u.party_flag = #{partyFlag}</if>
|
|
<if test="streetId != '' and streetId != null">
|
|
AND (find_in_set(#{streetId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{streetId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="communityId != '' and communityId != null">
|
|
AND (find_in_set(#{communityId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{communityId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="gridId != '' and gridId != null">
|
|
AND
|
|
find_in_set(#{gridId},u.ALL_DEPT_IDS)
|
|
</if>
|
|
ORDER BY
|
|
u.register_time desc
|
|
</select>
|
|
|
|
<select id="selectListAuthenticatedUserForWork"
|
|
resultType="com.elink.esua.epdc.dto.epdc.result.EpdcWorkUserResultDTO">
|
|
SELECT
|
|
u.ID as userId,
|
|
u.NICKNAME as nickname,
|
|
u.REGISTER_TIME as registerTime,
|
|
u.FACE_IMG as faceImg
|
|
FROM
|
|
epdc_user u
|
|
WHERE
|
|
u.PARTY_FLAG = #{partyFlag}
|
|
AND u.STATE = #{authenticatedFlag}
|
|
AND u.DEL_FLAG = '0'
|
|
<if test='authenticatedFlag == "1"'>and (u.IDENTITY_NO is null or u.IDENTITY_NO = '')</if>
|
|
<choose>
|
|
<when test="gridId != null and gridId > 0">AND u.DEPT_ID = #{gridId}</when>
|
|
<otherwise>
|
|
AND u.DEPT_ID in
|
|
<foreach collection="gridIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
|
|
</otherwise>
|
|
</choose>
|
|
ORDER BY u.register_time DESC
|
|
LIMIT #{pageIndex},#{pageSize}
|
|
</select>
|
|
|
|
<select id="selectWaitAuthenticatedListUserDto" resultType="com.elink.esua.epdc.dto.UserDTO">
|
|
SELECT
|
|
u.id,
|
|
u.REAL_NAME,
|
|
u.NICKNAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
u.CREATED_TIME,
|
|
IDENTITY_NO,
|
|
ADDRESS,
|
|
STATE,
|
|
PARTY_FLAG,
|
|
u.ALL_DEPT_NAMES,
|
|
u.FACE_IMG
|
|
FROM
|
|
epdc_user u
|
|
where
|
|
u.del_flag = '0'
|
|
and (u.IDENTITY_NO is null or u.IDENTITY_NO = '')
|
|
<if test="startTime != '' and endTime != ''">and u.CREATED_TIME between #{startTime} and #{endTime}</if>
|
|
<if test="state != '' and state != null">and u.state = #{state}</if>
|
|
<if test="realName != '' and realName != null">and u.real_name like '%${realName}%'</if>
|
|
<if test="nickname != '' and nickname != null">and u.NICKNAME like '%${nickname}%'</if>
|
|
<if test="mobile != '' and mobile != null">and u.mobile like '%${mobile}%'</if>
|
|
<if test="identityNo != '' and identityNo != null">and u.identity_no like '%${identityNo}%'</if>
|
|
<if test="partyFlag != '' and partyFlag != null">and u.party_flag = #{partyFlag}</if>
|
|
<if test="streetId != '' and streetId != null">
|
|
AND (find_in_set(#{streetId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{streetId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="communityId != '' and communityId != null">
|
|
AND (find_in_set(#{communityId},u.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{communityId},u.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="gridId != '' and gridId != null">
|
|
AND
|
|
find_in_set(#{gridId},u.ALL_DEPT_IDS)
|
|
</if>
|
|
ORDER BY
|
|
u.register_time desc
|
|
</select>
|
|
|
|
<select id="selectListUserPoints" resultType="com.elink.esua.epdc.dto.UserPointsDTO">
|
|
select * from(
|
|
SELECT u.id,
|
|
u.NICKNAME,
|
|
u.REAL_NAME,
|
|
u.MOBILE,
|
|
u.REGISTER_TIME,
|
|
ADDRESS,
|
|
ug.ALL_DEPT_NAMES AS myGridName,
|
|
u.DEL_FLAG,
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.GRID_ID, u.DEPT_ID) as GRID_ID,
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.PARENT_DEPT_IDS, u.PARENT_DEPT_IDS) as PARENT_DEPT_IDS,
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.ALL_DEPT_IDS, u.ALL_DEPT_IDS) as ALL_DEPT_IDS,
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), substring_index(ug.ALL_DEPT_NAMES, '-', -1), substring_index(u.ALL_DEPT_NAMES, '-', -1) ) as gridName,
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), substring_index(substring_index(ug.ALL_DEPT_NAMES,'-',-2), '-', 1) , substring_index(substring_index(u.ALL_DEPT_NAMES,'-',-2), '-', 1) ) as communityName,
|
|
u.POINTS,
|
|
u.POINTS_TOTLE
|
|
FROM epdc_user u
|
|
LEFT JOIN ( select * from (select * from epdc_user_grid_relation order by CREATED_TIME)t group by t.USER_ID) ug ON u.ID = ug.USER_ID
|
|
)ug
|
|
where
|
|
ug.del_flag = '0'
|
|
<if test="realName != '' and realName != null">and ug.real_name like '%${realName}%' or ug.nickname like '%${realName}%'</if>
|
|
<if test="mobile != '' and mobile != null">and ug.mobile like '%${mobile}%'</if>
|
|
<if test="streetId != '' and streetId != null">
|
|
AND (find_in_set(#{streetId},ug.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{streetId},ug.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="communityId != '' and communityId != null">
|
|
AND (find_in_set(#{communityId},ug.PARENT_DEPT_IDS)
|
|
OR find_in_set(#{communityId},ug.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="gridId != '' and gridId != null">
|
|
and (ug.grid_id = #{gridId}
|
|
OR find_in_set(#{gridId},ug.ALL_DEPT_IDS))
|
|
</if>
|
|
<if test="deptIdList!=null and deptIdList.size()>0">
|
|
AND ug.GRID_ID IN
|
|
<foreach collection="deptIdList" item="deptId" index="index" open="(" close=")" separator=",">
|
|
#{deptId}
|
|
</foreach>
|
|
</if>
|
|
GROUP BY
|
|
ug.ID
|
|
ORDER BY
|
|
ug.POINTS desc,
|
|
ug.register_time desc
|
|
</select>
|
|
|
|
<select id="selectListUsersRanking" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAppRankingUserDTO">
|
|
SELECT
|
|
u.*,
|
|
IF( @prevRank > 0 AND @prevRank = u.`POINTS`, @rank, @rank := @rank + 1 ) rank,
|
|
@prevRank := u.`POINTS`
|
|
FROM
|
|
(
|
|
SELECT
|
|
uu.`ID` AS userId,
|
|
uu.`POINTS`,
|
|
IF( uu.REAL_NAME IS NULL OR uu.`REAL_NAME` = '', uu.NICKNAME, uu.`REAL_NAME` ) realName,
|
|
uu.`FACE_IMG` AS faceImg
|
|
FROM
|
|
`epdc_user` uu
|
|
WHERE
|
|
uu.ID IN ( SELECT DISTINCT ug.user_id FROM epdc_user_grid_relation ug WHERE ug.ALL_DEPT_IDS LIKE '%${deptId}%' )
|
|
AND uu.state != '0'
|
|
AND uu.POINTS > 0
|
|
ORDER BY
|
|
uu.POINTS DESC ,uu.CREATED_TIME
|
|
) u,
|
|
( SELECT @rank := 0, @prevRank := NULL ) r
|
|
WHERE @rank <= #{pageSize}
|
|
</select>
|
|
|
|
<select id="selectListUsersGradeRanking" resultType="com.elink.esua.epdc.dto.epdc.result.UsersGradeRankingDTO">
|
|
SELECT
|
|
userGrade.userId,
|
|
userGrade.faceImg,
|
|
userGrade.nickName,
|
|
userGrade.grade
|
|
FROM(
|
|
SELECT
|
|
u.ID userId,
|
|
u.face_img faceImg,
|
|
u.REAL_NAME nickName,
|
|
CASE
|
|
WHEN IFNULL(u.POINTS_TOTLE,0) <= 0 THEN 0
|
|
ELSE
|
|
IFNULL(FLOOR(IFNULL(u.POINTS_TOTLE,0) / IFNULL(g.POINTS,0) * IFNULL(g.GRADE,0)),0)
|
|
END grade,
|
|
u.CREATED_TIME
|
|
FROM
|
|
epdc_user u
|
|
left join epdc_points_grade g ON 1=1 AND g.DEL_FLAG = 0
|
|
WHERE
|
|
u.DEL_FLAG = '0' AND u.STATE != '0'
|
|
<if test="streetId != null and streetId != '' ">
|
|
AND instr(u.PARENT_DEPT_IDS , #{streetId} ) > 0
|
|
</if>
|
|
) userGrade
|
|
ORDER BY userGrade.grade DESC, userGrade.CREATED_TIME DESC
|
|
LIMIT #{pageIndex}, #{pageSize}
|
|
</select>
|
|
|
|
<select id="selectCurrentUserRanking" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAppRankingUserDTO">
|
|
SELECT * FROM (
|
|
SELECT u.*,
|
|
IF( @prevRank = u.`POINTS`, @rank, @rank := @rank + 1 ) rank,
|
|
@prevRank := u.`POINTS`
|
|
FROM (
|
|
SELECT
|
|
uu.`ID` AS userId,
|
|
uu.`POINTS`,
|
|
IF
|
|
( uu.REAL_NAME IS NULL OR uu.`REAL_NAME` = '', uu.NICKNAME, uu.`REAL_NAME` ) realName,
|
|
uu.`FACE_IMG` AS faceImg
|
|
FROM
|
|
`epdc_user` uu
|
|
WHERE
|
|
uu.ID IN ( SELECT DISTINCT ug.user_id FROM epdc_user_grid_relation ug WHERE ug.ALL_DEPT_IDS LIKE '%${deptId}%' )
|
|
AND uu.state != '0'
|
|
ORDER BY
|
|
uu.POINTS DESC,
|
|
uu.CREATED_TIME ) u,
|
|
( SELECT @rank := 0, @prevRank := NULL ) r
|
|
)temp WHERE temp.userId = #{userId}
|
|
</select>
|
|
|
|
<select id="selectCurrentUserGradeRanking" resultType="com.elink.esua.epdc.dto.epdc.result.UsersGradeRankingDTO">
|
|
SELECT
|
|
userRanking.rank,
|
|
userRanking.faceImg,
|
|
userRanking.grade
|
|
FROM(
|
|
SELECT
|
|
(@i:=@i+1) rank,
|
|
tab.USER_ID userId,
|
|
GROUP_CONCAT(tab.USER_ID SEPARATOR ',') pdtj, -- 有展示上限,所以不用该字段 删选名次
|
|
tab.POINTS_TOTLE,
|
|
tab.faceImg,
|
|
tab.grade
|
|
FROM(
|
|
SELECT
|
|
u.ID USER_ID,
|
|
u.face_img faceImg,
|
|
u.POINTS_TOTLE,
|
|
CASE
|
|
WHEN IFNULL(u.POINTS_TOTLE,0) <= 0 THEN 0
|
|
ELSE
|
|
IFNULL(FLOOR(IFNULL(u.POINTS_TOTLE,0) / IFNULL(g.POINTS,0) * IFNULL(g.GRADE,0)),0)
|
|
END grade
|
|
FROM epdc_user u
|
|
LEFT JOIN epdc_points_grade g ON 1=1 AND g.DEL_FLAG = '0'
|
|
WHERE u.DEL_FLAG = '0'
|
|
AND instr(u.PARENT_DEPT_IDS , #{streetId} ) > 0
|
|
) tab ,(select @i:=0) t1
|
|
GROUP BY tab.grade
|
|
ORDER BY tab.grade DESC
|
|
) userRanking
|
|
WHERE userRanking.POINTS_TOTLE = #{pointsTotle}
|
|
</select>
|
|
|
|
<select id="selectListPoints" resultType="com.elink.esua.epdc.dto.UserPointResultDTO">
|
|
SELECT
|
|
SUM(t0.points) AS points,
|
|
SUM(t0.pointsTotle) AS pointsTotle,
|
|
t0.ALL_DEPT_IDS,
|
|
t0.PARENT_DEPT_IDS,
|
|
t0.PARENT_DEPT_NAMES,
|
|
<choose>
|
|
<when test='type != "" and type != null and type=="1"'>
|
|
t0.ALL_DEPT_NAMES as ALL_DEPT_NAMES
|
|
</when>
|
|
<otherwise>
|
|
t0.PARENT_DEPT_NAMES as ALL_DEPT_NAMES
|
|
</otherwise>
|
|
</choose>
|
|
FROM
|
|
(
|
|
(
|
|
SELECT
|
|
SUM(u.POINTS) AS points,
|
|
SUM(u.POINTS_TOTLE) AS pointsTotle,
|
|
u.ALL_DEPT_IDS,
|
|
u.ALL_DEPT_NAMES,
|
|
u.PARENT_DEPT_IDS,
|
|
u.PARENT_DEPT_NAMES,
|
|
u.ID
|
|
FROM
|
|
epdc_user u
|
|
WHERE
|
|
u.ALL_DEPT_IDS IS NOT NULL
|
|
AND TRIM(u.ALL_DEPT_IDS) != ''
|
|
AND u.DEL_FLAG = '0'
|
|
GROUP BY
|
|
u.ALL_DEPT_IDS
|
|
ORDER BY
|
|
pointsTotle DESC
|
|
)
|
|
UNION ALL
|
|
(
|
|
SELECT
|
|
SUM(u2.POINTS) AS points,
|
|
SUM(u2.POINTS_TOTLE) AS pointsTotle,
|
|
ug2.ALL_DEPT_IDS,
|
|
ug2.ALL_DEPT_NAMES,
|
|
ug2.PARENT_DEPT_IDS,
|
|
ug2.PARENT_DEPT_NAMES,
|
|
u2.ID
|
|
FROM
|
|
epdc_user u2
|
|
LEFT JOIN (
|
|
SELECT
|
|
u.ID,
|
|
ug.ALL_DEPT_IDS,
|
|
ug.ALL_DEPT_NAMES,
|
|
ug.PARENT_DEPT_IDS,
|
|
ug.PARENT_DEPT_NAMES
|
|
FROM
|
|
epdc_user u
|
|
LEFT JOIN epdc_user_grid_relation ug ON u.ID = ug.USER_ID
|
|
AND ug.DEL_FLAG = '0'
|
|
WHERE
|
|
u.DEL_FLAG = '0'
|
|
GROUP BY
|
|
u.ID
|
|
ORDER BY
|
|
ug.CREATED_TIME
|
|
) ug2 ON u2.ID = ug2.ID
|
|
WHERE
|
|
u2.ALL_DEPT_IDS IS NULL
|
|
OR TRIM(u2.ALL_DEPT_IDS) = ''
|
|
GROUP BY
|
|
ug2.ALL_DEPT_IDS
|
|
ORDER BY
|
|
pointsTotle DESC
|
|
)
|
|
) t0
|
|
LEFT JOIN ( select * from (select * from epdc_user_grid_relation order by CREATED_TIME)t group by t.USER_ID) ug3 ON t0.ID = ug3.USER_ID
|
|
where ug3.DEL_FLAG = '0'
|
|
<if test="deptIdList!=null and deptIdList.size()>0">
|
|
and ug3.GRID_ID IN
|
|
<foreach item="deptIdItem" collection="deptIdList" open="(" separator="," close=")">
|
|
#{deptIdItem}
|
|
</foreach>
|
|
</if>
|
|
GROUP BY
|
|
<choose>
|
|
<when test='type != "" and type != null and type=="1"'>
|
|
t0.ALL_DEPT_IDS
|
|
</when>
|
|
<otherwise>
|
|
t0.PARENT_DEPT_IDS
|
|
</otherwise>
|
|
</choose>
|
|
ORDER BY
|
|
points DESC
|
|
</select>
|
|
</mapper>
|
|
|