<?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.ltkj.system.mapper.SysDeptMapper">
|
|
<resultMap type="SysDept" id="SysDeptResult">
|
<id property="deptId" column="dept_id"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="ancestors" column="ancestors"/>
|
<result property="deptName" column="dept_name"/>
|
<result property="orderNum" column="order_num"/>
|
<result property="leader" column="leader"/>
|
<result property="phone" column="phone"/>
|
<result property="email" column="email"/>
|
<result property="status" column="status"/>
|
<result property="deleted" column="deleted"/>
|
<!-- <result property="parentName" column="parent_name" />-->
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by"/>
|
<result property="updateTime" column="update_time"/>
|
|
<result property="departmentEnName" column="department_en_name"/>
|
<result property="orgType" column="org_type"/>
|
<result property="departmentCode" column="department_code"/>
|
<result property="parentOrgId" column="parent_org_id"/>
|
<result property="parentOrgName" column="parent_org_name"/>
|
<result property="parentOrgCode" column="parent_org_code"/>
|
<result property="parentOrgType" column="parent_org_type"/>
|
<result property="hospId" column="hosp_id"/>
|
<result property="hospCode" column="hosp_code"/>
|
<result property="hospName" column="hosp_name"/>
|
<result property="contactPerson" column="contact_person"/>
|
<result property="contactPhone" column="contact_phone"/>
|
<result property="postalCode" column="postal_code"/>
|
<result property="officialWeb" column="official_web"/>
|
<result property="plaitBed" column="plait_bed"/>
|
<result property="openBed" column="open_bed"/>
|
<result property="buildDate" column="build_date"/>
|
<result property="overDate" column="over_date"/>
|
<result property="peofile" column="peofile"/>
|
<result property="standardDeptCode" column="standard_dept_code"/>
|
<result property="deptTypeCode" column="dept_type_code"/>
|
<result property="deptFcusTypeCode" column="dept_fcus_type_code"/>
|
<result property="modality" column="modality"/>
|
<result property="hisksid" column="hisksid"/>
|
<result property="hisksmc" column="hisksmc"/>
|
</resultMap>
|
|
<sql id="selectDeptVo">
|
select d.dept_id,
|
d.parent_id,
|
d.ancestors,
|
d.dept_name,
|
d.order_num,
|
d.leader,
|
d.phone,
|
d.email,
|
d.status,
|
d.deleted,
|
d.create_by,
|
d.create_time,
|
d.department_en_name,
|
d.org_type,
|
d.department_code,
|
d.parent_org_id,
|
d.parent_org_name,
|
d.parent_org_code,
|
d.parent_org_type,
|
d.hosp_id,
|
d.hosp_code,
|
d.hosp_name,
|
d.contact_person,
|
d.contact_phone,
|
d.postal_code,
|
d.official_web,
|
d.plait_bed,
|
d.open_bed,
|
d.build_date,
|
d.over_date,
|
d.peofile,
|
d.standard_dept_code,
|
d.dept_type_code,
|
d.dept_fcus_type_code,
|
d.modality,
|
d.hisksid,
|
d.hisksmc
|
from sys_dept d
|
</sql>
|
|
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
<include refid="selectDeptVo"/>
|
where d.deleted = '0'
|
<if test="deptId != null and deptId != 0">
|
AND dept_id = #{deptId}
|
</if>
|
<if test="parentId != null and parentId != 0">
|
AND parent_id = #{parentId}
|
</if>
|
<if test="deptName != null and deptName != ''">
|
AND dept_name like concat('%', #{deptName}, '%')
|
</if>
|
<if test="status != null and status != ''">
|
AND status = #{status}
|
</if>
|
<!-- 数据范围过滤 -->
|
${params.dataScope}
|
order by d.parent_id, d.order_num
|
</select>
|
|
<select id="selectDeptListByRoleId" resultType="Long">
|
select d.dept_id
|
from sys_dept d
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
where rd.role_id = #{roleId}
|
<if test="deptCheckStrictly">
|
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id =
|
rd.dept_id and rd.role_id = #{roleId})
|
</if>
|
order by d.parent_id, d.order_num
|
</select>
|
|
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
select d.dept_id,
|
d.parent_id,
|
d.ancestors,
|
d.dept_name,
|
d.order_num,
|
d.leader,
|
d.phone,
|
d.email,
|
d.status,
|
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
from sys_dept d
|
where d.dept_id = #{deptId}
|
</select>
|
|
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
select count(1)
|
from sys_user
|
where dept_id = #{deptId}
|
and deleted = '0'
|
</select>
|
|
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
select count(1)
|
from sys_dept
|
where deleted = '0'
|
and parent_id = #{deptId} limit 1
|
</select>
|
|
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
|
select *
|
from sys_dept
|
where find_in_set(#{deptId}, ancestors)
|
</select>
|
|
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
select count(*)
|
from sys_dept
|
where status = 0
|
and deleted = '0'
|
and find_in_set(#{deptId}, ancestors)
|
</select>
|
|
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
<include refid="selectDeptVo"/>
|
where dept_name=#{deptName} and parent_id = #{parentId} and deleted = '0' limit 1
|
</select>
|
|
<insert id="insertDept" parameterType="SysDept">
|
insert into sys_dept(
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="deptName != null and deptName != ''">dept_name,</if>
|
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
<if test="orderNum != null">order_num,</if>
|
<if test="leader != null and leader != ''">leader,</if>
|
<if test="phone != null and phone != ''">phone,</if>
|
<if test="email != null and email != ''">email,</if>
|
<if test="status != null">status,</if>
|
|
<if test="departmentEnName != null">department_en_name,</if>
|
<if test="orgType != null">org_type,</if>
|
<if test="departmentCode != null">department_code,</if>
|
<if test="parentOrgId != null">parent_org_id,</if>
|
<if test="parentOrgName != null">parent_org_name,</if>
|
<if test="parentOrgCode != null">parent_org_code,</if>
|
<if test="parentOrgType != null">parent_org_type,</if>
|
<if test="hospId != null">hosp_id,</if>
|
<if test="hospCode != null">hosp_code,</if>
|
<if test="hospName != null">hosp_name,</if>
|
<if test="contactPerson != null">contact_person,</if>
|
<if test="contactPhone != null">contact_phone,</if>
|
<if test="postalCode != null">postal_code,</if>
|
<if test="officialWeb != null">official_web,</if>
|
<if test="plaitBed != null">plait_bed,</if>
|
<if test="openBed != null">open_bed,</if>
|
<if test="buildDate != null">build_date,</if>
|
<if test="overDate != null">over_date,</if>
|
<if test="peofile != null">peofile,</if>
|
<if test="standardDeptCode != null">standard_dept_code,</if>
|
|
<if test="deptTypeCode != null">dept_type_code,</if>
|
<if test="deptFcusTypeCode != null">dept_fcus_type_code,</if>
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="modality != null and modality != ''">modality,</if>
|
<if test="hisksid != null and hisksid != ''">hisksid,</if>
|
<if test="hisksmc != null and hisksmc != ''">hisksmc,</if>
|
create_time
|
)values(
|
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
<if test="orderNum != null">#{orderNum},</if>
|
<if test="leader != null and leader != ''">#{leader},</if>
|
<if test="phone != null and phone != ''">#{phone},</if>
|
<if test="email != null and email != ''">#{email},</if>
|
<if test="status != null">#{status},</if>
|
|
<if test="departmentEnName != null">#{departmentEnName},</if>
|
<if test="orgType != null">#{orgType},</if>
|
<if test="departmentCode != null">#{departmentCode},</if>
|
<if test="parentOrgId != null">#{parentOrgId},</if>
|
<if test="parentOrgName != null">#{parentOrgName},</if>
|
<if test="parentOrgCode != null">#{parentOrgCode},</if>
|
<if test="parentOrgType != null">#{parentOrgType},</if>
|
<if test="hospId != null">#{hospId},</if>
|
<if test="hospCode != null">#{hospCode},</if>
|
<if test="hospName != null">#{hospName},</if>
|
<if test="contactPerson != null">#{contactPerson},</if>
|
<if test="contactPhone != null">#{contactPhone},</if>
|
<if test="postalCode != null">#{postalCode},</if>
|
<if test="officialWeb != null">#{officialWeb},</if>
|
<if test="plaitBed != null">#{plaitBed},</if>
|
<if test="openBed != null">#{openBed},</if>
|
<if test="buildDate != null">#{buildDate},</if>
|
<if test="overDate != null">#{overDate},</if>
|
<if test="peofile != null">#{peofile},</if>
|
<if test="standardDeptCode != null">#{standardDeptCode},</if>
|
<if test="deptTypeCode != null">#{deptTypeCode},</if>
|
<if test="deptFcusTypeCode != null">#{deptFcusTypeCode},</if>
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="modality != null and modality != ''">#{modality},</if>
|
<if test="hisksid != null and hisksid != ''">#{hisksid},</if>
|
<if test="hisksmc != null and hisksmc != ''">#{hisksmc},</if>
|
sysdate()
|
)
|
</insert>
|
|
<update id="updateDept" parameterType="SysDept">
|
update sys_dept
|
<set>
|
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
<if test="leader != null">leader = #{leader},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
<if test="email != null">email = #{email},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="departmentEnName != null">department_en_name = #{departmentEnName},</if>
|
<if test="orgType != null">org_type = #{orgType},</if>
|
<if test="departmentCode != null">department_code = #{departmentCode},</if>
|
<if test="parentOrgId != null">parent_org_id = #{parentOrgId},</if>
|
<if test="parentOrgName != null">parent_org_name = #{parentOrgName},</if>
|
<if test="parentOrgCode != null">parent_org_code = #{parentOrgCode},</if>
|
<if test="parentOrgType != null">parent_org_type = #{parentOrgType},</if>
|
<if test="hospId != null">hosp_id = #{hospId},</if>
|
<if test="hospCode != null">hosp_code = #{hospCode},</if>
|
<if test="hospName != null">hosp_name = #{hospName},</if>
|
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
|
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
|
<if test="postalCode != null">postal_code = #{postalCode},</if>
|
<if test="officialWeb != null">official_web = #{officialWeb},</if>
|
<if test="plaitBed != null">plait_bed = #{plaitBed},</if>
|
<if test="openBed != null">open_bed = #{openBed},</if>
|
<if test="buildDate != null">build_date = #{buildDate},</if>
|
<if test="overDate != null">over_date = #{overDate},</if>
|
<if test="peofile != null">peofile = #{peofile},</if>
|
<if test="standardDeptCode != null">standard_dept_code = #{standardDeptCode},</if>
|
<if test="deptTypeCode != null">dept_type_code = #{deptTypeCode},</if>
|
<if test="deptFcusTypeCode != null">dept_fcus_type_code = #{deptFcusTypeCode},</if>
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="modality != null and modality != ''">modality = #{modality},</if>
|
<if test="hisksid != null and hisksid != ''">hisksid = #{hisksid},</if>
|
<if test="hisksmc != null and hisksmc != ''">hisksmc = #{hisksmc},</if>
|
update_time = sysdate()
|
</set>
|
where dept_id = #{deptId}
|
</update>
|
|
<update id="updateDeptChildren" parameterType="java.util.List">
|
update sys_dept set ancestors =
|
<foreach collection="depts" item="item" index="index"
|
separator=" " open="case dept_id" close="end">
|
when #{item.deptId} then #{item.ancestors}
|
</foreach>
|
where dept_id in
|
<foreach collection="depts" item="item" index="index"
|
separator="," open="(" close=")">
|
#{item.deptId}
|
</foreach>
|
</update>
|
|
<update id="updateDeptStatusNormal" parameterType="Long">
|
update sys_dept set status = '0' where dept_id in
|
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
#{deptId}
|
</foreach>
|
</update>
|
|
<delete id="deleteDeptById" parameterType="Long">
|
update sys_dept
|
set deleted = '1'
|
where dept_id = #{deptId}
|
</delete>
|
|
<update id="updateDeptStatus" parameterType="SysDept">
|
update sys_dept
|
set status = #{status}
|
where dept_id = #{deptId}
|
</update>
|
|
|
<select id="getSysDeptYjWjCustomerList1" parameterType="java.util.Map" statementType="CALLABLE" resultType="java.util.Map">
|
{call pro_tjhzlb_list(
|
|
#{deptid,mode=IN,jdbcType=VARCHAR},
|
#{tjname,mode=IN,jdbcType=VARCHAR},
|
#{tjNumber,mode=IN,jdbcType=VARCHAR},
|
#{type,mode=IN,jdbcType=INTEGER},
|
#{page,mode=IN,jdbcType=INTEGER},
|
#{pageSize,mode=IN,jdbcType=INTEGER},
|
#{totalRows,mode=OUT,jdbcType=INTEGER}
|
)}
|
</select>
|
|
|
|
<select id="getSysDeptYjWjCustomerList2" parameterType="java.util.Map" statementType="CALLABLE" resultType="java.util.EventObject">
|
{call pro_tjhzlb_list(
|
|
#{deptid,mode=IN,jdbcType=VARCHAR},
|
#{tjname,mode=IN,jdbcType=VARCHAR},
|
#{tjNumber,mode=IN,jdbcType=VARCHAR},
|
#{type,mode=IN,jdbcType=INTEGER},
|
#{page,mode=IN,jdbcType=INTEGER},
|
#{pageSize,mode=IN,jdbcType=INTEGER},
|
#{totalRows,mode=OUT,jdbcType=INTEGER}
|
)}
|
</select>
|
|
|
<select id="getSysDeptYjWjCustomerList13" parameterType="java.util.Map" statementType="CALLABLE" resultType="java.util.Map">
|
{call pro_tjhzlb_list(
|
|
#{deptid,mode=IN,jdbcType=VARCHAR},
|
#{tjname,mode=IN,jdbcType=VARCHAR},
|
#{tjNumber,mode=IN,jdbcType=VARCHAR},
|
#{type,mode=IN,jdbcType=INTEGER},
|
#{page,mode=IN,jdbcType=INTEGER},
|
#{pageSize,mode=IN,jdbcType=INTEGER},
|
#{totalRows,mode=OUT,jdbcType=INTEGER}
|
)}
|
</select>
|
|
|
<select id="getSysDeptHyAndYxYjWjCustomerList13" parameterType="java.util.Map" statementType="CALLABLE" resultType="java.util.Map">
|
{call check_hyAndYx_list(
|
#{deptid,mode=IN,jdbcType=VARCHAR},
|
#{tjname,mode=IN,jdbcType=VARCHAR},
|
#{tjNumber,mode=IN,jdbcType=VARCHAR},
|
#{type,mode=IN,jdbcType=INTEGER},
|
#{page,mode=IN,jdbcType=INTEGER},
|
#{pageSize,mode=IN,jdbcType=INTEGER},
|
#{totalRows,mode=OUT,jdbcType=INTEGER}
|
)}
|
</select>
|
<select id="getDeptTreeById" resultType="java.lang.Long">
|
WITH RECURSIVE dept_tree AS (
|
SELECT dept_id
|
FROM sys_dept
|
WHERE dept_id = #{deptId}
|
|
UNION ALL
|
|
SELECT d.dept_id
|
FROM sys_dept d
|
INNER JOIN dept_tree dt ON d.parent_id = dt.dept_id
|
)
|
SELECT dept_id FROM dept_tree;
|
</select>
|
|
</mapper>
|