<?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.hrm.HrmSnapshotMapper">
    <resultMap id="BaseResultMap" type="com.engine.salary.entity.hrm.po.HrmSnapshotPO">
        <result column="ID" property="id"/>
        <result column="snapshot_time" property="snapshotTime"/>
        <result column="employee_id" property="employeeId"/>
        <result column="ACCOUNTID1" property="accountid1"/>
        <result column="ACCOUNTNAME" property="accountname"/>
        <result column="ACCOUNTTYPE" property="accounttype"/>
        <result column="ACCUMFUNDACCOUNT" property="accumfundaccount"/>
        <result column="ASSISTANTID" property="assistantid"/>
        <result column="BANKID1" property="bankid1"/>
        <result column="BELONGTO" property="belongto"/>
        <result column="BEMEMBERDATE" property="bememberdate"/>
        <result column="BEPARTYDATE" property="bepartydate"/>
        <result column="BIRTHDAY" property="birthday"/>
        <result column="BIRTHPLACE" property="birthplace"/>
        <result column="CERTIFICATENUM" property="certificatenum"/>
        <result column="companystartdate" property="companystartdate"/>
        <result column="companyworkyear" property="companyworkyear"/>
        <result column="COSTCENTERID" property="costcenterid"/>
        <result column="COUNTRYID" property="countryid"/>
        <result column="DEGREE" property="degree"/>
        <result column="DEPARTMENTID" property="departmentid"/>
        <result column="DEPARTMENTNAME" property="departmentname"/>
        <result column="EDUCATIONLEVEL" property="educationlevel"/>
        <result column="EMAIL" property="email"/>
        <result column="ENDDATE" property="enddate"/>
        <result column="EXTPHONE" property="extphone"/>
        <result column="FAX" property="fax"/>
        <result column="FOLK" property="folk"/>
        <result column="HEALTHINFO" property="healthinfo"/>
        <result column="HOMEADDRESS" property="homeaddress"/>
        <result column="ISLABOUUNION" property="islabouunion"/>
        <result column="JOBACTIVITYDESC" property="jobactivitydesc"/>
        <result column="JOBCALL" property="jobcall"/>
        <result column="jobcallname" property="jobcallname"/>
        <result column="JOBLEVEL" property="joblevel"/>
        <result column="JOBTITLE" property="jobtitle"/>
        <result column="JOBTITLENAME" property="jobtitlename"/>
        <result column="LASTLOGINDATE" property="lastlogindate"/>
        <result column="LASTNAME" property="lastname"/>
        <result column="LOCATIONID" property="locationid"/>
        <result column="loginid" property="loginid"/>
        <result column="MANAGERID" property="managerid"/>
        <result column="MANAGERSTR" property="managerstr"/>
        <result column="MARITALSTATUS" property="maritalstatus"/>
        <result column="MOBILE" property="mobile"/>
        <result column="MOBILECALL" property="mobilecall"/>
        <result column="NATIONALITY" property="nationality"/>
        <result column="NATIVEPLACE" property="nativeplace"/>
        <result column="POLICY" property="policy"/>
        <result column="PROBATIONENDDATE" property="probationenddate"/>
        <result column="REGRESIDENTPLACE" property="regresidentplace"/>
        <result column="RESIDENTPHONE" property="residentphone"/>
        <result column="RESIDENTPLACE" property="residentplace"/>
        <result column="RESIDENTPOSTCODE" property="residentpostcode"/>
        <result column="RESOURCETYPE" property="resourcetype"/>
        <result column="SECLEVEL" property="seclevel"/>
        <result column="SEX" property="sex"/>
        <result column="STARTDATE" property="startdate"/>
        <result column="STATUS" property="status"/>
        <result column="SUBCOMPANYID1" property="subcompanyid1"/>
        <result column="SUBCOMPANYNAME" property="subcompanyname"/>
        <result column="TELEPHONE" property="telephone"/>
        <result column="TEMPRESIDENTNUMBER" property="tempresidentnumber"/>
        <result column="USEKIND" property="usekind"/>
        <result column="WORKCODE" property="workcode"/>
        <result column="WORKROOM" property="workroom"/>
        <result column="workstartdate" property="workstartdate"/>
        <result column="workyear" property="workyear"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        ACCOUNTID1
        , t.ACCOUNTNAME
        , t.ACCOUNTTYPE
        , t.ACCUMFUNDACCOUNT
        , t.ASSISTANTID
        , t.BANKID1
        , t.BELONGTO
        , t.BEMEMBERDATE
        , t.BEPARTYDATE
        , t.BIRTHDAY
        , t.BIRTHPLACE
        , t.CERTIFICATENUM
        , t.companystartdate
        , t.companyworkyear
        , t.COSTCENTERID
        , t.COUNTRYID
        , t.DEGREE
        , t.DEPARTMENTID
        , t.DEPARTMENTNAME
        , t.EDUCATIONLEVEL
        , t.EMAIL
        , t.employee_id
        , t.ENDDATE
        , t.EXTPHONE
        , t.FAX
        , t.FOLK
        , t.HEALTHINFO
        , t.HOMEADDRESS
        , t.ID
        , t.ISLABOUUNION
        , t.JOBACTIVITYDESC
        , t.JOBCALL
        , t.jobcallname
        , t.JOBLEVEL
        , t.JOBTITLE
        , t.JOBTITLENAME
        , t.LASTLOGINDATE
        , t.LASTNAME
        , t.LOCATIONID
        , t.loginid
        , t.MANAGERID
        , t.MANAGERSTR
        , t.MARITALSTATUS
        , t.MOBILE
        , t.MOBILECALL
        , t.NATIONALITY
        , t.NATIVEPLACE
        , t.POLICY
        , t.PROBATIONENDDATE
        , t.REGRESIDENTPLACE
        , t.RESIDENTPHONE
        , t.RESIDENTPLACE
        , t.RESIDENTPOSTCODE
        , t.RESOURCETYPE
        , t.SECLEVEL
        , t.SEX
        , t.snapshot_time
        , t.STARTDATE
        , t.STATUS
        , t.SUBCOMPANYID1
        , t.SUBCOMPANYNAME
        , t.TELEPHONE
        , t.TEMPRESIDENTNUMBER
        , t.USEKIND
        , t.WORKCODE
        , t.WORKROOM
        , t.workstartdate
        , t.workyear
    </sql>

    <!-- 查询全部 -->
    <select id="listAll" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_hrm_snapshot t
    </select>


    <select id="snapshot" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_hrm_snapshot t
        WHERE snapshot_time >= #{snapshotTime}
        AND employee_id = #{employeeId}
        order by snapshot_time
    </select>

    <!-- 根据主键获取单条记录 -->
    <select id="getById" resultMap="BaseResultMap" parameterType="Long">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_hrm_snapshot t
        WHERE ID = #{id}
    </select>

    <!-- 条件查询 -->
    <select id="listSome" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.hrm.po.HrmSnapshotPO">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_hrm_snapshot t
        WHERE 1=1
        <if test="accountid1 != null">
            AND ACCOUNTID1 = #{accountid1}
        </if>
        <if test="accountname != null">
            AND ACCOUNTNAME = #{accountname}
        </if>
        <if test="accounttype != null">
            AND ACCOUNTTYPE = #{accounttype}
        </if>
        <if test="accumfundaccount != null">
            AND ACCUMFUNDACCOUNT = #{accumfundaccount}
        </if>
        <if test="assistantid != null">
            AND ASSISTANTID = #{assistantid}
        </if>
        <if test="bankid1 != null">
            AND BANKID1 = #{bankid1}
        </if>
        <if test="belongto != null">
            AND BELONGTO = #{belongto}
        </if>
        <if test="bememberdate != null">
            AND BEMEMBERDATE = #{bememberdate}
        </if>
        <if test="bepartydate != null">
            AND BEPARTYDATE = #{bepartydate}
        </if>
        <if test="birthday != null">
            AND BIRTHDAY = #{birthday}
        </if>
        <if test="birthplace != null">
            AND BIRTHPLACE = #{birthplace}
        </if>
        <if test="certificatenum != null">
            AND CERTIFICATENUM = #{certificatenum}
        </if>
        <if test="companystartdate != null">
            AND companystartdate = #{companystartdate}
        </if>
        <if test="companyworkyear != null">
            AND companyworkyear = #{companyworkyear}
        </if>
        <if test="costcenterid != null">
            AND COSTCENTERID = #{costcenterid}
        </if>
        <if test="countryid != null">
            AND COUNTRYID = #{countryid}
        </if>
        <if test="degree != null">
            AND DEGREE = #{degree}
        </if>
        <if test="departmentid != null">
            AND DEPARTMENTID = #{departmentid}
        </if>
        <if test="departmentname != null">
            AND DEPARTMENTNAME = #{departmentname}
        </if>
        <if test="educationlevel != null">
            AND EDUCATIONLEVEL = #{educationlevel}
        </if>
        <if test="email != null">
            AND EMAIL = #{email}
        </if>
        <if test="employeeId != null">
            AND employee_id = #{employeeId}
        </if>
        <if test="enddate != null">
            AND ENDDATE = #{enddate}
        </if>
        <if test="extphone != null">
            AND EXTPHONE = #{extphone}
        </if>
        <if test="fax != null">
            AND FAX = #{fax}
        </if>
        <if test="folk != null">
            AND FOLK = #{folk}
        </if>
        <if test="healthinfo != null">
            AND HEALTHINFO = #{healthinfo}
        </if>
        <if test="homeaddress != null">
            AND HOMEADDRESS = #{homeaddress}
        </if>
        <if test="id != null">
            AND ID = #{id}
        </if>
        <if test="islabouunion != null">
            AND ISLABOUUNION = #{islabouunion}
        </if>
        <if test="jobactivitydesc != null">
            AND JOBACTIVITYDESC = #{jobactivitydesc}
        </if>
        <if test="jobcall != null">
            AND JOBCALL = #{jobcall}
        </if>
        <if test="jobcallname != null">
            AND jobcallname = #{jobcallname}
        </if>
        <if test="joblevel != null">
            AND JOBLEVEL = #{joblevel}
        </if>
        <if test="jobtitle != null">
            AND JOBTITLE = #{jobtitle}
        </if>
        <if test="jobtitlename != null">
            AND JOBTITLENAME = #{jobtitlename}
        </if>
        <if test="lastlogindate != null">
            AND LASTLOGINDATE = #{lastlogindate}
        </if>
        <if test="lastname != null">
            AND LASTNAME = #{lastname}
        </if>
        <if test="locationid != null">
            AND LOCATIONID = #{locationid}
        </if>
        <if test="loginid != null">
            AND loginid = #{loginid}
        </if>
        <if test="managerid != null">
            AND MANAGERID = #{managerid}
        </if>
        <if test="managerstr != null">
            AND MANAGERSTR = #{managerstr}
        </if>
        <if test="maritalstatus != null">
            AND MARITALSTATUS = #{maritalstatus}
        </if>
        <if test="mobile != null">
            AND MOBILE = #{mobile}
        </if>
        <if test="mobilecall != null">
            AND MOBILECALL = #{mobilecall}
        </if>
        <if test="nationality != null">
            AND NATIONALITY = #{nationality}
        </if>
        <if test="nativeplace != null">
            AND NATIVEPLACE = #{nativeplace}
        </if>
        <if test="policy != null">
            AND POLICY = #{policy}
        </if>
        <if test="probationenddate != null">
            AND PROBATIONENDDATE = #{probationenddate}
        </if>
        <if test="regresidentplace != null">
            AND REGRESIDENTPLACE = #{regresidentplace}
        </if>
        <if test="residentphone != null">
            AND RESIDENTPHONE = #{residentphone}
        </if>
        <if test="residentplace != null">
            AND RESIDENTPLACE = #{residentplace}
        </if>
        <if test="residentpostcode != null">
            AND RESIDENTPOSTCODE = #{residentpostcode}
        </if>
        <if test="resourcetype != null">
            AND RESOURCETYPE = #{resourcetype}
        </if>
        <if test="seclevel != null">
            AND SECLEVEL = #{seclevel}
        </if>
        <if test="sex != null">
            AND SEX = #{sex}
        </if>
        <if test="snapshotTime != null">
            AND snapshot_time = #{snapshotTime}
        </if>
        <if test="startdate != null">
            AND STARTDATE = #{startdate}
        </if>
        <if test="status != null">
            AND STATUS = #{status}
        </if>
        <if test="subcompanyid1 != null">
            AND SUBCOMPANYID1 = #{subcompanyid1}
        </if>
        <if test="subcompanyname != null">
            AND SUBCOMPANYNAME = #{subcompanyname}
        </if>
        <if test="telephone != null">
            AND TELEPHONE = #{telephone}
        </if>
        <if test="tempresidentnumber != null">
            AND TEMPRESIDENTNUMBER = #{tempresidentnumber}
        </if>
        <if test="usekind != null">
            AND USEKIND = #{usekind}
        </if>
        <if test="workcode != null">
            AND WORKCODE = #{workcode}
        </if>
        <if test="workroom != null">
            AND WORKROOM = #{workroom}
        </if>
        <if test="workstartdate != null">
            AND workstartdate = #{workstartdate}
        </if>
        <if test="workyear != null">
            AND workyear = #{workyear}
        </if>
        <if test="ids != null and ids.size()>0">
            AND id IN
            <foreach collection="ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>


    <!-- 插入不为NULL的字段 -->
    <insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.hrm.po.HrmSnapshotPO">
        INSERT INTO hrsa_hrm_snapshot
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="accountid1 != null">
                ACCOUNTID1,
            </if>
            <if test="accountname != null">
                ACCOUNTNAME,
            </if>
            <if test="accounttype != null">
                ACCOUNTTYPE,
            </if>
            <if test="accumfundaccount != null">
                ACCUMFUNDACCOUNT,
            </if>
            <if test="assistantid != null">
                ASSISTANTID,
            </if>
            <if test="bankid1 != null">
                BANKID1,
            </if>
            <if test="belongto != null">
                BELONGTO,
            </if>
            <if test="bememberdate != null">
                BEMEMBERDATE,
            </if>
            <if test="bepartydate != null">
                BEPARTYDATE,
            </if>
            <if test="birthday != null">
                BIRTHDAY,
            </if>
            <if test="birthplace != null">
                BIRTHPLACE,
            </if>
            <if test="certificatenum != null">
                CERTIFICATENUM,
            </if>
            <if test="companystartdate != null">
                companystartdate,
            </if>
            <if test="companyworkyear != null">
                companyworkyear,
            </if>
            <if test="costcenterid != null">
                COSTCENTERID,
            </if>
            <if test="countryid != null">
                COUNTRYID,
            </if>
            <if test="degree != null">
                DEGREE,
            </if>
            <if test="departmentid != null">
                DEPARTMENTID,
            </if>
            <if test="departmentname != null">
                DEPARTMENTNAME,
            </if>
            <if test="educationlevel != null">
                EDUCATIONLEVEL,
            </if>
            <if test="email != null">
                EMAIL,
            </if>
            <if test="employeeId != null">
                employee_id,
            </if>
            <if test="enddate != null">
                ENDDATE,
            </if>
            <if test="extphone != null">
                EXTPHONE,
            </if>
            <if test="fax != null">
                FAX,
            </if>
            <if test="folk != null">
                FOLK,
            </if>
            <if test="healthinfo != null">
                HEALTHINFO,
            </if>
            <if test="homeaddress != null">
                HOMEADDRESS,
            </if>
            <if test="id != null">
                ID,
            </if>
            <if test="islabouunion != null">
                ISLABOUUNION,
            </if>
            <if test="jobactivitydesc != null">
                JOBACTIVITYDESC,
            </if>
            <if test="jobcall != null">
                JOBCALL,
            </if>
            <if test="jobcallname != null">
                jobcallname,
            </if>
            <if test="joblevel != null">
                JOBLEVEL,
            </if>
            <if test="jobtitle != null">
                JOBTITLE,
            </if>
            <if test="jobtitlename != null">
                JOBTITLENAME,
            </if>
            <if test="lastlogindate != null">
                LASTLOGINDATE,
            </if>
            <if test="lastname != null">
                LASTNAME,
            </if>
            <if test="locationid != null">
                LOCATIONID,
            </if>
            <if test="loginid != null">
                loginid,
            </if>
            <if test="managerid != null">
                MANAGERID,
            </if>
            <if test="managerstr != null">
                MANAGERSTR,
            </if>
            <if test="maritalstatus != null">
                MARITALSTATUS,
            </if>
            <if test="mobile != null">
                MOBILE,
            </if>
            <if test="mobilecall != null">
                MOBILECALL,
            </if>
            <if test="nationality != null">
                NATIONALITY,
            </if>
            <if test="nativeplace != null">
                NATIVEPLACE,
            </if>
            <if test="policy != null">
                POLICY,
            </if>
            <if test="probationenddate != null">
                PROBATIONENDDATE,
            </if>
            <if test="regresidentplace != null">
                REGRESIDENTPLACE,
            </if>
            <if test="residentphone != null">
                RESIDENTPHONE,
            </if>
            <if test="residentplace != null">
                RESIDENTPLACE,
            </if>
            <if test="residentpostcode != null">
                RESIDENTPOSTCODE,
            </if>
            <if test="resourcetype != null">
                RESOURCETYPE,
            </if>
            <if test="seclevel != null">
                SECLEVEL,
            </if>
            <if test="sex != null">
                SEX,
            </if>
            <if test="snapshotTime != null">
                snapshot_time,
            </if>
            <if test="startdate != null">
                STARTDATE,
            </if>
            <if test="status != null">
                STATUS,
            </if>
            <if test="subcompanyid1 != null">
                SUBCOMPANYID1,
            </if>
            <if test="subcompanyname != null">
                SUBCOMPANYNAME,
            </if>
            <if test="telephone != null">
                TELEPHONE,
            </if>
            <if test="tempresidentnumber != null">
                TEMPRESIDENTNUMBER,
            </if>
            <if test="usekind != null">
                USEKIND,
            </if>
            <if test="workcode != null">
                WORKCODE,
            </if>
            <if test="workroom != null">
                WORKROOM,
            </if>
            <if test="workstartdate != null">
                workstartdate,
            </if>
            <if test="workyear != null">
                workyear,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="accountid1 != null">
                #{accountid1},
            </if>
            <if test="accountname != null">
                #{accountname},
            </if>
            <if test="accounttype != null">
                #{accounttype},
            </if>
            <if test="accumfundaccount != null">
                #{accumfundaccount},
            </if>
            <if test="assistantid != null">
                #{assistantid},
            </if>
            <if test="bankid1 != null">
                #{bankid1},
            </if>
            <if test="belongto != null">
                #{belongto},
            </if>
            <if test="bememberdate != null">
                #{bememberdate},
            </if>
            <if test="bepartydate != null">
                #{bepartydate},
            </if>
            <if test="birthday != null">
                #{birthday},
            </if>
            <if test="birthplace != null">
                #{birthplace},
            </if>
            <if test="certificatenum != null">
                #{certificatenum},
            </if>
            <if test="companystartdate != null">
                #{companystartdate},
            </if>
            <if test="companyworkyear != null">
                #{companyworkyear},
            </if>
            <if test="costcenterid != null">
                #{costcenterid},
            </if>
            <if test="countryid != null">
                #{countryid},
            </if>
            <if test="degree != null">
                #{degree},
            </if>
            <if test="departmentid != null">
                #{departmentid},
            </if>
            <if test="departmentname != null">
                #{departmentname},
            </if>
            <if test="educationlevel != null">
                #{educationlevel},
            </if>
            <if test="email != null">
                #{email},
            </if>
            <if test="employeeId != null">
                #{employeeId},
            </if>
            <if test="enddate != null">
                #{enddate},
            </if>
            <if test="extphone != null">
                #{extphone},
            </if>
            <if test="fax != null">
                #{fax},
            </if>
            <if test="folk != null">
                #{folk},
            </if>
            <if test="healthinfo != null">
                #{healthinfo},
            </if>
            <if test="homeaddress != null">
                #{homeaddress},
            </if>
            <if test="id != null">
                #{id},
            </if>
            <if test="islabouunion != null">
                #{islabouunion},
            </if>
            <if test="jobactivitydesc != null">
                #{jobactivitydesc},
            </if>
            <if test="jobcall != null">
                #{jobcall},
            </if>
            <if test="jobcallname != null">
                #{jobcallname},
            </if>
            <if test="joblevel != null">
                #{joblevel},
            </if>
            <if test="jobtitle != null">
                #{jobtitle},
            </if>
            <if test="jobtitlename != null">
                #{jobtitlename},
            </if>
            <if test="lastlogindate != null">
                #{lastlogindate},
            </if>
            <if test="lastname != null">
                #{lastname},
            </if>
            <if test="locationid != null">
                #{locationid},
            </if>
            <if test="loginid != null">
                #{loginid},
            </if>
            <if test="managerid != null">
                #{managerid},
            </if>
            <if test="managerstr != null">
                #{managerstr},
            </if>
            <if test="maritalstatus != null">
                #{maritalstatus},
            </if>
            <if test="mobile != null">
                #{mobile},
            </if>
            <if test="mobilecall != null">
                #{mobilecall},
            </if>
            <if test="nationality != null">
                #{nationality},
            </if>
            <if test="nativeplace != null">
                #{nativeplace},
            </if>
            <if test="policy != null">
                #{policy},
            </if>
            <if test="probationenddate != null">
                #{probationenddate},
            </if>
            <if test="regresidentplace != null">
                #{regresidentplace},
            </if>
            <if test="residentphone != null">
                #{residentphone},
            </if>
            <if test="residentplace != null">
                #{residentplace},
            </if>
            <if test="residentpostcode != null">
                #{residentpostcode},
            </if>
            <if test="resourcetype != null">
                #{resourcetype},
            </if>
            <if test="seclevel != null">
                #{seclevel},
            </if>
            <if test="sex != null">
                #{sex},
            </if>
            <if test="snapshotTime != null">
                #{snapshotTime},
            </if>
            <if test="startdate != null">
                #{startdate},
            </if>
            <if test="status != null">
                #{status},
            </if>
            <if test="subcompanyid1 != null">
                #{subcompanyid1},
            </if>
            <if test="subcompanyname != null">
                #{subcompanyname},
            </if>
            <if test="telephone != null">
                #{telephone},
            </if>
            <if test="tempresidentnumber != null">
                #{tempresidentnumber},
            </if>
            <if test="usekind != null">
                #{usekind},
            </if>
            <if test="workcode != null">
                #{workcode},
            </if>
            <if test="workroom != null">
                #{workroom},
            </if>
            <if test="workstartdate != null">
                #{workstartdate},
            </if>
            <if test="workyear != null">
                #{workyear},
            </if>
        </trim>
    </insert>

    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.engine.salary.entity.hrm.po.HrmSnapshotPO">
        UPDATE hrsa_hrm_snapshot
        <set>
            ACCOUNTID1=#{accountid1},
            ACCOUNTNAME=#{accountname},
            ACCOUNTTYPE=#{accounttype},
            ACCUMFUNDACCOUNT=#{accumfundaccount},
            ASSISTANTID=#{assistantid},
            BANKID1=#{bankid1},
            BELONGTO=#{belongto},
            BEMEMBERDATE=#{bememberdate},
            BEPARTYDATE=#{bepartydate},
            BIRTHDAY=#{birthday},
            BIRTHPLACE=#{birthplace},
            CERTIFICATENUM=#{certificatenum},
            companystartdate=#{companystartdate},
            companyworkyear=#{companyworkyear},
            COSTCENTERID=#{costcenterid},
            COUNTRYID=#{countryid},
            DEGREE=#{degree},
            DEPARTMENTID=#{departmentid},
            DEPARTMENTNAME=#{departmentname},
            EDUCATIONLEVEL=#{educationlevel},
            EMAIL=#{email},
            employee_id=#{employeeId},
            ENDDATE=#{enddate},
            EXTPHONE=#{extphone},
            FAX=#{fax},
            FOLK=#{folk},
            HEALTHINFO=#{healthinfo},
            HOMEADDRESS=#{homeaddress},
            ISLABOUUNION=#{islabouunion},
            JOBACTIVITYDESC=#{jobactivitydesc},
            JOBCALL=#{jobcall},
            jobcallname=#{jobcallname},
            JOBLEVEL=#{joblevel},
            JOBTITLE=#{jobtitle},
            JOBTITLENAME=#{jobtitlename},
            LASTLOGINDATE=#{lastlogindate},
            LASTNAME=#{lastname},
            LOCATIONID=#{locationid},
            loginid=#{loginid},
            MANAGERID=#{managerid},
            MANAGERSTR=#{managerstr},
            MARITALSTATUS=#{maritalstatus},
            MOBILE=#{mobile},
            MOBILECALL=#{mobilecall},
            NATIONALITY=#{nationality},
            NATIVEPLACE=#{nativeplace},
            POLICY=#{policy},
            PROBATIONENDDATE=#{probationenddate},
            REGRESIDENTPLACE=#{regresidentplace},
            RESIDENTPHONE=#{residentphone},
            RESIDENTPLACE=#{residentplace},
            RESIDENTPOSTCODE=#{residentpostcode},
            RESOURCETYPE=#{resourcetype},
            SECLEVEL=#{seclevel},
            SEX=#{sex},
            snapshot_time=#{snapshotTime},
            STARTDATE=#{startdate},
            STATUS=#{status},
            SUBCOMPANYID1=#{subcompanyid1},
            SUBCOMPANYNAME=#{subcompanyname},
            TELEPHONE=#{telephone},
            TEMPRESIDENTNUMBER=#{tempresidentnumber},
            USEKIND=#{usekind},
            WORKCODE=#{workcode},
            WORKROOM=#{workroom},
            workstartdate=#{workstartdate},
            workyear=#{workyear},
        </set>
        WHERE ID = #{id}
    </update>


    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.engine.salary.entity.hrm.po.HrmSnapshotPO">
        UPDATE hrsa_hrm_snapshot
        <set>
            <if test="accountid1 != null">
                ACCOUNTID1=#{accountid1},
            </if>
            <if test="accountname != null">
                ACCOUNTNAME=#{accountname},
            </if>
            <if test="accounttype != null">
                ACCOUNTTYPE=#{accounttype},
            </if>
            <if test="accumfundaccount != null">
                ACCUMFUNDACCOUNT=#{accumfundaccount},
            </if>
            <if test="assistantid != null">
                ASSISTANTID=#{assistantid},
            </if>
            <if test="bankid1 != null">
                BANKID1=#{bankid1},
            </if>
            <if test="belongto != null">
                BELONGTO=#{belongto},
            </if>
            <if test="bememberdate != null">
                BEMEMBERDATE=#{bememberdate},
            </if>
            <if test="bepartydate != null">
                BEPARTYDATE=#{bepartydate},
            </if>
            <if test="birthday != null">
                BIRTHDAY=#{birthday},
            </if>
            <if test="birthplace != null">
                BIRTHPLACE=#{birthplace},
            </if>
            <if test="certificatenum != null">
                CERTIFICATENUM=#{certificatenum},
            </if>
            <if test="companystartdate != null">
                companystartdate=#{companystartdate},
            </if>
            <if test="companyworkyear != null">
                companyworkyear=#{companyworkyear},
            </if>
            <if test="costcenterid != null">
                COSTCENTERID=#{costcenterid},
            </if>
            <if test="countryid != null">
                COUNTRYID=#{countryid},
            </if>
            <if test="degree != null">
                DEGREE=#{degree},
            </if>
            <if test="departmentid != null">
                DEPARTMENTID=#{departmentid},
            </if>
            <if test="departmentname != null">
                DEPARTMENTNAME=#{departmentname},
            </if>
            <if test="educationlevel != null">
                EDUCATIONLEVEL=#{educationlevel},
            </if>
            <if test="email != null">
                EMAIL=#{email},
            </if>
            <if test="employeeId != null">
                employee_id=#{employeeId},
            </if>
            <if test="enddate != null">
                ENDDATE=#{enddate},
            </if>
            <if test="extphone != null">
                EXTPHONE=#{extphone},
            </if>
            <if test="fax != null">
                FAX=#{fax},
            </if>
            <if test="folk != null">
                FOLK=#{folk},
            </if>
            <if test="healthinfo != null">
                HEALTHINFO=#{healthinfo},
            </if>
            <if test="homeaddress != null">
                HOMEADDRESS=#{homeaddress},
            </if>
            <if test="islabouunion != null">
                ISLABOUUNION=#{islabouunion},
            </if>
            <if test="jobactivitydesc != null">
                JOBACTIVITYDESC=#{jobactivitydesc},
            </if>
            <if test="jobcall != null">
                JOBCALL=#{jobcall},
            </if>
            <if test="jobcallname != null">
                jobcallname=#{jobcallname},
            </if>
            <if test="joblevel != null">
                JOBLEVEL=#{joblevel},
            </if>
            <if test="jobtitle != null">
                JOBTITLE=#{jobtitle},
            </if>
            <if test="jobtitlename != null">
                JOBTITLENAME=#{jobtitlename},
            </if>
            <if test="lastlogindate != null">
                LASTLOGINDATE=#{lastlogindate},
            </if>
            <if test="lastname != null">
                LASTNAME=#{lastname},
            </if>
            <if test="locationid != null">
                LOCATIONID=#{locationid},
            </if>
            <if test="loginid != null">
                loginid=#{loginid},
            </if>
            <if test="managerid != null">
                MANAGERID=#{managerid},
            </if>
            <if test="managerstr != null">
                MANAGERSTR=#{managerstr},
            </if>
            <if test="maritalstatus != null">
                MARITALSTATUS=#{maritalstatus},
            </if>
            <if test="mobile != null">
                MOBILE=#{mobile},
            </if>
            <if test="mobilecall != null">
                MOBILECALL=#{mobilecall},
            </if>
            <if test="nationality != null">
                NATIONALITY=#{nationality},
            </if>
            <if test="nativeplace != null">
                NATIVEPLACE=#{nativeplace},
            </if>
            <if test="policy != null">
                POLICY=#{policy},
            </if>
            <if test="probationenddate != null">
                PROBATIONENDDATE=#{probationenddate},
            </if>
            <if test="regresidentplace != null">
                REGRESIDENTPLACE=#{regresidentplace},
            </if>
            <if test="residentphone != null">
                RESIDENTPHONE=#{residentphone},
            </if>
            <if test="residentplace != null">
                RESIDENTPLACE=#{residentplace},
            </if>
            <if test="residentpostcode != null">
                RESIDENTPOSTCODE=#{residentpostcode},
            </if>
            <if test="resourcetype != null">
                RESOURCETYPE=#{resourcetype},
            </if>
            <if test="seclevel != null">
                SECLEVEL=#{seclevel},
            </if>
            <if test="sex != null">
                SEX=#{sex},
            </if>
            <if test="snapshotTime != null">
                snapshot_time=#{snapshotTime},
            </if>
            <if test="startdate != null">
                STARTDATE=#{startdate},
            </if>
            <if test="status != null">
                STATUS=#{status},
            </if>
            <if test="subcompanyid1 != null">
                SUBCOMPANYID1=#{subcompanyid1},
            </if>
            <if test="subcompanyname != null">
                SUBCOMPANYNAME=#{subcompanyname},
            </if>
            <if test="telephone != null">
                TELEPHONE=#{telephone},
            </if>
            <if test="tempresidentnumber != null">
                TEMPRESIDENTNUMBER=#{tempresidentnumber},
            </if>
            <if test="usekind != null">
                USEKIND=#{usekind},
            </if>
            <if test="workcode != null">
                WORKCODE=#{workcode},
            </if>
            <if test="workroom != null">
                WORKROOM=#{workroom},
            </if>
            <if test="workstartdate != null">
                workstartdate=#{workstartdate},
            </if>
            <if test="workyear != null">
                workyear=#{workyear},
            </if>
        </set>
        WHERE ID = #{id}
    </update>


    <!-- 根据主键删除记录 -->
    <delete id="delete">
        UPDATE hrsa_hrm_snapshot
        SET delete_type=1
        WHERE id = #{id}
          AND delete_type = 0
    </delete>

    <delete id="deleteByIds">
        UPDATE hrsa_hrm_snapshot
        SET delete_type = 1
        WHERE  id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteBySnapshotTime">
        delete from  hrsa_hrm_snapshot
        WHERE snapshot_time = #{snapshotTime}
    </delete>

    <sql id="empColumns">
        e
        .
        ID as employee_id
        ,e.loginid
        ,e.LASTNAME
        ,e.SEX
        ,e.BIRTHDAY
        ,e.NATIONALITY
        ,e.MARITALSTATUS
        ,e.TELEPHONE
        ,e.MOBILE
        ,e.MOBILECALL
        ,e.EMAIL
        ,e.LOCATIONID
        ,e.WORKROOM
        ,e.HOMEADDRESS
        ,e.RESOURCETYPE
        ,e.STARTDATE
        ,e.ENDDATE
        ,e.JOBTITLE
        ,j.JOBTITLENAME
        ,e.JOBACTIVITYDESC
        ,e.JOBLEVEL
        ,e.SECLEVEL
        ,e.DEPARTMENTID
        ,d.DEPARTMENTNAME
        ,e.SUBCOMPANYID1
        ,c.SUBCOMPANYNAME
        ,e.COSTCENTERID
        ,e.MANAGERID
        ,e.ASSISTANTID
        ,e.BANKID1
        ,e.ACCOUNTID1
        ,e.LASTLOGINDATE
        ,e.CERTIFICATENUM
        ,e.NATIVEPLACE
        ,e.EDUCATIONLEVEL
        ,e.BEMEMBERDATE
        ,e.BEPARTYDATE
        ,e.WORKCODE
        ,e.REGRESIDENTPLACE
        ,e.HEALTHINFO
        ,e.RESIDENTPLACE
        ,e.POLICY
        ,e.DEGREE
        ,e.USEKIND
        ,e.JOBCALL
        ,job.NAME as jobcallname
        ,e.ACCUMFUNDACCOUNT
        ,e.BIRTHPLACE
        ,e.FOLK
        ,e.RESIDENTPHONE
        ,e.RESIDENTPOSTCODE
        ,e.EXTPHONE
        ,e.MANAGERSTR
        ,e.STATUS
        ,e.FAX
        ,e.ISLABOUUNION
        ,e.TEMPRESIDENTNUMBER
        ,e.PROBATIONENDDATE
        ,e.COUNTRYID
        ,e.ACCOUNTTYPE
        ,e.BELONGTO
        ,e.ACCOUNTNAME
        ,e.companystartdate
        ,e.workstartdate
        ,e.companyworkyear
        ,e.workyear
    </sql>

    <select id="currentEmpData" resultMap="BaseResultMap">
        select
        <include refid="empColumns"/>
        from hrmresource e
        left join hrmdepartment d on e.departmentid = d.id
        left join HrmSubCompany c on e.SUBCOMPANYID1=c.id
        left join hrmjobtitles j on e.jobtitle = j.id
        left join hrmjobcall job on e.jobcall=job.id
    </select>

</mapper>