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

272 lines
12 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="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
WHERE delete_type = 0
</select>
<!-- 查询对应id的数据 -->
<select id="listByIds" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
WHERE id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<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>
<select id="getRePayList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id
WHERE t.delete_type = 0
AND t.run_status = '3'
AND (
(social.social_end_time is not null and social.social_end_time <![CDATA[ <> ]]> '' and social.social_end_time <![CDATA[ > ]]> #{today})
OR
(fund.fund_end_time is not null and fund.fund_end_time <![CDATA[ <> ]]> '' and fund.fund_end_time <![CDATA[ > ]]> #{today})
OR
(other.other_end_time is not null and other.other_end_time <![CDATA[ <> ]]> '' and other.other_end_time <![CDATA[ > ]]> #{today})
)
</select>
<select id="getReStayDelList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
LEFT JOIN( SELECT social.employee_id, social.social_end_time FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON t.employee_id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_end_time FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON t.employee_id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_end_time FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON t.employee_id = other.employee_id
WHERE t.delete_type = 0
AND t.run_status = '2'
AND social.social_end_time is not null and social.social_end_time <![CDATA[ <> ]]> '' and social.social_end_time <![CDATA[ <= ]]> #{today}
AND fund.fund_end_time is not null and fund.fund_end_time <![CDATA[ <> ]]> '' and fund.fund_end_time <![CDATA[ <= ]]> #{today}
AND other.other_end_time is not null and other.other_end_time <![CDATA[ <> ]]> '' and other.other_end_time <![CDATA[ <= ]]> #{today}
</select>
<select id="getAbnormalList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
LEFT JOIN hrmresource e ON e.id = t.employee_id
WHERE t.delete_type = 0
<!-- 档案状态 -->
<if test="param.runStatuses != null and param.runStatuses.size()>0">
AND t.run_status IN
<foreach collection="param.runStatuses" open="(" item="runStatus" separator="," close=")">
#{runStatus}
</foreach>
</if>
<!-- 人事状态 -->
<if test="param.personnelStatuses != null and param.personnelStatuses.size()>0">
AND e.status IN
<foreach collection="param.personnelStatuses" open="(" item="personnelStatus" separator="," close=")">
#{personnelStatus}
</foreach>
</if>
</select>
<update id="updateRunStatusByIds" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
UPDATE hrsa_insurance_base_info
<set>
run_status=#{runStatus}
</set>
WHERE id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<update id="updateRunStatusByEmployeeIds" parameterType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
UPDATE hrsa_insurance_base_info
<set>
run_status=#{runStatus}
</set>
WHERE employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</update>
<update id="batchUpdate">
UPDATE hrsa_insurance_base_info
<trim prefix="set" suffixOverrides=",">
<trim prefix="run_status = case" suffix="end,">
<foreach collection="collection" item="item" index="index">
WHEN id = #{item.id} THEN #{item.runStatus}
</foreach>
</trim>
<trim prefix="update_time = case" suffix="end,">
<foreach collection="collection" item="item" index="index">
WHEN id = #{item.id} THEN #{item.updateTime}
</foreach>
</trim>
<trim prefix="delete_type = case" suffix="end,">
<foreach collection="collection" item="item" index="index">
WHEN id = #{item.id} THEN #{item.deleteType}
</foreach>
</trim>
</trim>
WHERE delete_type = 0
AND id IN
<foreach collection="collection" item="item" open="(" close=")" separator=",">
#{item.id}
</foreach>
</update>
</mapper>