<?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.prolog.cs.biz.outbound.dao.InnerCheckDMapper">


    <select id="getInnerCheckD" resultType="com.prolog.cs.biz.outbound.model.entity.InnerCheckDDO">
        select
          d.*,
          d.CHECKER_NAME CHECKER1,     
          d.CHECKER_NAME_2 CHECKER2,     
          (select sum(QTY) red_qty from WMS_SALE_RED_RECORD r where r.BILL_ID=s.BILL_ID and r.BILL_D_ID=s.BILL_D_ID
                                                                and r.type=4 and r.PICK_TASK_D_ID=d.PICK_TASK_D_ID) redQty,
          d.CHECKER2_QTY CHECKER2_QTY,
          s.BILL_D_ID billDId,
          s.ITEM_ID itemId,
          s.warehouse_id warehouseId
        from wms_pick_task_d d
        left join wms_wave_storage s on d.WAVE_STORAGE_ID = s.ID
        left join wms_pick_task_h h on d.pick_task_id = h.pick_task_id
        WHERE h.bill_group_id = #{billGroupId} AND h.CONTAINER_CODE = #{containerCode}
    </select>


</mapper>