<?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.hzs.scm.ic.mapper.IcOnHandNumBMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="IcOnHandNumB" type="com.hzs.common.domain.scm.ic.IcOnHandNumB">
        <id column="PK_ID" property="pkId" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_ONHANDNUM" property="pkOnhandnum" />
        <result column="ORDER_TYPE" property="orderType" />
        <result column="PK_GENERAL_H" property="pkGeneralH" />
        <result column="PK_GENERAL_B" property="pkGeneralB" />
        <result column="NNUM" property="nnum" />
    </resultMap>
    <update id="insertIcOnHandNumbByList">
        INSERT ALL
        <foreach collection="onHandNumbList" item="item" separator=" ">
            into IC_ON_HAND_NUM_B(PK_ONHANDNUM, ORDER_TYPE,
            PK_GENERAL_H,PK_GENERAL_B,NNUM,PK_COUNTRY, PK_CREATOR)
            VALUES (#{item.pkOnhandnum}, #{item.orderType},
            #{item.pkGeneralH},#{item.pkGeneralB},#{item.nnum},#{item.pkCountry}, #{item.pkCreator}
            )
        </foreach>
        SELECT 1 FROM dual
    </update>
    <select id="queryOnHandNumByHandNumbList" resultMap="IcOnHandNumB">
        <foreach collection="icOnHandNumbList" item="item" separator=" union ">
            select pk_onhandnum,order_type,pk_general_h,pk_general_b,nnum from ic_on_hand_num_b
            where del_flag = 0 and order_type=#{item.orderType}
            and pk_general_h=#{item.pkGeneralH} and pk_general_b= #{item.pkGeneralB}
        </foreach>
    </select>

</mapper>
