1045 lines
42 KiB
XML
1045 lines
42 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.salaryacct.SalaryAcctEmployeeMapper">
|
|
<resultMap id="SalaryAccEmployeeMap"
|
|
type="com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO">
|
|
<id column="id" property="id"/>
|
|
<result column="salary_acct_record_id" property="salaryAcctRecordId"/>
|
|
<result column="salary_sob_id" property="salarySobId"/>
|
|
<result column="employee_id" property="employeeId"/>
|
|
<result column="tax_agent_id" property="taxAgentId"/>
|
|
<result column="salary_month" property="salaryMonth"/>
|
|
<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="employee_type" property="employeeType"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="SalaryAccEmployeeCountMap"
|
|
type="com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeCountDTO">
|
|
<id column="salary_acct_record_id" property="salaryAcctRecordId"/>
|
|
<result column="cnt" property="countBySalaryAcctRecordId"/>
|
|
</resultMap>
|
|
|
|
<sql id="SalaryAccEmployeeColumn">
|
|
t
|
|
.
|
|
id
|
|
,
|
|
t.salary_acct_record_id,
|
|
t.salary_sob_id,
|
|
t.employee_id,
|
|
t.tax_agent_id,
|
|
t.salary_month,
|
|
t.creator,
|
|
t.create_time,
|
|
t.update_time,
|
|
t.delete_type,
|
|
t.tenant_key,
|
|
t.employee_type
|
|
</sql>
|
|
|
|
<sql id="emp1Column">
|
|
emp1
|
|
.
|
|
id
|
|
, emp1.salary_acct_record_id, emp1.salary_sob_id, emp1.employee_id, emp1.tax_agent_id, emp1.salary_month,
|
|
emp1.creator, emp1.create_time, emp1.update_time, emp1.delete_type, emp1.tenant_key,emp1.employee_type
|
|
</sql>
|
|
|
|
<insert id="batchInsert">
|
|
INSERT INTO hrsa_salary_acct_emp(
|
|
salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key,employee_type)
|
|
VALUES
|
|
<foreach collection="collection" item="emp" separator=",">
|
|
(
|
|
#{emp.salaryAcctRecordId},
|
|
#{emp.salarySobId},
|
|
#{emp.employeeId},
|
|
#{emp.taxAgentId},
|
|
#{emp.salaryMonth},
|
|
#{emp.creator},
|
|
#{emp.createTime},
|
|
#{emp.updateTime},
|
|
#{emp.deleteType},
|
|
#{emp.tenantKey},
|
|
#{emp.employeeType}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchInsert" databaseId="oracle">
|
|
INSERT INTO hrsa_salary_acct_emp(
|
|
salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key,employee_type)
|
|
|
|
<foreach collection="collection" item="emp" separator="union all">
|
|
select
|
|
#{emp.salaryAcctRecordId,jdbcType=DOUBLE},
|
|
#{emp.salarySobId,jdbcType=DOUBLE},
|
|
#{emp.employeeId,jdbcType=DOUBLE},
|
|
#{emp.taxAgentId,jdbcType=DOUBLE},
|
|
#{emp.salaryMonth,jdbcType=DATE},
|
|
#{emp.creator,jdbcType=DOUBLE},
|
|
#{emp.createTime,jdbcType=DATE},
|
|
#{emp.updateTime,jdbcType=DATE},
|
|
#{emp.deleteType,jdbcType=INTEGER},
|
|
#{emp.tenantKey,jdbcType=VARCHAR},
|
|
#{emp.employeeType,jdbcType=INTEGER}
|
|
from dual
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchInsert" databaseId="sqlserver">
|
|
<foreach collection="collection" item="emp" separator=";">
|
|
INSERT INTO hrsa_salary_acct_emp(
|
|
salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key,employee_type)
|
|
VALUES
|
|
(
|
|
#{emp.salaryAcctRecordId},
|
|
#{emp.salarySobId},
|
|
#{emp.employeeId},
|
|
#{emp.taxAgentId},
|
|
#{emp.salaryMonth},
|
|
#{emp.creator},
|
|
#{emp.createTime},
|
|
#{emp.updateTime},
|
|
#{emp.deleteType},
|
|
#{emp.tenantKey},
|
|
#{emp.employeeType}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="countGroupBySalaryAcctRecordId" resultMap="SalaryAccEmployeeCountMap">
|
|
SELECT salary_acct_record_id, COUNT(*) cnt
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
GROUP BY salary_acct_record_id
|
|
</select>
|
|
|
|
<select id="listPage4ConsolidatedTax" resultMap="SalaryAccEmployeeMap">
|
|
SELECT DISTINCT
|
|
<include refid="emp1Column"/>
|
|
FROM (
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
<select id="listPage4ConsolidatedTax" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT DISTINCT
|
|
|
|
emp1.id, emp1.salary_acct_record_id, emp1.salary_sob_id, emp1.employee_id, emp1.tax_agent_id, emp1.salary_month,
|
|
emp1.creator, emp1.create_time, emp1.update_time, emp1.delete_type, emp1.tenant_key,emp1.employee_type
|
|
|
|
FROM (
|
|
SELECT
|
|
|
|
id, salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key,employee_type
|
|
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.taxAgentId != null">
|
|
AND tax_agent_id = #{param.taxAgentId}
|
|
</if>
|
|
<if test="(param.employeeName != null and param.employeeName != '')
|
|
or (param.workcode != null and param.workcode != '')
|
|
or (param.departmentIds != null and param.departmentIds.size()>0)
|
|
or (param.positionIds != null and param.positionIds.size()>0)
|
|
or (param.status != null and param.status.toString != 'ALL')">
|
|
AND employee_id IN
|
|
(
|
|
SELECT id FROM hrmresource em WHERE em.status not in (7)
|
|
and (em.accounttype is null or em.accounttype = 0)
|
|
<if test="param.employeeName != null and param.employeeName != ''">
|
|
AND em.lastname LIKE '%'||#{param.employeeName}||'%'
|
|
</if>
|
|
<if test="param.workcode != null and param.workcode != ''">
|
|
AND em.workcode like '%'||#{param.workcode}||'%'
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND em.departmentid IN
|
|
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
|
|
#{departmentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND em.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
|
|
#{positionId}
|
|
</foreach>
|
|
</if>
|
|
-- 在职
|
|
<if test="param.status != null and param.status.toString == 'NORMAL'">
|
|
AND em.status in (0,1,2,3)
|
|
</if>
|
|
-- 离职
|
|
<if test="param.status != null and param.status.toString == 'UNAVAILABLE'">
|
|
AND em.status in (4,5,6)
|
|
</if>
|
|
)
|
|
</if>
|
|
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
|
|
id, salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key
|
|
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
<select id="listPage4ConsolidatedTax" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT DISTINCT
|
|
|
|
emp1.id, emp1.salary_acct_record_id, emp1.salary_sob_id, emp1.employee_id, emp1.tax_agent_id, emp1.salary_month,
|
|
emp1.creator, emp1.create_time, emp1.update_time, emp1.delete_type, emp1.tenant_key,emp1.employee_type
|
|
|
|
FROM (
|
|
SELECT
|
|
|
|
id, salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key,employee_type
|
|
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.taxAgentId != null">
|
|
AND tax_agent_id = #{param.taxAgentId}
|
|
</if>
|
|
<if test="(param.employeeName != null and param.employeeName != '')
|
|
or (param.workcode != null and param.workcode != '')
|
|
or (param.departmentIds != null and param.departmentIds.size()>0)
|
|
or (param.positionIds != null and param.positionIds.size()>0)
|
|
or (param.status != null and param.status.toString != 'ALL')">
|
|
AND employee_id IN
|
|
(
|
|
SELECT id FROM hrmresource em WHERE em.status not in (7)
|
|
and (em.accounttype is null or em.accounttype = 0)
|
|
<if test="param.employeeName != null and param.employeeName != ''">
|
|
AND em.lastname LIKE '%'+#{param.employeeName}+'%'
|
|
</if>
|
|
<if test="param.workcode != null and param.workcode != ''">
|
|
AND em.workcode like '%'+#{param.workcode}+'%'
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND em.departmentid IN
|
|
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
|
|
#{departmentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND em.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
|
|
#{positionId}
|
|
</foreach>
|
|
</if>
|
|
-- 在职
|
|
<if test="param.status != null and param.status.toString == 'NORMAL'">
|
|
AND em.status in (0,1,2,3)
|
|
</if>
|
|
-- 离职
|
|
<if test="param.status != null and param.status.toString == 'UNAVAILABLE'">
|
|
AND em.status in (4,5,6)
|
|
</if>
|
|
)
|
|
</if>
|
|
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
|
|
id, salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
|
|
creator, create_time, update_time, delete_type, tenant_key
|
|
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
|
|
<select id="list4ConsolidatedTax" resultMap="SalaryAccEmployeeMap">
|
|
SELECT DISTINCT
|
|
<include refid="emp1Column"/>
|
|
FROM (
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
<select id="list4ConsolidatedTax" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT DISTINCT
|
|
<include refid="emp1Column"/>
|
|
FROM (
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
<select id="list4ConsolidatedTax" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT DISTINCT
|
|
<include refid="emp1Column"/>
|
|
FROM (
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
) emp1,
|
|
(
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE
|
|
delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="otherSalaryAcctRecordIds" open="(" separator="," item="otherSalaryAcctRecordId" close=")">
|
|
#{otherSalaryAcctRecordId}
|
|
</foreach>
|
|
) emp2
|
|
WHERE emp1.employee_id = emp2.employee_id AND emp1.tax_agent_id = emp2.tax_agent_id
|
|
</select>
|
|
|
|
<select id="listPage" resultMap="SalaryAccEmployeeMap">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="listPage" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="listPage" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="list" resultMap="SalaryAccEmployeeMap">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="list" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT
|
|
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="list" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT
|
|
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
|
|
<sql id="SalaryAcctEmployeeParamSql">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.taxAgentId != null">
|
|
AND t.tax_agent_id = #{param.taxAgentId}
|
|
</if>
|
|
<if test="(param.employeeName != null and param.employeeName != '')
|
|
or (param.workcode != null and param.workcode != '')
|
|
or (param.subcompanyIds != null and param.subcompanyIds.size()>0)
|
|
or (param.departmentIds != null and param.departmentIds.size()>0)
|
|
or (param.positionIds != null and param.positionIds.size()>0)
|
|
or (param.statuses != null and param.statuses.size()>0)
|
|
or (param.status != null and param.status.toString != 'ALL')">
|
|
AND t.employee_id IN
|
|
(
|
|
SELECT id FROM hrmresource em WHERE em.status not in (7)
|
|
and (em.accounttype is null or em.accounttype = 0)
|
|
<if test="param.employeeName != null and param.employeeName != ''">
|
|
AND em.lastname LIKE CONCAT('%',#{param.employeeName},'%')
|
|
</if>
|
|
<if test="param.workcode != null and param.workcode != ''">
|
|
AND em.workcode like CONCAT('%',#{param.workcode},'%')
|
|
</if>
|
|
-- 分部
|
|
<if test="param.subcompanyIds != null and param.subcompanyIds.size()>0">
|
|
AND em.subcompanyid1 IN
|
|
<foreach collection="param.subcompanyIds" open="(" item="subcompanyId" separator="," close=")">
|
|
#{subcompanyId}
|
|
</foreach>
|
|
</if>
|
|
-- 部门
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND em.departmentid IN
|
|
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
|
|
#{departmentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND em.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
|
|
#{positionId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.statuses != null and param.statuses.size()>0">
|
|
AND em.status IN
|
|
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
|
|
#{userStatus}
|
|
</foreach>
|
|
</if>
|
|
-- 在职
|
|
<if test="param.status != null and param.status.toString == 'NORMAL'">
|
|
AND em.status in (0,1,2,3)
|
|
</if>
|
|
-- 离职(解雇,离职,退休)
|
|
<if test="param.status != null and param.status.toString == 'UNAVAILABLE'">
|
|
AND em.status in (4,5,6)
|
|
</if>
|
|
-- 试用
|
|
<if test="param.status != null and param.status.toString == 'TRIAL'">
|
|
AND em.status in (0)
|
|
</if>
|
|
-- 正式
|
|
<if test="param.status != null and param.status.toString == 'FORMAL'">
|
|
AND em.status in (1)
|
|
</if>
|
|
-- 临时
|
|
<if test="param.status != null and param.status.toString == 'TEMPORARY'">
|
|
AND em.status in (2)
|
|
</if>
|
|
-- 试用延期
|
|
<if test="param.status != null and param.status.toString == 'DELAY'">
|
|
AND em.status in (3)
|
|
</if>
|
|
-- 解雇
|
|
<if test="param.status != null and param.status.toString == 'FIRE'">
|
|
AND em.status in (4)
|
|
</if>
|
|
-- 离职
|
|
<if test="param.status != null and param.status.toString == 'DEPARTURE'">
|
|
AND em.status in (5)
|
|
</if>
|
|
-- 退休
|
|
<if test="param.status != null and param.status.toString == 'RETIRED'">
|
|
AND em.status in (6)
|
|
</if>
|
|
)
|
|
</if>
|
|
</sql>
|
|
<sql id="SalaryAcctEmployeeParamSql" databaseId="oracle">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.taxAgentId != null">
|
|
AND t.tax_agent_id = #{param.taxAgentId}
|
|
</if>
|
|
<if test="(param.employeeName != null and param.employeeName != '')
|
|
or (param.workcode != null and param.workcode != '')
|
|
or (param.subcompanyIds != null and param.subcompanyIds.size()>0)
|
|
or (param.departmentIds != null and param.departmentIds.size()>0)
|
|
or (param.positionIds != null and param.positionIds.size()>0)
|
|
or (param.statuses != null and param.statuses.size()>0)
|
|
or (param.status != null and param.status.toString != 'ALL')">
|
|
AND t.employee_id IN
|
|
(
|
|
SELECT id FROM hrmresource em WHERE em.status not in (7)
|
|
and (em.accounttype is null or em.accounttype = 0)
|
|
<if test="param.employeeName != null and param.employeeName != ''">
|
|
AND em.lastname LIKE '%'||#{param.employeeName}||'%'
|
|
</if>
|
|
<if test="param.workcode != null and param.workcode != ''">
|
|
AND em.workcode like '%'||#{param.workcode}||'%'
|
|
</if>
|
|
<if test="param.subcompanyIds != null and param.subcompanyIds.size()>0">
|
|
AND em.subcompanyid1 IN
|
|
<foreach collection="param.subcompanyIds" open="(" item="subcompanyId" separator="," close=")">
|
|
#{subcompanyId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND em.departmentid IN
|
|
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
|
|
#{departmentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND em.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
|
|
#{positionId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.statuses != null and param.statuses.size()>0">
|
|
AND em.status IN
|
|
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
|
|
#{userStatus}
|
|
</foreach>
|
|
</if>
|
|
-- 在职
|
|
<if test="param.status != null and param.status.toString == 'NORMAL'">
|
|
AND em.status in (0,1,2,3)
|
|
</if>
|
|
-- 离职(解雇,离职,退休)
|
|
<if test="param.status != null and param.status.toString == 'UNAVAILABLE'">
|
|
AND em.status in (4,5,6)
|
|
</if>
|
|
-- 试用
|
|
<if test="param.status != null and param.status.toString == 'TRIAL'">
|
|
AND em.status in (0)
|
|
</if>
|
|
-- 正式
|
|
<if test="param.status != null and param.status.toString == 'FORMAL'">
|
|
AND em.status in (1)
|
|
</if>
|
|
-- 临时
|
|
<if test="param.status != null and param.status.toString == 'TEMPORARY'">
|
|
AND em.status in (2)
|
|
</if>
|
|
-- 试用延期
|
|
<if test="param.status != null and param.status.toString == 'DELAY'">
|
|
AND em.status in (3)
|
|
</if>
|
|
-- 解雇
|
|
<if test="param.status != null and param.status.toString == 'FIRE'">
|
|
AND em.status in (4)
|
|
</if>
|
|
-- 离职
|
|
<if test="param.status != null and param.status.toString == 'DEPARTURE'">
|
|
AND em.status in (5)
|
|
</if>
|
|
-- 退休
|
|
<if test="param.status != null and param.status.toString == 'RETIRED'">
|
|
AND em.status in (6)
|
|
</if>
|
|
)
|
|
</if>
|
|
</sql>
|
|
<sql id="SalaryAcctEmployeeParamSql" databaseId="sqlserver">
|
|
<if test="param.ids != null and param.ids.size()>0">
|
|
AND t.id IN
|
|
<foreach collection="param.ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.taxAgentId != null">
|
|
AND t.tax_agent_id = #{param.taxAgentId}
|
|
</if>
|
|
<if test="(param.employeeName != null and param.employeeName != '')
|
|
or (param.workcode != null and param.workcode != '')
|
|
or (param.subcompanyIds != null and param.subcompanyIds.size()>0)
|
|
or (param.departmentIds != null and param.departmentIds.size()>0)
|
|
or (param.positionIds != null and param.positionIds.size()>0)
|
|
or (param.statuses != null and param.statuses.size()>0)
|
|
or (param.status != null and param.status.toString != 'ALL')">
|
|
AND t.employee_id IN
|
|
(
|
|
SELECT id FROM hrmresource em WHERE em.status not in (7)
|
|
and (em.accounttype is null or em.accounttype = 0)
|
|
<if test="param.employeeName != null and param.employeeName != ''">
|
|
AND em.lastname LIKE '%'+#{param.employeeName}+'%'
|
|
</if>
|
|
<if test="param.workcode != null and param.workcode != ''">
|
|
AND em.workcode like '%'+#{param.workcode}+'%'
|
|
</if>
|
|
<if test="param.subcompanyIds != null and param.subcompanyIds.size()>0">
|
|
AND em.subcompanyid1 IN
|
|
<foreach collection="param.subcompanyIds" open="(" item="subcompanyId" separator="," close=")">
|
|
#{subcompanyId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.departmentIds != null and param.departmentIds.size()>0">
|
|
AND em.departmentid IN
|
|
<foreach collection="param.departmentIds" open="(" item="departmentId" separator="," close=")">
|
|
#{departmentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.positionIds != null and param.positionIds.size()>0">
|
|
AND em.jobtitle IN
|
|
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
|
|
#{positionId}
|
|
</foreach>
|
|
</if>
|
|
<if test="param.statuses != null and param.statuses.size()>0">
|
|
AND em.status IN
|
|
<foreach collection="param.statuses" open="(" item="userStatus" separator="," close=")">
|
|
#{userStatus}
|
|
</foreach>
|
|
</if>
|
|
-- 在职
|
|
<if test="param.status != null and param.status.toString == 'NORMAL'">
|
|
AND em.status in (0,1,2,3)
|
|
</if>
|
|
|
|
-- 离职(解雇,离职,退休)
|
|
<if test="param.status != null and param.status.toString == 'UNAVAILABLE'">
|
|
AND em.status in (4,5,6)
|
|
</if>
|
|
-- 试用
|
|
<if test="param.status != null and param.status.toString == 'TRIAL'">
|
|
AND em.status in (0)
|
|
</if>
|
|
-- 正式
|
|
<if test="param.status != null and param.status.toString == 'FORMAL'">
|
|
AND em.status in (1)
|
|
</if>
|
|
-- 临时
|
|
<if test="param.status != null and param.status.toString == 'TEMPORARY'">
|
|
AND em.status in (2)
|
|
</if>
|
|
-- 试用延期
|
|
<if test="param.status != null and param.status.toString == 'POSTPONE'">
|
|
AND em.status in (3)
|
|
</if>
|
|
-- 解雇
|
|
<if test="param.status != null and param.status.toString == 'FIRE'">
|
|
AND em.status in (4)
|
|
</if>
|
|
-- 离职
|
|
<if test="param.status != null and param.status.toString == 'DEPARTURE'">
|
|
AND em.status in (5)
|
|
</if>
|
|
-- 退休
|
|
<if test="param.status != null and param.status.toString == 'RETIRED'">
|
|
AND em.status in (6)
|
|
</if>
|
|
|
|
)
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="listPage4Reduce" resultMap="SalaryAccEmployeeMap">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="listPage4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT
|
|
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
<select id="listPage4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT
|
|
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
|
|
FROM hrsa_salary_acct_emp t
|
|
LEFT JOIN hrmresource e ON e.id = t.employee_id
|
|
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
|
LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAcctRecordId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
<!-- 排序 -->
|
|
<if test="param.orderRule != null">
|
|
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="list4Reduce" resultMap="SalaryAccEmployeeMap">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAccountingId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
ORDER BY id DESC
|
|
</select>
|
|
<select id="list4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAccountingId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
ORDER BY id DESC
|
|
</select>
|
|
<select id="list4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
|
|
SELECT
|
|
<include refid="SalaryAccEmployeeColumn"/>
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="lastMonSalaryAcctRecordIds" item="salaryAcctRecordId" open="(" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
AND employee_id NOT IN
|
|
(
|
|
SELECT employee_id
|
|
FROM hrsa_salary_acct_emp
|
|
WHERE AND delete_type = 0
|
|
AND salary_acct_record_id = #{param.salaryAccountingId}
|
|
)
|
|
<include refid="SalaryAcctEmployeeParamSql"/>
|
|
ORDER BY id DESC
|
|
</select>
|
|
|
|
<update id="deleteByIds">
|
|
UPDATE hrsa_salary_acct_emp
|
|
SET delete_type = 1
|
|
WHERE delete_type = 0
|
|
AND id IN
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<delete id="deleteBySalaryAcctRecordIds">
|
|
DELETE FROM hrsa_salary_acct_emp
|
|
WHERE delete_type = 0
|
|
AND salary_acct_record_id IN
|
|
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO">
|
|
<result column="id" property="id"/>
|
|
<result column="salary_acct_record_id" property="salaryAcctRecordId"/>
|
|
<result column="salary_sob_id" property="salarySobId"/>
|
|
<result column="employee_id" property="employeeId"/>
|
|
<result column="tax_agent_id" property="taxAgentId"/>
|
|
<result column="salary_month" property="salaryMonth"/>
|
|
<result column="tax_cycle" property="taxCycle"/>
|
|
<result column="creator" property="creator"/>
|
|
<result column="create_time" property="createTime"/>
|
|
<result column="update_time" property="updateTime"/>
|
|
<result column="delete_type" property="deleteType"/>
|
|
<result column="tenant_key" property="tenantKey"/>
|
|
</resultMap>
|
|
|
|
<!-- 表字段 -->
|
|
<sql id="baseColumns">
|
|
t
|
|
.
|
|
id
|
|
, t.salary_acct_record_id
|
|
, t.salary_sob_id
|
|
, t.employee_id
|
|
, t.tax_agent_id
|
|
, t.salary_month
|
|
, t.creator
|
|
, t.create_time
|
|
, t.update_time
|
|
, t.delete_type
|
|
, t.tenant_key
|
|
, t.employee_type
|
|
</sql>
|
|
|
|
|
|
<!-- 条件查询 -->
|
|
<select id="listSome" resultMap="BaseResultMap"
|
|
parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO">
|
|
SELECT
|
|
<include refid="baseColumns"/>
|
|
,r.tax_cycle,b.income_category
|
|
FROM hrsa_salary_acct_emp t
|
|
left join hrsa_salary_acct_record r on t.salary_acct_record_id = r.id
|
|
left join hrsa_salary_sob b on r.salary_sob_id = b.id
|
|
WHERE t.delete_type = 0 and r.delete_type = 0 and b.delete_type = 0
|
|
<if test="id != null">
|
|
AND t.id = #{id}
|
|
</if>
|
|
<if test="salaryAcctRecordId != null">
|
|
AND t.salary_acct_record_id = #{salaryAcctRecordId}
|
|
</if>
|
|
<if test="salarySobId != null">
|
|
AND t.salary_sob_id = #{salarySobId}
|
|
</if>
|
|
<if test="employeeId != null">
|
|
AND t.employee_id = #{employeeId}
|
|
</if>
|
|
<if test="taxAgentId != null">
|
|
AND t.tax_agent_id = #{taxAgentId}
|
|
</if>
|
|
<if test="salaryMonth != null">
|
|
AND t.salary_month = #{salaryMonth}
|
|
</if>
|
|
<if test="taxCycle != null">
|
|
AND r.tax_cycle = #{taxCycle}
|
|
</if>
|
|
<if test="creator != null">
|
|
AND t.creator = #{creator}
|
|
</if>
|
|
<if test="createTime != null">
|
|
AND t.create_time = #{createTime}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
AND t.update_time = #{updateTime}
|
|
</if>
|
|
<if test="deleteType != null">
|
|
AND t.delete_type = #{deleteType}
|
|
</if>
|
|
<if test="tenantKey != null">
|
|
AND t.tenant_key = #{tenantKey}
|
|
</if>
|
|
<if test="ids != null and ids.size()>0">
|
|
AND t.id IN
|
|
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="salaryAcctRecordIds != null and salaryAcctRecordIds.size()>0">
|
|
AND t.salary_acct_record_id IN
|
|
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
|
|
#{salaryAcctRecordId}
|
|
</foreach>
|
|
</if>
|
|
<if test="employeeIds != null and employeeIds.size()>0">
|
|
AND t.employee_id IN
|
|
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
|
|
#{employeeId}
|
|
</foreach>
|
|
</if>
|
|
<if test="taxAgentIds != null and taxAgentIds.size()>0">
|
|
AND t.tax_agent_id IN
|
|
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
|
|
#{taxAgentId}
|
|
</foreach>
|
|
</if>
|
|
<if test="salaryMonths != null and salaryMonths.size()>0">
|
|
AND t.salary_month IN
|
|
<foreach collection="salaryMonths" open="(" item="salaryMonth" separator="," close=")">
|
|
#{salaryMonth}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY t.id DESC
|
|
</select>
|
|
|
|
|
|
<!-- 根据主键获取单条记录 -->
|
|
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
|
SELECT
|
|
<include refid="baseColumns"/>
|
|
FROM hrsa_salary_acct_emp t
|
|
WHERE id = #{id} AND delete_type = 0
|
|
</select>
|
|
</mapper>
|