2024-01-03 11:04:18 +08:00
|
|
|
<?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.zcloud.mapper.datasource.system.DepartmentMapper">
|
|
|
|
|
|
|
|
<resultMap type="Department" id="departmentResultMap">
|
|
|
|
<id column="DEPARTMENT_ID" property="DEPARTMENT_ID"/>
|
|
|
|
<result column="NAME" property="NAME"/>
|
|
|
|
<result column="PARENT_ID" property="PARENT_ID"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!--表名 -->
|
|
|
|
<sql id="tableName">
|
|
|
|
OA_DEPARTMENT
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<!-- 字段 -->
|
|
|
|
<sql id="Field">
|
|
|
|
NAME,
|
|
|
|
NAME_EN,
|
|
|
|
BIANMA,
|
|
|
|
PARENT_ID,
|
|
|
|
HEADMAN,
|
|
|
|
TEL,
|
|
|
|
FUNCTIONS,
|
|
|
|
ADDRESS,
|
|
|
|
BZ,
|
|
|
|
DEPARTMENT_ID,
|
|
|
|
CORPINFO_ID,
|
|
|
|
LEVEL,
|
|
|
|
DEP_ORDER,
|
|
|
|
ISSUPERVISE,
|
|
|
|
ISDELETE
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<!-- 字段值 -->
|
|
|
|
<sql id="FieldValue">
|
|
|
|
#{NAME},
|
|
|
|
#{NAME_EN},
|
|
|
|
#{BIANMA},
|
|
|
|
#{PARENT_ID},
|
|
|
|
#{HEADMAN},
|
|
|
|
#{TEL},
|
|
|
|
#{FUNCTIONS},
|
|
|
|
#{ADDRESS},
|
|
|
|
#{BZ},
|
|
|
|
#{DEPARTMENT_ID},
|
|
|
|
#{CORPINFO_ID},
|
|
|
|
#{LEVEL},
|
|
|
|
#{DEP_ORDER},
|
|
|
|
#{ISSUPERVISE},
|
|
|
|
0
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<!-- 新增-->
|
|
|
|
<insert id="save" parameterType="pd">
|
|
|
|
insert into
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
(
|
|
|
|
<include refid="Field"></include>
|
|
|
|
) values (
|
|
|
|
<include refid="FieldValue"></include>
|
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 删除-->
|
|
|
|
<update id="delete" parameterType="pd">
|
|
|
|
update
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
set ISDELETE = 1
|
|
|
|
where
|
|
|
|
DEPARTMENT_ID = #{DEPARTMENT_ID}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 修改 -->
|
|
|
|
<update id="edit" parameterType="pd">
|
|
|
|
update
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
set
|
|
|
|
NAME = #{NAME},
|
|
|
|
NAME_EN = #{NAME_EN},
|
|
|
|
HEADMAN = #{HEADMAN},
|
|
|
|
BZ = #{BZ},
|
|
|
|
TEL = #{TEL},
|
|
|
|
FUNCTIONS = #{FUNCTIONS},
|
|
|
|
ADDRESS = #{ADDRESS},
|
|
|
|
LEVEL = #{LEVEL},
|
|
|
|
DEPARTMENT_ID = DEPARTMENT_ID,
|
|
|
|
DEP_ORDER = #{DEP_ORDER},
|
|
|
|
ISSUPERVISE = #{ISSUPERVISE}
|
|
|
|
where ISDELETE = 0 and
|
|
|
|
DEPARTMENT_ID = #{DEPARTMENT_ID}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 通过ID获取数据 -->
|
|
|
|
<select id="findById" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>,
|
|
|
|
(select NAME from OA_DEPARTMENT o where t.PARENT_ID=o.DEPARTMENT_ID) as PARENT_NAME
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include> t
|
|
|
|
where
|
|
|
|
DEPARTMENT_ID = #{DEPARTMENT_ID}
|
|
|
|
</select>
|
|
|
|
<select id="findByName" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include> t ,
|
|
|
|
(select NAME from OA_DEPARTMENT o where t.PARENT_ID=o.DEPARTMENT_ID) as PARENT_NAME
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include> t
|
|
|
|
where t.ISDELETE = 0 and
|
|
|
|
t.NAME = #{NAME} and t.CORPINFO_ID = #{CORPINFO_ID}
|
|
|
|
<if test="PARENT_ID != null and PARENT_ID != ''">
|
|
|
|
AND t.PARENT_ID = #{PARENT_ID}
|
|
|
|
</if>
|
|
|
|
<if test="ISEDIT != null and ISEDIT != ''">
|
|
|
|
AND t.DEPARTMENT_ID != #{DEPARTMENT_ID}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--通过条件获取全部 -->
|
|
|
|
<select id="findByCorpId" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include> f
|
|
|
|
where f.ISDELETE = 0 and
|
|
|
|
f.CORPINFO_ID = #{CORPINFO_ID} and f.PARENT_ID='0'
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过编码获取数据 -->
|
|
|
|
<select id="findByBianma" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
where
|
|
|
|
BIANMA = #{BIANMA}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
<select id="datalistPage" parameterType="page" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
where
|
|
|
|
ISDELETE = 0
|
|
|
|
<if test="pd.DEPARTMENT_ID!= null and pd.DEPARTMENT_ID != ''"><!-- 检索 -->
|
|
|
|
and PARENT_ID = #{pd.DEPARTMENT_ID}
|
|
|
|
</if>
|
|
|
|
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
|
|
|
|
AND
|
|
|
|
CORPINFO_ID = #{pd.CORPINFO_ID}
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if test="pd.keywords != null and pd.keywords != ''"><!-- 关键词检索 -->
|
|
|
|
and
|
|
|
|
(
|
|
|
|
NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
or
|
|
|
|
NAME_EN LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
or
|
|
|
|
BIANMA LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
order by DEP_ORDER asc , NAME
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过ID获取其子级列表 -->
|
|
|
|
<select id="listSubDepartmentByParentId" parameterType="String" resultMap="departmentResultMap">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
where ISDELETE = 0
|
|
|
|
<if test="_parameter != null and _parameter != ''"><!-- 关键词检索 -->
|
|
|
|
and PARENT_ID = #{parentId}
|
|
|
|
</if>
|
|
|
|
|
|
|
|
order by DEP_ORDER asc, NAME
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 通过ID获取其子级列表 -->
|
|
|
|
<select id="listSubDepByParentId" parameterType="pd" resultMap="departmentResultMap">
|
|
|
|
select
|
|
|
|
f.*,
|
|
|
|
IF(o.SUPERVISIONDEPARTMENT_ID is not null,'false','true') DISABLED
|
|
|
|
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include> f
|
|
|
|
left join oa_supervision_department o on f.DEPARTMENT_ID = o.SUB_DEPARTMENT_ID AND o.SUP_DEPARTMENT_ID = #{SUP_DEPARTMENT_ID} and o.isdelete= '0'
|
|
|
|
|
|
|
|
where f.ISDELETE = 0
|
|
|
|
|
|
|
|
<if test="parentId != null and parentId != ''"><!-- 关键词检索 -->
|
|
|
|
and f.PARENT_ID = #{parentId}
|
|
|
|
</if>
|
|
|
|
order by f.DEP_ORDER asc, f.NAME
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过ID获取其子级列表 -->
|
|
|
|
<select id="listAll" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
<include refid="Field"></include>
|
|
|
|
from
|
|
|
|
<include refid="tableName"></include>
|
|
|
|
where ISDELETE = 0
|
|
|
|
<if test="parameter != null and parameter != ''"><!-- 关键词检索 -->
|
|
|
|
and PARENT_ID = #{parameter}
|
|
|
|
</if>
|
|
|
|
<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
|
|
|
|
AND
|
|
|
|
CORPINFO_ID = #{CORPINFO_ID}
|
|
|
|
</if>
|
|
|
|
<if test="PARENT_ID != null and PARENT_ID != ''"><!-- 关键词检索 -->
|
|
|
|
AND
|
|
|
|
PARENT_ID = #{PARENT_ID}
|
|
|
|
</if>
|
|
|
|
order by DEP_ORDER asc ,NAME
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 列表关联部门级别 -->
|
|
|
|
<select id="forLevelNamedatalistPage" parameterType="page" resultType="pd">
|
|
|
|
select
|
|
|
|
f.NAME,
|
|
|
|
f.NAME_EN,
|
|
|
|
getFullName(f.DEPARTMENT_ID) DEPARTMENTNAME_ALL,
|
|
|
|
f.BIANMA,
|
|
|
|
f.PARENT_ID,
|
|
|
|
f.HEADMAN,
|
|
|
|
f.TEL,
|
|
|
|
f.FUNCTIONS,
|
|
|
|
f.ADDRESS,
|
|
|
|
f.BZ,
|
|
|
|
f.DEPARTMENT_ID,
|
|
|
|
f.CORPINFO_ID,
|
|
|
|
f.LEVEL,
|
|
|
|
f.ISSUPERVISE,
|
|
|
|
s.name as leName,
|
|
|
|
f.DEP_ORDER
|
|
|
|
from OA_DEPARTMENT f
|
|
|
|
LEFT JOIN SYS_DICTIONARIES s on s.BIANMA = f.LEVEL
|
|
|
|
where
|
|
|
|
f.ISDELETE = 0
|
|
|
|
<if test="pd.keywords != null and pd.keywords != ''"><!-- 关键词检索 -->
|
|
|
|
and
|
|
|
|
(
|
|
|
|
f.NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
or
|
|
|
|
f.NAME_EN LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
or
|
|
|
|
f.BIANMA LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
|
|
|
|
AND
|
|
|
|
f.CORPINFO_ID = #{pd.CORPINFO_ID}
|
|
|
|
</if>
|
|
|
|
<if test="pd.LEVEL != null and pd.LEVEL != ''"><!-- 关键词检索 -->
|
|
|
|
AND
|
|
|
|
f.LEVEL = #{pd.LEVEL}
|
|
|
|
</if>
|
|
|
|
<if test="pd.DEPARTMENT_ID!= null and pd.DEPARTMENT_ID != ''"><!-- 检索 -->
|
|
|
|
and f.PARENT_ID = #{pd.DEPARTMENT_ID}
|
|
|
|
</if>
|
|
|
|
<!-- <if test="pd.SELECT_DEPARTMENT_ID != null and pd.SELECT_DEPARTMENT_ID != ''"><!– 关键词检索 –>-->
|
|
|
|
<!-- AND-->
|
|
|
|
<!-- (f.PARENT_ID = #{pd.SELECT_DEPARTMENT_ID} or f.DEPARTMENT_ID = #{pd.SELECT_DEPARTMENT_ID})-->
|
|
|
|
<!-- </if>-->
|
|
|
|
|
|
|
|
<choose>
|
|
|
|
<when test='pd.ISMAIN != null and pd.ISMAIN != "" and pd.ISMAIN == "1"'>
|
|
|
|
<if test="pd.DEPT_IDS != null and pd.DEPT_IDS != ''">
|
|
|
|
and
|
|
|
|
f.DEPARTMENT_ID in
|
|
|
|
<foreach item="item" index="index"
|
|
|
|
collection="pd.DEPT_IDS" open="(" separator="," close=")">
|
|
|
|
'${item}'
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
</when>
|
|
|
|
<otherwise>
|
|
|
|
<choose>
|
|
|
|
<when test='pd.ISSUPERVISE != null and pd.ISSUPERVISE != "" and pd.ISSUPERVISE == "1"'>
|
|
|
|
<choose>
|
|
|
|
<when test="pd.DEPT_IDS != null and pd.DEPT_IDS != ''">
|
|
|
|
and
|
|
|
|
f.DEPARTMENT_ID in
|
|
|
|
<foreach item="item" index="index"
|
|
|
|
collection="pd.DEPT_IDS" open="(" separator="," close=")">
|
|
|
|
'${item}'
|
|
|
|
</foreach>
|
|
|
|
</when>
|
|
|
|
<otherwise>
|
|
|
|
and
|
|
|
|
f.DEPARTMENT_ID in (
|
|
|
|
select
|
|
|
|
SUB_DEPARTMENT_ID
|
|
|
|
from
|
|
|
|
oa_supervision_department osd
|
|
|
|
where
|
|
|
|
osd.SUP_DEPARTMENT_ID = #{pd.DEPARTMENT_ID}
|
|
|
|
and osd.ISDELETE = '0'
|
|
|
|
and osd.CORPINFO_ID = #{pd.CORPINFO_ID}
|
|
|
|
)
|
|
|
|
</otherwise>
|
|
|
|
</choose>
|
|
|
|
</when>
|
|
|
|
<when test="pd.DEPARTMENT_ID == '' and pd.SELECT_DEPARTMENT_ID != null and pd.SELECT_DEPARTMENT_ID != ''">
|
|
|
|
and (f.PARENT_ID = #{pd.SELECT_DEPARTMENT_ID} or f.DEPARTMENT_ID = #{pd.SELECT_DEPARTMENT_ID})
|
|
|
|
</when>
|
|
|
|
<otherwise>
|
|
|
|
</otherwise>
|
|
|
|
</choose>
|
|
|
|
</otherwise>
|
|
|
|
</choose>
|
|
|
|
order by DEP_ORDER asc ,NAME
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询公司部门总数 -->
|
|
|
|
<select id="getDepCount" parameterType="pd" resultType="int" >
|
|
|
|
SELECT
|
|
|
|
COUNT( 1 )
|
|
|
|
FROM
|
|
|
|
oa_department
|
|
|
|
WHERE ISDELETE = 0 and
|
|
|
|
CORPINFO_ID = #{CORPINFO_ID}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询公司检查过清单的部门总数 -->
|
|
|
|
<select id="getWorkedDepCount" parameterType="pd" resultType="int" >
|
|
|
|
SELECT
|
|
|
|
count( 1 )
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
count( s.DEPARTMENT_ID )
|
|
|
|
FROM
|
|
|
|
oa_department s
|
|
|
|
LEFT JOIN bus_checkuser cu ON s.DEPARTMENT_ID = cu.DEPARTMENT_ID
|
|
|
|
LEFT JOIN bus_checkrecord f ON f.CHECKRECORD_ID = cu.CHECKRECORD_ID
|
|
|
|
WHERE
|
|
|
|
s.CORPINFO_ID = #{CORPINFO_ID}
|
|
|
|
AND s.ISDELETE = 0
|
|
|
|
AND f.FINISHED = '1'
|
|
|
|
AND f.isdelete = '0'
|
|
|
|
AND f.CHECKRECORD_ID IS NOT NULL
|
|
|
|
AND DATE_FORMAT(f.CHECK_TIME, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
|
|
|
|
GROUP BY
|
|
|
|
s.DEPARTMENT_ID
|
|
|
|
) q
|
|
|
|
</select>
|
2024-01-04 09:07:20 +08:00
|
|
|
|
|
|
|
<select id="findBySubId" parameterType="pd" resultType="pd">
|
|
|
|
select
|
|
|
|
f.*
|
|
|
|
from
|
|
|
|
oa_supervision_department f
|
|
|
|
where f.ISDELETE = 0
|
|
|
|
<if test="SUP_DEPARTMENT_ID != null and SUP_DEPARTMENT_ID != ''"><!-- 关键词检索 -->
|
|
|
|
and f.SUP_DEPARTMENT_ID = #{SUP_DEPARTMENT_ID}
|
|
|
|
</if>
|
|
|
|
</select>
|
2024-01-03 11:04:18 +08:00
|
|
|
</mapper>
|