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

686 lines
25 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.AddUpSituationMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.datacollection.AddUpSituation">
<result column="add_up_accumulation_fund_total" property="addUpAccumulationFundTotal"/>
<result column="add_up_advance_tax" property="addUpAdvanceTax"/>
<result column="add_up_allowed_donation" property="addUpAllowedDonation"/>
<result column="add_up_child_education" property="addUpChildEducation"/>
<result column="add_up_continuing_education" property="addUpContinuingEducation"/>
<result column="add_up_enterprise_and_other" property="addUpEnterpriseAndOther"/>
<result column="add_up_housing_loan_interest" property="addUpHousingLoanInterest"/>
<result column="add_up_housing_rent" property="addUpHousingRent"/>
<result column="add_up_income" property="addUpIncome"/>
<result column="add_up_other_deduction" property="addUpOtherDeduction"/>
<result column="add_up_social_security_total" property="addUpSocialSecurityTotal"/>
<result column="add_up_subtraction" property="addUpSubtraction"/>
<result column="add_up_support_elderly" property="addUpSupportElderly"/>
<result column="add_up_tax_exempt_income" property="addUpTaxExemptIncome"/>
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<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="tax_year_month" property="taxYearMonth"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="year" property="year"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
add_up_accumulation_fund_total
, t.add_up_advance_tax
, t.add_up_allowed_donation
, t.add_up_child_education
, t.add_up_continuing_education
, t.add_up_enterprise_and_other
, t.add_up_housing_loan_interest
, t.add_up_housing_rent
, t.add_up_income
, t.add_up_other_deduction
, t.add_up_social_security_total
, t.add_up_subtraction
, t.add_up_support_elderly
, t.add_up_tax_exempt_income
, t.create_time
, t.creator
, t.delete_type
, t.employee_id
, t.id
, t.tax_agent_id
, t.tax_year_month
, t.tenant_key
, t.update_time
, t.year
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_add_up_situation t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_add_up_situation t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 插入全部字段 -->
<insert id="insert" parameterType="com.engine.salary.entity.datacollection.AddUpSituation"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_add_up_situation
<trim prefix="(" suffix=")" suffixOverrides=",">
add_up_accumulation_fund_total,
add_up_advance_tax,
add_up_allowed_donation,
add_up_child_education,
add_up_continuing_education,
add_up_enterprise_and_other,
add_up_housing_loan_interest,
add_up_housing_rent,
add_up_income,
add_up_other_deduction,
add_up_social_security_total,
add_up_subtraction,
add_up_support_elderly,
add_up_tax_exempt_income,
create_time,
creator,
delete_type,
employee_id,
id,
tax_agent_id,
tax_year_month,
tenant_key,
update_time,
year,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{addUpAccumulationFundTotal},
#{addUpAdvanceTax},
#{addUpAllowedDonation},
#{addUpChildEducation},
#{addUpContinuingEducation},
#{addUpEnterpriseAndOther},
#{addUpHousingLoanInterest},
#{addUpHousingRent},
#{addUpIncome},
#{addUpOtherDeduction},
#{addUpSocialSecurityTotal},
#{addUpSubtraction},
#{addUpSupportElderly},
#{addUpTaxExemptIncome},
#{createTime},
#{creator},
#{deleteType},
#{employeeId},
#{id},
#{taxAgentId},
#{taxYearMonth},
#{tenantKey},
#{updateTime},
#{year},
</trim>
</insert>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.datacollection.AddUpSituation"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_add_up_situation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="addUpAccumulationFundTotal != null">
add_up_accumulation_fund_total,
</if>
<if test="addUpAdvanceTax != null">
add_up_advance_tax,
</if>
<if test="addUpAllowedDonation != null">
add_up_allowed_donation,
</if>
<if test="addUpChildEducation != null">
add_up_child_education,
</if>
<if test="addUpContinuingEducation != null">
add_up_continuing_education,
</if>
<if test="addUpEnterpriseAndOther != null">
add_up_enterprise_and_other,
</if>
<if test="addUpHousingLoanInterest != null">
add_up_housing_loan_interest,
</if>
<if test="addUpHousingRent != null">
add_up_housing_rent,
</if>
<if test="addUpIncome != null">
add_up_income,
</if>
<if test="addUpOtherDeduction != null">
add_up_other_deduction,
</if>
<if test="addUpSocialSecurityTotal != null">
add_up_social_security_total,
</if>
<if test="addUpSubtraction != null">
add_up_subtraction,
</if>
<if test="addUpSupportElderly != null">
add_up_support_elderly,
</if>
<if test="addUpTaxExemptIncome != null">
add_up_tax_exempt_income,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="id != null">
id,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="taxYearMonth != null">
tax_year_month,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="year != null">
year,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="addUpAccumulationFundTotal != null">
#{addUpAccumulationFundTotal},
</if>
<if test="addUpAdvanceTax != null">
#{addUpAdvanceTax},
</if>
<if test="addUpAllowedDonation != null">
#{addUpAllowedDonation},
</if>
<if test="addUpChildEducation != null">
#{addUpChildEducation},
</if>
<if test="addUpContinuingEducation != null">
#{addUpContinuingEducation},
</if>
<if test="addUpEnterpriseAndOther != null">
#{addUpEnterpriseAndOther},
</if>
<if test="addUpHousingLoanInterest != null">
#{addUpHousingLoanInterest},
</if>
<if test="addUpHousingRent != null">
#{addUpHousingRent},
</if>
<if test="addUpIncome != null">
#{addUpIncome},
</if>
<if test="addUpOtherDeduction != null">
#{addUpOtherDeduction},
</if>
<if test="addUpSocialSecurityTotal != null">
#{addUpSocialSecurityTotal},
</if>
<if test="addUpSubtraction != null">
#{addUpSubtraction},
</if>
<if test="addUpSupportElderly != null">
#{addUpSupportElderly},
</if>
<if test="addUpTaxExemptIncome != null">
#{addUpTaxExemptIncome},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="id != null">
#{id},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="taxYearMonth != null">
#{taxYearMonth},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="year != null">
#{year},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.datacollection.AddUpSituation">
UPDATE hrsa_add_up_situation
<set>
add_up_accumulation_fund_total=#{addUpAccumulationFundTotal},
add_up_advance_tax=#{addUpAdvanceTax},
add_up_allowed_donation=#{addUpAllowedDonation},
add_up_child_education=#{addUpChildEducation},
add_up_continuing_education=#{addUpContinuingEducation},
add_up_enterprise_and_other=#{addUpEnterpriseAndOther},
add_up_housing_loan_interest=#{addUpHousingLoanInterest},
add_up_housing_rent=#{addUpHousingRent},
add_up_income=#{addUpIncome},
add_up_other_deduction=#{addUpOtherDeduction},
add_up_social_security_total=#{addUpSocialSecurityTotal},
add_up_subtraction=#{addUpSubtraction},
add_up_support_elderly=#{addUpSupportElderly},
add_up_tax_exempt_income=#{addUpTaxExemptIncome},
create_time=#{createTime},
creator=#{creator},
delete_type=#{deleteType},
employee_id=#{employeeId},
tax_agent_id=#{taxAgentId},
tax_year_month=#{taxYearMonth},
tenant_key=#{tenantKey},
update_time=#{updateTime},
year=#{year},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.datacollection.AddUpSituation">
UPDATE hrsa_add_up_situation
<set>
<if test="addUpAccumulationFundTotal != null">
add_up_accumulation_fund_total=#{addUpAccumulationFundTotal},
</if>
<if test="addUpAdvanceTax != null">
add_up_advance_tax=#{addUpAdvanceTax},
</if>
<if test="addUpAllowedDonation != null">
add_up_allowed_donation=#{addUpAllowedDonation},
</if>
<if test="addUpChildEducation != null">
add_up_child_education=#{addUpChildEducation},
</if>
<if test="addUpContinuingEducation != null">
add_up_continuing_education=#{addUpContinuingEducation},
</if>
<if test="addUpEnterpriseAndOther != null">
add_up_enterprise_and_other=#{addUpEnterpriseAndOther},
</if>
<if test="addUpHousingLoanInterest != null">
add_up_housing_loan_interest=#{addUpHousingLoanInterest},
</if>
<if test="addUpHousingRent != null">
add_up_housing_rent=#{addUpHousingRent},
</if>
<if test="addUpIncome != null">
add_up_income=#{addUpIncome},
</if>
<if test="addUpOtherDeduction != null">
add_up_other_deduction=#{addUpOtherDeduction},
</if>
<if test="addUpSocialSecurityTotal != null">
add_up_social_security_total=#{addUpSocialSecurityTotal},
</if>
<if test="addUpSubtraction != null">
add_up_subtraction=#{addUpSubtraction},
</if>
<if test="addUpSupportElderly != null">
add_up_support_elderly=#{addUpSupportElderly},
</if>
<if test="addUpTaxExemptIncome != null">
add_up_tax_exempt_income=#{addUpTaxExemptIncome},
</if>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="taxAgentId != null">
tax_agent_id=#{taxAgentId},
</if>
<if test="taxYearMonth != null">
tax_year_month=#{taxYearMonth},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="year != null">
year=#{year},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.datacollection.AddUpSituation">
UPDATE hrsa_add_up_situation
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
2022-03-08 18:10:03 +08:00
<sql id="addUpSituationColumn">
t1.id,
t1.tax_year_month,
t1.employee_id,
e.lastname as username,
d.departmentName AS departmentName,
e.mobile,
e.workcode as job_num,
e.companystartdate as hiredate,
t2.name AS tax_agent_name,
t1.add_up_income,
t1.add_up_subtraction,
t1.add_up_social_security_total,
t1.add_up_accumulation_fund_total,
t1.add_up_child_education,
t1.add_up_continuing_education,
t1.add_up_housing_loan_interest,
t1.add_up_housing_rent,
t1.add_up_support_elderly,
t1.add_up_enterprise_and_other,
t1.add_up_other_deduction,
t1.add_up_tax_exempt_income,
t1.add_up_allowed_donation,
t1.add_up_advance_tax
</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.year != null">
AND t1.year = #{param.year}
</if>
<if test="param.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<!-- 关键字(姓名、部门、工号 -->
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.username like CONCAT('%',#{param.keyword},'%')
OR d.name like CONCAT('%',#{param.keyword},'%')
OR e.job_num like CONCAT('%',#{param.keyword},'%')
)
</if>
<!-- 税款所属期 -->
<if test="param.taxYearMonth != null">
<if test="param.taxYearMonth.size() == 1">
AND t1.tax_year_month = #{param.taxYearMonth[0]}
</if>
<if test="param.taxYearMonth.size() == 2">
AND (t1.tax_year_month BETWEEN #{param.taxYearMonth[0]} AND #{param.taxYearMonth[1]})
</if>
</if>
<!-- 姓名 -->
<if test="param.username != null and param.username != ''">
AND e.username like CONCAT('%',#{param.username},'%')
</if>
<if test="param.taxAgentId != null">
AND t1.tax_agent_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.jobNum != null and param.jobNum != ''">
AND e.job_num like CONCAT('%',#{param.jobNum},'%')
</if>
<!-- 入职日期 -->
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.hiredate 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.year != null">
AND t1.year = #{param.year}
</if>
<if test="param.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.username like '%'||#{param.keyword}||'%'
OR d.name like '%'||#{param.keyword}||'%'
OR e.job_num like '%'||#{param.keyword}||'%'
)
</if>
<if test="param.taxYearMonth != null">
<if test="param.taxYearMonth.size() == 1">
AND t1.tax_year_month = #{param.taxYearMonth[0]}
</if>
<if test="param.taxYearMonth.size() == 2">
AND (t1.tax_year_month BETWEEN #{param.taxYearMonth[0]} AND #{param.taxYearMonth[1]})
</if>
</if>
<if test="param.username != null and param.username != ''">
AND e.username like '%'||#{param.username}||'%'
</if>
<if test="param.taxAgentId != null">
AND t1.tax_agent_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.jobNum != null and param.jobNum != ''">
AND e.job_num like '%'||#{param.jobNum}||'%'
</if>
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.hiredate 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.year != null">
AND t1.year = #{param.year}
</if>
<if test="param.employeeId != null">
AND t1.employee_id = #{param.employeeId}
</if>
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.username like '%'+#{param.keyword}+'%'
OR d.name like '%'+#{param.keyword}+'%'
OR e.job_num like '%'+#{param.keyword}+'%'
)
</if>
<if test="param.taxYearMonth != null">
<if test="param.taxYearMonth.size() == 1">
AND t1.tax_year_month = #{param.taxYearMonth[0]}
</if>
<if test="param.taxYearMonth.size() == 2">
AND (t1.tax_year_month BETWEEN #{param.taxYearMonth[0]} AND #{param.taxYearMonth[1]})
</if>
</if>
<if test="param.username != null and param.username != ''">
AND e.username like '%'+#{param.username}+'%'
</if>
<if test="param.taxAgentId != null">
AND t1.tax_agent_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.jobNum != null and param.jobNum != ''">
AND e.job_num like '%'+#{param.jobNum}+'%'
</if>
<if test="param.hiredate != null and param.hiredate.size() == 2">
AND (e.hiredate 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.AddUpSituationDTO">
SELECT
<include refid="addUpSituationColumn"/>
FROM
hrsa_add_up_situation t1
INNER JOIN
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
2022-03-09 16:40:14 +08:00
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.department
2022-03-08 18:10:03 +08:00
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
WHERE
t1.delete_type = 0
AND t2.delete_type = 0
AND e.status not in (7)
<include refid="paramSql"/>
ORDER BY t1.id DESC
</select>
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.AddUpSituationDTO"
databaseId="oracle">
SELECT
<include refid="addUpSituationColumn"/>
FROM
hrsa_add_up_situation t1
INNER JOIN
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.department
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
WHERE
t1.delete_type = 0
AND t2.delete_type = 0
AND e.status not in (7)
<include refid="paramSql"/>
ORDER BY t1.id DESC
</select>
<select id="list" resultType="com.engine.salary.entity.datacollection.dto.AddUpSituationDTO"
databaseId="sqlserver">
SELECT
<include refid="addUpSituationColumn"/>
FROM
hrsa_add_up_situation t1
INNER JOIN
(SELECT employee_id, MAX(tax_year_month) tax_year_month FROM hrsa_add_up_situation GROUP BY employee_id) t ON
t.employee_id = t1.employee_id AND t.tax_year_month = t1.tax_year_month
2022-03-09 16:40:14 +08:00
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.department
2022-03-08 18:10:03 +08:00
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
WHERE
t1.delete_type = 0
AND t2.delete_type = 0
AND e.status not in (7)
<include refid="paramSql"/>
ORDER BY t1.id DESC
</select>
2022-03-03 13:50:03 +08:00
2022-03-09 16:40:14 +08:00
<select id="recordList" resultType="com.engine.salary.entity.datacollection.dto.AddUpSituationRecordDTO">
SELECT
<include refid="addUpSituationColumn"/>
FROM
hrsa_add_up_situation t1
LEFT JOIN hrmresource e ON e.id = t1.employee_id
LEFT JOIN hrmdepartment d ON d.id = e.department
LEFT JOIN hrsa_tax_agent t2 ON t1.tax_agent_id = t2.id
WHERE
t1.delete_type = 0
AND t2.delete_type = 0
AND e.status not in (7)
<include refid="paramSql"/>
ORDER BY t1.tax_year_month DESC
</select>
2022-03-03 13:50:03 +08:00
</mapper>