<?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.yifu.cloud.plus.v1.business.mapper.salary.TBusSalaryMapper">
    <resultMap id="tBusSalaryMap" type="com.yifu.cloud.plus.v1.business.entity.salary.TBusSalary">
        <id property="id" column="id"/>
        <result property="teleNo" column="tele_no"/>
        <result property="empName" column="emp_name"/>
        <result property="empIdCard" column="emp_id_card"/>
        <result property="deptId" column="dept_id"/>
        <result property="deptLevel" column="dept_level"/>
        <result property="deptName" column="dept_name"/>
        <result property="deptTreeLogo" column="dept_tree_logo"/>
        <result property="post" column="post"/>
        <result property="salaryMonth" column="salary_month"/>
        <result property="relaySalary" column="relay_salary"/>
        <result property="relayIncent" column="relay_incent"/>
        <result property="relayOther" column="relay_other"/>
        <result property="relaySum" column="relay_sum"/>
        <result property="withholidPersonSocial" column="withholid_person_social"/>
        <result property="withholidPersonFund" column="withholid_person_fund"/>
        <result property="withholidPersonTax" column="withholid_person_tax"/>
        <result property="withholidOther" column="withholid_other"/>
        <result property="withholidSum" column="withholid_sum"/>
        <result property="actualSalary" column="actual_salary"/>
        <result property="unitSocial" column="unit_social"/>
        <result property="unitFund" column="unit_fund"/>
        <result property="createUserId" column="create_user_id"/>
        <result property="createUserName" column="create_user_name"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <sql id="Base_Column_List">
             a.id,
                  a.tele_no,
                  a.emp_name,
                  a.emp_id_card,
                  a.dept_id,
                  a.dept_level,
                  a.dept_name,
                  a.dept_tree_logo,
                  a.post,
                  a.salary_month,
                  a.relay_salary,
                  a.relay_incent,
                  a.relay_other,
                  a.relay_sum,
                  a.withholid_person_social,
                  a.withholid_person_fund,
                  a.withholid_person_tax,
                  a.withholid_other,
                  a.withholid_sum,
                  a.actual_salary,
                  a.unit_social,
                  a.unit_fund,
                  a.create_user_id,
                  a.create_user_name,
                  a.create_time
         </sql>
    <sql id="tBusSalary_where">
        <if test="tBusSalary != null">
            <if test="tBusSalary.id != null and tBusSalary.id.trim() != ''">
                AND a.id = #{tBusSalary.id}
            </if>
            <if test="tBusSalary.teleNo != null and tBusSalary.teleNo.trim() != ''">
                AND a.tele_no = #{tBusSalary.teleNo}
            </if>
            <if test="tBusSalary.empName != null and tBusSalary.empName.trim() != ''">
                AND a.emp_name like concat('%',#{tBusSalary.empName}, '%')
            </if>
            <if test="tBusSalary.empIdCard != null and tBusSalary.empIdCard.trim() != ''">
                AND a.emp_id_card like concat(#{tBusSalary.empIdCard}, '%')
            </if>
            /* 查找部门树以及底下的数据 */
            <if test="tBusSalary.deptId != null and tBusSalary.deptId != 1">
                AND (a.dept_id = #{tBusSalary.deptId} or a.dept_tree_logo like concat('%-', #{tBusSalary.deptId},'-%'))
            </if>
            <if test="tBusSalary.deptLevel != null">
                AND a.dept_level = #{tBusSalary.deptLevel}
            </if>
            <if test="tBusSalary.deptName != null and tBusSalary.deptName.trim() != ''">
                AND a.dept_name like concat('%', #{tBusSalary.deptName}, '%')
            </if>
            <if test="tBusSalary.deptTreeLogo != null and tBusSalary.deptTreeLogo.trim() != ''">
                AND a.dept_tree_logo = #{tBusSalary.deptTreeLogo}
            </if>
            <if test="tBusSalary.post != null and tBusSalary.post.trim() != ''">
                AND a.post = #{tBusSalary.post}
            </if>
            <if test="tBusSalary.salaryMonth != null and tBusSalary.salaryMonth.trim() != ''">
                AND a.salary_month = #{tBusSalary.salaryMonth}
            </if>
            <if test="tBusSalary.relaySalary != null">
                AND a.relay_salary = #{tBusSalary.relaySalary}
            </if>
            <if test="tBusSalary.relayIncent != null">
                AND a.relay_incent = #{tBusSalary.relayIncent}
            </if>
            <if test="tBusSalary.relayOther != null">
                AND a.relay_other = #{tBusSalary.relayOther}
            </if>
            <if test="tBusSalary.relaySum != null">
                AND a.relay_sum = #{tBusSalary.relaySum}
            </if>
            <if test="tBusSalary.withholidPersonSocial != null">
                AND a.withholid_person_social = #{tBusSalary.withholidPersonSocial}
            </if>
            <if test="tBusSalary.withholidPersonFund != null">
                AND a.withholid_person_fund = #{tBusSalary.withholidPersonFund}
            </if>
            <if test="tBusSalary.withholidPersonTax != null">
                AND a.withholid_person_tax = #{tBusSalary.withholidPersonTax}
            </if>
            <if test="tBusSalary.withholidOther != null">
                AND a.withholid_other = #{tBusSalary.withholidOther}
            </if>
            <if test="tBusSalary.withholidSum != null">
                AND a.withholid_sum = #{tBusSalary.withholidSum}
            </if>
            <if test="tBusSalary.actualSalary != null">
                AND a.actual_salary = #{tBusSalary.actualSalary}
            </if>
            <if test="tBusSalary.unitSocial != null">
                AND a.unit_social = #{tBusSalary.unitSocial}
            </if>
            <if test="tBusSalary.unitFund != null">
                AND a.unit_fund = #{tBusSalary.unitFund}
            </if>
            <if test="tBusSalary.createUserId != null and tBusSalary.createUserId.trim() != ''">
                AND a.create_user_id = #{tBusSalary.createUserId}
            </if>
            <if test="tBusSalary.createUserName != null and tBusSalary.createUserName.trim() != ''">
                AND a.create_user_name = #{tBusSalary.createUserName}
            </if>
            <if test="tBusSalary.createTime != null">
                AND a.create_time = #{tBusSalary.createTime}
            </if>
        </if>
    </sql>
    <!--tBusSalary简单分页查询-->
    <select id="getTBusSalaryPage" resultMap="tBusSalaryMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_salary a
        <where>
            1=1
            <include refid="tBusSalary_where"/>
        </where>
    </select>
    <!--tBusSalary导出-->
    <select id="doExport" resultMap="tBusSalaryMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_salary a
        <where>
            1=1
            <if test="idList != null and idList.size > 0">
                AND a.id in
                <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="idList == null or idList.size == 0">
                <include refid="tBusSalary_where"/>
            </if>
        </where>
    </select>
</mapper>
