123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?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.retdata.yaoyibi.mapper.CsoSysUserMapper">
- <select id="selectPageByParams" resultType="com.retdata.yaoyibi.domain.CsoSysUserSearchDto">
- select
- u1.user_id,u1.realname,u1.phone,u1.del_flag,u1.lock_flag,u1.create_time,
- d1.name as dept_name,
- ur2.roles,
- qr1.quiz_result,
- scs1.sub_cert_status
- from sys_user u1
- left join sys_dept d1 on d1.dept_id=u1.dept_id
- and u1.db_source_id=d1.db_source_id
- left join (
- select ur1.user_id,GROUP_CONCAT(DISTINCT r1.role_name ORDER BY r1.role_id ASC SEPARATOR ',') roles
- , ur1.db_source_id
- from sys_user_role ur1
- left join sys_role r1 on r1.role_id=ur1.role_id
- and r1.db_source_id=ur1.db_source_id
- group by ur1.user_id, ur1.db_source_id
- ) ur2 on ur2.user_id=u1.user_id
- and ur2.db_source_id=u1.db_source_id
- left join (
- select user_id,GROUP_CONCAT(JSON_EXTRACT(quiz_res,"$.finalMark") SEPARATOR '/') as quiz_result
- , db_source_id
- from wm_user_plat_quiz_res
- group by user_id, db_source_id
- ) qr1 on qr1.user_id=u1.user_id
- and qr1.db_source_id=u1.db_source_id
- left join (
- select us1.user_id,GROUP_CONCAT(DISTINCT CONCAT(di1.label,':',us1.gig_type,'_',us1.cert_status) ORDER BY di1.sort ASC SEPARATOR ',') as sub_cert_status
- , us1.db_source_id
- from sys_user_sub us1
- inner join sys_dict_item di1 on di1.value=us1.subject_location and di1.type='subject_location'
- and us1.db_source_id=di1.db_source_id
- group by us1.user_id, us1.db_source_id
- ) scs1 on scs1.user_id=u1.user_id
- and scs1.db_source_id=u1.db_source_id
- <where>
- <if test="searchParams.realname!=null and searchParams.realname!=''">
- and u1.realname like concat('%',#{searchParams.realname},'%')
- </if>
- <if test="searchParams.phone!=null and searchParams.phone!=''">
- and u1.phone like concat('%',#{searchParams.phone},'%')
- </if>
- <if test="searchParams.drugEntId!=null and searchParams.drugEntId!=''">
- and u1.drug_ent_id=#{searchParams.drugEntId}
- </if>
- <if test="searchParams.deptId!=null and searchParams.deptId.length>0">
- and u1.dept_id in <foreach collection="searchParams.deptId" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- <if test="searchParams.roleId!=null">
- and u1.user_id in (select user_id from sys_user_role where role_id=#{searchParams.roleId})
- </if>
- <if test="searchParams.gigType!=null">
- and u1.user_id in (select user_id from sys_user_sub where gig_type=#{searchParams.gigType})
- </if>
- <if test="searchParams.delFlag!=null">
- and u1.del_flag=#{searchParams.delFlag}
- </if>
- <if test="searchParams.lockFlag!=null">
- and u1.lock_flag=#{searchParams.lockFlag}
- </if>
- <if test="searchParams.subjectLocation!=null">
- and u1.user_id in (select user_id from sys_user_sub where subject_location=#{searchParams.subjectLocation})
- </if>
- </where>
- </select>
- <select id="selectDetailById" resultType="com.retdata.yaoyibi.domain.CsoSysUserDetailDto">
- select
- u1.user_id,u1.realname,u1.phone,u1.del_flag,u1.lock_flag,u1.create_time,u1.id_card_number,u1.gender,u1.degree,u1.province,u1.city,u1.area,u1.qualification_record_number,u1.qualifications_url,
- ur2.roles,
- qr1.quiz_result,
- scs1.sub_cert_status,
- d1.name as dept_name,
- de1.entname as drug_ent_name,
- ut1.completed_tasks,ut1.verified_tasks,
- scs2.gig_types
- from sys_user u1
- left join (
- select ur1.user_id,GROUP_CONCAT(DISTINCT r1.role_name ORDER BY r1.role_id ASC SEPARATOR ',') roles
- , ur1.db_source_id
- from sys_user_role ur1
- left join sys_role r1 on r1.role_id=ur1.role_id
- and ur1.db_source_id=r1.db_source_id
- group by ur1.user_id, ur1.db_source_id
- ) ur2 on ur2.user_id=u1.user_id
- and ur2.db_source_id=u1.db_source_id
- left join (
- select user_id,GROUP_CONCAT(JSON_EXTRACT(quiz_res,"$.finalMark") SEPARATOR '/') as quiz_result
- ,db_source_id
- from wm_user_plat_quiz_res
- group by user_id, db_source_id
- ) qr1 on qr1.user_id=u1.user_id
- and qr1.db_source_id=u1.db_source_id
- left join (
- select us1.user_id,GROUP_CONCAT(DISTINCT CONCAT(di1.label,':',us1.gig_type,'_',us1.cert_status) ORDER BY di1.sort ASC SEPARATOR ',') as sub_cert_status
- , us1.db_source_id
- from sys_user_sub us1
- inner join sys_dict_item di1 on di1.value=us1.subject_location and di1.type='subject_location'
- and di1.db_source_id=us1.db_source_id
- group by us1.user_id, us1.db_source_id
- ) scs1 on scs1.user_id=u1.user_id
- and scs1.db_source_id=u1.db_source_id
- left join sys_dept d1 on d1.dept_id=u1.dept_id
- and d1.db_source_id=u1.db_source_id
- left join wm_da_drug_ent de1 on de1.id=u1.drug_ent_id
- and de1.db_source_id=u1.db_source_id
- left join (
- select task_user_id,count(1) as completed_tasks,sum(case when task_status=3 then 1 else 0 end) as verified_tasks
- , db_source_id
- from wm_task
- where task_status!=4 and task_user_id=CAST(#{userId} AS NCHAR)
- group by task_user_id, db_source_id
- ) ut1 on ut1.task_user_id=u1.user_id
- and ut1.db_source_id=u1.db_source_id
- left join (
- select us1.user_id,GROUP_CONCAT(DISTINCT di1.label ORDER BY di1.sort ASC SEPARATOR ',') as gig_types
- , us1.db_source_id
- from sys_user_sub us1
- inner join sys_dict_item di1 on di1.value=us1.gig_type and di1.type='sub_type'
- and us1.db_source_id=di1.db_source_id
- group by us1.user_id, us1.db_source_id
- ) scs2 on scs2.user_id=u1.user_id
- and scs2.db_source_id=u1.db_source_id
- where u1.user_id=#{userId}
- </select>
- </mapper>
|