weaver-hrm-salary/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationValueMapper.xml

472 lines
15 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.taxdeclaration.TaxDeclarationValueMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO">
<result column="id" property="id"/>
<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"/>
<result column="tax_declare_record_id" property="taxDeclareRecordId"/>
<result column="tax_declaration_id" property="taxDeclarationId"/>
<result column="employee_type" property="employeeType"/>
<result column="employee_id" property="employeeId"/>
<result column="result_value_json" property="resultValueJson"/>
<result column="source" property="source"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
, t.tax_declare_record_id
, t.tax_declaration_id
, t.employee_type
, t.employee_id
, t.result_value_json
, t.source
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_value t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_value t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration_value t
WHERE delete_type = 0
<if test="id != null">
AND id = #{id}
</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="taxDeclareRecordId != null">
AND tax_declare_record_id = #{taxDeclareRecordId}
</if>
<if test="taxDeclarationId != null">
AND tax_declaration_id = #{taxDeclarationId}
</if>
<if test="employeeType != null">
AND employee_type = #{employeeType}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="resultValueJson != null">
AND result_value_json = #{resultValueJson}
</if>
<if test="source != null">
AND source = #{source}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="taxDeclarationIds != null and taxDeclarationIds.size()>0">
AND tax_declaration_id IN
<foreach collection="taxDeclarationIds" open="(" item="taxDeclarationId" separator="," close=")">
#{taxDeclarationId}
</foreach>
</if>
ORDER BY id DESC
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO">
INSERT INTO hrsa_tax_declaration_value
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
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>
<if test="taxDeclareRecordId != null">
tax_declare_record_id,
</if>
<if test="taxDeclarationId != null">
tax_declaration_id,
</if>
<if test="employeeType != null">
employee_type,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="resultValueJson != null">
result_value_json,
</if>
<if test="source != null">
source,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</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>
<if test="taxDeclareRecordId != null">
#{taxDeclareRecordId},
</if>
<if test="taxDeclarationId != null">
#{taxDeclarationId},
</if>
<if test="employeeType != null">
#{employeeType},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="resultValueJson != null">
#{resultValueJson},
</if>
<if test="source != null">
#{source},
</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO hrsa_tax_declaration_value
(
id,
create_time,
update_time,
creator,
delete_type,
tenant_key,
tax_declare_record_id,
tax_declaration_id,
employee_type,
employee_id,
result_value_json,
source
)
VALUES
(
<foreach collection="collection" item="item" separator=",">
#{item.id},
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.deleteType},
#{item.tenantKey},
#{item.taxDeclareRecordId},
#{item.taxDeclarationId},
#{item.employeeType},
#{item.employeeId},
#{item.resultValueJson},
#{item.source}
</foreach>
)
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_declaration_value (
id,
create_time,
update_time,
creator,
delete_type,
tenant_key,
tax_declare_record_id,
tax_declaration_id,
employee_type,
employee_id,
result_value_json,
source
)
<foreach collection="collection" item="item" separator="union all">
select
#{item.id,jdbcType=DOUBLE},
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.deleteType,jdbcType=INTEGER},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.taxDeclareRecordId,jdbcType=DOUBLE},
#{item.taxDeclarationId,jdbcType=DOUBLE},
#{item.employeeType,jdbcType=INTEGER},
#{item.employeeId,jdbcType=DOUBLE},
#{item.resultValueJson,jdbcType=VARCHAR},
#{item.source,jdbcType=INTEGER}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
<foreach collection="collection" item="item" separator=";">
INSERT INTO hrsa_tax_declaration_value (
id,
create_time,
update_time,
creator,
delete_type,
tenant_key,
tax_declare_record_id,
tax_declaration_id,
employee_type,
employee_id,
result_value_json,
source
)
VALUES
(
#{item.id},
#{item.createTime},
#{item.updateTime},
#{item.creator},
#{item.deleteType},
#{item.tenantKey},
#{item.taxDeclareRecordId},
#{item.taxDeclarationId},
#{item.employeeType},
#{item.employeeId},
#{item.resultValueJson},
#{item.source}
)
</foreach>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO">
UPDATE hrsa_tax_declaration_value
<set>
create_time=#{createTime},
update_time=#{updateTime},
creator=#{creator},
delete_type=#{deleteType},
tenant_key=#{tenantKey},
tax_declare_record_id=#{taxDeclareRecordId},
tax_declaration_id=#{taxDeclarationId},
employee_type=#{employeeType},
employee_id=#{employeeId},
result_value_json=#{resultValueJson},
source=#{source},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO">
UPDATE hrsa_tax_declaration_value
<set>
<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>
<if test="taxDeclareRecordId != null">
tax_declare_record_id=#{taxDeclareRecordId},
</if>
<if test="taxDeclarationId != null">
tax_declaration_id=#{taxDeclarationId},
</if>
<if test="employeeType != null">
employee_type=#{employeeType},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="resultValueJson != null">
result_value_json=#{resultValueJson},
</if>
<if test="source != null">
source=#{source},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete">
UPDATE hrsa_tax_declaration_value
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_tax_declaration_value
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteBytaxDeclareRecordIds">
UPDATE hrsa_tax_declaration_value
SET delete_type = 1
WHERE delete_type = 0
AND tax_declare_record_id IN
<foreach collection="taxDeclareRecordIds" open="(" item="taxDeclareRecordId" separator="," close=")">
#{taxDeclareRecordId}
</foreach>
</delete>
<resultMap id="TaxDeclareEmployeeMap" type="com.engine.salary.entity.taxdeclaration.po.TaxDeclareEmployeePO">
<result column="employee_id" property="employeeId"/>
<result column="employee_type" property="employeeType"/>
</resultMap>
<sql id="TaxDeclareEmployeeSql">
employee_id
, employee_type
</sql>
<sql id="NotDeclareSql">
SELECT DISTINCT
<include refid="TaxDeclareEmployeeSql"/>
FROM hrsa_tax_declaration_value
WHERE delete_type = 0
AND tax_declare_record_id = #{param.taxDeclareRecordId}
AND employee_id NOT IN (
SELECT employee_id
FROM hrsa_employee_declare hed
WHERE hed.delete_type = 0
AND hed.tax_agent_id = #{param.taxAgentId}
AND hed.tax_cycle = #{param.taxCycle}
AND hed.successfully_declared = 1
AND (hed.dismiss_date is null OR hed.dismiss_date <![CDATA[ >= ]]> #{param.taxCycle} OR hed.reissue_tax_cycle = #{param.taxCycle})
AND hed.declare_status IN (4)
)
</sql>
<select id="listPage4NotDeclareByParam" resultMap="TaxDeclareEmployeeMap">
<include refid="NotDeclareSql"/>
</select>
<select id="list4NotDeclareByParam" resultMap="TaxDeclareEmployeeMap">
<include refid="NotDeclareSql"/>
</select>
<sql id="NoValueSql">
SELECT
<include refid="TaxDeclareEmployeeSql"/>
FROM hrsa_employee_declare
WHERE delete_type = 0
AND tax_agent_id = #{param.taxAgentId}
AND tax_cycle = #{param.taxCycle}
AND successfully_declared = 1
AND (dismiss_date is null OR dismiss_date <![CDATA[ >= ]]> #{param.taxCycle} OR reissue_tax_cycle = #{param.taxCycle})
AND employee_id NOT IN (
SELECT employee_id
FROM hrsa_tax_declaration_value htdv
WHERE htdv.delete_type = 0
AND htdv.tax_declare_record_id = #{param.taxDeclareRecordId}
)
</sql>
<select id="listPage4NoValueByParam" resultMap="TaxDeclareEmployeeMap">
<include refid="NoValueSql"/>
</select>
<select id="list4NoValueByParam" resultMap="TaxDeclareEmployeeMap">
<include refid="NoValueSql"/>
</select>
<select id="queryNotWagesEmpIds" resultType="Long">
select b.employee_id
from hrsa_tax_declaration a
left join hrsa_tax_declaration_value b on a.id = b.tax_declaration_id
where a.delete_type = 0
and b.delete_type = 0
and a.income_category = 2
and a.tax_declare_record_id = #{taxDeclareRecordId}
</select>
<select id="queryWagesEmpIds" resultType="Long">
select b.employee_id
from hrsa_tax_declaration a
left join hrsa_tax_declaration_value b on a.id = b.tax_declaration_id
where a.delete_type = 0
and b.delete_type = 0
and a.income_category = 1
and a.tax_declare_record_id = #{taxDeclareRecordId}
</select>
</mapper>