weaver-hrm-salary/src/com/engine/salary/mapper/siaccount/InsuranceAccountDetailMappe...

896 lines
30 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.siaccount.InsuranceAccountDetailMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
<result column="id" property="id"/>
<result column="employee_id" property="employeeId"/>
<result column="bill_month" property="billMonth"/>
<result column="bill_status" property="billStatus"/>
<result column="payment_status" property="paymentStatus"/>
<result column="supplementary_month" property="supplementaryMonth"/>
<result column="supplementary_projects" property="supplementaryProjects"/>
<result column="resource_from" property="resourceFrom"/>
<result column="social_pay_org" property="socialPayOrg"/>
<result column="social_account" property="socialAccount"/>
<result column="fund_pay_org" property="fundPayOrg"/>
<result column="fund_account" property="fundAccount"/>
<result column="supplement_fund_account" property="supplementFundAccount"/>
<result column="other_pay_org" property="otherPayOrg"/>
<result column="social_scheme_id" property="socialSchemeId"/>
<result column="social_payment_base_string" property="socialPaymentBaseString"/>
<result column="fund_scheme_id" property="fundSchemeId"/>
<result column="fund_payment_base_string" property="fundPaymentBaseString"/>
<result column="other_scheme_id" property="otherSchemeId"/>
<result column="other_payment_base_string" property="otherPaymentBaseString"/>
<result column="social_per_json" property="socialPerJson"/>
<result column="social_per_sum" property="socialPerSum"/>
<result column="fund_per_json" property="fundPerJson"/>
<result column="fund_per_sum" property="fundPerSum"/>
<result column="other_per_json" property="otherPerJson"/>
<result column="other_per_sum" property="otherPerSum"/>
<result column="per_sum" property="perSum"/>
<result column="social_com_json" property="socialComJson"/>
<result column="social_com_sum" property="socialComSum"/>
<result column="fund_com_json" property="fundComJson"/>
<result column="fund_com_sum" property="fundComSum"/>
<result column="other_com_json" property="otherComJson"/>
<result column="other_com_sum" property="otherComSum"/>
<result column="com_sum" property="comSum"/>
<result column="social_sum" property="socialSum"/>
<result column="fund_sum" property="fundSum"/>
<result column="other_sum" property="otherSum"/>
<result column="total" property="total"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id
, t.employee_id
, t.bill_month
, t.bill_status
, t.payment_status
, t.supplementary_month
, t.supplementary_projects
, t.resource_from
, t.social_pay_org
, t.social_account
, t.fund_pay_org
, t.fund_account
, t.supplement_fund_account
, t.other_pay_org
, t.social_scheme_id
, t.social_payment_base_string
, t.fund_scheme_id
, t.fund_payment_base_string
, t.other_scheme_id
, t.other_payment_base_string
, t.social_per_json
, t.social_per_sum
, t.fund_per_json
, t.fund_per_sum
, t.other_per_json
, t.other_per_sum
, t.per_sum
, t.social_com_json
, t.social_com_sum
, t.fund_com_json
, t.fund_com_sum
, t.other_com_json
, t.other_com_sum
, t.com_sum
, t.social_sum
, t.fund_sum
, t.other_sum
, t.total
, t.creator
, t.delete_type
, t.create_time
, t.update_time
, t.tenant_key
</sql>
<sql id="paramSql">
<if test="param.billMonth != null and param.billMonth != ''">
AND
t.bill_month = #{param.billMonth}
</if>
<if test="param.paymentStatus != null and param.paymentStatus != ''">
AND
t.payment_status = #{param.paymentStatus}
</if>
<if test="param.employeeIds != null and param.employeeIds.size()>0">
AND t.employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
</sql>
<select id="list" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
<include refid="paramSql"/>
ORDER BY t.update_time DESC
</select>
<select id="selectList" resultMap="BaseResultMap">
SELECT
t.employee_id,t.social_sum,t.fund_sum,t.other_sum
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<select id="selectAccountIds" resultType="java.lang.Long">
SELECT
t.employee_id
FROM
hrsa_bill_detail t
WHERE t.delete_type = 0
AND t.bill_month = #{billMonth}
</select>
<!-- 根据主键删除记录 -->
<delete id="deleteById" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="batchDeleteNotFile" parameterType="com.engine.salary.entity.siaccount.po.InsuranceAccountDetailPO">
DELETE
FROM hrsa_bill_detail
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND bill_status = 0
</delete>
<delete id="batchDelSupplementAccountDetails">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="pos" open="(" item="po" separator="," close=")">
#{po.id}
</foreach>
</delete>
<update id="batchUnConfirmedInspectDetails">
UPDATE
hrsa_bill_inspect
SET
inspect_status = 0
WHERE
delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<update id="batchIgnoreInspectDetails">
UPDATE
hrsa_bill_inspect
SET
inspect_status = 1
WHERE
delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 批量删除 -->
<delete id="batchDelAccountDetails">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</delete>
<delete id="batchDelSupplementDetailsByIds">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND employee_id IN
<foreach collection="pos" open="(" item="po" separator="," close=")">
#{po.employeeId}
</foreach>
</delete>
<insert id="batchSaveAccountDetails">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="hrsa_bill_detail" databaseId="oracle">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
<foreach collection="accounts" item="item" separator="union all">
select
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
from dual
</foreach>
</insert>
<insert id="hrsa_bill_detail" databaseId="sqlserver">
INSERT INTO hrsa_bill_detail
(employee_id,bill_month,bill_status,payment_status,supplementary_month,supplementary_projects,resource_from,social_pay_org,social_account,fund_pay_org,
fund_account,supplement_fund_account,other_pay_org,social_scheme_id,social_payment_base_string,fund_scheme_id,fund_payment_base_string,other_scheme_id,other_payment_base_string,social_per_json,
social_per_sum,fund_per_json,fund_per_sum,other_per_json,other_per_sum,per_sum,social_com_json,social_com_sum,fund_com_json,
fund_com_sum,other_com_json,other_com_sum,com_sum,social_sum,fund_sum,other_sum,total,creator,delete_type,create_time,update_time.tenant_key)
VALUES
<foreach collection="accounts" item="item" separator=",">
(
#{item.employeeId},
#{item.billMonth},
#{item.billStatus},
#{item.paymentStatus},
#{item.supplementaryMonth},
#{item.supplementaryProjects},
#{item.resourceFrom},
#{item.socialPayOrg},
#{item.socialAccount},
#{item.fundPayOrg},
#{item.fundAccount}
#{item.supplementFundAccount}
#{item.otherPayOrg}
#{item.socialSchemeId}
#{item.socialPaymentBaseString}
#{item.fundSchemeId}
#{item.fundPaymentBaseString}
#{item.otherSchemeId}
#{item.otherPaymentBaseString}
#{item.socialPerJson}
#{item.socialPerSum}
#{item.fundPerJson}
#{item.fundPerSum}
#{item.otherPerJson}
#{item.otherPerSum}
#{item.perSum}
#{item.socialComJson}
#{item.socialComSum}
#{item.fundComJson}
#{item.fundComSum}
#{item.otherComJson}
#{item.otherComSum}
#{item.comSum}
#{item.socialSum}
#{item.fundSum}
#{item.otherSum}
#{item.total}
#{item.creator}
#{item.deleteType}
#{item.createTime}
#{item.updateTime}
#{item.tenantKey}
)
</foreach>
</insert>
<select id="changeList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO">
SELECT DISTINCT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.`NAME` AS departmentName,
e.`STATUS` AS userStatus,
e.POSITION AS position,
h.payment_status AS paymentStatus,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
hrsa_bill_detail h
LEFT JOIN {$publicdb}.employee e ON e.ID = h.employee_id AND h.delete_type = 0
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.`STATUS` = 'unavailable' AND h.payment_status = 0
<if test="userName != null and userName != ''">
AND e.username like CONCAT('%',#{userName},'%')
</if>
AND(l.DIMISSION_TIME IS NOT NULL)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
fund.fund_start_time IS NOT NULL
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
OR(
social.social_start_time IS NOT NULL
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
OR(
other.other_start_time IS NOT NULL
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
UNION
SELECT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.`NAME` AS departmentName,
e.`STATUS` AS userStatus,
e.POSITION AS position,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
{$publicdb}.employee e
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.`STATUS` = 'normal'
<if test="userName != null and userName != ''">
AND e.username like CONCAT('%',#{userName},'%')
</if>
AND(
l.DIMISSION_TIME IS NULL OR l.DIMISSION_TIME = ''
)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
(
fund.fund_start_time IS NULL
OR fund.fund_start_time = ''
)
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
AND(
(
social.social_start_time IS NULL
OR social.social_start_time = ''
)
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
AND(
(
other.other_start_time IS NULL
OR other.other_start_time = ''
)
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
LIMIT #{startNum},#{pageSize}
</select>
<select id="changeList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO" databaseId="oracle">
SELECT DISTINCT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.NAME AS departmentName,
e.STATUS AS userStatus,
e.POSITION AS position,
h.payment_status AS paymentStatus,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
hrsa_bill_detail h
LEFT JOIN {$publicdb}.employee e ON e.ID = h.employee_id AND h.delete_type = 0
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.STATUS = 'unavailable' AND h.payment_status = 0
<if test="userName != null and userName != ''">
AND e.username like '%'||#{userName}||'%'
</if>
AND(l.DIMISSION_TIME IS NOT NULL)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
fund.fund_start_time IS NOT NULL
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
OR(
social.social_start_time IS NOT NULL
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
OR(
other.other_start_time IS NOT NULL
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
UNION
SELECT * FROM (SELECT TMP.*,ROWNUM ROW_ID FROM (SELECT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.NAME AS departmentName,
e.STATUS AS userStatus,
e.POSITION AS position,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
{$publicdb}.employee e
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.STATUS = 'normal'
<if test="userName != null and userName != ''">
AND e.username like '%'||#{userName}||'%'
</if>
AND(
l.DIMISSION_TIME IS NULL OR l.DIMISSION_TIME = ''
)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
(
fund.fund_start_time IS NULL
OR fund.fund_start_time = ''
)
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
AND(
(
social.social_start_time IS NULL
OR social.social_start_time = ''
)
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
AND(
(
other.other_start_time IS NULL
OR other.other_start_time = ''
)
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
) TMP WHERE ROWNUM &lt;=(#{pageSize}+#{startNum})) WHERE ROW_ID &gt;#{startNum}
</select>
<select id="changeList" resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesEmployeePO" databaseId="sqlserver">
SELECT DISTINCT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.NAME AS departmentName,
e.STATUS AS userStatus,
e.POSITION AS position,
h.payment_status AS paymentStatus,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
hrsa_bill_detail h
LEFT JOIN {$publicdb}.employee e ON e.ID = h.employee_id AND h.delete_type = 0
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.STATUS = 'unavailable' AND h.payment_status = 0
<if test="userName != null and userName != ''">
AND e.username like '%'+#{userName}+'%'
</if>
AND(l.DIMISSION_TIME IS NOT NULL)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
fund.fund_start_time IS NOT NULL
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
OR(
social.social_start_time IS NOT NULL
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
OR(
other.other_start_time IS NOT NULL
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
UNION
select * from (select top (#{pageSize}) atmp.* from ( select row_number() over(order by CURRENT_TIMESTAMP) as rownumber,atmp.* from (SELECT
a.employeeId,
a.userName,
a.departmentId,
a.jobNum,
a.telephone,
a.departmentName,
a.position,
a.userStatus,
a.hiredate,
a.dimissionDate,
a.siSchemeId,
a.fundSchemeId,
a.otherSchemeId
FROM
(
SELECT
t.*, social.social_start_time,
social.social_end_time,
fund.fund_start_time,
fund.fund_end_time,
other.other_start_time,
other.other_end_time,
social.social_scheme_id AS siSchemeId,
fund.fund_scheme_id AS fundSchemeId,
other.other_scheme_id AS otherSchemeId
FROM
(
SELECT
e.username AS userName,
e.JOB_NUM AS jobNum,
e.DEPARTMENT AS departmentId,
d.NAME AS departmentName,
e.STATUS AS userStatus,
e.POSITION AS position,
e.HIREDATE AS hiredate,
l.DIMISSION_TIME AS dimissionDate,
e.ID AS employeeId,
e.MOBILE AS telephone
FROM
{$publicdb}.employee e
LEFT JOIN {$publicdb}.dimission_log l ON e.ID = l.DIMISSION_ID
LEFT JOIN {$publicdb}.department d ON d.ID = e.DEPARTMENT
WHERE
e.STATUS = 'normal'
<if test="userName != null and userName != ''">
AND e.username like '%'+#{userName}+'%'
</if>
AND(
l.DIMISSION_TIME IS NULL OR l.DIMISSION_TIME = ''
)
)AS t
LEFT JOIN hrsa_social_archives social ON t.employeeId = social.employee_id AND social.delete_type = 0
LEFT JOIN hrsa_fund_archives fund ON t.employeeId = fund.employee_id AND fund.delete_type = 0
LEFT JOIN hrsa_other_archives other ON t.employeeId = other.employee_id AND other.delete_type = 0
WHERE
(
(
fund.fund_start_time IS NULL
OR fund.fund_start_time = ''
)
AND(
fund.fund_end_time IS NULL
OR fund.fund_end_time = ''
)
)
AND(
(
social.social_start_time IS NULL
OR social.social_start_time = ''
)
AND(
social.social_end_time IS NULL
OR social.social_end_time = ''
)
)
AND(
(
other.other_start_time IS NULL
OR other.other_start_time = ''
)
AND(
other.other_end_time IS NULL
OR other.other_end_time = ''
)
)
)a
) atmp )atmp where rownumber &gt;#{startNum})atmp
</select>
</mapper>