<?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.yifu.archives.mapper.TBusinessEmployeeExtendInfoMapper">

    <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.BusinessEmployeeExtendVO">
            <id property="id" column="ID" jdbcType="VARCHAR"/>
            <result property="empIdcard" column="EMP_IDCARD" jdbcType="VARCHAR"/>
            <result property="empName" column="EMP_NAME" jdbcType="VARCHAR"/>
            <result property="departName" column="DEPART_NAME" jdbcType="VARCHAR"/>
            <result property="departId" column="DEPART_ID" jdbcType="INTEGER"/>
            <result property="departCode" column="DEPART_CODE" jdbcType="VARCHAR"/>
            <result property="businessPost" column="BUSINESS_POST" jdbcType="VARCHAR"/>
            <result property="businessTelecomNumber" column="BUSINESS_TELECOM_NUMBER" jdbcType="VARCHAR"/>
            <result property="employeeTags" column="EMPLOYEE_TAGS" jdbcType="VARCHAR"/>
            <result property="firstDegreeAndMajor" column="FIRST_DEGREE_AND_MAJOR" jdbcType="VARCHAR"/>
            <result property="firstDegreeGraduateSchool" column="FIRST_DEGREE_GRADUATE_SCHOOL" jdbcType="VARCHAR"/>
            <result property="highestDegreeAndMajor" column="HIGHEST_DEGREE_AND_MAJOR" jdbcType="VARCHAR"/>
            <result property="highestDegreeGraduateSchool" column="HIGHEST_DEGREE_GRADUATE_SCHOOL" jdbcType="VARCHAR"/>
            <result property="contactInfo" column="CONTACT_INFO" jdbcType="VARCHAR"/>
            <result property="archivesAddr" column="ARCHIVES_ADDR" jdbcType="VARCHAR"/>
            <result property="businessWorkingStatus" column="BUSINESS_WORKING_STATUS" jdbcType="CHAR"/>
            <result property="documentType" column="DOCUMENT_TYPE" jdbcType="VARCHAR"/>
            <result property="businessLeaveDate" column="BUSINESS_LEAVE_DATE"/>
            <result property="businessEnjoinDate" column="BUSINESS_ENJOIN_DATE"/>
            <result property="businessLeaveReason" column="BUSINESS_LEAVE_REASON" jdbcType="VARCHAR"/>
            <result property="deleteFlag" column="DELETE_FLAG" jdbcType="CHAR"/>
    </resultMap>

    <!-- 离职信息导入获取 -->
    <resultMap id="LeaveResultMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.BusinessEmployeeExtendByLeave">
        <result property="businessTelecomNumber" column="BUSINESS_TELECOM_NUMBER" jdbcType="VARCHAR"/>
        <result property="empIdcard" column="EMP_IDCARD" jdbcType="VARCHAR"/>
        <result property="empName" column="EMP_NAME" jdbcType="VARCHAR"/>
        <result property="departName" column="DEPART_NAME" jdbcType="VARCHAR"/>
        <result property="departId" column="DEPART_ID" jdbcType="INTEGER"/>
        <result property="businessPost" column="BUSINESS_POST" jdbcType="VARCHAR"/>
        <result property="businessWorkingStatus" column="BUSINESS_WORKING_STATUS" jdbcType="CHAR"/>
        <result property="departCode" column="DEPART_CODE" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        a.ID,
        a.EMP_IDCARD,
        a.EMP_NAME,
        a.DEPART_NAME,
        a.DEPART_ID,
        a.BUSINESS_POST,
        a.BUSINESS_TELECOM_NUMBER,
        a.BUSINESS_ENJOIN_DATE,
        a.EMPLOYEE_TAGS,
        a.FIRST_DEGREE_AND_MAJOR,
        a.FIRST_DEGREE_GRADUATE_SCHOOL,
        a.BUSINESS_LEAVE_DATE,
        a.BUSINESS_LEAVE_REASON,
        a.HIGHEST_DEGREE_AND_MAJOR,
        a.HIGHEST_DEGREE_GRADUATE_SCHOOL,
        a.CONTACT_INFO,
        a.BUSINESS_WORKING_STATUS,
        a.DOCUMENT_TYPE,
        a.ARCHIVES_ADDR
    </sql>
    <select id="getNotLeaveExtendList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_business_employee_extend_info a
        <where>
            1=1
            and a.BUSINESS_WORKING_STATUS <![CDATA[<>]]> '1'
            and a.DELETE_FLAG = '0'
        </where>
    </select>

    <!-- hgw 2021-8-18 16:41:01 获取所有扩展信息 -->
    <select id="getInfoByLeaveList" resultMap="LeaveResultMap">
        select
            a.BUSINESS_TELECOM_NUMBER,
            a.EMP_IDCARD,
            a.EMP_NAME,
            a.DEPART_NAME,
            a.DEPART_ID,
            a.BUSINESS_POST,
            a.BUSINESS_WORKING_STATUS,
			a.DEPART_CODE
        from t_business_employee_extend_info a
        where a.BUSINESS_TELECOM_NUMBER is not null
        GROUP BY a.BUSINESS_TELECOM_NUMBER
    </select>
    <select id="getDataByEmpIdcard" resultType="com.yifu.cloud.plus.v1.yifu.archives.entity.TBusinessEmployeeExtendInfo">
        select
            a.ID,
            a.EMP_IDCARD,
            b.EMP_NAME,
            a.DEPART_NAME,
            a.DEPART_ID,
            a.BUSINESS_POST,
            a.BUSINESS_TELECOM_NUMBER,
            a.BUSINESS_ENJOIN_DATE,
            a.EMPLOYEE_TAGS,
            a.FIRST_DEGREE_AND_MAJOR,
            a.FIRST_DEGREE_GRADUATE_SCHOOL,
            a.BUSINESS_LEAVE_DATE,
            a.BUSINESS_LEAVE_REASON,
            a.HIGHEST_DEGREE_AND_MAJOR,
            a.HIGHEST_DEGREE_GRADUATE_SCHOOL,
            a.CONTACT_INFO,
            a.BUSINESS_WORKING_STATUS,
            a.DOCUMENT_TYPE,
            a.ARCHIVES_ADDR
        from t_business_employee_extend_info a
        left join t_employee_info b on a.EMP_IDCARD = b.EMP_IDCARD
        where 1=1
        and a.EMP_IDCARD = #{empIdcard}
        and b.DELETE_FLAG = '0'
        limit 1
    </select>
    <select id="getDataById" resultType="com.yifu.cloud.plus.v1.yifu.archives.entity.TBusinessEmployeeExtendInfo">
        select
            a.ID,
            a.EMP_IDCARD,
            b.EMP_NAME,
            a.DEPART_NAME,
            a.DEPART_ID,
            a.BUSINESS_POST,
            a.BUSINESS_TELECOM_NUMBER,
            a.BUSINESS_ENJOIN_DATE,
            a.EMPLOYEE_TAGS,
            a.FIRST_DEGREE_AND_MAJOR,
            a.FIRST_DEGREE_GRADUATE_SCHOOL,
            a.BUSINESS_LEAVE_DATE,
            a.BUSINESS_LEAVE_REASON,
            a.HIGHEST_DEGREE_AND_MAJOR,
            a.HIGHEST_DEGREE_GRADUATE_SCHOOL,
            a.CONTACT_INFO,
            a.BUSINESS_WORKING_STATUS,
            a.DOCUMENT_TYPE,
            a.ARCHIVES_ADDR
        from t_business_employee_extend_info a
                 left join t_employee_info b on a.EMP_IDCARD = b.EMP_IDCARD
        where 1=1
          and a.ID = #{extendId}
          and b.DELETE_FLAG = '0'
        limit 1
    </select>

</mapper>
