<?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="cn.com.countrygarden.bi.main.dao.dataMigration.BdPsndocMapper">
    <!--<insert id="insertOrUpdate" parameterType="java.util.List">-->
    <!--INSERT INTO bd_psndoc-->
    <!--(ADDR,BIRTHDATE,CODE,CREATIONTIME,CREATOR,DATAORIGINFLAG,EMAIL,ENABLESTATE,HOMEPHONE,ID,IDTYPE,ISSHOPASSIST,JOINWORKDATE,MNECODE,MOBILE,MODIFIEDTIME,MODIFIER,NAME,NAME2,NAME3,NAME4,NAME5,NAME6,OFFICEPHONE,PK_GROUP,PK_ORG,PK_PSNDOC,SEX,TS,USEDNAME,BLOODTYPE,CENSUSADDR,CHARACTERRPR,COUNTRY,DIE_DATE,DIE_REMARK,EDU,FAX,FILEADDRESS,HEALTH,ISHISKEYPSN,JOINPOLITYDATE,MARITAL,MARRIAGEDATE,NATIONALITY,NATIVEPLACE,PENELAUTH,PERMANRESIDE,PHOTO,PK_DEGREE,PK_HRORG,POLITY,POSTALCODE,PREVIEWPHOTO,PROF,RETIREDATE,SECRET_EMAIL,SHORTNAME,TITLETECHPOST,FIRSTNAME,LASTNAME,ISCADRE,ISHISLEADER,AGE,WORKAGE,GLBDEF21,GLBDEF1,GLBDEF2,GLBDEF3,GLBDEF4,GLBDEF5,GLBDEF6,GLBDEF7,GLBDEF8,GLBDEF9,GLBDEF10,GLBDEF11,GLBDEF12,GLBDEF13,GLBDEF14,GLBDEF15,GLBDEF17,GLBDEF18,GLBDEF19,GLBDEF20,GLBDEF22,GLBDEF23,GLBDEF16,GLBDEF24,GLBDEF25,GLBDEF26,GLBDEF27,GLBDEF28,GLBDEF29,GLBDEF30,RN,DR)-->
    <!--VALUES-->
    <!--<foreach collection="bd" item="bdlist" separator=",">-->
    <!--(#{bdlist.ADDR},#{bdlist.BIRTHDATE},#{bdlist.CODE},#{bdlist.CREATIONTIME},#{bdlist.CREATOR},#{bdlist.DATAORIGINFLAG},#{bdlist.EMAIL},#{bdlist.ENABLESTATE},#{bdlist.HOMEPHONE},#{bdlist.ID},#{bdlist.IDTYPE},#{bdlist.ISSHOPASSIST},#{bdlist.JOINWORKDATE},#{bdlist.MNECODE},#{bdlist.MOBILE},#{bdlist.MODIFIEDTIME},#{bdlist.MODIFIER},#{bdlist.NAME},#{bdlist.NAME2},#{bdlist.NAME3},#{bdlist.NAME4},#{bdlist.NAME5},#{bdlist.NAME6},#{bdlist.OFFICEPHONE},#{bdlist.PK_GROUP},#{bdlist.PK_ORG},#{bdlist.PK_PSNDOC},#{bdlist.SEX},#{bdlist.TS},#{bdlist.USEDNAME},#{bdlist.BLOODTYPE},#{bdlist.CENSUSADDR},#{bdlist.CHARACTERRPR},#{bdlist.COUNTRY},#{bdlist.DIE_DATE},#{bdlist.DIE_REMARK},#{bdlist.EDU},#{bdlist.FAX},#{bdlist.FILEADDRESS},#{bdlist.HEALTH},#{bdlist.ISHISKEYPSN},#{bdlist.JOINPOLITYDATE},#{bdlist.MARITAL},#{bdlist.MARRIAGEDATE},#{bdlist.NATIONALITY},#{bdlist.NATIVEPLACE},#{bdlist.PENELAUTH},#{bdlist.PERMANRESIDE},#{bdlist.PHOTO},#{bdlist.PK_DEGREE},#{bdlist.PK_HRORG},#{bdlist.POLITY},#{bdlist.POSTALCODE},#{bdlist.PREVIEWPHOTO},#{bdlist.PROF},#{bdlist.RETIREDATE},#{bdlist.SECRET_EMAIL},#{bdlist.SHORTNAME},#{bdlist.TITLETECHPOST},#{bdlist.FIRSTNAME},#{bdlist.LASTNAME},#{bdlist.ISCADRE},#{bdlist.ISHISLEADER},#{bdlist.AGE},#{bdlist.WORKAGE},#{bdlist.GLBDEF21},#{bdlist.GLBDEF1},#{bdlist.GLBDEF2},#{bdlist.GLBDEF3},#{bdlist.GLBDEF4},#{bdlist.GLBDEF5},#{bdlist.GLBDEF6},#{bdlist.GLBDEF7},#{bdlist.GLBDEF8},#{bdlist.GLBDEF9},#{bdlist.GLBDEF10},#{bdlist.GLBDEF11},#{bdlist.GLBDEF12},#{bdlist.GLBDEF13},#{bdlist.GLBDEF14},#{bdlist.GLBDEF15},#{bdlist.GLBDEF17},#{bdlist.GLBDEF18},#{bdlist.GLBDEF19},#{bdlist.GLBDEF20},#{bdlist.GLBDEF22},#{bdlist.GLBDEF23},#{bdlist.GLBDEF16},#{bdlist.GLBDEF24},#{bdlist.GLBDEF25},#{bdlist.GLBDEF26},#{bdlist.GLBDEF27},#{bdlist.GLBDEF28},#{bdlist.GLBDEF29},#{bdlist.GLBDEF30},#{bdlist.RN},#{bdlist.DR})-->

    <!--</foreach>-->
    <!--</insert>-->
    <insert id="insertOrUpdatePlus" parameterType="java.util.List">
        INSERT INTO performance_app.bd_psndoc_bak
        (ADDR,
        BIRTHDATE,
        CODE,
        CREATIONTIME,
        CREATOR,
        DATAORIGINFLAG,
        EMAIL,
        ENABLESTATE,
        HOMEPHONE,
        ID,
        IDTYPE,
        ISSHOPASSIST,JOINWORKDATE,MNECODE,MOBILE,MODIFIEDTIME,MODIFIER,
        NAME,NAME2,NAME3,NAME4,NAME5,NAME6,OFFICEPHONE,PK_GROUP,PK_ORG,
        PK_PSNDOC,SEX,TS,USEDNAME,BLOODTYPE,CENSUSADDR,
        CHARACTERRPR,COUNTRY,DIE_DATE,DIE_REMARK,EDU,
        FAX,FILEADDRESS,HEALTH,ISHISKEYPSN,
        JOINPOLITYDATE,MARITAL,MARRIAGEDATE,
        NATIONALITY,NATIVEPLACE,
        PENELAUTH,PERMANRESIDE,
        PK_DEGREE,PK_HRORG,POLITY,
        POSTALCODE,PROF,RETIREDATE,SECRET_EMAIL,SHORTNAME,TITLETECHPOST,FIRSTNAME,
        LASTNAME,ISCADRE,ISHISLEADER,AGE,WORKAGE,GLBDEF21,GLBDEF1,
        GLBDEF2,GLBDEF3,GLBDEF4,GLBDEF5,GLBDEF6,GLBDEF7,
        GLBDEF8,GLBDEF9,GLBDEF10,GLBDEF11,GLBDEF12,GLBDEF13,
        GLBDEF14,GLBDEF15,GLBDEF17,GLBDEF18,GLBDEF19,GLBDEF20,GLBDEF22,GLBDEF23,GLBDEF16,
        GLBDEF24,GLBDEF25,GLBDEF26,GLBDEF27,GLBDEF28,GLBDEF29,GLBDEF30,RN,DR)
        VALUES
        <foreach collection="bd" item="bdlist" separator=",">
            (#{bdlist.ADDR},
            #{bdlist.BIRTHDATE},
            #{bdlist.CODE},
            #{bdlist.CREATIONTIME},
            #{bdlist.CREATOR},
            #{bdlist.DATAORIGINFLAG},
            #{bdlist.EMAIL},
            #{bdlist.ENABLESTATE},
            #{bdlist.HOMEPHONE},
            #{bdlist.ID},
            #{bdlist.IDTYPE},
            #{bdlist.ISSHOPASSIST},
            #{bdlist.JOINWORKDATE},
            #{bdlist.MNECODE},
            #{bdlist.MOBILE},
            #{bdlist.MODIFIEDTIME},
            #{bdlist.MODIFIER},
            #{bdlist.NAME},
            #{bdlist.NAME2},
            #{bdlist.NAME3},
            #{bdlist.NAME4},
            #{bdlist.NAME5},
            #{bdlist.NAME6},
            #{bdlist.OFFICEPHONE},
            #{bdlist.PK_GROUP},
            #{bdlist.PK_ORG},
            #{bdlist.PK_PSNDOC},
            #{bdlist.SEX},
            #{bdlist.TS},
            #{bdlist.USEDNAME},#{bdlist.BLOODTYPE},#{bdlist.CENSUSADDR},#{bdlist.CHARACTERRPR},#{bdlist.COUNTRY},#{bdlist.DIE_DATE},#{bdlist.DIE_REMARK},#{bdlist.EDU},#{bdlist.FAX},#{bdlist.FILEADDRESS},#{bdlist.HEALTH},#{bdlist.ISHISKEYPSN},#{bdlist.JOINPOLITYDATE},#{bdlist.MARITAL},#{bdlist.MARRIAGEDATE},#{bdlist.NATIONALITY},#{bdlist.NATIVEPLACE},#{bdlist.PENELAUTH},#{bdlist.PERMANRESIDE},#{bdlist.PK_DEGREE},#{bdlist.PK_HRORG},#{bdlist.POLITY},#{bdlist.POSTALCODE},#{bdlist.PROF},#{bdlist.RETIREDATE},#{bdlist.SECRET_EMAIL},#{bdlist.SHORTNAME},#{bdlist.TITLETECHPOST},#{bdlist.FIRSTNAME},#{bdlist.LASTNAME},#{bdlist.ISCADRE},#{bdlist.ISHISLEADER},#{bdlist.AGE},#{bdlist.WORKAGE},#{bdlist.GLBDEF21},#{bdlist.GLBDEF1},#{bdlist.GLBDEF2},#{bdlist.GLBDEF3},#{bdlist.GLBDEF4},#{bdlist.GLBDEF5},#{bdlist.GLBDEF6},#{bdlist.GLBDEF7},#{bdlist.GLBDEF8},#{bdlist.GLBDEF9},#{bdlist.GLBDEF10},#{bdlist.GLBDEF11},#{bdlist.GLBDEF12},#{bdlist.GLBDEF13},#{bdlist.GLBDEF14},#{bdlist.GLBDEF15},#{bdlist.GLBDEF17},#{bdlist.GLBDEF18},#{bdlist.GLBDEF19},#{bdlist.GLBDEF20},#{bdlist.GLBDEF22},#{bdlist.GLBDEF23},#{bdlist.GLBDEF16},#{bdlist.GLBDEF24},#{bdlist.GLBDEF25},#{bdlist.GLBDEF26},#{bdlist.GLBDEF27},#{bdlist.GLBDEF28},#{bdlist.GLBDEF29},#{bdlist.GLBDEF30},#{bdlist.RN},#{bdlist.DR})

        </foreach>
    </insert>

    <insert id="insertErrorInfo">
        insert into performance_app.error_info (error_page_index, error_msg) VALUES (#{errorPageIndex}, #{errorMsg})
    </insert>

    <select id="getMaxId" resultType="long">
        SELECT max(BID) FROM performance_app.bd_psndoc_bak
    </select>

    <select id="getMinId" resultType="long">
        SELECT min(BID) FROM performance_app.bd_psndoc_bak
    </select>

    <update id="updateAll">
        update performance_app.bd_psndoc b1 join
        (select <include refid="allFiledEx"/> from performance_app.bd_psndoc_bak where BID >= #{startId} and BID <![CDATA[<=]]> #{endId} ) b2 on b2.PK_PSNDOC = b1.PK_PSNDOC
        set <include refid="updateFiledEx"/>
    </update>

    <insert id="insertWillAdd">
        INSERT INTO performance_app.bd_psndoc <include refid="allFiled"/> (SELECT <include refid="allFiledEx"/> FROM performance_app.bd_psndoc_bak
        b2 WHERE b2.BID >= #{startId} and b2.BID <![CDATA[<=]]> #{endId}
        AND b2.PK_PSNDOC NOT IN (SELECT PK_PSNDOC FROM performance_app.bd_psndoc))
    </insert>

    <sql id="allFiled">
        (ADDR,
        BIRTHDATE,
        CODE,
        CREATIONTIME,
        CREATOR,
        DATAORIGINFLAG,
        EMAIL,
        ENABLESTATE,
        HOMEPHONE,
        ID,
        IDTYPE,
        ISSHOPASSIST,JOINWORKDATE,MNECODE,MOBILE,MODIFIEDTIME,MODIFIER,
        NAME,NAME2,NAME3,NAME4,NAME5,NAME6,OFFICEPHONE,PK_GROUP,PK_ORG,
        PK_PSNDOC,SEX,TS,USEDNAME,BLOODTYPE,CENSUSADDR,
        CHARACTERRPR,COUNTRY,DIE_DATE,DIE_REMARK,EDU,
        FAX,FILEADDRESS,HEALTH,ISHISKEYPSN,
        JOINPOLITYDATE,MARITAL,MARRIAGEDATE,
        NATIONALITY,NATIVEPLACE,
        PENELAUTH,PERMANRESIDE,
        PK_DEGREE,PK_HRORG,POLITY,
        POSTALCODE,PROF,RETIREDATE,SECRET_EMAIL,SHORTNAME,TITLETECHPOST,FIRSTNAME,
        LASTNAME,ISCADRE,ISHISLEADER,AGE,WORKAGE,GLBDEF21,GLBDEF1,
        GLBDEF2,GLBDEF3,GLBDEF4,GLBDEF5,GLBDEF6,GLBDEF7,
        GLBDEF8,GLBDEF9,GLBDEF10,GLBDEF11,GLBDEF12,GLBDEF13,
        GLBDEF14,GLBDEF15,GLBDEF17,GLBDEF18,GLBDEF19,GLBDEF20,GLBDEF22,GLBDEF23,GLBDEF16,
        GLBDEF24,GLBDEF25,GLBDEF26,GLBDEF27,GLBDEF28,GLBDEF29,GLBDEF30,RN,DR)
    </sql>

    <sql id="allFiledEx">
        ADDR,
        BIRTHDATE,
        CODE,
        CREATIONTIME,
        CREATOR,
        DATAORIGINFLAG,
        EMAIL,
        ENABLESTATE,
        HOMEPHONE,
        ID,
        IDTYPE,
        ISSHOPASSIST,JOINWORKDATE,MNECODE,MOBILE,MODIFIEDTIME,MODIFIER,
        NAME,NAME2,NAME3,NAME4,NAME5,NAME6,OFFICEPHONE,PK_GROUP,PK_ORG,
        PK_PSNDOC,SEX,TS,USEDNAME,BLOODTYPE,CENSUSADDR,
        CHARACTERRPR,COUNTRY,DIE_DATE,DIE_REMARK,EDU,
        FAX,FILEADDRESS,HEALTH,ISHISKEYPSN,
        JOINPOLITYDATE,MARITAL,MARRIAGEDATE,
        NATIONALITY,NATIVEPLACE,
        PENELAUTH,PERMANRESIDE,
        PK_DEGREE,PK_HRORG,POLITY,
        POSTALCODE,PROF,RETIREDATE,SECRET_EMAIL,SHORTNAME,TITLETECHPOST,FIRSTNAME,
        LASTNAME,ISCADRE,ISHISLEADER,AGE,WORKAGE,GLBDEF21,GLBDEF1,
        GLBDEF2,GLBDEF3,GLBDEF4,GLBDEF5,GLBDEF6,GLBDEF7,
        GLBDEF8,GLBDEF9,GLBDEF10,GLBDEF11,GLBDEF12,GLBDEF13,
        GLBDEF14,GLBDEF15,GLBDEF17,GLBDEF18,GLBDEF19,GLBDEF20,GLBDEF22,GLBDEF23,GLBDEF16,
        GLBDEF24,GLBDEF25,GLBDEF26,GLBDEF27,GLBDEF28,GLBDEF29,GLBDEF30,RN,DR
    </sql>

    <sql id="updateFiledEx">
            b1.ADDR = b2.ADDR,
            b1.BIRTHDATE = b2.BIRTHDATE,
            b1.CODE = b2.CODE,
            b1.CREATIONTIME = b2.CREATIONTIME,
            b1.CREATOR = b2.CREATOR,
            b1.DATAORIGINFLAG = b2.DATAORIGINFLAG,
            b1.EMAIL = b2.EMAIL,
            b1.ENABLESTATE = b2.ENABLESTATE,
            b1.HOMEPHONE = b2.HOMEPHONE,
            b1.ID = b2.ID,
            b1.IDTYPE = b2.IDTYPE,
            b1.ISSHOPASSIST = b2.ISSHOPASSIST,
            b1.JOINWORKDATE = b2.JOINWORKDATE,
            b1.MNECODE = b2.MNECODE,
            b1.MOBILE = b2.MOBILE,
            b1.MODIFIEDTIME = b2.MODIFIEDTIME,
            b1.MODIFIER = b2.MODIFIER,
            b1.NAME = b2.NAME,
            b1.NAME2 = b2.NAME2,
            b1.NAME3 = b2.NAME3,
            b1.NAME4 = b2.NAME4,
            b1.NAME5 = b2.NAME5,
            b1.NAME6 = b2.NAME6,
            b1.OFFICEPHONE = b2.OFFICEPHONE,
            b1.PK_GROUP = b2.PK_GROUP,
            b1.PK_ORG = b2.PK_ORG,
            b1.PK_PSNDOC = b2.PK_PSNDOC,
            b1.SEX = b2.SEX,
            b1.TS = b2.TS,
            b1.USEDNAME = b2.USEDNAME,
            b1.BLOODTYPE = b2.BLOODTYPE,
            b1.CENSUSADDR = b2.CENSUSADDR,
            b1.CHARACTERRPR = b2.CHARACTERRPR,
            b1.COUNTRY = b2.COUNTRY,
            b1.DIE_DATE = b2.DIE_DATE,
            b1.DIE_REMARK = b2.DIE_REMARK,
            b1.EDU = b2.EDU,
            b1.FAX = b2.FAX,
            b1.FILEADDRESS = b2.FILEADDRESS,
            b1.HEALTH = b2.HEALTH,
            b1.ISHISKEYPSN = b2.ISHISKEYPSN,
            b1.JOINPOLITYDATE = b2.JOINPOLITYDATE,
            b1.MARITAL = b2.MARITAL,
            b1.MARRIAGEDATE = b2.MARRIAGEDATE,
            b1.NATIONALITY = b2.NATIONALITY,
            b1.NATIVEPLACE = b2.NATIVEPLACE,
            b1.PENELAUTH = b2.PENELAUTH,
            b1.PERMANRESIDE = b2.PERMANRESIDE,
            b1.PK_DEGREE = b2.PK_DEGREE,
            b1.PK_HRORG = b2.PK_HRORG,
            b1.POLITY = b2.POLITY,
            b1.POSTALCODE = b2.POSTALCODE,
            b1.PROF = b2.PROF,
            b1.RETIREDATE = b2.RETIREDATE,
            b1.SECRET_EMAIL = b2.SECRET_EMAIL,
            b1.SHORTNAME = b2.SHORTNAME,
            b1.TITLETECHPOST = b2.TITLETECHPOST,
            b1.FIRSTNAME = b2.FIRSTNAME,
            b1.LASTNAME = b2.LASTNAME,
            b1.ISCADRE = b2.ISCADRE,
            b1.ISHISLEADER = b2.ISHISLEADER,
            b1.AGE = b2.AGE,
            b1.WORKAGE = b2.WORKAGE,
            b1.GLBDEF21 = b2.GLBDEF21,
            b1.GLBDEF1 = b2.GLBDEF1,
            b1.GLBDEF2 = b2.GLBDEF2,
            b1.GLBDEF3 = b2.GLBDEF3,
            b1.GLBDEF4 = b2.GLBDEF4,
            b1.GLBDEF5 = b2.GLBDEF5,
            b1.GLBDEF6 = b2.GLBDEF6,
            b1.GLBDEF7 = b2.GLBDEF7,
            b1.GLBDEF8 = b2.GLBDEF8,
            b1.GLBDEF9 = b2.GLBDEF9,
            b1.GLBDEF10 = b2.GLBDEF10,
            b1.GLBDEF11 = b2.GLBDEF11,
            b1.GLBDEF12 = b2.GLBDEF12,
            b1.GLBDEF13 = b2.GLBDEF13,
            b1.GLBDEF14 = b2.GLBDEF14,
            b1.GLBDEF15 = b2.GLBDEF15,
            b1.GLBDEF17 = b2.GLBDEF17,
            b1.GLBDEF18 = b2.GLBDEF18,
            b1.GLBDEF19 = b2.GLBDEF19,
            b1.GLBDEF20 = b2.GLBDEF20,
            b1.GLBDEF22 = b2.GLBDEF22,
            b1.GLBDEF23 = b2.GLBDEF23,
            b1.GLBDEF16 = b2.GLBDEF16,
            b1.GLBDEF24 = b2.GLBDEF24,
            b1.GLBDEF25 = b2.GLBDEF25,
            b1.GLBDEF26 = b2.GLBDEF26,
            b1.GLBDEF27 = b2.GLBDEF27,
            b1.GLBDEF28 = b2.GLBDEF28,
            b1.GLBDEF29 = b2.GLBDEF29,
            b1.GLBDEF30 = b2.GLBDEF30,
            b1.RN = b2.RN,
            b1.DR = b2.DR
    </sql>

    <delete id="truncateTableBdPsndocBak">
        TRUNCATE TABLE performance_app.bd_psndoc_bak
    </delete>
</mapper>

