<?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.cim.idm.dao.FgStockInDao">
<!--    更新入库标记-->
    <update id="updateBsMesShipped" parameterType="java.util.List">
        UPDATE BS_MES_SHIPPED T
        SET
        T.RECEIVE_FLAG = 'Y',
        T.RECEIVETIME = SYSDATE
        WHERE
        T.LOTNAME IN
        <foreach item="box" index="index" collection="boxList" open="(" separator="," close=")">
            #{box.materialPackingName}
        </foreach>
    </update>

<!--    获取所有待入库的信息-->
    <select id="getBoxList"
            resultType="com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking" parameterType="java.util.List">
        SELECT
        T.LOTNAME MATERIALPACKINGNAME,
        T.LOTNAME LKMATERIALPACKINGNAME,
        T.QTY MATERIALQUANTITY,
        T.QTY SUBPACKINGQUANTITY,
        T.QTY MaterialCreateQuantity,
        'SDK' siteName,
        'Released' PackingState,
        'Created' stockState,
        T.DURABLETYPE durableType,
        #{erpFactory} ERPFactory,
        #{erpLocation} ERPLOCATION,
        #{locationName} LOCATIONNAME,
        T.AREA areaName,
        NVL(T.MAKEDATE, SYSDATE ) MAKEDATE ,
        NVL(T.MAKEDATE, SYSDATE ) + NVL(M3.EXPIRATIONDAY, '9999') expiringDate,
        SYSDATE ReceiveTime,
        T.REQUESTNAME productOrder,
        T.CAREER_ASSISTANCE ,
        M3.MATERIALSPECTYPE ,
        T.BUSINESS_UNIT,
        T.SALESPERSON,
        T.UNIT,
        T.REQUESTNAME,
        T.PRODUCTSPECNAME MATERIALSPECNAME,
        SS.SPECNAME ,
        T.SDK_ID ,
        T.AREA ,
        T.SHIPUSER ,
        T.PACKINGGRADE ,
        T.PACKINGGRADEDETAIL ,
        T.SHIPTIME ,
        M3.MATERIALTYPE ,
        T.PHASE,
        T.GXID,
        T.MATERIALSPECTYPE
        FROM
        BS_MES_SHIPPED T
        LEFT JOIN SDK_SPEC SS ON
        T.SDK_ID = SS.SDK_ID
        LEFT JOIN MATERIALSPEC M3 ON
        T.PRODUCTSPECNAME = M3.MATERIALSPECNAME
        WHERE
        (T.RECEIVE_FLAG IS NULL
        OR T.RECEIVE_FLAG !='Y')
        AND T.LOTNAME IN
        <foreach item="box" index="index" collection="boxList" open="(" separator="," close=")">
            #{box.materialPackingName}
        </foreach>
    </select>

</mapper>