<?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.dgtly.sync.mapper.MetaEmployeeMapper">
    
    <resultMap type="MetaEmployee" id="MetaEmployeeResult">
        <result property="name"    column="name"    />
        <result property="loginName"    column="login_name"    />
        <result property="email"    column="email"    />
        <result property="mobile"    column="mobile"    />
        <result property="sapEmployeeId"    column="sap_employee_id"    />
        <result property="sapCostCenterCode"    column="sap_cost_center_code"    />
        <result property="sapCostCenter"    column="sap_cost_center"    />
        <result property="sapCompanyCode"    column="sap_company_code"    />
        <result property="status"    column="status"    />
        <result property="contract"    column="contract"    />
        <result property="contractName"    column="contract_name"    />
        <result property="contractBegin"    column="contract_begin"    />
        <result property="duty"    column="duty"    />
        <result property="dutyName"    column="duty_name"    />
        <result property="org"    column="org"    />
        <result property="orgName"    column="org_name"    />
        <result property="employeePost"    column="employee_post"    />
        <result property="employeePostName"    column="employee_post_name"    />
        <result property="posty"    column="posty"    />
        <result property="poste"    column="poste"    />
        <result property="posnc"    column="posnc"    />
        <result property="bossEmployeeId"    column="boss_employee_id"    />
        <result property="bossName"    column="boss_name"    />
        <result property="bossEmployeePost"    column="boss_employee_post"    />
        <result property="sex"    column="sex"    />
        <result property="objid1"    column="objid_1"    />
        <result property="stext1"    column="stext_1"    />
        <result property="objid2"    column="objid_2"    />
        <result property="stext2"    column="stext_2"    />
        <result property="objid3"    column="objid_3"    />
        <result property="stext3"    column="stext_3"    />
        <result property="objid4"    column="objid_4"    />
        <result property="stext4"    column="stext_4"    />
        <result property="objid5"    column="objid_5"    />
        <result property="stext5"    column="stext_5"    />
        <result property="objid6"    column="objid_6"    />
        <result property="stext6"    column="stext_6"    />
        <result property="objid7"    column="objid_7"    />
        <result property="stext7"    column="stext_7"    />
        <result property="objidQy"    column="objid_qy"    />
        <result property="stextQy"    column="stext_qy"    />
        <result property="etlCreatime"    column="etl_creatime"    />
        <result property="dataversion"    column="dataversion"    />
        <result property="lineId"    column="line_id"    />
        <result property="packageId"    column="package_id"    />
        <result property="businessUnit"    column="business_unit"    />
    </resultMap>

    <sql id="selectMetaEmployeeVo">
        select name, login_name, email, mobile, sap_employee_id, sap_cost_center_code, sap_cost_center, sap_company_code, status, contract, contract_name, contract_begin, duty, duty_name, org, org_name, employee_post, employee_post_name, posty, poste, posnc, boss_employee_id, boss_name, boss_employee_post, sex, objid_1, stext_1, objid_2, stext_2, objid_3, stext_3, objid_4, stext_4, objid_5, stext_5, objid_6, stext_6, objid_7, stext_7, objid_qy, stext_qy, etl_creatime, dataversion, line_id, package_id, business_unit from meta_employee_diy
    </sql>

    <select id="selectMetaEmployeeDiyCopy1List" parameterType="MetaEmployee" resultMap="MetaEmployeeResult">
        <include refid="selectMetaEmployeeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="loginName != null  and loginName != ''"> and login_name like concat('%', #{loginName}, '%')</if>
            <if test="email != null  and email != ''"> and email = #{email}</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="sapEmployeeId != null  and sapEmployeeId != ''"> and sap_employee_id = #{sapEmployeeId}</if>
            <if test="sapCostCenterCode != null  and sapCostCenterCode != ''"> and sap_cost_center_code = #{sapCostCenterCode}</if>
            <if test="sapCostCenter != null  and sapCostCenter != ''"> and sap_cost_center = #{sapCostCenter}</if>
            <if test="sapCompanyCode != null  and sapCompanyCode != ''"> and sap_company_code = #{sapCompanyCode}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="contract != null  and contract != ''"> and contract = #{contract}</if>
            <if test="contractName != null  and contractName != ''"> and contract_name like concat('%', #{contractName}, '%')</if>
            <if test="contractBegin != null  and contractBegin != ''"> and contract_begin = #{contractBegin}</if>
            <if test="duty != null  and duty != ''"> and duty = #{duty}</if>
            <if test="dutyName != null  and dutyName != ''"> and duty_name like concat('%', #{dutyName}, '%')</if>
            <if test="org != null  and org != ''"> and org = #{org}</if>
            <if test="orgName != null  and orgName != ''"> and org_name like concat('%', #{orgName}, '%')</if>
            <if test="employeePost != null  and employeePost != ''"> and employee_post = #{employeePost}</if>
            <if test="employeePostName != null  and employeePostName != ''"> and employee_post_name like concat('%', #{employeePostName}, '%')</if>
            <if test="posty != null  and posty != ''"> and posty = #{posty}</if>
            <if test="poste != null  and poste != ''"> and poste = #{poste}</if>
            <if test="posnc != null  and posnc != ''"> and posnc = #{posnc}</if>
            <if test="bossEmployeeId != null  and bossEmployeeId != ''"> and boss_employee_id = #{bossEmployeeId}</if>
            <if test="bossName != null  and bossName != ''"> and boss_name like concat('%', #{bossName}, '%')</if>
            <if test="bossEmployeePost != null  and bossEmployeePost != ''"> and boss_employee_post = #{bossEmployeePost}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="objid1 != null  and objid1 != ''"> and objid_1 = #{objid1}</if>
            <if test="stext1 != null  and stext1 != ''"> and stext_1 = #{stext1}</if>
            <if test="objid2 != null  and objid2 != ''"> and objid_2 = #{objid2}</if>
            <if test="stext2 != null  and stext2 != ''"> and stext_2 = #{stext2}</if>
            <if test="objid3 != null  and objid3 != ''"> and objid_3 = #{objid3}</if>
            <if test="stext3 != null  and stext3 != ''"> and stext_3 = #{stext3}</if>
            <if test="objid4 != null  and objid4 != ''"> and objid_4 = #{objid4}</if>
            <if test="stext4 != null  and stext4 != ''"> and stext_4 = #{stext4}</if>
            <if test="objid5 != null  and objid5 != ''"> and objid_5 = #{objid5}</if>
            <if test="stext5 != null  and stext5 != ''"> and stext_5 = #{stext5}</if>
            <if test="objid6 != null  and objid6 != ''"> and objid_6 = #{objid6}</if>
            <if test="stext6 != null  and stext6 != ''"> and stext_6 = #{stext6}</if>
            <if test="objid7 != null  and objid7 != ''"> and objid_7 = #{objid7}</if>
            <if test="stext7 != null  and stext7 != ''"> and stext_7 = #{stext7}</if>
            <if test="objidQy != null  and objidQy != ''"> and objid_qy = #{objidQy}</if>
            <if test="stextQy != null  and stextQy != ''"> and stext_qy = #{stextQy}</if>
            <if test="etlCreatime != null "> and etl_creatime = #{etlCreatime}</if>
            <if test="dataversion != null  and dataversion != ''"> and dataversion = #{dataversion}</if>
            <if test="lineId != null  and lineId != ''"> and line_id = #{lineId}</if>
            <if test="packageId != null  and packageId != ''"> and package_id = #{packageId}</if>
            <if test="businessUnit != null  and businessUnit != ''"> and business_unit = #{businessUnit}</if>
        </where>
    </select>
    
    <select id="selectMetaEmployeeDiyCopy1ById" parameterType="String" resultMap="MetaEmployeeResult">
        <include refid="selectMetaEmployeeVo"/>
        where name = #{name}
    </select>

    <select id="selectMetaEmployeeDiyListByDivision" parameterType="MetaEmployee" resultMap="MetaEmployeeResult">
        <include refid="selectMetaEmployeeVo"/>
        where 1=1
        and business_unit in ('12城北区事业部','36城事业部','BMD事业部','12城中区事业部','12城南区事业部')
    </select>




    <select id="selectMetaEmployeetClueReporting" parameterType="MetaEmployee" resultMap="MetaEmployeeResult">
        <include refid="selectMetaEmployeeVo"/>
        where 1=1
        and  business_unit not in ('YSL','DIY','12城北区事业部','36城事业部','BMD事业部','12城中区事业部','12城南区事业部')
    </select>
</mapper>