<?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.BdTypeMapper">
    <!--<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_type_bak` (
        `one`,
        `pk_group`,
        `two`,
        `two_tissue`,
        `three`,
        `three_tissue`,
        `Four`,
        `Four_tissue`,
        `five`,
        `pk_org`,
        `one_branch`,
        `pk_dept`,
        `two_branch`,
        `two_name`,
        `three_branch`,
        `three_name`,
        `Four_branch`,
        `Four_name`)
        VALUES
        <foreach collection="bd" item="bdlist" separator=",">
            (#{bdlist.one},
            #{bdlist.pkGroup},
            #{bdlist.two},
            #{bdlist.twoTissue},
            #{bdlist.three},
            #{bdlist.threeTissue},
            #{bdlist.four},
            #{bdlist.fourTissue},
            #{bdlist.five},
            #{bdlist.pkOrg},
            #{bdlist.oneBranch},
            #{bdlist.pkDept},
            #{bdlist.twoBranch},
            #{bdlist.twoName},
            #{bdlist.threeBranch},
            #{bdlist.threeName},
            #{bdlist.fourBranch},
            #{bdlist.fourName})
        </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(tid) FROM performance_app.bd_type_bak
    </select>
    <select id="getMinId" resultType="long">
        SELECT min(tid) FROM performance_app.bd_type_bak
    </select>

    <delete id="truncateTable">
        TRUNCATE TABLE performance_app.bd_type
    </delete>

    <insert id="midToBusness">
        INSERT INTO performance_app.bd_type  (SELECT * FROM performance_app.bd_type_bak
        b2 WHERE b2.tid > #{startId} and b2.tid <![CDATA[<=]]> #{endId})
    </insert>

    <delete id="truncateTableBdTypeBak">
        TRUNCATE TABLE performance_app.bd_type_bak
    </delete>
</mapper>