feat: 根据部门和层级获取人员 及 区域 及 全部意见CID条件查询

This commit is contained in:
super_liu
2021-06-04 17:28:51 +08:00
parent a18735496e
commit 8457c5ce97
19 changed files with 742 additions and 9 deletions
@@ -199,6 +199,139 @@
</set>
where usid = #{usid}
</update>
<select id="getUserByRolePage" resultType="com.adc.da.sys.vo.RoleUserVO" parameterType="com.adc.da.base.page.BasePage">
SELECT userIdAndRoleId,
userId,
userName,
email,
roleId,
roleName,
orgId,
orgType,
orgName,
pOrgId,
pOrgName
FROM (
select distinct
concat(TS_USER.usid,TS_ROLE.ID) as userIdAndRoleId,
TS_USER.usid as userId,
TS_USER.uname as userName,
TS_USER.email as email,
TS_ROLE.ID as roleId,
TS_ROLE.NAME as roleName,
tog.ID as orgId,
tog.ORG_TYPE as orgType,
tog.ORG_NAME as orgName,
tog.PARENT_ID as pOrgId,
(select ORG_NAME from TS_ORG where TS_ORG.ID=tog.PARENT_ID) as pOrgName
from TS_USER
left join TS_USER_ROLE on TS_USER_ROLE.USER_ID = TS_USER.USID
left join TS_ROLE on TS_ROLE.ID = TS_USER_ROLE.ROLE_ID
left join TS_USER_ORG on TS_USER_ORG.USER_ID = TS_USER.USID
left join TS_ORG tog on tog.ID = TS_USER_ORG.ORG_ID
<where>
TS_USER.VALID_FLAG = '0'
and TS_ROLE.VALID_FLAG = '0'
and TS_ROLE.USE_FLAG = 0
<if test="orgIdList != null ">
and (
tog.ID in
<foreach collection="orgIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<foreach collection="orgIdList" index="index" item="item" open="" separator="" close="">
or tog.PARENT_IDS like concat('%',#{item},'%')
</foreach>
)
</if>
<if test="roleHierarchy != null">
and TS_ROLE.role_hierarchy = #{roleHierarchy}
</if>
<if test="roleIdList != null">
and TS_ROLE.ID in
<foreach collection="roleIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="roleNameList != null">
and TS_ROLE.NAME in
<foreach collection="roleNameList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userName != null">
and (
TS_USER.UNAME ${userNameOperator} concat('%',#{userName},'%')
) or (
TS_USER.email ${userNameOperator} concat('%',#{userName},'%')
)
</if>
) tmp_user
limit ${pager.startIndex-1},${pageSize}
</where>
</select>
<select id="getUserByRolePageCount" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
select count(1) from (
select distinct
concat(TS_USER.usid,TS_ROLE.ID) as userIdAndRoleId,
TS_USER.usid as userId,
TS_USER.uname as userName,
TS_USER.email as email,
TS_ROLE.ID as roleId,
TS_ROLE.NAME as roleName,
tog.ID as orgId,
tog.ORG_TYPE as orgType,
tog.ORG_NAME as orgName,
tog.PARENT_ID as pOrgId,
(select ORG_NAME from TS_ORG where TS_ORG.ID=tog.PARENT_ID) as pOrgName
from TS_USER
left join TS_USER_ROLE on TS_USER_ROLE.USER_ID = TS_USER.USID
left join TS_ROLE on TS_ROLE.ID = TS_USER_ROLE.ROLE_ID
left join TS_USER_ORG on TS_USER_ORG.USER_ID = TS_USER.USID
left join TS_ORG tog on tog.ID = TS_USER_ORG.ORG_ID
<where>
TS_USER.VALID_FLAG = '0'
and TS_ROLE.VALID_FLAG = '0'
and TS_ROLE.USE_FLAG = 0
<if test="orgIdList != null ">
and (
tog.ID in
<foreach collection="orgIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<foreach collection="orgIdList" index="index" item="item" open="" separator="" close="">
or tog.PARENT_IDS like concat('%',#{item},'%')
</foreach>
)
</if>
<if test="roleHierarchy != null">
and TS_ROLE.role_hierarchy = #{roleHierarchy}
</if>
<if test="roleIdList != null">
and TS_ROLE.ID in
<foreach collection="roleIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="roleNameList != null">
and TS_ROLE.NAME in
<foreach collection="roleNameList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userName != null">
and (
TS_USER.UNAME ${userNameOperator} concat('%',#{userName},'%')
) or (
TS_USER.email ${userNameOperator} concat('%',#{userName},'%')
)
</if>
) tmp_user
</where>
</select>
<!-- 根据用户ID获取角色ID列表 -->
<select id="getRoleIdListByUserId" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select role_id