weaver-hrm-salary/src/com/engine/salary/mapper/salaryacct/SalaryAcctEmployeeMapper.xml

1176 lines
47 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"/>
</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">
id
, salary_acct_record_id, salary_sob_id, employee_id, tax_agent_id, salary_month,
creator, create_time, update_time, delete_type, tenant_key
</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
</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)
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}
)
</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)
<foreach collection="collection" item="emp" separator="union all">
select
#{emp.salaryAcctRecordId},
#{emp.salarySobId},
#{emp.employeeId},
#{emp.taxAgentId},
#{emp.salaryMonth},
#{emp.creator},
#{emp.createTime},
#{emp.updateTime},
#{emp.deleteType},
#{emp.tenantKey}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
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)
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}
)
</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
WHERE
delete_type = 0
AND salary_acct_record_id = #{param.salaryAcctRecordId}
<include refid="SalaryAcctEmployeeParamSql"/>
) emp1,
(
SELECT
<include refid="SalaryAccEmployeeColumn"/>
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="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
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
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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</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
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
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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</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
WHERE
delete_type = 0
AND salary_acct_record_id = #{param.salaryAcctRecordId}
<include refid="SalaryAcctEmployeeParamSql"/>
) emp1,
(
SELECT
<include refid="SalaryAccEmployeeColumn"/>
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" 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
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
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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</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" 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
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
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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</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="listPage" resultMap="SalaryAccEmployeeMap">
SELECT
<include refid="SalaryAccEmployeeColumn"/>
FROM hrsa_salary_acct_emp
WHERE delete_type = 0
AND salary_acct_record_id = #{param.salaryAcctRecordId}
<include refid="SalaryAcctEmployeeParamSql"/>
ORDER BY id DESC
</select>
<select id="listPage" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
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 = #{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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<select id="listPage" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
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 = #{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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<select id="list" resultMap="SalaryAccEmployeeMap">
SELECT
<include refid="SalaryAccEmployeeColumn"/>
FROM hrsa_salary_acct_emp
WHERE delete_type = 0
AND salary_acct_record_id = #{param.salaryAcctRecordId}
<include refid="SalaryAcctEmployeeParamSql"/>
ORDER BY id DESC
</select>
<select id="list" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
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 = #{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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<select id="list" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
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 = #{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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<sql id="SalaryAcctEmployeeParamSql">
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE CONCAT('%',#{param.employeeName},'%')
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
</sql>
<sql id="SalaryAcctEmployeeParamSql" databaseId="oracle">
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
</sql>
<sql id="SalaryAcctEmployeeParamSql" databaseId="sqlserver">
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
</sql>
<select id="listPage4Reduce" 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.salaryAcctRecordId}
)
<include refid="SalaryAcctEmployeeParamSql"/>
ORDER BY id DESC
</select>
<select id="listPage4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="oracle">
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="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}
)
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<select id="listPage4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
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="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}
)
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</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
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="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}
)
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'||#{param.employeeName}||'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
ORDER BY id DESC
</select>
<select id="list4Reduce" resultMap="SalaryAccEmployeeMap" databaseId="sqlserver">
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="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}
)
<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.departmentIds != null and param.departmentIds.size()>0)
or (param.positionIds != null and param.positionIds.size()>0)
or (param.status != null and param.status != 'ALL')">
AND employee_id IN
(
SELECT id FROM {$publicdb}.employee em WHERE 1=1
<if test="param.employeeName != null and param.employeeName != ''">
AND em.username LIKE '%'+#{param.employeeName}+'%'
</if>
<if test="param.departmentIds != null and param.departmentIds.size()>0">
AND em.department 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.position IN
<foreach collection="param.positionIds" open="(" item="positionId" separator="," close=")">
#{positionId}
</foreach>
</if>
<if test="param.status != null and param.status != 'ALL'">
AND em.status = #{param.status}
</if>
)
</if>
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="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
</sql>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_acct_emp t
WHERE delete_type = 0
<if test="id != null">
AND id = #{id}
</if>
<if test="salaryAcctRecordId != null">
AND salary_acct_record_id = #{salaryAcctRecordId}
</if>
<if test="salarySobId != null">
AND salary_sob_id = #{salarySobId}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="salaryMonth != null">
AND salary_month = #{salaryMonth}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="salaryAcctRecordIds != null and salaryAcctRecordIds.size()>0">
AND 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 employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
ORDER BY 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>