weaver-hrm-salary/src/com/engine/salary/mapper/archive/SalaryArchiveMapper.xml

347 lines
11 KiB
XML
Raw Normal View History

2022-03-28 16:36:40 +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.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"/>
2022-07-14 10:36:51 +08:00
<result column="tax_agent_id" property="taxAgentId"/>
<result column="pay_start_date" property="payStartDate"/>
<result column="pay_end_date" property="payEndDate"/>
2022-03-28 16:36:40 +08:00
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.employee_id
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
2022-07-14 10:36:51 +08:00
, t.tax_agent_id
, t.pay_start_date
, t.pay_end_date
2022-03-28 16:36:40 +08:00
</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>
<!-- 根据主键删除记录 -->
<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">
2022-03-31 18:41:41 +08:00
t1
.
id
, t1.employee_id
, t1.create_time
, t1.update_time
, t1.creator
, t1.delete_type
, t1.tenant_key
, t1.tax_agent_id
, t1.pay_start_date
, t1.pay_end_date
, e.mobile
, e.lastname as username
, e.status AS employeeStatus
, d.departmentname AS departmentName
2022-03-28 16:36:40 +08:00
</sql>
2022-03-31 18:41:41 +08:00
2022-03-28 16:36:40 +08:00
2022-06-01 20:46:51 +08:00
<!-- 薪资档案列表 -->
<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
2022-06-06 16:55:02 +08:00
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
2022-03-28 16:36:40 +08:00
<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>
2022-07-14 14:32:59 +08:00
<!-- 个税扣缴义务人 -->
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
2022-07-14 14:32:59 +08:00
</if>
2022-03-28 16:36:40 +08:00
<!-- 姓名 -->
<if test="param.username != null and param.username != ''">
2022-03-29 17:10:59 +08:00
AND e.lastname like CONCAT('%',#{param.username},'%')
2022-03-28 16:36:40 +08:00
</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">
2022-03-29 17:10:59 +08:00
AND e.jobtitle IN
2022-03-28 16:36:40 +08:00
<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">
2022-03-31 18:41:41 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-28 16:36:40 +08:00
</if>
ORDER BY t1.id DESC
</select>
<select id="list" resultType="com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO" databaseId="oracle">
SELECT
2022-07-14 14:32:59 +08:00
<include refid="salaryArchiveColumn"/>
2022-03-28 16:36:40 +08:00
FROM
hrsa_salary_archive t1
2022-03-29 17:10:59 +08:00
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
2022-03-31 18:41:41 +08:00
WHERE t1.delete_type = 0
2022-06-06 10:19:11 +08:00
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
2022-03-28 16:36:40 +08:00
<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>
2022-07-14 14:32:59 +08:00
<!-- 个税扣缴义务人 -->
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
2022-07-14 14:32:59 +08:00
</if>
2022-03-28 16:36:40 +08:00
<if test="param.username != null and param.username != ''">
2022-03-29 17:10:59 +08:00
AND e.lastname like '%'||#{param.username}||'%'
2022-03-28 16:36:40 +08:00
</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">
2022-03-29 17:10:59 +08:00
AND e.jobtitle IN
2022-03-28 16:36:40 +08:00
<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">
2022-03-31 18:41:41 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-28 16:36:40 +08:00
</if>
ORDER BY t1.id DESC
</select>
2022-03-31 18:41:41 +08:00
<select id="list" resultType="com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO"
databaseId="sqlserver">
2022-03-28 16:36:40 +08:00
SELECT
2022-07-14 14:32:59 +08:00
<include refid="salaryArchiveColumn"/>
2022-03-28 16:36:40 +08:00
FROM
hrsa_salary_archive t1
2022-03-29 17:10:59 +08:00
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
2022-03-31 18:41:41 +08:00
WHERE t1.delete_type = 0
2022-06-06 10:19:11 +08:00
and e.status not in (7)
and (e.accounttype is null or e.accounttype = 0)
2022-03-28 16:36:40 +08:00
<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>
2022-07-14 14:32:59 +08:00
<!-- 个税扣缴义务人 -->
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
2022-07-14 14:32:59 +08:00
</if>
2022-03-28 16:36:40 +08:00
<if test="param.username != null and param.username != ''">
2022-03-29 17:10:59 +08:00
AND e.lastname like '%'+#{param.username}+'%'
2022-03-28 16:36:40 +08:00
</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">
2022-03-29 17:10:59 +08:00
AND e.jobtitle IN
2022-03-28 16:36:40 +08:00
<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">
2022-03-31 18:41:41 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-28 16:36:40 +08:00
</if>
ORDER BY t1.id DESC
</select>
<insert id="batchInsert">
INSERT INTO hrsa_salary_archive (
2022-04-20 11:17:25 +08:00
id,
2022-03-28 16:36:40 +08:00
employee_id,
create_time,
update_time,
creator,
2022-07-14 10:36:51 +08:00
tenant_key,
tax_agent_id,
pay_start_date,
pay_end_date
2022-03-28 16:36:40 +08:00
)
VALUES
<foreach collection="collection" item="item" separator=",">
(
2022-04-20 11:17:25 +08:00
#{item.id},
2022-03-28 16:36:40 +08:00
#{item.employeeId},
#{item.createTime},
#{item.updateTime},
#{item.creator},
2022-07-14 10:36:51 +08:00
#{item.tenantKey},
#{item.taxAgentId},
#{item.payStartDate},
#{item.payEndDate}
2022-03-28 16:36:40 +08:00
)
</foreach>
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_salary_archive (
2022-04-20 11:17:25 +08:00
id,
2022-03-28 16:36:40 +08:00
employee_id,
create_time,
update_time,
creator,
2022-07-14 10:36:51 +08:00
tenant_key,
tax_agent_id,
pay_start_date,
pay_end_date
2022-03-28 16:36:40 +08:00
)
<foreach collection="collection" item="item" separator="union all">
select
2022-04-20 11:17:25 +08:00
#{item.id},
2022-03-28 16:36:40 +08:00
#{item.employeeId},
#{item.createTime},
#{item.updateTime},
#{item.creator},
2022-07-14 10:36:51 +08:00
#{item.tenantKey},
#{item.taxAgentId},
#{item.payStartDate},
#{item.payEndDate}
2022-03-28 16:36:40 +08:00
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
2022-04-22 18:00:35 +08:00
<foreach collection="collection" item="item" separator=";">
2022-06-06 10:19:11 +08:00
INSERT INTO hrsa_salary_archive (
id,
employee_id,
create_time,
update_time,
creator,
2022-07-14 10:36:51 +08:00
tenant_key,
tax_agent_id,
pay_start_date,
pay_end_date
2022-06-06 10:19:11 +08:00
)
VALUES
2022-03-28 16:36:40 +08:00
(
2022-04-20 11:17:25 +08:00
#{item.id},
2022-03-28 16:36:40 +08:00
#{item.employeeId},
#{item.createTime},
#{item.updateTime},
#{item.creator},
2022-07-14 10:36:51 +08:00
#{item.tenantKey},
#{item.taxAgentId},
#{item.payStartDate},
#{item.payEndDate}
2022-03-28 16:36:40 +08:00
)
</foreach>
</insert>
2022-07-14 10:36:51 +08:00
<select id="getHistoryData" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_archive t
WHERE delete_type = 0 and tax_agent_id is null
</select>
<delete id="batchDeleteHistoryData" parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
UPDATE hrsa_salary_archive
SET delete_type=1
WHERE delete_type = 0
and tax_agent_id is null
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
2022-03-28 16:36:40 +08:00
<select id="listSome" resultType="com.engine.salary.entity.salaryarchive.po.SalaryArchivePO">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_salary_archive t
WHERE t.delete_type = 0
<if test="param.ids != null and param.ids.size()>0">
AND t.employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
<!-- 个税扣缴义务人 -->
<if test="param.taxAgentId != null">
AND t.tax_agent_id = #{param.taxAgentId}
</if>
ORDER BY t.id DESC
</select>
2022-03-28 16:36:40 +08:00
</mapper>