<?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.ProduceReturnDao">

    <select id="getMaterialPacking" resultType="map">
        SELECT mp.LOTNAME MATERIALPACKINGNAME, mp.PRODUCTSPECNAME MATERIALSPECNAME, mp.PHASE, mp.PACKINGGRADE,
               mp.CHARGE, m.DESC_CN, #{erpFactory} AS ERPFACTORY,
               #{erpLocation} AS ERPLOCATION, #{locationName} AS LOCATIONNAME,
               mp.QTY MATERIALQUANTITY, mp.UNIT
        FROM BS_MES_SHIPPED mp
                 LEFT JOIN MATERIALSPEC m ON m.MATERIALSPECNAME = mp.PRODUCTSPECNAME
        WHERE mp.LOTNAME = #{name}
    </select>

    <select id="getMesShip" resultType="map">
        select bms.PRODUCTSPECNAME as MATERIALSPECNAME, bms.REQUESTNAME as RECEIVEREQUESTNAME,
               0 as HAVEQUANTITY, sum(bms.QTY) as TOTALQTY, bms.UNIT
		FROM BS_MES_SHIPPED bms
		where bms.LOTNAME = #{name}
		GROUP BY bms.REQUESTNAME, bms.PRODUCTSPECNAME, bms.UNIT
    </select>
</mapper>