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.
145 lines
5.0 KiB
145 lines
5.0 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.SysDeptDao">
|
|
|
|
<select id="getList" resultType="com.elink.esua.epdc.entity.SysDeptEntity">
|
|
select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1
|
|
where t1.del_flag = 0
|
|
<if test="deptIdList != null">
|
|
and t1.id in
|
|
<foreach item="id" collection="deptIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
order by t1.sort asc
|
|
</select>
|
|
|
|
<select id="getById" resultType="com.elink.esua.epdc.entity.SysDeptEntity">
|
|
select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1
|
|
where t1.id = #{value} and t1.del_flag = 0
|
|
</select>
|
|
|
|
<select id="getIdAndPidList" resultType="com.elink.esua.epdc.entity.SysDeptEntity">
|
|
select t1.id, t1.pid from sys_dept t1 where t1.del_flag = 0
|
|
</select>
|
|
|
|
<select id="getSubDeptIdList" resultType="long">
|
|
select id from sys_dept where pids like #{id} and del_flag = 0
|
|
</select>
|
|
|
|
<select id="listSimpleDeptInfo" resultType="com.elink.esua.epdc.dto.SysSimpleDeptDTO">
|
|
SELECT
|
|
temp.id,temp.name
|
|
FROM
|
|
( SELECT * FROM sys_dept d WHERE d.pid = #{deptId} ) temp
|
|
</select>
|
|
|
|
<select id="listGridIdByPid" resultType="java.lang.Long">
|
|
SELECT
|
|
d.id
|
|
FROM
|
|
sys_dept d
|
|
WHERE
|
|
d.pids LIKE '%${pid}%'
|
|
AND NOT EXISTS
|
|
( SELECT 1 FROM sys_dept dd WHERE dd.pid = d.id )
|
|
</select>
|
|
<select id="getCompleteDept" resultType="com.elink.esua.epdc.dto.CompleteDeptDTO">
|
|
SELECT
|
|
dis.`name` district,
|
|
dis.id districtId,
|
|
str.`name` street,
|
|
str.id streetId,
|
|
com.`name` community,
|
|
com.id communityId,
|
|
gri.`name` grid,
|
|
gri.id gridId
|
|
FROM
|
|
sys_dept gri
|
|
LEFT JOIN sys_dept com ON gri.pid = com.id
|
|
LEFT JOIN sys_dept str ON com.pid = str.id
|
|
LEFT JOIN sys_dept dis ON str.pid = dis.id
|
|
WHERE
|
|
gri.ID = #{gridId}
|
|
AND gri.del_flag = '0'
|
|
AND dis.id IS NOT NULL
|
|
</select>
|
|
|
|
<select id="selectListOfItemCirculationDept" resultType="com.elink.esua.epdc.dto.SysDeptDTO">
|
|
SELECT
|
|
id,
|
|
`name`,
|
|
type_key
|
|
FROM
|
|
sys_dept
|
|
WHERE
|
|
del_flag = '0'
|
|
AND pid = #{deptId}
|
|
AND type_key = 'street_dept' UNION ALL
|
|
SELECT
|
|
id,
|
|
`name`,
|
|
type_key
|
|
FROM
|
|
sys_dept
|
|
WHERE
|
|
del_flag = '0'
|
|
AND type_key = 'district_dept'
|
|
</select>
|
|
|
|
|
|
<select id="selectListGridForLeader" resultType="com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO">
|
|
SELECT
|
|
dis.`name` district,
|
|
dis.id districtId,
|
|
str.`name` street,
|
|
str.id streetId,
|
|
com.`name` community,
|
|
com.id communityId,
|
|
gri.`name` grid,
|
|
gri.id gridId,
|
|
gri.create_date switchedTime
|
|
FROM
|
|
sys_dept gri
|
|
LEFT JOIN sys_dept com ON gri.pid = com.id
|
|
LEFT JOIN sys_dept str ON com.pid = str.id
|
|
LEFT JOIN sys_dept dis ON str.pid = dis.id
|
|
WHERE
|
|
gri.ID in
|
|
<foreach collection="gridIdList" item="gridId" open="(" separator="," close=")">#{gridId}</foreach>
|
|
AND gri.del_flag = '0'
|
|
AND dis.id IS NOT NULL
|
|
</select>
|
|
|
|
<select id="selectListHeadDeptNode" resultType="com.elink.esua.epdc.entity.SysDeptEntity">
|
|
SELECT
|
|
d1.id,
|
|
d1.`name`
|
|
FROM
|
|
sys_dept d
|
|
LEFT JOIN sys_dept d1 ON d.pids LIKE CONCAT( '%', d1.id, '%' )
|
|
WHERE
|
|
d.id IN
|
|
<foreach collection="dataScopeDeptList" item="deptId" open="(" separator="," close=")" >
|
|
#{deptId}
|
|
</foreach>
|
|
AND d1.pid = 0
|
|
GROUP BY d1.id
|
|
ORDER BY d1.create_date ASC
|
|
</select>
|
|
<select id="selectChildrenDeptNode" resultType="com.elink.esua.epdc.entity.SysDeptEntity">
|
|
SELECT
|
|
tem2.*
|
|
FROM
|
|
( SELECT * FROM sys_dept d1 WHERE d1.id IN <foreach collection="dataScopeDeptList" item="item" open="(" separator="," close=")" > #{item} </foreach> ) tem1,
|
|
( SELECT * FROM sys_dept d2 WHERE d2.pid IN <foreach collection="parentDeptIdList" item="deptId" open="(" separator="," close=")" > #{deptId} </foreach>) tem2
|
|
WHERE
|
|
tem1.PIDS LIKE CONCAT( '%', tem2.id, '%' )
|
|
OR NOT EXISTS ( SELECT 1 FROM sys_dept d WHERE d.PID = tem2.ID )
|
|
AND tem2.ID != ''
|
|
GROUP BY tem2.ID
|
|
ORDER BY tem2.create_date ASC
|
|
</select>
|
|
|
|
</mapper>
|
|
|