<?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.HiPsndocWorkMapper">
    <insert id="insertOrUpdatePlus" parameterType="java.util.List" >
            INSERT INTO performance_app.hi_psndoc_work_bak
            (BEGINDATE,BG_CHECK,CERTIPHONE,CERTIFIER,CREATIONTIME,CREATOR,DIMISSION_REASON,ENDDATE,LASTFLAG,LINKPHONE,MEMO,MODIFIEDTIME,MODIFIER,PK_GROUP,PK_ORG,PK_PSNDOC,PK_PSNDOC_SUB,PK_PSNJOB,PK_PSNORG,RECORDNUM,TS,WORK_ADDR,WORKACHIVE,WORKCORP,WORKDEPT,WORKDUTY,WORKJOB,WORKPOST,GLBDEF1,GLBDEF2,GLBDEF3,GLBDEF4,GLBDEF5,GLBDEF6,GLBDEF7,GLBDEF8,GLBDEF9,GLBDEF10,GLBDEF11,GLBDEF12,GLBDEF13,GLBDEF14,RN,DR)
            VALUES  
            <foreach collection="bd" item="bdlist"  separator=",">
            (#{bdlist.BEGINDATE},#{bdlist.BG_CHECK},#{bdlist.CERTIFIER},#{bdlist.CERTIPHONE},#{bdlist.CREATIONTIME},#{bdlist.CREATOR},#{bdlist.DIMISSION_REASON},#{bdlist.ENDDATE},#{bdlist.LASTFLAG},#{bdlist.LINKPHONE},#{bdlist.MEMO},#{bdlist.MODIFIEDTIME},#{bdlist.MODIFIER},#{bdlist.PK_GROUP},#{bdlist.PK_ORG},#{bdlist.PK_PSNDOC},#{bdlist.PK_PSNDOC_SUB},#{bdlist.PK_PSNJOB},#{bdlist.PK_PSNORG},#{bdlist.RECORDNUM},#{bdlist.TS},#{bdlist.WORK_ADDR},#{bdlist.WORKACHIVE},#{bdlist.WORKCORP},#{bdlist.WORKDEPT},#{bdlist.WORKDUTY},#{bdlist.WORKJOB},#{bdlist.WORKPOST},#{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.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(HID) FROM performance_app.hi_psndoc_work_bak
    </select>
    <select id="getMinId" resultType="long">
        SELECT min(HID) FROM performance_app.hi_psndoc_work_bak
    </select>

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

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