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

508 lines
19 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.siarchives.SocialSchemeMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siarchives.po.InsuranceArchivesSocialSchemePO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="non_payment" property="nonPayment"/>
<result column="welfare_type" property="welfareType"/>
<result column="social_start_time" property="socialStartTime"/>
<result column="social_end_time" property="socialEndTime"/>
<result column="social_scheme_id" property="socialSchemeId"/>
<result column="social_account" property="socialAccount"/>
<result column="payment_organization" property="paymentOrganization"/>
<result column="under_take" property="underTake"/>
<result column="social_payment_base_string" property="socialPaymentBaseString"/>
<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"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.employee_id
, t.non_payment
, t.welfare_type
, t.social_start_time
, t.social_end_time
, t.social_scheme_id
, t.social_account
, t.payment_organization
, t.under_take
, t.social_payment_base_string
, t.create_time
, t.update_time
, t.creator
, t.delete_type
, t.tenant_key
</sql>
<!-- 根据人员id获取记录 -->
<select id="getSocialByEmployeeId" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_social_archives t
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>
</select>
<!-- 批量删除 -->
<delete id="batchDeleteByEmployeeIds">
UPDATE hrsa_social_archives
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>
<!-- 批量保存 -->
<insert id="batchSave">
INSERT INTO hrsa_social_archives(
welfare_type,
delete_type,
social_payment_base_string,
social_scheme_id,
create_time,
social_end_time,
social_start_time,
creator,
non_payment,
tenant_key,
employee_id,
update_time,
under_take,
social_account,
payment_organization)
VALUES
<foreach collection="socialSchemePOS" item="item" separator=",">
(
#{item.welfareType},
#{item.deleteType},
#{item.socialPaymentBaseString},
#{item.socialSchemeId},
#{item.createTime},
#{item.socialEndTime},
#{item.socialStartTime},
#{item.creator},
#{item.nonPayment},
#{item.tenantKey},
#{item.employeeId},
#{item.updateTime},
#{item.underTake},
#{item.socialAccount},
#{item.paymentOrganization}
)
</foreach>
</insert>
<insert id="batchSave" databaseId="oracle">
INSERT INTO hrsa_social_archives(
welfare_type,
delete_type,
social_payment_base_string,
social_scheme_id,
create_time,
social_end_time,
social_start_time,
creator,
non_payment,
tenant_key,
employee_id,
update_time,
under_take,
social_account,
payment_organization)
<foreach collection="socialSchemePOS" item="item" separator="union all">
select
#{item.welfareType,jdbcType=INTEGER},
#{item.deleteType,jdbcType=INTEGER},
#{item.socialPaymentBaseString,jdbcType=VARCHAR},
#{item.socialSchemeId,jdbcType=DOUBLE},
#{item.createTime,jdbcType=DATE},
#{item.socialEndTime,jdbcType=VARCHAR},
#{item.socialStartTime,jdbcType=VARCHAR},
#{item.creator,jdbcType=DOUBLE},
#{item.nonPayment,jdbcType=INTEGER},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.employeeId,jdbcType=DOUBLE},
#{item.updateTime,jdbcType=DATE},
#{item.underTake,jdbcType=INTEGER},
#{item.socialAccount,jdbcType=VARCHAR},
#{item.paymentOrganization,jdbcType=DOUBLE}
from dual
</foreach>
</insert>
<insert id="batchSave" databaseId="sqlserver">
<foreach collection="socialSchemePOS" item="item" separator=";">
INSERT INTO hrsa_social_archives(
welfare_type,
delete_type,
social_payment_base_string,
social_scheme_id,
create_time,
social_end_time,
social_start_time,
creator,
non_payment,
tenant_key,
employee_id,
update_time,
under_take,
social_account,
payment_organization)
VALUES
(
#{item.welfareType},
#{item.deleteType},
#{item.socialPaymentBaseString},
#{item.socialSchemeId},
#{item.createTime},
#{item.socialEndTime},
#{item.socialStartTime},
#{item.creator},
#{item.nonPayment},
#{item.tenantKey},
#{item.employeeId},
#{item.updateTime},
#{item.underTake},
#{item.socialAccount},
#{item.paymentOrganization}
)
</foreach>
</insert>
<!-- 人员档案信息 -->
<sql id="paramSql">
<!-- 关键字(姓名、工号 -->
<if test="param.keyword != null and param.keyword != ''">
AND
(
a.lastname like CONCAT('%',#{param.keyword},'%')
OR a.workcode like CONCAT('%',#{param.keyword},'%')
)
</if>
</sql>
<sql id="paramSql" databaseId="oracle">
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'||#{param.keyword}||'%'
OR e.workcode like '%'||#{param.keyword}||'%'
)
</if>
</sql>
<sql id="paramSql" databaseId="sqlserver">
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'+#{param.keyword}+'%'
OR e.workcode like '%'+#{param.keyword}+'%'
)
</if>
</sql>
<sql id="paramSqlCommon">
<!--部门 多选-->
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND a.departmentid IN
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentId}
</foreach>
</if>
<!--状态 多选-->
<if test="param.statuses != null and param.statuses.size()>0">
AND a.status IN
<foreach collection="param.statuses" open="(" item="status" separator="," close=")">
#{status}
</foreach>
</if>
<!--岗位 多选-->
<if test="param.positions != null and param.positions.size()>0">
AND a.jobtitle IN
<foreach collection="param.positions" open="(" item="position" separator="," close=")">
#{position}
</foreach>
</if>
<!--入职日期-->
<if test="param.hiredateStart != null and param.hiredateEnd != null">
AND a.companystartdate between #{param.hiredateStart} and #{param.hiredateEnd}
</if>
<!--离职日期-->
<if test="param.dimissionDateStart != null and param.dimissionDateEnd != null">
AND f.dismissdate between #{param.dimissionDateStart} and #{param.dimissionDateEnd}
</if>
<!--方案主键-->
<if test ="param.siSchemeId != null">
AND c.social_scheme_id = #{param.siSchemeId}
</if>
<if test ="param.fundSchemeId != null">
AND d.fund_scheme_id = #{param.fundSchemeId}
</if>
<if test ="param.otherSchemeId != null">
AND e.other_scheme_id = #{param.otherSchemeId}
</if>
</sql>
<select id="listPageEmployeePOS" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO">
SELECT
a.id as employeeId,
a.lastname as userName,
b.departmentname as departmentName,
a.mobile as telephone
FROM
hrmresource a
LEFT JOIN hrmdepartment b ON a.departmentid = b.id
LEFT JOIN hrsa_social_archives c ON a.id = c.employee_id
LEFT JOIN hrsa_fund_archives d ON a.id = d.employee_id
LEFT JOIN hrsa_other_archives e ON a.id = e.employee_id
LEFT JOIN bill_hrmdismiss f on a.id = f.resource_n
WHERE
a.status not in (7)
and (a.accounttype is null or a.accounttype = 0)
<include refid="paramSql"/>
<include refid="paramSqlCommon"/>
ORDER BY a.id asc
</select>
<select id="tips" resultType="long">
SELECT
employee_id
FROM
hrsa_social_archives
WHERE
social_start_time is not null and social_end_time is null
</select>
<select id="queryEmployeeList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO">
SELECT e.ID AS employeeId, e.lastname AS userName, e.departmentid AS departmentId, e.workcode AS jobNum, e.MOBILE AS telephone,
d.departmentname AS departmentName, e.jobtitle AS position, e.STATUS AS userStatus,e.companystartdate AS hiredate,
e.enddate as dimissionDate,
social.siSchemeId,
social.paymentOrganization,
fund.fundSchemeId,
other.otherSchemeId
FROM hrmresource e
LEFT JOIN hrmdepartment d ON e.departmentid = d.ID
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
LEFT JOIN( SELECT social.employee_id, social.social_scheme_id AS siSchemeId, social.payment_organization AS paymentOrganization FROM hrsa_social_archives social WHERE social.delete_type = 0 )social ON e.id = social.employee_id
LEFT JOIN( SELECT fund.employee_id, fund.fund_scheme_id AS fundSchemeId FROM hrsa_fund_archives fund WHERE fund.delete_type = 0 )fund ON e.id = fund.employee_id
LEFT JOIN( SELECT other.employee_id, other.other_scheme_id AS otherSchemeId FROM hrsa_other_archives other WHERE other.delete_type = 0 )other ON e.id = other.employee_id
WHERE
1=1
<include refid="condition"></include>
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
</if>
</select>
<!--]]>-->
<sql id="condition">
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like CONCAT('%',#{param.keyword},'%')
)
</if>
<if test="param.userName != null and param.userName != ''">
AND e.lastname like CONCAT('%',#{param.userName},'%')
</if>
<if test="param.jobNum != null and param.jobNum != ''">
AND e.workcode like CONCAT('%',#{param.jobNum},'%')
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND e.departmentid IN
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentId}
</foreach>
</if>
<if test="param.statuses != null and param.statuses.size()>0">
AND e.STATUS IN
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
#{userStatus}
</foreach>
</if>
<if test="param.positions != null and param.positions.size()>0">
AND e.jobtitle IN
<foreach collection="param.positions" open="(" item="position" separator="," close=")">
#{position}
</foreach>
</if>
<if test="param.hiredateStart != null">
AND e.companystartdate &gt; #{param.hiredateStart}
</if>
<if test="param.hiredateEnd != null">
AND e.companystartdate &lt; #{param.hiredateEnd}
</if>
<if test="param.dimissionDateStart != null">
AND e.enddate &gt; #{param.dimissionDateStart}
</if>
<if test="param.dimissionDateEnd != null">
AND e.enddate &lt; #{param.dimissionDateEnd}
</if>
<if test="param.siSchemeId != null and param.siSchemeId != 0">
AND siSchemeId = #{param.siSchemeId}
</if>
<if test="param.fundSchemeId != null and param.fundSchemeId != 0">
AND fundSchemeId = #{param.fundSchemeId}
</if>
<if test="param.otherSchemeId != null and param.otherSchemeId != 0">
AND otherSchemeId = #{param.otherSchemeId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size() > 0">
AND e.ID IN
<foreach collection="param.employeeIds" open="(" separator="," item="item" close=")">
#{item}
</foreach>
</if>
</sql>
<sql id="condition" databaseId="sqlserver">
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'+#{param.keyword}+'%'
)
</if>
<if test="param.userName != null and param.userName != ''">
AND e.lastname like '%'+#{param.userName}+'%'
</if>
<if test="param.jobNum != null and param.jobNum != ''">
AND e.workcode like '%'+#{param.jobNum}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND e.departmentid IN
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentId}
</foreach>
</if>
<if test="param.statuses != null and param.statuses.size()>0">
AND e.STATUS IN
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
#{userStatus}
</foreach>
</if>
<if test="param.positions != null and param.positions.size()>0">
AND e.jobtitle IN
<foreach collection="param.positions" open="(" item="position" separator="," close=")">
#{position}
</foreach>
</if>
<if test="param.hiredateStart != null">
AND e.companystartdate &gt; #{param.hiredateStart}
</if>
<if test="param.hiredateEnd != null">
AND e.companystartdate &lt; #{param.hiredateEnd}
</if>
<if test="param.dimissionDateStart != null">
AND e.enddate &gt; #{param.dimissionDateStart}
</if>
<if test="param.dimissionDateEnd != null">
AND e.enddate &lt; #{param.dimissionDateEnd}
</if>
<if test="param.siSchemeId != null and param.siSchemeId != 0">
AND siSchemeId = #{param.siSchemeId}
</if>
<if test="param.fundSchemeId != null and param.fundSchemeId != 0">
AND fundSchemeId = #{param.fundSchemeId}
</if>
<if test="param.otherSchemeId != null and param.otherSchemeId != 0">
AND otherSchemeId = #{param.otherSchemeId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size() > 0">
AND e.ID IN
<foreach collection="param.employeeIds" open="(" separator="," item="item" close=")">
#{item}
</foreach>
</if>
</sql>
<sql id="condition" databaseId="oracle">
<if test="param.keyword != null and param.keyword != ''">
AND
(
e.lastname like '%'||#{param.keyword}||'%'
)
</if>
<if test="param.userName != null and param.userName != ''">
AND e.lastname like '%'||#{param.userName}||'%'
</if>
<if test="param.jobNum != null and param.jobNum != ''">
AND e.workcode like '%'||#{param.jobNum}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND e.departmentid IN
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentId}
</foreach>
</if>
<if test="param.statuses != null and param.statuses.size()>0">
AND e.STATUS IN
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
#{userStatus}
</foreach>
</if>
<if test="param.positions != null and param.positions.size()>0">
AND e.jobtitle IN
<foreach collection="param.positions" open="(" item="position" separator="," close=")">
#{position}
</foreach>
</if>
<if test="param.hiredateStart != null">
AND e.companystartdate &gt; #{param.hiredateStart}
</if>
<if test="param.hiredateEnd != null">
AND e.companystartdate &lt; #{param.hiredateEnd}
</if>
<if test="param.dimissionDateStart != null">
AND e.enddate &gt; #{param.dimissionDateStart}
</if>
<if test="param.dimissionDateEnd != null">
AND e.enddate &lt; #{param.dimissionDateEnd}
</if>
<if test="param.siSchemeId != null and param.siSchemeId != 0">
AND siSchemeId = #{param.siSchemeId}
</if>
<if test="param.fundSchemeId != null and param.fundSchemeId != 0">
AND fundSchemeId = #{param.fundSchemeId}
</if>
<if test="param.otherSchemeId != null and param.otherSchemeId != 0">
AND otherSchemeId = #{param.otherSchemeId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size() > 0">
AND e.ID IN
<foreach collection="param.employeeIds" open="(" separator="," item="item" close=")">
#{item}
</foreach>
</if>
</sql>
<!-- 根据社保缴纳组织id获取记录 -->
<select id="getSocialByPaymentOrganization" resultMap="BaseResultMap" >
SELECT
<include refid="baseColumns"/>
FROM hrsa_social_archives t
WHERE delete_type = 0
AND payment_organization = #{paymentOrganization}
</select>
</mapper>