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

573 lines
21 KiB
XML
Raw Normal View History

2022-03-03 13:50:03 +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.AddUpDeductionMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.datacollection.AddUpDeduction">
<result column="add_up_child_education" property="addUpChildEducation"/>
<result column="add_up_continuing_education" property="addUpContinuingEducation"/>
<result column="add_up_housing_loan_interest" property="addUpHousingLoanInterest"/>
<result column="add_up_housing_rent" property="addUpHousingRent"/>
<result column="add_up_support_elderly" property="addUpSupportElderly"/>
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="declare_month" property="declareMonth"/>
<result column="delete_type" property="deleteType"/>
<result column="employee_id" property="employeeId"/>
<result column="id" property="id"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
2022-05-20 14:41:42 +08:00
<result column="add_up_illness_medical" property="addUpIllnessMedical"/>
<result column="add_up_infant_care" property="addUpInfantCare"/>
2022-03-03 13:50:03 +08:00
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
add_up_child_education
, t.add_up_continuing_education
, t.add_up_housing_loan_interest
, t.add_up_housing_rent
, t.add_up_support_elderly
, t.create_time
, t.creator
, t.declare_month
, t.delete_type
, t.employee_id
, t.id
, t.tax_agent_id
, t.tenant_key
, t.update_time
2022-05-20 14:41:42 +08:00
, t.add_up_illness_medical
, t.add_up_infant_care
2022-03-03 13:50:03 +08:00
</sql>
<!-- 批量删除 -->
<update id="deleteData">
UPDATE hrsa_add_up_deduction t
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="collection" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
2022-03-03 13:50:03 +08:00
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_add_up_deduction t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_add_up_deduction t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 员工基本信息 -->
<select id="listEmployee" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
2022-03-07 15:08:56 +08:00
select e.ID as employeeId,
e.LASTNAME as username,
2022-05-19 14:50:01 +08:00
d.DEPARTMENTNAME as departmentName
2022-03-03 13:50:03 +08:00
from hrmresource e
2022-03-07 15:08:56 +08:00
left join hrmdepartment d on e.departmentid = d.id
2022-03-08 18:10:03 +08:00
where e.status not in (7)
2022-06-06 10:19:11 +08:00
and (e.accounttype is null or e.accounttype = 0)
2022-03-03 13:50:03 +08:00
</select>
2022-03-07 15:08:56 +08:00
<!-- E10 sql -->
2022-03-04 10:10:38 +08:00
<sql id="addUpDeductionColumn">
2022-03-07 15:08:56 +08:00
t1
.
id
,
2022-03-04 10:10:38 +08:00
t1.declare_month,
t1.employee_id,
2022-03-10 11:09:08 +08:00
e.lastname as username,
2022-05-25 16:51:43 +08:00
e.certificatenum as idNo,
2022-03-04 10:10:38 +08:00
d.departmentname AS departmentName,
e.mobile,
e.workcode as job_num,
2022-03-08 18:10:03 +08:00
e.companystartdate as hiredate,
2022-05-25 13:10:03 +08:00
t2.name AS taxAgentName,
t2.id AS taxAgentId,
2022-03-04 10:10:38 +08:00
t1.add_up_child_education,
t1.add_up_continuing_education,
t1.add_up_housing_loan_interest,
t1.add_up_housing_rent,
2022-05-20 14:41:42 +08:00
t1.add_up_support_elderly,
t1.add_up_illness_medical,
t1.add_up_infant_care
2022-03-04 10:10:38 +08:00
</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-04 10:10:38 +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-04 10:10:38 +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-04 10:10:38 +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">
2022-03-08 18:10:03 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-04 10:10:38 +08:00
</if>
<!-- 手机号 -->
<if test="param.mobile != null and param.mobile != ''">
AND e.mobile like CONCAT('%',#{param.mobile},'%')
</if>
2022-09-26 18:51:17 +08:00
2022-03-04 10:10:38 +08:00
</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-04 10:10:38 +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-04 10:10:38 +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-04 10:10:38 +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">
2022-03-08 18:10:03 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-04 10:10:38 +08:00
</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-04 10:10:38 +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-04 10:10:38 +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-04 10:10:38 +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">
2022-03-08 18:10:03 +08:00
AND (e.companystartdate BETWEEN #{param.hiredate[0]} AND #{param.hiredate[1]})
2022-03-04 10:10:38 +08:00
</if>
<if test="param.mobile != null and param.mobile != ''">
AND e.mobile like '%'+#{param.mobile}+'%'
</if>
</sql>
2022-06-10 16:43:38 +08:00
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO">
2022-03-04 10:10:38 +08:00
SELECT
<include refid="addUpDeductionColumn"/>
FROM
hrsa_add_up_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
2022-09-26 18:51:17 +08:00
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
2022-03-04 10:10:38 +08:00
WHERE
2022-03-07 15:08:56 +08:00
t1.delete_type = 0 AND t2.delete_type = 0
2022-03-08 18:10:03 +08:00
AND e.status not in (7)
2022-06-06 10:19:11 +08:00
and (e.accounttype is null or e.accounttype = 0)
2022-03-04 10:10:38 +08:00
<include refid="paramSql"/>
2022-09-26 18:51:17 +08:00
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
2022-03-04 10:10:38 +08:00
</select>
2022-06-10 16:43:38 +08:00
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO"
2022-03-07 15:08:56 +08:00
databaseId="oracle">
2022-03-04 10:10:38 +08:00
SELECT
<include refid="addUpDeductionColumn"/>
FROM
hrsa_add_up_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
2022-09-26 18:51:17 +08:00
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
2022-03-04 10:10:38 +08:00
WHERE
2022-03-07 15:08:56 +08:00
t1.delete_type = 0 AND t2.delete_type = 0
2022-03-08 18:10:03 +08:00
AND e.status not in (7)
2022-06-06 10:19:11 +08:00
and (e.accounttype is null or e.accounttype = 0)
2022-03-04 10:10:38 +08:00
<include refid="paramSql"/>
2022-09-26 18:51:17 +08:00
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
2022-03-04 10:10:38 +08:00
</select>
2022-06-10 16:43:38 +08:00
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO"
2022-03-07 15:08:56 +08:00
databaseId="sqlserver">
2022-03-04 10:10:38 +08:00
SELECT
<include refid="addUpDeductionColumn"/>
FROM
hrsa_add_up_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
2022-09-26 18:51:17 +08:00
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
2022-03-04 10:10:38 +08:00
WHERE
2022-03-07 15:08:56 +08:00
t1.delete_type = 0 AND t2.delete_type = 0
2022-03-08 18:10:03 +08:00
AND e.status not in (7)
2022-06-06 10:19:11 +08:00
and (e.accounttype is null or e.accounttype = 0)
2022-03-04 10:10:38 +08:00
<include refid="paramSql"/>
2022-09-26 18:51:17 +08:00
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
2022-03-04 10:10:38 +08:00
</select>
2022-03-07 15:08:56 +08:00
<select id="listSome" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_add_up_deduction t
WHERE delete_type = 0
<if test="param.declareMonth != null">
2022-04-11 20:17:47 +08:00
and declare_month = #{param.declareMonth}
</if>
<if test="param.employeeIds != null and param.employeeIds.size()>0">
AND employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
2022-03-07 15:08:56 +08:00
</if>
2022-04-21 14:15:56 +08:00
<if test="param.taxAgentIds != null and param.taxAgentIds.size()>0">
AND tax_agent_id IN
<foreach collection="param.taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
2022-03-07 15:08:56 +08:00
</select>
2022-03-04 10:10:38 +08:00
2022-03-07 15:08:56 +08:00
<insert id="insertData">
INSERT INTO hrsa_add_up_deduction(
employee_id,
tax_agent_id,
declare_month,
add_up_child_education,
add_up_continuing_education,
add_up_housing_loan_interest,
add_up_housing_rent,
add_up_support_elderly,
2022-05-20 14:41:42 +08:00
add_up_illness_medical,
add_up_infant_care,
2022-03-07 15:08:56 +08:00
create_time,
update_time,
creator,
tenant_key
)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.employeeId},
#{item.taxAgentId},
#{item.declareMonth},
#{item.addUpChildEducation},
#{item.addUpContinuingEducation},
#{item.addUpHousingLoanInterest},
#{item.addUpHousingRent},
#{item.addUpSupportElderly},
2022-05-20 14:41:42 +08:00
#{item.addUpIllnessMedical},
#{item.addUpInfantCare},
2022-03-07 15:08:56 +08:00
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="insertData" databaseId="oracle">
INSERT INTO hrsa_add_up_deduction(
employee_id,
tax_agent_id,
declare_month,
add_up_child_education,
add_up_continuing_education,
add_up_housing_loan_interest,
add_up_housing_rent,
add_up_support_elderly,
2022-05-20 14:41:42 +08:00
add_up_illness_medical,
add_up_infant_care,
2022-03-07 15:08:56 +08:00
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.addUpChildEducation,jdbcType=VARCHAR},
#{item.addUpContinuingEducation,jdbcType=VARCHAR},
#{item.addUpHousingLoanInterest,jdbcType=VARCHAR},
#{item.addUpHousingRent,jdbcType=VARCHAR},
#{item.addUpSupportElderly,jdbcType=VARCHAR},
#{item.addUpIllnessMedical,jdbcType=VARCHAR},
#{item.addUpInfantCare,jdbcType=VARCHAR},
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.tenantKey,jdbcType=VARCHAR}
2022-03-07 15:08:56 +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-05-20 14:41:42 +08:00
INSERT INTO hrsa_add_up_deduction(
employee_id,
tax_agent_id,
declare_month,
add_up_child_education,
add_up_continuing_education,
add_up_housing_loan_interest,
add_up_housing_rent,
add_up_support_elderly,
add_up_illness_medical,
add_up_infant_care,
create_time,
update_time,
creator,
tenant_key
)
VALUES
2022-03-07 15:08:56 +08:00
(
#{item.employeeId},
#{item.taxAgentId},
#{item.declareMonth},
#{item.addUpChildEducation},
#{item.addUpContinuingEducation},
#{item.addUpHousingLoanInterest},
#{item.addUpHousingRent},
#{item.addUpSupportElderly},
2022-05-20 14:41:42 +08:00
#{item.addUpIllnessMedical},
#{item.addUpInfantCare},
2022-03-07 15:08:56 +08:00
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.tenantKey}
)
</foreach>
</insert>
2022-03-04 10:10:38 +08:00
2022-03-07 15:08:56 +08:00
<update id="updateData" parameterType="java.util.List">
update hrsa_add_up_deduction
<trim prefix="set" suffixOverrides=",">
<trim prefix="add_up_child_education =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpChildEducation!=null">
when id=#{item.id} then #{item.addUpChildEducation}
</if>
</foreach>
</trim>
<trim prefix="add_up_continuing_education =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpContinuingEducation!=null">
when id=#{item.id} then #{item.addUpContinuingEducation}
</if>
</foreach>
</trim>
<trim prefix="add_up_housing_loan_interest =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpHousingLoanInterest!=null">
when id=#{item.id} then #{item.addUpHousingLoanInterest}
</if>
</foreach>
</trim>
<trim prefix="add_up_housing_rent =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpHousingRent!=null">
when id=#{item.id} then #{item.addUpHousingRent}
</if>
</foreach>
</trim>
<trim prefix="add_up_support_elderly =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpSupportElderly!=null">
when id=#{item.id} then #{item.addUpSupportElderly}
</if>
</foreach>
</trim>
2022-05-20 14:41:42 +08:00
<trim prefix="add_up_illness_medical =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpIllnessMedical!=null">
when id=#{item.id} then #{item.addUpIllnessMedical}
</if>
</foreach>
</trim>
<trim prefix="add_up_infant_care =case" suffix="end,">
<foreach collection="collection" item="item" index="index">
<if test="item.addUpInfantCare!=null">
when id=#{item.id} then #{item.addUpInfantCare}
</if>
</foreach>
</trim>
2022-03-07 15:08:56 +08:00
</trim>
where
id in
<foreach collection="collection" item="item" index="index" separator="," open="(" close=")">
#{item.id}
</foreach>
</update>
2022-03-04 10:10:38 +08:00
2022-06-10 16:43:38 +08:00
<select id="recordList" resultType="com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO">
2022-03-08 15:40:26 +08:00
SELECT
<include refid="addUpDeductionColumn"/>
FROM
hrsa_add_up_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-08 15:40:26 +08:00
<include refid="paramSql"/>
ORDER BY t1.declare_month DESC
</select>
2022-03-04 10:10:38 +08:00
2022-03-03 13:50:03 +08:00
</mapper>