weaver-hrm-salary/src/com/engine/salary/mapper/employeedeclare/EmployeeDeclareMapper.xml

1047 lines
35 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.employeedeclare.EmployeeDeclareMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
<result column="id" property="id"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="tax_cycle" property="taxCycle"/>
<result column="employee_id" property="employeeId"/>
<result column="employee_type" property="employeeType"/>
<result column="employee_name" property="employeeName"/>
<result column="job_num" property="jobNum"/>
<result column="nationality" property="nationality"/>
<result column="card_type" property="cardType"/>
<result column="card_num" property="cardNum"/>
<result column="gender" property="gender"/>
<result column="birthday" property="birthday"/>
<result column="employment_status" property="employmentStatus"/>
<result column="mobile" property="mobile"/>
<result column="employment_type" property="employmentType"/>
<result column="employment_first_year" property="employmentFirstYear"/>
<result column="employment_date" property="employmentDate"/>
<result column="dismiss_date" property="dismissDate"/>
<result column="reissue_salary" property="reissueSalary"/>
<result column="reissue_tax_cycle" property="reissueTaxCycle"/>
<result column="disability" property="disability"/>
<result column="entry_date" property="entryDate"/>
<result column="departure_date" property="departureDate"/>
<result column="disability_card_no" property="disabilityCardNo"/>
<result column="lonely_old" property="lonelyOld"/>
<result column="martyr_dependents" property="martyrDependents"/>
<result column="martyr_dependents_card_no" property="martyrDependentsCardNo"/>
<result column="deduct_expenses" property="deductExpenses"/>
<result column="successfully_declared" property="successfullyDeclared"/>
<result column="new_employee_info" property="newEmployeeInfo"/>
<result column="declare_status" property="declareStatus"/>
<result column="declare_error_msg" property="declareErrorMsg"/>
<result column="tenant_key" property="tenantKey"/>
<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="birthplace" property="birthplace"/>
<result column="tax_reasons" property="taxReasons"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.tax_agent_id
, t.tax_cycle
, t.employee_id
, t.employee_type
, t.employee_name
, t.job_num
, t.nationality
, t.card_type
, t.card_num
, t.gender
, t.birthday
, t.employment_status
, t.mobile
, t.employment_type
, t.employment_first_year
, t.employment_date
, t.dismiss_date
, t.reissue_salary
, t.reissue_tax_cycle
, t.entry_date
, t.departure_date
, t.disability
, t.disability_card_no
, t.lonely_old
, t.martyr_dependents
, t.martyr_dependents_card_no
, t.deduct_expenses
, t.successfully_declared
, t.new_employee_info
, t.declare_status
, t.declare_error_msg
, t.tenant_key
, t.creator
, t.delete_type
, t.create_time
, t.update_time
, t.birthplace
, t.tax_reasons
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE delete_type = 0
<if test="id != null">
AND id = #{id}
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="taxCycle != null">
AND tax_cycle = #{taxCycle}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="employeeType != null">
AND employee_type = #{employeeType}
</if>
<if test="employeeName != null">
AND employee_name = #{employeeName}
</if>
<if test="jobNum != null">
AND job_num = #{jobNum}
</if>
<if test="nationality != null">
AND nationality = #{nationality}
</if>
<if test="cardType != null">
AND card_type = #{cardType}
</if>
<if test="cardNum != null">
AND card_num = #{cardNum}
</if>
<if test="gender != null">
AND gender = #{gender}
</if>
<if test="birthday != null">
AND birthday = #{birthday}
</if>
<if test="employmentStatus != null">
AND employment_status = #{employmentStatus}
</if>
<if test="mobile != null">
AND mobile = #{mobile}
</if>
<if test="employmentType != null">
AND employment_type = #{employmentType}
</if>
<if test="employmentFirstYear != null">
AND employment_first_year = #{employmentFirstYear}
</if>
<if test="employmentDate != null">
AND employment_date = #{employmentDate}
</if>
<if test="dismissDate != null">
AND dismiss_date = #{dismissDate}
</if>
<if test="reissueSalary != null">
AND reissue_salary = #{reissueSalary}
</if>
<if test="reissueTaxCycle != null">
AND reissue_tax_cycle = #{reissueTaxCycle}
</if>
<if test="disability != null">
AND disability = #{disability}
</if>
<if test="disabilityCardNo != null">
AND disability_card_no = #{disabilityCardNo}
</if>
<if test="lonelyOld != null">
AND lonely_old = #{lonelyOld}
</if>
<if test="martyrDependents != null">
AND martyr_dependents = #{martyrDependents}
</if>
<if test="martyrDependentsCardNo != null">
AND martyr_dependents_card_no = #{martyrDependentsCardNo}
</if>
<if test="deductExpenses != null">
AND deduct_expenses = #{deductExpenses}
</if>
<if test="successfullyDeclared != null">
AND successfully_declared = #{successfullyDeclared}
</if>
<if test="newEmployeeInfo != null">
AND new_employee_info = #{newEmployeeInfo}
</if>
<if test="declareStatus != null">
AND declare_status = #{declareStatus}
</if>
<if test="declareErrorMsg != null">
AND declare_error_msg = #{declareErrorMsg}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</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="employeeIds != null and employeeIds.size()>0">
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</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="taxAgentIds != null and taxAgentIds.size()>0">
AND tax_agent_id IN
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
#{taxAgentId}
</foreach>
</if>
ORDER BY id DESC
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
INSERT INTO hrsa_employee_declare
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="taxCycle != null">
tax_cycle,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="employeeType != null">
employee_type,
</if>
<if test="employeeName != null">
employee_name,
</if>
<if test="jobNum != null">
job_num,
</if>
<if test="nationality != null">
nationality,
</if>
<if test="cardType != null">
card_type,
</if>
<if test="cardNum != null">
card_num,
</if>
<if test="gender != null">
gender,
</if>
<if test="birthday != null">
birthday,
</if>
<if test="employmentStatus != null">
employment_status,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="employmentType != null">
employment_type,
</if>
<if test="employmentFirstYear != null">
employment_first_year,
</if>
<if test="employmentDate != null">
employment_date,
</if>
<if test="dismissDate != null">
dismiss_date,
</if>
<if test="reissueSalary != null">
reissue_salary,
</if>
<if test="reissueTaxCycle != null">
reissue_tax_cycle,
</if>
<if test="entryDate != null">
entry_date,
</if>
<if test="departureDate != null">
departure_date,
</if>
<if test="disability != null">
disability,
</if>
<if test="disabilityCardNo != null">
disability_card_no,
</if>
<if test="lonelyOld != null">
lonely_old,
</if>
<if test="martyrDependents != null">
martyr_dependents,
</if>
<if test="martyrDependentsCardNo != null">
martyr_dependents_card_no,
</if>
<if test="deductExpenses != null">
deduct_expenses,
</if>
<if test="successfullyDeclared != null">
successfully_declared,
</if>
<if test="newEmployeeInfo != null">
new_employee_info,
</if>
<if test="declareStatus != null">
declare_status,
</if>
<if test="declareErrorMsg != null">
declare_error_msg,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="birthplace != null">
birthplace,
</if>
<if test="taxReasons != null">
tax_reasons,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="taxCycle != null">
#{taxCycle},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="employeeType != null">
#{employeeType},
</if>
<if test="employeeName != null">
#{employeeName},
</if>
<if test="jobNum != null">
#{jobNum},
</if>
<if test="nationality != null">
#{nationality},
</if>
<if test="cardType != null">
#{cardType},
</if>
<if test="cardNum != null">
#{cardNum},
</if>
<if test="gender != null">
#{gender},
</if>
<if test="birthday != null">
#{birthday},
</if>
<if test="employmentStatus != null">
#{employmentStatus},
</if>
<if test="mobile != null">
#{mobile},
</if>
<if test="employmentType != null">
#{employmentType},
</if>
<if test="employmentFirstYear != null">
#{employmentFirstYear},
</if>
<if test="employmentDate != null">
#{employmentDate},
</if>
<if test="dismissDate != null">
#{dismissDate},
</if>
<if test="reissueSalary != null">
#{reissueSalary},
</if>
<if test="reissueTaxCycle != null">
#{reissueTaxCycle},
</if>
<if test="entryDate != null">
#{entryDate},
</if>
<if test="departureDate != null">
#{departureDate},
</if>
<if test="disability != null">
#{disability},
</if>
<if test="disabilityCardNo != null">
#{disabilityCardNo},
</if>
<if test="lonelyOld != null">
#{lonelyOld},
</if>
<if test="martyrDependents != null">
#{martyrDependents},
</if>
<if test="martyrDependentsCardNo != null">
#{martyrDependentsCardNo},
</if>
<if test="deductExpenses != null">
#{deductExpenses},
</if>
<if test="successfullyDeclared != null">
#{successfullyDeclared},
</if>
<if test="newEmployeeInfo != null">
#{newEmployeeInfo},
</if>
<if test="declareStatus != null">
#{declareStatus},
</if>
<if test="declareErrorMsg != null">
#{declareErrorMsg},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="birthplace != null">
#{birthplace},
</if>
<if test="taxReasons != null">
#{taxReasons},
</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO hrsa_employee_declare
(
birthday,
card_num,
nationality,
card_type,
create_time,
creator,
declare_error_msg,
declare_status,
deduct_expenses,
delete_type,
disability,
disability_card_no,
dismiss_date,
reissue_salary,
reissue_tax_cycle,
entry_date,
departure_date,
employee_id,
employee_name,
employee_type,
employment_date,
employment_first_year,
employment_status,
employment_type,
gender,
id,
job_Num,
lonely_old,
martyr_dependents,
martyr_dependents_card_no,
mobile,
new_employee_info,
successfully_declared,
tax_agent_id,
tax_cycle,
tenant_key,
update_time,
birthplace,
tax_reasons
)
VALUES
<foreach collection="collection" item="item" separator=",">(
#{item.birthday},
#{item.cardNum},
#{item.nationality},
#{item.cardType},
#{item.createTime},
#{item.creator},
#{item.declareErrorMsg},
#{item.declareStatus},
#{item.deductExpenses},
#{item.deleteType},
#{item.disability},
#{item.disabilityCardNo},
#{item.dismissDate},
#{item.reissueSalary},
#{item.reissueTaxCycle},
#{item.entryDate},
#{item.departureDate},
#{item.employeeId},
#{item.employeeName},
#{item.employeeType},
#{item.employmentDate},
#{item.employmentFirstYear},
#{item.employmentStatus},
#{item.employmentType},
#{item.gender},
#{item.id},
#{item.jobNum},
#{item.lonelyOld},
#{item.martyrDependents},
#{item.martyrDependentsCardNo},
#{item.mobile},
#{item.newEmployeeInfo},
#{item.successfullyDeclared},
#{item.taxAgentId},
#{item.taxCycle},
#{item.tenantKey},
#{item.updateTime},
#{item.birthplace},
#{item.taxReasons}
)
</foreach>
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_employee_declare (
birthday,
card_num,
nationality,
card_type,
create_time,
creator,
declare_error_msg,
declare_status,
deduct_expenses,
delete_type,
disability,
disability_card_no,
dismiss_date,
reissue_salary,
reissue_tax_cycle,
entry_date,
departure_date,
employee_id,
employee_name,
employee_type,
employment_date,
employment_first_year,
employment_status,
employment_type,
gender,
id,
job_Num,
lonely_old,
martyr_dependents,
martyr_dependents_card_no,
mobile,
new_employee_info,
successfully_declared,
tax_agent_id,
tax_cycle,
tenant_key,
update_time,
birthplace,
tax_reasons
)
<foreach collection="collection" item="item" separator="union all">
select
#{item.birthday,jdbcType=DATE},
#{item.cardNum,jdbcType=VARCHAR},
#{item.nationality,jdbcType=VARCHAR},
#{item.cardType,jdbcType=INTEGER},
#{item.createTime,jdbcType=DATE},
#{item.creator,jdbcType=DOUBLE},
#{item.declareErrorMsg,jdbcType=VARCHAR},
#{item.declareStatus,jdbcType=INTEGER},
#{item.deductExpenses,jdbcType=INTEGER},
#{item.deleteType,jdbcType=INTEGER},
#{item.disability,jdbcType=INTEGER},
#{item.disabilityCardNo,jdbcType=VARCHAR},
#{item.dismissDate,jdbcType=DATE},
#{item.reissueSalary,jdbcType=INTEGER},
#{item.reissueTaxCycle,jdbcType=DATE},
#{item.entryDate,jdbcType=DATE},
#{item.departureDate,jdbcType=DATE},
#{item.employeeId,jdbcType=DOUBLE},
#{item.employeeName,jdbcType=VARCHAR},
#{item.employeeType,jdbcType=INTEGER},
#{item.employmentDate,jdbcType=DATE},
#{item.employmentFirstYear,jdbcType=VARCHAR},
#{item.employmentStatus,jdbcType=INTEGER},
#{item.employmentType,jdbcType=INTEGER},
#{item.gender,jdbcType=INTEGER},
#{item.id,jdbcType=DOUBLE},
#{item.jobNum,jdbcType=VARCHAR},
#{item.lonelyOld,jdbcType=INTEGER},
#{item.martyrDependents,jdbcType=INTEGER},
#{item.martyrDependentsCardNo,jdbcType=VARCHAR},
#{item.mobile,jdbcType=VARCHAR},
#{item.newEmployeeInfo,jdbcType=INTEGER},
#{item.successfullyDeclared,jdbcType=INTEGER},
#{item.taxAgentId,jdbcType=DOUBLE},
#{item.taxCycle,jdbcType=DATE},
#{item.tenantKey,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=DATE},
#{item.birthplace,jdbcType=VARCHAR},
#{item.taxReasons,jdbcType=VARCHAR}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
<foreach collection="collection" item="item" separator=";">
INSERT INTO hrsa_employee_declare (
birthday,
card_num,
nationality,
card_type,
create_time,
creator,
declare_error_msg,
declare_status,
deduct_expenses,
delete_type,
disability,
disability_card_no,
dismiss_date,
reissue_salary,
reissue_tax_cycle,
entry_date,
departure_date,
employee_id,
employee_name,
employee_type,
employment_date,
employment_first_year,
employment_status,
employment_type,
gender,
id,
job_Num,
lonely_old,
martyr_dependents,
martyr_dependents_card_no,
mobile,
new_employee_info,
successfully_declared,
tax_agent_id,
tax_cycle,
tenant_key,
update_time,
birthplace,
tax_reasons
)
VALUES
(
#{item.birthday},
#{item.cardNum},
#{item.nationality},
#{item.cardType},
#{item.createTime},
#{item.creator},
#{item.declareErrorMsg},
#{item.declareStatus},
#{item.deductExpenses},
#{item.deleteType},
#{item.disability},
#{item.disabilityCardNo},
#{item.dismissDate},
#{item.reissueSalary},
#{item.reissueTaxCycle},
#{item.entryDate},
#{item.departureDate},
#{item.employeeId},
#{item.employeeName},
#{item.employeeType},
#{item.employmentDate},
#{item.employmentFirstYear},
#{item.employmentStatus},
#{item.employmentType},
#{item.gender},
#{item.id},
#{item.jobNum},
#{item.lonelyOld},
#{item.martyrDependents},
#{item.martyrDependentsCardNo},
#{item.mobile},
#{item.newEmployeeInfo},
#{item.successfullyDeclared},
#{item.taxAgentId},
#{item.taxCycle},
#{item.tenantKey},
#{item.updateTime},
#{item.birthplace},
#{item.taxReasons}
)
</foreach>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
UPDATE hrsa_employee_declare
<set>
tax_agent_id=#{taxAgentId},
tax_cycle=#{taxCycle},
employee_id=#{employeeId},
employee_type=#{employeeType},
employee_name=#{employeeName},
job_num=#{jobNum},
nationality=#{nationality},
card_type=#{cardType},
card_num=#{cardNum},
gender=#{gender},
birthday=#{birthday},
employment_status=#{employmentStatus},
mobile=#{mobile},
employment_type=#{employmentType},
employment_first_year=#{employmentFirstYear},
employment_date=#{employmentDate},
dismiss_date=#{dismissDate},
reissue_salary=#{reissueSalary},
reissue_tax_cycle=#{reissueTaxCycle},
entry_date=#{entryDate},
departure_date=#{departureDate},
disability=#{disability},
disability_card_no=#{disabilityCardNo},
lonely_old=#{lonelyOld},
martyr_dependents=#{martyrDependents},
martyr_dependents_card_no=#{martyrDependentsCardNo},
deduct_expenses=#{deductExpenses},
successfully_declared=#{successfullyDeclared},
new_employee_info=#{newEmployeeInfo},
declare_status=#{declareStatus},
declare_error_msg=#{declareErrorMsg},
tenant_key=#{tenantKey},
creator=#{creator},
delete_type=#{deleteType},
create_time=#{createTime},
update_time=#{updateTime},
birthplace=#{birthplace},
tax_reasons=#{taxReasons},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
UPDATE hrsa_employee_declare
<set>
<if test="taxAgentId != null">
tax_agent_id=#{taxAgentId},
</if>
<if test="taxCycle != null">
tax_cycle=#{taxCycle},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="employeeType != null">
employee_type=#{employeeType},
</if>
<if test="employeeName != null">
employee_name=#{employeeName},
</if>
<if test="jobNum != null">
job_num=#{jobNum},
</if>
<if test="nationality != null">
nationality=#{nationality},
</if>
<if test="cardType != null">
card_type=#{cardType},
</if>
<if test="cardNum != null">
card_num=#{cardNum},
</if>
<if test="gender != null">
gender=#{gender},
</if>
<if test="birthday != null">
birthday=#{birthday},
</if>
<if test="employmentStatus != null">
employment_status=#{employmentStatus},
</if>
<if test="mobile != null">
mobile=#{mobile},
</if>
<if test="employmentType != null">
employment_type=#{employmentType},
</if>
<if test="employmentFirstYear != null">
employment_first_year=#{employmentFirstYear},
</if>
<if test="employmentDate != null">
employment_date=#{employmentDate},
</if>
dismiss_date=#{dismissDate},
reissue_salary=#{reissueSalary},
reissue_tax_cycle=#{reissueTaxCycle},
entry_date=#{entryDate},
departure_date=#{departureDate},
birthplace=#{birthplace},
tax_reasons=#{taxReasons},
<if test="disability != null">
disability=#{disability},
</if>
<if test="disabilityCardNo != null">
disability_card_no=#{disabilityCardNo},
</if>
<if test="lonelyOld != null">
lonely_old=#{lonelyOld},
</if>
<if test="martyrDependents != null">
martyr_dependents=#{martyrDependents},
</if>
<if test="martyrDependentsCardNo != null">
martyr_dependents_card_no=#{martyrDependentsCardNo},
</if>
<if test="deductExpenses != null">
deduct_expenses=#{deductExpenses},
</if>
<if test="successfullyDeclared != null">
successfully_declared=#{successfullyDeclared},
</if>
<if test="newEmployeeInfo != null">
new_employee_info=#{newEmployeeInfo},
</if>
<if test="declareStatus != null">
declare_status=#{declareStatus},
</if>
<if test="declareErrorMsg != null">
declare_error_msg=#{declareErrorMsg},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO">
UPDATE hrsa_employee_declare
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<delete id="deleteByIds">
UPDATE hrsa_employee_declare
SET delete_type=1,
update_time = #{date}
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" separator="," item="id" close=")">
#{id}
</foreach>
</if>
</delete>
<sql id="KeywordSql" databaseId="mysql">
<if test="param.keyword != null and param.keyword != ''">
AND (employee_name LIKE CONCAT('%',#{param.keyword},'%') OR job_num LIKE CONCAT('%',#{param.keyword},'%'))
</if>
</sql>
<sql id="KeywordSql" databaseId="oracle">
<if test="param.keyword != null and param.keyword != ''">
AND (employee_name LIKE '%'||#{param.keyword}||'%' OR job_num LIKE '%'||#{param.keyword}||'%')
</if>
</sql>
<sql id="KeywordSql" databaseId="postgresql">
<if test="param.keyword != null and param.keyword != ''">
AND (employee_name LIKE '%'||#{param.keyword}||'%' OR job_num LIKE '%'||#{param.keyword}||'%')
</if>
</sql>
<sql id="KeywordSql" databaseId="sqlserver">
<if test="param.keyword != null and param.keyword != ''">
AND (employee_name LIKE '%'+#{param.keyword}+'%' OR job_num LIKE '%'+#{param.keyword}+'%')
</if>
</sql>
<sql id="ParamSql">
AND tax_agent_id = #{param.taxAgentId}
AND tax_cycle = #{param.taxCycle}
<if test="param.ids != null and param.ids.size()>0">
AND id IN
<foreach collection="param.ids" open="(" separator="," item="id" close=")">
#{id}
</foreach>
</if>
<if test="param.declareStatus != null">
AND declare_status = #{param.declareStatus.value}
</if>
<if test="param.employeeId != null">
AND employee_id=#{param.employeeId}
</if>
<if test="param.employmentStatus != null">
AND employment_status = #{param.employmentStatus.value}
</if>
<if test="param.employmentType != null">
AND employment_type = #{param.employmentType.value}
</if>
<if test="param.fromEmploymentDate != null">
AND employment_date >= #{param.fromEmploymentDate}
</if>
<if test="param.endEmploymentDate != null">
AND #{param.endEmploymentDate} >= employment_date
</if>
<if test="param.fromDismissDate != null">
AND dismiss_date >= #{param.fromDismissDate}
</if>
<if test="param.endDismissDate != null">
AND #{param.endDismissDate} >= dismiss_date
</if>
<if test="param.disability != null">
AND disability = #{param.disability.value}
</if>
<if test="param.lonelyOld != null">
AND lonely_old = #{param.lonelyOld.value}
</if>
<if test="param.martyrDependents != null">
AND martyr_dependents = #{param.martyrDependents.value}
</if>
<if test="param.deductExpenses != null">
AND deduct_expenses = #{param.deductExpenses.value}
</if>
<!-- <if test="param.departmentIds != null and param.departmentIds.size()>0">-->
<!-- AND employee_type = 0 and employee_id IN (select id from {$publicdb}.employee emp where emp.department in (-->
<!-- <foreach collection="param.departmentIds" item="departmentId" separator=",">-->
<!-- #{departmentId}-->
<!-- </foreach>-->
<!-- ))-->
<!-- </if>-->
<!-- <if test="param.positionIds != null and param.positionIds.size()>0">-->
<!-- AND employee_type = 0 and employee_id IN (select id from {$publicdb}.employee emp where emp.position in (-->
<!-- <foreach collection="param.positionIds" item="positionId" separator=",">-->
<!-- #{positionId}-->
<!-- </foreach>-->
<!-- ))-->
<!-- </if>-->
<include refid="KeywordSql"/>
</sql>
<select id="listByParam" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE delete_type = 0
<include refid="ParamSql"/>
</select>
<select id="list4AddByParam" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE delete_type = 0
<include refid="ParamSql"/>
AND employee_id NOT IN (
SELECT employee_id
FROM hrsa_employee_declare
WHERE delete_type = 0
AND tax_agent_id = #{param.taxAgentId}
AND tax_cycle = #{param.preTaxCycle}
)
</select>
<select id="list4UpdateByParam" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_employee_declare t
WHERE delete_type = 0
AND new_employee_info = 1
<include refid="ParamSql"/>
</select>
</mapper>