486 lines
16 KiB
XML
486 lines
16 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.salary.mapper.archive.SalaryArchiveMapper">
|
|
<resultMap id="BaseResultMap" type="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
|
<result column="id" property="id"/>
|
|
<result column="employee_id" property="employeeId"/>
|
|
<result column="create_time" property="createTime"/>
|
|
<result column="update_time" property="updateTime"/>
|
|
<result column="creator" property="creator"/>
|
|
<result column="delete_type" property="deleteType"/>
|
|
<result column="tenant_key" property="tenantKey"/>
|
|
</resultMap>
|
|
|
|
<!-- 表字段 -->
|
|
<sql id="baseColumns">
|
|
t
|
|
.
|
|
id
|
|
, t.employee_id
|
|
, t.create_time
|
|
, t.update_time
|
|
, t.creator
|
|
, t.delete_type
|
|
, t.tenant_key
|
|
</sql>
|
|
|
|
<!-- 查询全部 -->
|
|
<select id="listAll" resultMap="BaseResultMap">
|
|
SELECT
|
|
<include refid="baseColumns"/>
|
|
FROM hrsa_salary_archive t
|
|
WHERE delete_type = 0
|
|
</select>
|
|
|
|
<!-- 根据主键获取单条记录 -->
|
|
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
|
SELECT
|
|
<include refid="baseColumns"/>
|
|
FROM hrsa_salary_archive t
|
|
WHERE id = #{id} AND delete_type = 0
|
|
</select>
|
|
|
|
<!-- 条件查询 -->
|
|
<select id="listSome" resultMap="BaseResultMap"
|
|
parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
|
SELECT
|
|
<include refid="baseColumns"/>
|
|
FROM hrsa_salary_archive t
|
|
WHERE delete_type = 0
|
|
<if test="id != null">
|
|
AND id = #{id}
|
|
</if>
|
|
<if test="employeeId != null">
|
|
AND employee_id = #{employeeId}
|
|
</if>
|
|
<if test="createTime != null">
|
|
AND create_time = #{createTime}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
AND update_time = #{updateTime}
|
|
</if>
|
|
<if test="creator != null">
|
|
AND creator = #{creator}
|
|
</if>
|
|
<if test="deleteType != null">
|
|
AND delete_type = #{deleteType}
|
|
</if>
|
|
<if test="tenantKey != null">
|
|
AND tenant_key = #{tenantKey}
|
|
</if>
|
|
<if test="ids != null and ids.size()>0">
|
|
AND id IN
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY id DESC
|
|
</select>
|
|
|
|
|
|
<!-- 插入不为NULL的字段 -->
|
|
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO"
|
|
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
|
|
>
|
|
INSERT INTO hrsa_salary_archive
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="id != null">
|
|
id,
|
|
</if>
|
|
<if test="employeeId != null">
|
|
employee_id,
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time,
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time,
|
|
</if>
|
|
<if test="creator != null">
|
|
creator,
|
|
</if>
|
|
<if test="deleteType != null">
|
|
delete_type,
|
|
</if>
|
|
<if test="tenantKey != null">
|
|
tenant_key,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">
|
|
#{id},
|
|
</if>
|
|
<if test="employeeId != null">
|
|
#{employeeId},
|
|
</if>
|
|
<if test="createTime != null">
|
|
#{createTime},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
#{updateTime},
|
|
</if>
|
|
<if test="creator != null">
|
|
#{creator},
|
|
</if>
|
|
<if test="deleteType != null">
|
|
#{deleteType},
|
|
</if>
|
|
<if test="tenantKey != null">
|
|
#{tenantKey},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<!-- 更新,更新全部字段 -->
|
|
<update id="update" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
|
UPDATE hrsa_salary_archive
|
|
<set>
|
|
employee_id=#{employeeId},
|
|
create_time=#{createTime},
|
|
update_time=#{updateTime},
|
|
creator=#{creator},
|
|
delete_type=#{deleteType},
|
|
tenant_key=#{tenantKey},
|
|
</set>
|
|
WHERE id = #{id} AND delete_type = 0
|
|
</update>
|
|
|
|
|
|
<!-- 更新不为NULL的字段 -->
|
|
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
|
UPDATE hrsa_salary_archive
|
|
<set>
|
|
<if test="employeeId != null">
|
|
employee_id=#{employeeId},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time=#{createTime},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time=#{updateTime},
|
|
</if>
|
|
<if test="creator != null">
|
|
creator=#{creator},
|
|
</if>
|
|
<if test="deleteType != null">
|
|
delete_type=#{deleteType},
|
|
</if>
|
|
<if test="tenantKey != null">
|
|
tenant_key=#{tenantKey},
|
|
</if>
|
|
</set>
|
|
WHERE id = #{id} AND delete_type = 0
|
|
</update>
|
|
|
|
|
|
<!-- 根据主键删除记录 -->
|
|
<delete id="delete" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
|
|
UPDATE hrsa_salary_archive
|
|
SET delete_type=1
|
|
WHERE id = #{id}
|
|
AND delete_type = 0
|
|
</delete>
|
|
|
|
|
|
<sql id="salaryArchiveColumn">
|
|
t1
|
|
.
|
|
id
|
|
,
|
|
t1.employee_id,
|
|
e.mobile,
|
|
e.lastname as username,
|
|
e.status AS employeeStatus,
|
|
d.departmentname AS departmentName
|
|
</sql>
|
|
|
|
|
|
<sql id="paramSql">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t1.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<!-- 姓名 -->
|
|
<if test="param.username != null and param.username != ''">
|
|
AND e.lastname like CONCAT('%',#{param.username},'%')
|
|
</if>
|
|
<!-- 个税扣缴义务人id todo 业务上处理 -->
|
|
<!-- <if test="param.taxAgentId != null">-->
|
|
<!-- AND t4.id = #{param.taxAgentId}-->
|
|
<!-- </if>-->
|
|
<!-- 部门 -->
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND d.id IN
|
|
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<!-- 岗位 -->
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND e.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<!-- 状态 -->
|
|
<if test="param.userstatus != null and param.userstatus != ''">
|
|
AND e.status = #{param.userstatus}
|
|
</if>
|
|
<!-- 入职日期 -->
|
|
<if test="param.hiredate != null and param.hiredate.size() == 2">
|
|
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
|
|
</if>
|
|
</sql>
|
|
<sql id="paramSql" databaseId="oracle">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t1.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.username != null and param.username != ''">
|
|
AND e.lastname like '%'||#{param.username}||'%'
|
|
</if>
|
|
|
|
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND d.id IN
|
|
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND e.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.userstatus != null and param.userstatus != ''">
|
|
AND e.status = #{param.userstatus}
|
|
</if>
|
|
|
|
<if test="param.hiredate != null and param.hiredate.size() == 2">
|
|
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
|
|
</if>
|
|
</sql>
|
|
<sql id="paramSql" databaseId="sqlserver">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t1.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.username != null and param.username != ''">
|
|
AND e.lastname like '%'+#{param.username}+'%'
|
|
</if>
|
|
|
|
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND d.id IN
|
|
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND e.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.userstatus != null and param.userstatus != ''">
|
|
AND e.status = #{param.userstatus}
|
|
</if>
|
|
|
|
<if test="param.hiredate != null and param.hiredate.size() == 2">
|
|
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
|
|
</if>
|
|
</sql>
|
|
|
|
<!-- 薪资档案列表 -->
|
|
<select id="list" resultType="com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO">
|
|
SELECT
|
|
<include refid="salaryArchiveColumn"/>
|
|
FROM
|
|
hrsa_salary_archive t1
|
|
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
WHERE t1.delete_type = 0
|
|
<include refid="paramSql"/>
|
|
ORDER BY t1.id DESC
|
|
</select>
|
|
<select id="list" resultType="com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO" databaseId="oracle">
|
|
SELECT
|
|
|
|
t1.id,
|
|
t1.employee_id,
|
|
e.mobile,
|
|
e.lastname as username,
|
|
e.status AS employeeStatus,
|
|
d.departmentname AS departmentName
|
|
|
|
FROM
|
|
hrsa_salary_archive t1
|
|
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
WHERE t1.delete_type = 0
|
|
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t1.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.username != null and param.username != ''">
|
|
AND e.lastname like '%'||#{param.username}||'%'
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND d.id IN
|
|
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND e.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.userstatus != null and param.userstatus != ''">
|
|
AND e.status = #{param.userstatus}
|
|
</if>
|
|
|
|
<if test="param.hiredate != null and param.hiredate.size() == 2">
|
|
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
|
|
</if>
|
|
|
|
ORDER BY t1.id DESC
|
|
</select>
|
|
<select id="list" resultType="com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO"
|
|
databaseId="sqlserver">
|
|
SELECT
|
|
|
|
t1.id,
|
|
t1.employee_id,
|
|
e.mobile,
|
|
e.lastname as username,
|
|
e.status AS employeeStatus,
|
|
d.departmentname AS departmentName
|
|
|
|
FROM
|
|
hrsa_salary_archive t1
|
|
LEFT JOIN hrmresource e ON e.id = t1.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
WHERE t1.delete_type = 0
|
|
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t1.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.username != null and param.username != ''">
|
|
AND e.lastname like '%'+#{param.username}+'%'
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND d.id IN
|
|
<foreach collection="param.departmentIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND e.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="param.userstatus != null and param.userstatus != ''">
|
|
AND e.status = #{param.userstatus}
|
|
</if>
|
|
|
|
<if test="param.hiredate != null and param.hiredate.size() == 2">
|
|
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
|
|
</if>
|
|
|
|
ORDER BY t1.id DESC
|
|
</select>
|
|
|
|
<insert id="batchInsert">
|
|
INSERT INTO hrsa_salary_archive (
|
|
id,
|
|
employee_id,
|
|
create_time,
|
|
update_time,
|
|
creator,
|
|
tenant_key
|
|
)
|
|
VALUES
|
|
<foreach collection="collection" item="item" separator=",">
|
|
(
|
|
#{item.id},
|
|
#{item.employeeId},
|
|
#{item.createTime},
|
|
#{item.updateTime},
|
|
#{item.creator},
|
|
#{item.tenantKey}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchInsert" databaseId="oracle">
|
|
INSERT INTO hrsa_salary_archive (
|
|
id,
|
|
employee_id,
|
|
create_time,
|
|
update_time,
|
|
creator,
|
|
tenant_key
|
|
)
|
|
|
|
<foreach collection="collection" item="item" separator="union all">
|
|
select
|
|
#{item.id},
|
|
#{item.employeeId},
|
|
#{item.createTime},
|
|
#{item.updateTime},
|
|
#{item.creator},
|
|
#{item.tenantKey}
|
|
from dual
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchInsert" databaseId="sqlserver">
|
|
INSERT INTO hrsa_salary_archive (
|
|
id,
|
|
employee_id,
|
|
create_time,
|
|
update_time,
|
|
creator,
|
|
tenant_key
|
|
)
|
|
VALUES
|
|
<foreach collection="collection" item="item" separator=",">
|
|
(
|
|
#{item.id},
|
|
#{item.employeeId},
|
|
#{item.createTime},
|
|
#{item.updateTime},
|
|
#{item.creator},
|
|
#{item.tenantKey}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
|
|
</mapper> |