weaver-hrm-salary/src/com/engine/salary/mapper/siarchives/InsuranceBaseInfoMapper.xml

148 lines
6.0 KiB
XML
Raw Normal View History

<?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.siarchives.InsuranceBaseInfoMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="payment_organization" property="paymentOrganization"/>
<result column="social_archives_id" property="socialArchivesId"/>
<result column="fund_archives_id" property="fundArchivesId"/>
<result column="other_archives_id" property="otherArchivesId"/>
<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="run_status" property="runStatus"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.employee_id
, t.payment_organization
, t.social_archives_id
, t.fund_archives_id
, t.other_archives_id
, t.run_status
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
</sql>
<select id="getInsuranceBaseInfoListByInsuranceDetail" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT social.employee_id,
social.id AS socialArchivesId,
social.payment_organization,
fund.id AS fundArchivesId,
other.id AS otherArchivesId
FROM hrsa_social_archives social
LEFT JOIN( SELECT fund.employee_id, fund.id FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON social.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.id FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON social.employee_id = other.employee_id
WHERE
social.delete_type = 0
<if test="employeeIds != null and employeeIds.size()>0">
AND social.employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</select>
<select id="getInsuranceBaseInfoList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
WHERE
t.delete_type = 0
</select>
<insert id="batchSave">
INSERT INTO hrsa_insurance_base_info
(id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status)
VALUES
<foreach collection="infos" item="item" separator=",">
(
#{item.id},
#{item.employeeId},
#{item.paymentOrganization},
#{item.socialArchivesId},
#{item.fundArchivesId},
#{item.otherArchivesId},
#{item.tenantKey},
#{item.creator},
#{item.deleteType},
#{item.createTime},
#{item.updateTime},
#{item.runStatus}
)
</foreach>
</insert>
<insert id="batchSave" databaseId="oracle">
INSERT INTO hrsa_insurance_base_info
(id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status)
<foreach collection="infos" item="item" separator="union all">
select
#{item.id,jdbcType=DOUBLE},
#{item.employeeId,jdbcType=DOUBLE},
#{item.paymentOrganization,jdbcType=DOUBLE},
#{item.socialArchivesId,jdbcType=DOUBLE},
#{item.fundArchivesId,jdbcType=DOUBLE},
#{item.otherArchivesId,jdbcType=DOUBLE},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.creator,jdbcType=DOUBLE},
#{item.deleteType},
#{item.createTime},
#{item.updateTime},
#{item.runStatus,jdbcType=VARCHAR}
from dual
</foreach>
</insert>
<insert id="batchSave" databaseId="sqlserver">
<foreach collection="infos" item="item" separator=";">
INSERT INTO hrsa_insurance_base_info
(id,employee_id,payment_organization,social_archives_id,fund_archives_id,other_archives_id,tenant_key,creator,delete_type,create_time,update_time,run_status)
VALUES
(
#{item.id},
#{item.employeeId},
#{item.paymentOrganization},
#{item.socialArchivesId},
#{item.fundArchivesId},
#{item.otherArchivesId},
#{item.tenantKey},
#{item.creator},
#{item.deleteType},
#{item.createTime},
#{item.updateTime},
#{item.runStatus}
)
</foreach>
</insert>
<!-- 批量删除 -->
<delete id="batchDeleteByEmployeeIds">
UPDATE hrsa_insurance_base_info
SET delete_type = 1
WHERE delete_type = 0
<if test="employeeIds != null and employeeIds.size()>0">
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</delete>
<!-- 根据个税扣缴义务人id获取记录 -->
<select id="getSocialByPaymentOrganization" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
WHERE delete_type = 0
AND payment_organization = #{paymentOrganization}
</select>
</mapper>