You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/src/com/engine/organization/mapper/job/JobMapper.xml

679 lines
22 KiB
XML

<?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.engine.organization.mapper.job.JobMapper">
<resultMap id="BaseResultMap" type="com.engine.organization.entity.job.po.JobPO">
<result column="id" property="id"/>
<result column="job_no" property="jobNo"/>
<result column="job_name" property="jobName"/>
<result column="parent_comp" property="parentComp"/>
<result column="parent_dept" property="parentDept"/>
<result column="ec_company" property="ecCompany"/>
<result column="ec_department" property="ecDepartment"/>
<result column="sequence_id" property="sequenceId"/>
<result column="scheme_id" property="schemeId"/>
<result column="parent_job" property="parentJob"/>
<result column="is_key" property="isKey"/>
<result column="workplace" property="workplace"/>
<result column="work_duty" property="workDuty"/>
<result column="work_authority" property="workAuthority"/>
<result column="description" property="description"/>
<result column="show_order" property="showOrder"/>
<result column="forbidden_tag" property="forbiddenTag"/>
<result column="grade_id" property="gradeId"/>
<result column="level_id" property="levelId"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
,
t.job_no,
t.job_name,
t.parent_comp,
t.parent_dept,
t.ec_company,
t.ec_department,
t.sequence_id,
t.scheme_id,
t.parent_job,
t.is_key,
t.workplace,
t.description,
t.work_duty,
t.work_authority,
t.show_order,
t.forbidden_tag,
t.grade_id,
t.level_id
</sql>
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.job.po.JobPO"
keyProperty="id"
keyColumn="id" useGeneratedKeys="true">
INSERT INTO jcl_org_job
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="jobNo != null ">
job_no,
</if>
<if test="jobName != null ">
job_name,
</if>
<if test="parentComp != null ">
parent_comp,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="sequenceId != null ">
sequence_id,
</if>
<if test="schemeId != null ">
scheme_id,
</if>
<if test="parentJob != null ">
parent_job,
</if>
<if test="isKey != null ">
is_key,
</if>
<if test="workplace != null ">
workplace,
</if>
<if test="description != null ">
description,
</if>
<if test="workDuty != null ">
work_duty,
</if>
<if test="workAuthority != null ">
work_authority,
</if>
<if test="showOrder != null ">
show_order,
</if>
3 years ago
<if test="ecCompany != null ">
ec_company,
</if>
<if test="ecDepartment != null ">
ec_department,
</if>
forbidden_tag,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="jobNo != null ">
#{jobNo},
</if>
<if test="jobName != null ">
#{jobName},
</if>
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="sequenceId != null ">
#{sequenceId},
</if>
<if test="schemeId != null ">
#{schemeId},
</if>
<if test="parentJob != null ">
#{parentJob},
</if>
<if test="isKey != null ">
#{isKey},
</if>
<if test="workplace != null ">
#{workplace},
</if>
<if test="description != null ">
#{description},
</if>
<if test="workDuty != null ">
#{workDuty},
</if>
<if test="workAuthority != null ">
#{workAuthority},
</if>
<if test="showOrder != null ">
#{showOrder},
</if>
3 years ago
<if test="ecCompany != null ">
#{ecCompany},
</if>
<if test="ecDepartment != null ">
#{ecDepartment},
</if>
0,
</trim>
</insert>
3 years ago
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.job.po.JobPO" databaseId="oracle">
<selectKey keyProperty="id" resultType="long" order="AFTER">
3 years ago
select JCL_ORG_JOB_ID.currval from dual
</selectKey>
INSERT INTO jcl_org_job
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="jobNo != null ">
job_no,
</if>
<if test="jobName != null ">
job_name,
</if>
<if test="parentComp != null ">
parent_comp,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="sequenceId != null ">
sequence_id,
</if>
<if test="schemeId != null ">
scheme_id,
</if>
<if test="parentJob != null ">
parent_job,
</if>
<if test="isKey != null ">
is_key,
</if>
<if test="workplace != null ">
workplace,
</if>
<if test="description != null ">
description,
</if>
<if test="workDuty != null ">
work_duty,
</if>
<if test="workAuthority != null ">
work_authority,
</if>
<if test="showOrder != null ">
show_order,
</if>
3 years ago
<if test="ecCompany != null ">
ec_company,
</if>
<if test="ecDepartment != null ">
ec_department,
</if>
3 years ago
forbidden_tag,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="jobNo != null ">
#{jobNo},
</if>
<if test="jobName != null ">
#{jobName},
</if>
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="sequenceId != null ">
#{sequenceId},
</if>
<if test="schemeId != null ">
#{schemeId},
</if>
<if test="parentJob != null ">
#{parentJob},
</if>
<if test="isKey != null ">
#{isKey},
</if>
<if test="workplace != null ">
#{workplace},
</if>
<if test="description != null ">
#{description},
</if>
<if test="workDuty != null ">
#{workDuty},
</if>
<if test="workAuthority != null ">
#{workAuthority},
</if>
<if test="showOrder != null ">
#{showOrder},
</if>
3 years ago
<if test="ecCompany != null ">
#{ecCompany},
</if>
<if test="ecDepartment != null ">
#{ecDepartment},
</if>
3 years ago
0,
</trim>
</insert>
<update id="updateBaseJob" parameterType="com.engine.organization.entity.job.po.JobPO">
update jcl_org_job
<set>
creator=#{creator},
update_time=#{updateTime},
job_name=#{jobName},
parent_comp=#{parentComp},
parent_dept=#{parentDept},
3 years ago
ec_company=#{ecCompany},
ec_department=#{ecDepartment},
sequence_id=#{sequenceId},
scheme_id=#{schemeId},
parent_job=#{parentJob},
is_key=#{isKey},
workplace=#{workplace},
description=#{description},
work_duty=#{workDuty},
work_authority=#{workAuthority},
show_order=#{showOrder},
<if test="forbiddenTag != null">
forbidden_tag=#{forbiddenTag},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="updateForbiddenTagById">
update jcl_org_job
<set>
forbidden_tag=#{forbiddenTag},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="deleteByIds">
UPDATE jcl_org_job
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
3 years ago
<update id="updateJobCompany">
update jcl_org_job
<set>
parent_comp = #{parentCompany},
ec_company =#{ecCompany},
</set>
where delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<select id="listByFilter" resultType="com.engine.organization.entity.job.dto.JobListDTO"
parameterType="com.engine.organization.entity.job.po.JobPO">
SELECT
a.comp_name ,
b.dept_name ,
c.sequence_name,
d.scheme_name,
<include refid="baseColumns"/>
FROM jcl_org_job t
left join jcl_org_comp a on
t.parent_comp = a.id
left join jcl_org_dept b on
t.parent_dept = b.id
left join jcl_org_sequence c on
t.sequence_id = c.id
left join jcl_org_scheme d on
t.scheme_id = d.id
WHERE t.delete_type = 0
<include refid="likeSQL"/>
<if test=" jobPO.parentComp != null ">
and t.parent_comp = #{jobPO.parentComp}
</if>
<if test=" jobPO.parentDept != null ">
and t.parent_dept = #{jobPO.parentDept}
</if>
3 years ago
<if test=" jobPO.parentJob != null ">
and t.parent_job = #{jobPO.parentJob}
</if>
3 years ago
<if test=" jobPO.ecCompany != null ">
and t.ec_company = #{jobPO.ecCompany}
</if>
<if test=" jobPO.ecDepartment != null ">
and t.ec_department = #{jobPO.ecDepartment}
</if>
<if test=" jobPO.sequenceId != null ">
and t.sequence_id = #{jobPO.sequenceId}
</if>
<if test=" jobPO.schemeId != null ">
and t.scheme_id = #{jobPO.schemeId}
</if>
<if test=" jobPO.isKey != null ">
and t.is_key = #{jobPO.isKey}
</if>
<if test=" jobPO.forbiddenTag != null ">
and t.forbidden_tag = #{jobPO.forbiddenTag}
</if>
order by ${orderSql}
</select>
<select id="listNoFilter" resultType="com.engine.organization.entity.job.dto.JobListDTO">
SELECT
a.comp_name ,
b.dept_name ,
c.sequence_name,
d.scheme_name,
<include refid="baseColumns"/>
FROM jcl_org_job t
left join jcl_org_comp a on
t.parent_comp = a.id
left join jcl_org_dept b on
t.parent_dept = b.id
left join jcl_org_sequence c on
t.sequence_id = c.id
left join jcl_org_scheme d on
t.scheme_id = d.id
WHERE t.delete_type = 0 order by ${orderSql}
</select>
<select id="getJobById" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
and id = #{id}
</select>
<select id="listJobsByIds" resultType="java.util.Map">
select
3 years ago
id as "id",
job_name as "name"
from jcl_org_job t
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listByNo" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t where job_no = #{jobNo} AND delete_type = 0
</select>
<select id="getJobsByPid" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
and parent_job = #{pid}
</select>
3 years ago
<select id="listUsedId" resultType="java.lang.String">
select job_id
from JCL_ORG_STAFF
where delete_type = 0
union
select field100002
from cus_fielddata
inner join
hrmresource on STATUS &lt; 4
</select>
3 years ago
<select id="listJobsByDepartmentId" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
and parent_dept = #{departmentId}
</select>
<select id="listAll" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
</select>
3 years ago
<select id="listPOsByFilter" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
FROM jcl_org_job t
WHERE t.delete_type = 0
<include refid="likeSQL"/>
<if test=" jobPO.parentComp != null ">
and t.parent_comp = #{jobPO.parentComp}
3 years ago
</if>
<if test=" jobPO.parentDept != null ">
and t.parent_dept = #{jobPO.parentDept}
3 years ago
</if>
<if test=" jobPO.sequenceId != null ">
and t.sequence_id = #{jobPO.sequenceId}
3 years ago
</if>
<if test=" jobPO.schemeId != null ">
and t.scheme_id = #{jobPO.schemeId}
3 years ago
</if>
<if test=" jobPO.isKey != null ">
and t.is_key = #{jobPO.isKey}
3 years ago
</if>
<if test=" jobPO.forbiddenTag != null ">
and t.forbidden_tag = #{jobPO.forbiddenTag}
3 years ago
</if>
</select>
<select id="getMaxShowOrder" resultType="java.lang.Integer">
select max(show_order)
from jcl_org_job
</select>
3 years ago
<select id="getIdByNameAndPid" resultType="java.lang.Long">
select id
from jcl_org_job
where delete_type = 0 and job_name = #{jobName}
and parent_comp = #{parentCompany}
3 years ago
<include refid="nullparentDept"/>
3 years ago
<include refid="nullparentJob"/>
</select>
<select id="getJobsByIds" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listByNameExceptId" resultType="com.engine.organization.entity.job.po.JobPO">
select
<include refid="baseColumns"/>
from jcl_org_job t
where delete_type = 0
AND job_name = #{jobName}
AND id != #{id}
</select>
3 years ago
<select id="checkRepeatNo" resultType="java.lang.Integer">
select count(1)
from jcl_org_job t
where t.delete_type = 0
AND job_no = #{jobNo}
<if test=" id != null ">
and t.id != #{id}
</if>
</select>
3 years ago
<select id="getCusJobIds" resultType="java.lang.String">
SELECT FIELD100002
FROM CUS_FIELDDATA
WHERE SCOPE = 'HrmCustomFieldByInfoType'
AND SCOPEID = -1
</select>
3 years ago
<select id="getIdByNameAndEcId" resultType="java.lang.Long">
select id
from jcl_org_job
where delete_type = 0
and job_name = #{jobName}
and ec_company = #{ecCompany}
and ec_department = #{ecDepartment}
</select>
<select id="countRepeatNameByPid" resultType="java.lang.Integer">
select count(1) from jcl_org_job
where delete_type = 0
AND job_name = #{jobName}
<if test="id != null">
AND id != #{id}
</if>
AND ec_department =#{ecDepartment}
<if test="parentJob != null">
AND parent_job = #{parentJob}
</if>
</select>
<select id="isHasResource" resultType="java.lang.Integer">
select count(a.id)
from jcl_org_hrmresource a
inner join jcl_org_job b on a.job_title = b.id
where a.status &lt; 4
and b.id = #{jobId}
</select>
3 years ago
<sql id="nullparentJob">
and ifnull(parent_job,0) =
#{parentJob}
</sql>
<sql id="nullparentJob" databaseId="sqlserver">
and isnull(parent_job,0) =
#{parentJob}
</sql>
<sql id="nullparentJob" databaseId="oracle">
and NVL(parent_job,0) =
#{parentJob}
</sql>
3 years ago
<sql id="nullparentDept">
and ifnull(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="nullparentDept" databaseId="sqlserver">
and isnull(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="nullparentDept" databaseId="oracle">
and NVL(parent_dept,0) =
#{parentDepartment}
</sql>
<sql id="likeSQL">
<if test=" jobPO.jobNo != null and jobPO.jobNo != '' ">
and t.job_no like CONCAT('%',#{jobPO.jobNo},'%')
</if>
<if test=" jobPO.jobName != null and jobPO.jobName != '' ">
and t.job_name like CONCAT('%',#{jobPO.jobName},'%')
</if>
<if test=" jobPO.workplace != null and jobPO.workplace != '' ">
and t.workplace like CONCAT('%',#{jobPO.workplace},'%')
</if>
<if test=" jobPO.description != null and jobPO.description != '' ">
and t.description like CONCAT('%',#{jobPO.description},'%')
</if>
<if test=" jobPO.workDuty != null and jobPO.workDuty != '' ">
and t.work_duty like CONCAT('%',#{jobPO.workDuty},'%')
</if>
<if test=" jobPO.workAuthority != null and jobPO.workAuthority != '' ">
and t.work_authority like CONCAT('%',#{jobPO.workAuthority},'%')
</if>
</sql>
<sql id="likeSQL" databaseId="oracle">
<if test=" jobPO.jobNo != null and jobPO.jobNo != '' ">
and t.job_no like '%'||#{jobPO.jobNo}||'%'
</if>
<if test=" jobPO.jobName != null and jobPO.jobName != '' ">
and t.job_name like '%'||#{jobPO.jobName}||'%'
</if>
<if test=" jobPO.workplace != null and jobPO.workplace != '' ">
and t.workplace like '%'||#{jobPO.workplace}||'%'
</if>
<if test=" jobPO.description != null and jobPO.description != '' ">
and t.description like '%'||#{jobPO.description}||'%'
</if>
<if test=" jobPO.workDuty != null and jobPO.workDuty != '' ">
and t.work_duty like '%'||#{jobPO.workDuty}||'%'
</if>
<if test=" jobPO.workAuthority != null and jobPO.workAuthority != '' ">
and t.work_authority like '%'||#{jobPO.workAuthority}||'%'
</if>
</sql>
<sql id="likeSQL" databaseId="sqlserver">
<if test=" jobPO.jobNo != null and jobPO.jobNo != '' ">
and t.job_no like '%'+#{jobPO.jobNo}+'%'
</if>
<if test=" jobPO.jobName != null and jobPO.jobName != '' ">
and t.job_name like '%'+#{jobPO.jobName}+'%'
</if>
<if test=" jobPO.workplace != null and jobPO.workplace != '' ">
and t.workplace like '%'+#{jobPO.workplace}+'%'
</if>
<if test=" jobPO.description != null and jobPO.description != '' ">
and t.description like '%'+#{jobPO.description}+'%'
</if>
<if test=" jobPO.workDuty != null and jobPO.workDuty != '' ">
and t.work_duty like '%'+#{jobPO.workDuty}+'%'
</if>
<if test=" jobPO.workAuthority != null and jobPO.workAuthority != '' ">
and t.work_authority like '%'+#{jobPO.workAuthority}+'%'
</if>
</sql>
</mapper>