weaver-hrm-salary/src/com/engine/salary/mapper/datacollection/OtherDeductionMapper.xml

445 lines
16 KiB
XML
Raw Normal View History

2022-03-10 17:57:46 +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.datacollection.OtherDeductionMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.datacollection.po.OtherDeductionPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="declare_month" property="declareMonth"/>
<result column="business_healthy_insurance" property="businessHealthyInsurance"/>
<result column="tax_delay_endowment_insurance" property="taxDelayEndowmentInsurance"/>
<result column="other_deduction" property="otherDeduction"/>
<result column="deduction_allowed_donation" property="deductionAllowedDonation"/>
<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.tax_agent_id
, t.declare_month
, t.business_healthy_insurance
, t.tax_delay_endowment_insurance
, t.other_deduction
, t.deduction_allowed_donation
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
</sql>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_other_deduction t
WHERE id = #{id} AND delete_type = 0
</select>
<sql id="otherDeductionColumn">
t1
.
id
,
t1.declare_month,
t1.employee_id,
2022-06-22 10:58:18 +08:00
t2.id AS tax_agent_id,
2022-05-31 09:58:35 +08:00
t2.name AS tax_agent_name,
2022-03-10 17:57:46 +08:00
e.lastname as username,
2022-05-31 10:29:18 +08:00
e.certificatenum as idNo,
2022-03-10 17:57:46 +08:00
d.departmentname AS departmentName,
e.mobile,
e.workcode as job_num,
e.companystartdate as hiredate,
t1.business_healthy_insurance,
t1.tax_delay_endowment_insurance,
t1.other_deduction,
t1.deduction_allowed_donation
</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.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<!-- 关键字(姓名、部门、工号 -->
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like CONCAT('%',#{param.keyword},'%')
OR d.departmentname like CONCAT('%',#{param.keyword},'%')
OR e.workcode like CONCAT('%',#{param.keyword},'%')
)
</if>
<!-- 申报月份 -->
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate != null">
<if test="param.declareMonthDate.size() == 1">
AND t1.declare_month = #{param.declareMonthDate[0]}
2022-03-10 17:57:46 +08:00
</if>
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate.size() == 2">
AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]})
2022-03-10 17:57:46 +08:00
</if>
</if>
<!-- 姓名 -->
<if test="param.username != null and param.username != ''">
AND e.lastname like CONCAT('%',#{param.username},'%')
</if>
<!-- 个税扣缴义务人 -->
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
</if>
2022-06-09 17:45:28 +08:00
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND t1.tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
2022-03-10 17:57:46 +08:00
<!-- 部门 -->
<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.jobNum != null and param.jobNum != ''">
AND e.workcode like CONCAT('%',#{param.jobNum},'%')
</if>
<!-- 入职日期 -->
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
</if>
<!-- 手机号 -->
<if test="param.mobile != null and param.mobile != ''">
AND e.mobile like CONCAT('%',#{param.mobile},'%')
</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.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'||#{param.keyword}||'%'
OR d.departmentname like '%'||#{param.keyword}||'%'
OR e.workcode like '%'||#{param.keyword}||'%'
)
</if>
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate != null">
<if test="param.declareMonthDate.size() == 1">
AND t1.declare_month = #{param.declareMonthDate[0]}
2022-03-10 17:57:46 +08:00
</if>
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate.size() == 2">
AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]})
2022-03-10 17:57:46 +08:00
</if>
</if>
<if test="param.username != null and param.username != ''">
AND e.lastname like '%'||#{param.username}||'%'
</if>
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
</if>
2022-06-09 17:45:28 +08:00
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND t1.tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
2022-03-10 17:57:46 +08:00
<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.jobNum != null and param.jobNum != ''">
AND e.workcode like '%'||#{param.jobNum}||'%'
</if>
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
</if>
<if test="param.mobile != null and param.mobile != ''">
AND e.mobile like '%'||#{param.mobile}||'%'
</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.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'+#{param.keyword}+'%'
OR d.departmentname like '%'+#{param.keyword}+'%'
OR e.workcode like '%'+#{param.keyword}+'%'
)
</if>
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate != null">
<if test="param.declareMonthDate.size() == 1">
AND t1.declare_month = #{param.declareMonthDate[0]}
2022-03-10 17:57:46 +08:00
</if>
2022-06-24 18:05:08 +08:00
<if test="param.declareMonthDate.size() == 2">
AND (t1.declare_month BETWEEN #{param.declareMonthDate[0]} AND #{param.declareMonthDate[1]})
2022-03-10 17:57:46 +08:00
</if>
</if>
<if test="param.username != null and param.username != ''">
AND e.lastname like '%'+#{param.username}+'%'
</if>
<if test="param.taxAgentId != null">
AND t1.tax_agent_id = #{param.taxAgentId}
</if>
2022-06-09 17:45:28 +08:00
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND t1.tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
2022-03-10 17:57:46 +08:00
<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.jobNum != null and param.jobNum != ''">
AND e.workcode like '%'+#{param.jobNum}+'%'
</if>
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
</if>
<if test="param.mobile != null and param.mobile != ''">
AND e.mobile like '%'+#{param.mobile}+'%'
</if>
</sql>
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO">
SELECT
<include refid="otherDeductionColumn"/>
FROM
hrsa_other_deduction t1
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
WHERE
t1.delete_type = 0 AND t2.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-10 17:57:46 +08:00
<include refid="paramSql"/>
ORDER BY t1.id DESC
</select>
<select id="recordList" resultType="com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO">
SELECT
<include refid="otherDeductionColumn"/>
FROM
hrsa_other_deduction t1
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
WHERE
t1.delete_type = 0 AND t2.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-10 17:57:46 +08:00
<include refid="paramSql"/>
ORDER BY t1.declare_month DESC
</select>
<select id="listSome" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_other_deduction t
WHERE delete_type = 0
<if test="param.declareMonth != null">
and declare_month = #{param.declareMonth}
</if>
<if test="param.employeeIds != null and param.employeeIds.size()>0">
2022-04-12 19:25:19 +08:00
AND t.employee_id IN
2022-03-10 17:57:46 +08:00
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
2022-04-21 14:15:56 +08:00
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND t.tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
2022-03-10 17:57:46 +08:00
</select>
<insert id="insertData">
INSERT INTO hrsa_other_deduction(
employee_id,
tax_agent_id,
declare_month,
business_healthy_insurance,
tax_delay_endowment_insurance,
other_deduction,
deduction_allowed_donation,
create_time,
update_time,
creator,
tenant_key
)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.employeeId},
#{item.taxAgentId},
#{item.declareMonth},
#{item.businessHealthyInsurance},
#{item.taxDelayEndowmentInsurance},
#{item.otherDeduction},
#{item.deductionAllowedDonation},
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="insertData" databaseId="oracle">
INSERT INTO hrsa_other_deduction(
employee_id,
tax_agent_id,
declare_month,
business_healthy_insurance,
tax_delay_endowment_insurance,
other_deduction,
deduction_allowed_donation,
create_time,
update_time,
creator,
tenant_key
)
<foreach collection="collection" item="item" separator="union all">
select
2022-08-17 13:28:33 +08:00
#{item.employeeId,jdbcType=DOUBLE},
#{item.taxAgentId,jdbcType=DOUBLE},
#{item.declareMonth,jdbcType=DATE},
#{item.businessHealthyInsurance,jdbcType=VARCHAR},
#{item.taxDelayEndowmentInsurance,jdbcType=VARCHAR},
#{item.otherDeduction,jdbcType=VARCHAR},
#{item.deductionAllowedDonation,jdbcType=VARCHAR},
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.tenantKey,jdbcType=VARCHAR}
2022-03-10 17:57:46 +08:00
from dual
</foreach>
</insert>
<insert id="insertData" databaseId="sqlserver">
2022-04-22 18:00:35 +08:00
<foreach collection="collection" item="item" separator=";">
2022-03-10 17:57:46 +08:00
INSERT INTO hrsa_other_deduction(
employee_id,
tax_agent_id,
declare_month,
business_healthy_insurance,
tax_delay_endowment_insurance,
other_deduction,
deduction_allowed_donation,
create_time,
update_time,
creator,
tenant_key
)
VALUES
(
#{item.employeeId},
#{item.taxAgentId},
#{item.declareMonth},
#{item.businessHealthyInsurance},
#{item.taxDelayEndowmentInsurance},
#{item.otherDeduction},
#{item.deductionAllowedDonation},
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.tenantKey}
)
</foreach>
</insert>
<update id="updateData" parameterType="java.util.List">
update hrsa_other_deduction
<trim prefix="set" suffixOverrides=",">
<trim prefix="business_healthy_insurance =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.businessHealthyInsurance!=null">
when id=#{item.id} then #{item.businessHealthyInsurance}
</if>
</foreach>
</trim>
<trim prefix="tax_delay_endowment_insurance =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.taxDelayEndowmentInsurance!=null">
when id=#{item.id} then #{item.taxDelayEndowmentInsurance}
</if>
</foreach>
</trim>
<trim prefix="other_deduction =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.otherDeduction!=null">
when id=#{item.id} then #{item.otherDeduction}
</if>
</foreach>
</trim>
<trim prefix="deduction_allowed_donation =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.deductionAllowedDonation!=null">
when id=#{item.id} then #{item.deductionAllowedDonation}
</if>
</foreach>
</trim>
</trim>
where
id in
<foreach collection="collection" item="item" index="index" separator="," open="(" close=")">
#{item.id}
</foreach>
</update>
</mapper>