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

156 lines
5.5 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.TaxDeclarationMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO">
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="description" property="description"/>
<result column="id" property="id"/>
<result column="salary_month" property="salaryMonth"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tax_cycle" property="taxCycle"/>
<result column="tenant_key" property="tenantKey"/>
<result column="update_time" property="updateTime"/>
<result column="income_category" property="incomeCategory"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
create_time
, t.creator
, t.delete_type
, t.description
, t.id
, t.salary_month
, t.tax_agent_id
, t.tax_cycle
, t.tenant_key
, t.update_time
,t.income_category
</sql>
<update id="deleteByIdZj">
UPDATE hrsa_tax_declaration
SET delete_type = 1
WHERE delete_type = 0
AND id = #{id}
</update>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultType="com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_tax_declaration t
WHERE delete_type = 0
<if test="salaryMonths != null and salaryMonths.fromDate != null">
AND salary_month <![CDATA[ >= ]]> #{salaryMonths.fromDate}
</if>
<if test="salaryMonths != null and salaryMonths.endDate != null">
AND salary_month <![CDATA[ <= ]]> #{salaryMonths.endDate}
</if>
<if test="taxCycleFromDate != null">
AND tax_cycle <![CDATA[ >= ]]> #{taxCycleFromDate}
</if>
<if test="taxCycleEndDate != null">
AND tax_cycle <![CDATA[ <= ]]> #{taxCycleEndDate}
</if>
<if test="taxAgentIds != null and taxAgentIds.size()>0">
AND tax_agent_id IN
<foreach collection="taxAgentIds" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="taxCycle != null">
AND tax_cycle = #{taxCycle}
</if>
ORDER BY id DESC
</select>
<insert id="batchInsert">
INSERT INTO hrsa_tax_declaration(id, salary_month, tax_cycle, tax_agent_id, description,
creator, create_time, update_time, delete_type, tenant_key ,income_category)
VALUES
<foreach collection="collection" separator="," item="item">
(
#{item.id},
#{item.salaryMonth},
#{item.taxCycle},
#{item.taxAgentId},
#{item.description},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey},
#{item.incomeCategory}
)
</foreach>
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_tax_declaration(id,salary_month, tax_cycle, tax_agent_id, description,
creator, create_time, update_time, delete_type, tenant_key ,income_category)
<foreach collection="collection" separator="union all" item="item">
select
#{item.id,jdbcType=DOUBLE},
#{item.salaryMonth,jdbcType=DATE},
#{item.taxCycle,jdbcType=DATE},
#{item.taxAgentId,jdbcType=DOUBLE},
#{item.description,jdbcType=VARCHAR},
#{item.creator,jdbcType=DOUBLE},
#{item.createTime,jdbcType=DATE},
#{item.updateTime,jdbcType=DATE},
#{item.deleteType,jdbcType=INTEGER},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.incomeCategory,jdbcType=INTEGER}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
<foreach collection="collection" separator=";" item="item">
INSERT INTO hrsa_tax_declaration(id,salary_month, tax_cycle, tax_agent_id, description,
creator, create_time, update_time, delete_type, tenant_key ,income_category)
VALUES
(
#{item.id},
#{item.salaryMonth},
#{item.taxCycle},
#{item.taxAgentId},
#{item.description},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey},
#{item.incomeCategory}
)
</foreach>
</insert>
<update id="deleteByIds">
UPDATE hrsa_tax_declaration
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>