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.
456 lines
15 KiB
456 lines
15 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.epmet.dao.CustomerStaffDao">
|
|
|
|
<!-- 根据手机号查询工作人员信息 -->
|
|
<select id="selectListCustomerStaffDTO" parameterType="java.lang.String" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
select * from customer_staff cs
|
|
where cs.MOBILE=#{mobile}
|
|
and cs.DEL_FLAG='0'
|
|
order by cs.ACTIVE_TIME desc,cs.CREATED_TIME asc
|
|
</select>
|
|
|
|
<!-- 根据手机号+客户id获取工作人员基本信息 -->
|
|
<select id="selectListCustomerStaffInfo" parameterType="com.epmet.dto.form.CustomerStaffFormDTO" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
select * from customer_staff cs
|
|
where cs.MOBILE=#{mobile}
|
|
and cs.CUSTOMER_ID=#{customerId}
|
|
and cs.DEL_FLAG='0'
|
|
</select>
|
|
<select id="selectStaffInfoByUserId" parameterType="com.epmet.dto.CustomerStaffDTO" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
select * from customer_staff cs
|
|
where cs.USER_ID=#{userId}
|
|
and cs.DEL_FLAG='0'
|
|
</select>
|
|
|
|
<!-- 根据userId查询网格下的用户信息 -->
|
|
<select id="selectStaffGridListByUserId" parameterType="com.epmet.dto.CustomerStaffGridDTO" resultType="com.epmet.dto.StaffGridListDTO">
|
|
SELECT
|
|
cs.user_id AS staffId,
|
|
cs.real_name AS staffName,
|
|
IFNULL(cs.head_photo,'') AS staffHeadPhoto,
|
|
IFNULL(gsr.role_name,'') AS roleName,
|
|
cs.gender
|
|
FROM
|
|
customer_staff cs
|
|
LEFT JOIN gov_staff_role gsr ON cs.user_id = gsr.id
|
|
WHERE
|
|
cs.user_id in
|
|
<foreach collection="list" item="staff" open="(" separator="," close=")">
|
|
#{staff.userId}
|
|
</foreach>
|
|
AND cs.del_flag = 0
|
|
</select>
|
|
|
|
<!-- 根据userId查询网格下未被禁用的人员数量 -->
|
|
<select id="selectGridStaffCountByUserId" resultType="com.epmet.dto.GridStaffCountDTO">
|
|
SELECT
|
|
count(*) AS enableCount
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
user_id in
|
|
<foreach collection="list" item="staff" open="(" separator="," close=")">
|
|
#{staff.userId}
|
|
</foreach>
|
|
AND del_flag = 0
|
|
AND enable_flag = 'enable'
|
|
</select>
|
|
<select id="selectCustomerStaffList" resultType="com.epmet.dto.result.StaffInfoResultDTO" parameterType="com.epmet.dto.form.StaffsInAgencyFromDTO">
|
|
SELECT
|
|
cs.USER_ID AS "staffId",
|
|
cs.REAL_NAME AS "staffName",
|
|
cs.GENDER AS "gender",
|
|
IFNULL( cs.HEAD_PHOTO, "" ) AS "staffHeadPhoto",
|
|
cs.ENABLE_FLAG AS "enableFlag",
|
|
IFNULL( role.ROLE_NAME, "" ) AS "roleName"
|
|
FROM
|
|
customer_staff cs
|
|
LEFT JOIN (
|
|
SELECT
|
|
sr.STAFF_ID,
|
|
sr.ROLE_ID,
|
|
gsr.ROLE_NAME
|
|
FROM
|
|
staff_role sr
|
|
LEFT JOIN gov_staff_role gsr ON sr.ROLE_ID = gsr.ID
|
|
AND gsr.DEL_FLAG = '0'
|
|
AND gsr.CUSTOMER_ID = #{customerId}
|
|
WHERE
|
|
sr.DEL_FLAG = '0'
|
|
AND sr.ORG_ID = #{agencyId}
|
|
AND gsr.ROLE_KEY = 'agency_leader'
|
|
) role ON cs.USER_ID = role.STAFF_ID
|
|
WHERE
|
|
cs.DEL_FLAG = '0'
|
|
AND cs.CUSTOMER_ID = #{customerId}
|
|
AND cs.ENABLE_FLAG = 'enable'
|
|
AND cs.USER_ID IN
|
|
<foreach item="userId" collection="staffList" separator="," open="(" close=")" index="">
|
|
#{userId}
|
|
</foreach>
|
|
ORDER BY
|
|
role.ROLE_NAME DESC,
|
|
cs.CREATED_TIME DESC
|
|
LIMIT 12
|
|
</select>
|
|
|
|
<!-- 根据staffid查询用户基本信息 -->
|
|
<select id="selectByUserId" parameterType="java.lang.String" resultType="com.epmet.entity.CustomerStaffEntity">
|
|
SELECT
|
|
*
|
|
FROM
|
|
customer_staff CS
|
|
WHERE
|
|
cs.DEL_FLAG = '0'
|
|
AND CS.USER_ID =#{userId}
|
|
</select>
|
|
<select id="selectStaffList" resultType="com.epmet.dto.result.StaffInfoResultDTO" parameterType="com.epmet.dto.form.StaffsInAgencyFromDTO">
|
|
SELECT
|
|
cs.USER_ID AS "staffId",
|
|
cs.REAL_NAME AS "staffName",
|
|
cs.GENDER AS "gender",
|
|
IFNULL(cs.HEAD_PHOTO, "") AS "staffHeadPhoto",
|
|
cs.ENABLE_FLAG AS "enableFlag"
|
|
FROM
|
|
customer_staff cs
|
|
WHERE
|
|
cs.DEL_FLAG = '0'
|
|
AND cs.CUSTOMER_ID = #{customerId}
|
|
<foreach item="userId" collection="staffList" separator="OR" open="AND (" close=")" index="">
|
|
cs.USER_ID = #{userId}
|
|
</foreach>
|
|
ORDER BY convert(cs.REAL_NAME using gbk) ASC
|
|
</select>
|
|
<select id="selectStaffInfo" resultType="com.epmet.dto.CustomerStaffDTO" parameterType="com.epmet.dto.form.StaffInfoFromDTO">
|
|
SELECT
|
|
USER_ID,
|
|
REAL_NAME,
|
|
MOBILE,
|
|
GENDER,
|
|
IFNULL(HEAD_PHOTO, "") AS "headPhoto",
|
|
ENABLE_FLAG,
|
|
ACTIVE_FLAG,
|
|
ACTIVE_TIME,
|
|
WORK_TYPE
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND CUSTOMER_ID = #{customerId}
|
|
AND USER_ID = #{staffId}
|
|
</select>
|
|
<select id="selectDepartmentStaffList" resultType="com.epmet.dto.result.DepartInStaffListResultDTO">
|
|
SELECT
|
|
user_id AS 'staffId',
|
|
real_name AS 'staffName',
|
|
IF (head_photo IS NULL,'',head_photo) AS 'staffHeadPhoto',
|
|
gender AS 'gender'
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag = '0'
|
|
AND customer_id = #{customerId}
|
|
AND user_id in
|
|
<foreach item="userId" collection="userIdList" separator="," open="(" close=")" index="">
|
|
#{userId}
|
|
</foreach>
|
|
ORDER BY CONVERT (real_name USING gbk) ASC<!--按中文对应的拼音升序排列-->
|
|
</select>
|
|
|
|
<!-- 根据UserId列表查询用户Id、头像、昵称,过滤掉被禁用的,包含未激活的-->
|
|
<select id="selectEnableStaffMsg" resultType="com.epmet.dto.result.CommonStaffInfoResultDTO">
|
|
SELECT
|
|
USER_ID AS staffId,
|
|
IFNULL(REAL_NAME,"") AS staffName,
|
|
IFNULL(HEAD_PHOTO,"") AS staffHeadPhoto ,
|
|
IFNULL(GENDER,0) AS gender
|
|
FROM
|
|
CUSTOMER_STAFF
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND
|
|
CUSTOMER_ID = #{customerId}
|
|
AND
|
|
ENABLE_FLAG = 'enable'
|
|
<foreach collection="userIds" item="userId" open="AND USER_ID IN (" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectStaffByIds" resultType="com.epmet.dto.result.StaffListResultDTO">
|
|
SELECT
|
|
CUSTOMER_ID AS customerId,
|
|
user_id AS staffId,
|
|
IFNULL(real_name,"") AS staffName,
|
|
IFNULL(head_photo,"") AS staffHeadPhoto ,
|
|
IFNULL(gender,0) AS gender,
|
|
IFNULL(mobile,"") AS mobile
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag = '0'
|
|
<foreach item="userId" collection="staffIdList" separator="OR" open="AND (" close=")" index="">
|
|
user_id = #{userId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectByStaffId" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
SELECT
|
|
*
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag = '0'
|
|
AND user_id = #{staffId}
|
|
</select>
|
|
|
|
<select id="selectStaff" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
SELECT
|
|
*
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag='0'
|
|
AND customer_id = #{customerId}
|
|
AND mobile = #{mobile}
|
|
ORDER BY active_time DESC, created_time ASC
|
|
</select>
|
|
|
|
<!-- 查询工作人员的信息 -->
|
|
<select id="getStaffInfoList" resultType="com.epmet.dto.result.StaffSinGridResultDTO">
|
|
SELECT
|
|
cs.user_id AS staffId,
|
|
cs.real_name AS staffName,
|
|
IFNULL( uw.head_img_url, '' ) AS headPhoto,
|
|
gender AS gender
|
|
FROM
|
|
customer_staff cs
|
|
LEFT JOIN user_wechat uw ON uw.user_id = cs.user_id AND uw.del_flag = 0
|
|
WHERE
|
|
cs.del_flag = 0
|
|
AND cs.enable_flag = 'enable'
|
|
AND
|
|
(
|
|
<foreach collection="userIds" item="userId" separator="OR">
|
|
cs.user_id = #{userId}
|
|
</foreach>
|
|
)
|
|
</select>
|
|
|
|
|
|
<!-- 工作人员信息Map -->
|
|
<resultMap id="StaffInfoAndRoleMap" type="com.epmet.dto.result.ExtStaffInfoResultDTO">
|
|
<result property="nickname" column="nickname"/>
|
|
<result property="profile" column="profile"/>
|
|
<result property="realName" column="realName"/>
|
|
<result property="gridId" column="GRID_ID"/>
|
|
<result property="mobile" column="MOBILE"/>
|
|
<result property="customerId" column="CUSTOMER_ID"/>
|
|
<collection property="roleList" ofType="com.epmet.dto.result.ExtRoleMapResultDTO">
|
|
<result property="roleKey" column="ROLE_KEY" />
|
|
<result property="roleName" column="ROLE_NAME" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<!-- 查询工作人员信息 (对外接口) -->
|
|
<select id="selectStaffInfoExt" resultMap="StaffInfoAndRoleMap">
|
|
SELECT
|
|
staff.REAL_NAME AS nickname,
|
|
'' AS PROFILE,
|
|
staff.REAL_NAME AS realName,
|
|
staff.MOBILE,
|
|
role.ROLE_KEY,
|
|
role.ROLE_NAME,
|
|
vis.GRID_ID
|
|
FROM
|
|
CUSTOMER_STAFF staff
|
|
LEFT JOIN (
|
|
SELECT
|
|
role.STAFF_ID,
|
|
rolename.CUSTOMER_ID,
|
|
rolename.ROLE_KEY,
|
|
rolename.ROLE_NAME
|
|
FROM
|
|
STAFF_ROLE role
|
|
LEFT JOIN GOV_STAFF_ROLE rolename ON role.ROLE_ID = rolename.ID
|
|
AND rolename.DEL_FLAG = '0'
|
|
WHERE
|
|
role.DEL_FLAG = '0'
|
|
AND role.STAFF_ID = #{staffId}
|
|
) role ON staff.USER_ID = role.STAFF_ID
|
|
LEFT JOIN ( SELECT GRID_ID, CUSTOMER_ID, STAFF_ID FROM STAFF_GRID_VISITED WHERE DEL_FLAG = '0' AND STAFF_ID = #{staffId} ORDER BY UPDATED_TIME DESC LIMIT 1 ) vis ON staff.USER_ID = vis.STAFF_ID
|
|
AND vis.CUSTOMER_ID = role.CUSTOMER_ID
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND USER_ID = #{staffId}
|
|
</select>
|
|
|
|
<select id="selectRootManage" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
SELECT s.ID
|
|
FROM
|
|
staff_role sr
|
|
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )
|
|
INNER JOIN customer_staff s ON (sr.STAFF_ID = s.USER_ID)
|
|
WHERE
|
|
r.ROLE_KEY = #{roleKey}
|
|
AND sr.ORG_ID = #{orgId}
|
|
AND sr.DEL_FLAG = '0'
|
|
AND r.DEL_FLAG = '0'
|
|
AND S.DEL_FLAG = '0'
|
|
</select>
|
|
|
|
<select id="selectByCustomerIdAndPhone" resultType="com.epmet.dto.result.GovWebOperLoginResultDTO">
|
|
SELECT
|
|
user_id AS "userId",
|
|
`password` AS "passWord"
|
|
FROM
|
|
`customer_staff`
|
|
WHERE
|
|
del_flag = '0'
|
|
AND customer_id = #{customerId}
|
|
AND mobile = #{mobile}
|
|
ORDER BY created_time DESC
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="selectStaffBasicInfo" resultType="com.epmet.dto.result.StaffBasicInfoResultDTO">
|
|
SELECT
|
|
cs.CUSTOMER_ID customerId,
|
|
cs.USER_ID id,
|
|
cs.REAL_NAME realName,
|
|
cs.GENDER gender,
|
|
cs.EMAIL email,
|
|
cs.MOBILE phone,
|
|
1 superAdmin,
|
|
CASE cs.ENABLE_FLAG
|
|
WHEN 'enable' THEN
|
|
1
|
|
ELSE
|
|
0
|
|
END `status`,
|
|
cs.HEAD_PHOTO headUrl,
|
|
'' wxOpenId
|
|
FROM
|
|
customer_staff cs
|
|
WHERE
|
|
cs.DEL_FLAG = '0'
|
|
AND cs.USER_ID = #{userId}
|
|
</select>
|
|
|
|
<select id="getStaffBasicInfo" resultType="com.epmet.dto.result.BasicInfoResultDTO">
|
|
SELECT
|
|
user_id AS "staffId",
|
|
real_name AS "realName",
|
|
mobile AS "mobile",
|
|
gender AS "gender",
|
|
IFNULL(head_photo, "") AS "staffHeadPhoto",
|
|
enable_flag AS "enableFlag",
|
|
active_flag AS "activeFlag",
|
|
active_time AS "activeTime",
|
|
work_type AS "workType"
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag = '0'
|
|
AND user_id = #{staffId}
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="listDTOS" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
select id,
|
|
customer_id,
|
|
user_id,
|
|
real_name,
|
|
gender,
|
|
email,
|
|
mobile,
|
|
address,
|
|
del_flag,
|
|
revision,
|
|
created_by,
|
|
created_time,
|
|
updated_by,
|
|
updated_time,
|
|
work_type,
|
|
head_photo,
|
|
active_flag,
|
|
active_time,
|
|
enable_flag
|
|
from customer_staff
|
|
<where>
|
|
<if test="realName != null and realName != ''">
|
|
REAL_NAME = #{realName}
|
|
</if>
|
|
<if test="customerId != null and customerId != ''">
|
|
and CUSTOMER_ID = #{customerId}
|
|
</if>
|
|
<if test="mobile != null and mobile != ''">
|
|
and MOBILE = #{mobile}
|
|
</if>
|
|
<if test="userIds != null and userIds.size() > 0">
|
|
and user_id in
|
|
<foreach collection="userIds" item="userId" separator="," open="(" close=")">
|
|
#{userId}
|
|
</foreach>
|
|
</if>
|
|
and DEL_FLAG = 0
|
|
</where>
|
|
|
|
</select>
|
|
|
|
<!-- 查询用户名字 -->
|
|
<select id="selectUserName" resultType="com.epmet.dto.result.UserNameResultDTO">
|
|
SELECT
|
|
USER_ID,
|
|
IFNULL( REAL_NAME, '' ) AS userName
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND (
|
|
<foreach collection="userIds" item="userId" separator=" OR ">
|
|
USER_ID = #{userId}
|
|
</foreach>
|
|
)
|
|
</select>
|
|
|
|
<select id="selectStaffRoles" parameterType="map" resultType="java.lang.String">
|
|
select distinct gsr.ROLE_KEY from gov_staff_role gsr
|
|
where gsr.DEL_FLAG='0'
|
|
AND GSR.CUSTOMER_ID=#{customerId}
|
|
AND gsr.id in(
|
|
select sr.ROLE_ID from staff_role sr
|
|
where sr.DEL_FLAG='0'
|
|
and sr.STAFF_ID=#{userId}
|
|
)
|
|
</select>
|
|
|
|
<select id="getByRealNames" resultType="com.epmet.dto.CustomerStaffDTO">
|
|
SELECT
|
|
id,
|
|
customer_id,
|
|
user_id,
|
|
real_name,
|
|
gender,
|
|
email,
|
|
mobile,
|
|
address,
|
|
work_type,
|
|
head_photo,
|
|
active_flag,
|
|
active_time,
|
|
enable_flag
|
|
FROM
|
|
customer_staff
|
|
WHERE
|
|
del_flag = '0'
|
|
AND customer_id = #{customerId}
|
|
<foreach collection="realNames" item="name" open="AND real_name IN (" separator="," close=")">
|
|
#{name}
|
|
</foreach>
|
|
</select>
|
|
<select id="gridStaffMobileList" resultType="com.epmet.dto.result.GridMobileListResultDTO"></select>
|
|
|
|
</mapper>
|
|
|