<?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.trans.mapper.IcTransInBMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="IcTransInBExt" type="com.hzs.common.domain.scm.trans.ext.IcTransInBExt">
        <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_UNIT" property="pkUnit" />
        <result column="PK_TRANSFER_OUT" property="pkTransferOut" />
        <result column="PK_TRANSFER_OUT_B" property="pkTransferOutB" />
        <result column="PK_TRANSFER_IN" property="pkTransferIn" />
        <result column="PK_CLOCATION" property="pkClocation" />
        <result column="PK_PRODUCT_BAS" property="pkProductBas" />
        <result column="PK_PRODUCT" property="pkProduct" />
        <result column="TRANS_TYPE" property="transType" />
        <result column="BIZ_DATE" property="bizDate" />
        <result column="PK_CUBASDOC" property="pkCubasdoc" />
        <result column="PK_CUSTOMER" property="pkCustomer" />
        <result column="PK_OUT_STOREHOUSE" property="pkOutStorehouse" />
        <result column="PK_STOREHOUSE" property="pkStorehouse" />
        <result column="PK_RATE" property="pkRate" />
        <result column="NNUM" property="nnum" />
        <result column="NORIGPRICE" property="norigprice" />
        <result column="NTAXRATE" property="ntaxrate" />
        <result column="NORIGTAXPRICE" property="norigtaxprice" />
        <result column="NORIGMNY" property="norigmny" />
        <result column="NTAX" property="ntax" />
        <result column="NORIGTAXMNY" property="norigtaxmny" />
        <result column="PK_BATCH_CODE" property="pkBatchCode" />
        <result column="PK_PRODUCT" property="pkProduct" />
        <result column="PRODUCT_CODE" property="productCode" />
        <result column="PRODUCT_NAME" property="productName" />
        <result column="SPECS_NAME" property="specsName" />
        <result column="STOREHOUSE_NAME" property="storehouseName" />
        <result column="product_date" property="productDate" />
        <result column="expire_date" property="expireDate" />
        <collection property="scmItemSpecsList" ofType="com.hzs.common.domain.scm.pub.ScmItemSpecs" >
            <result column="PK_SPECS_TYPE" property="pkSpecsType" />
            <result column="PK_SPECS" property="pkSpecs" />
            <result column="SPECS_NAME" property="specsName" />
        </collection>
    </resultMap>
    <delete id="deletePurchaseInbByList">
        update ic_transin_b set del_flag=1,pk_modified=#{pkModified},modified_time=sysdate
        where del_flag=0 and pk_id in
        <foreach collection="transInbList" item="item" open="(" close=")" separator=",">
            #{item.pkId}
        </foreach>
    </delete>
    <select id="queryTransferInbByPk" resultMap="IcTransInBExt">
        select ib.*,ic.product_date,ic.expire_date,it.pk_specs_type,it.pk_specs,it.specs_name from ic_transin_b ib
        inner join scm_item_specs it
        on ib.pk_id=it.pk_order_items
        left join ic_batch_code ic
        on ic.pk_id=ib.pk_batch_code
        where ib.del_flag=0 and it.del_flag=0
        and it.order_type= #{orderType}
        and it.pk_order_items in
        <foreach collection="transInbList" item="item" open="(" close=")" separator=",">
            #{item.pkId}
        </foreach>
        order by ib.pk_id,it.pk_specs
    </select>

</mapper>
