<?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.bonus.canteen.core.drp.mapper.DrpOutDetailMapper">

<!--    <select id="selectListByIntoId" resultType="net.xnzn.core.drp.vo.DrpOutDetailPageVO">-->
<!--        SELECT dod.detail_id,-->
<!--               dod.inventory_id,-->
<!--               di.material_id,-->
<!--               mm.material_code,-->
<!--               mm.material_name,-->
<!--               mm.category_id,-->
<!--               mmc.category_name,-->
<!--               dod.fetch_num,-->
<!--               di.unit_id,-->
<!--               du.unit_name,-->
<!--               dod.size,-->
<!--               dod.into_detail_id,-->
<!--               dod.material_url,-->
<!--               did.into_id,-->
<!--               dii.into_date,-->
<!--               did.inventory_num,-->
<!--               did.unit_price,-->
<!--               did.expire_time,-->
<!--               dod.total_price,-->
<!--               dod.if_overdraft-->
<!--        FROM drp_out_detail dod-->
<!--                 LEFT JOIN drp_inventory di ON di.inventory_id = dod.inventory_id-->
<!--                 LEFT JOIN menu_material mm ON mm.material_id = di.material_id-->
<!--                 LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id-->
<!--                 LEFT JOIN drp_unit du ON du.unit_id = di.unit_id-->
<!--                 LEFT JOIN drp_into_detail did ON did.detail_id = dod.into_detail_id-->
<!--                 LEFT JOIN drp_into_inventory dii on dii.into_id = did.into_id-->
<!--        where dod.out_id = #{outId}-->
<!--    </select>-->

<!--    &lt;!&ndash; 获取指定出库记录详情列表(安卓) &ndash;&gt;-->
<!--    <select id="selectAndroidListByOutId"-->
<!--            resultType="net.xnzn.core.drp.vo.AndroidOutDetailPageVO">-->
<!--        select dod.detail_id      detailId,-->
<!--               dod.inventory_id,-->
<!--               di.material_id     materialId,-->
<!--               mm.material_name   materialName,-->
<!--               did.supplier_id,-->
<!--               ds.supplier_name,-->
<!--               did.inventory_num  inventoryNum,-->
<!--               dod.fetch_num      fetchNum,-->
<!--               di.unit_id         unitId,-->
<!--               du.unit_name       unitName,-->
<!--               dod.into_detail_id intoDetailId,-->
<!--               did.unit_price     unitPrice,-->
<!--               dod.total_price    totalPrice,-->
<!--               dod.material_url   materialUrl-->
<!--        from drp_out_detail dod-->
<!--                 left join drp_inventory di on dod.inventory_id = di.inventory_id-->
<!--                 left join menu_material mm on di.material_id = mm.material_id-->
<!--                 left join drp_unit du on di.unit_id = du.unit_id-->
<!--                 left join drp_into_detail did on dod.into_detail_id = did.detail_id-->
<!--                 left join drp_supplier ds on ds.supplier_id = did.supplier_id-->
<!--        where dod.out_id = #{outId}-->
<!--    </select>-->

<!--    <select id="listExcelDetail" resultType="net.xnzn.core.drp.vo.DrpExcelOutDetailVO">-->
<!--        SELECT c.material_code,-->
<!--               c.material_name,-->
<!--               h.category_name,-->
<!--               f.expire_time,-->
<!--               g.into_date,-->
<!--               f.into_id,-->
<!--               f.inventory_num,-->
<!--               a.fetch_num,-->
<!--               e.unit_name,-->
<!--               f.unit_price  neUnitPrice,-->
<!--               a.total_price neTotalPrice-->
<!--        FROM drp_out_detail a-->
<!--                 LEFT JOIN drp_inventory b ON b.inventory_id = a.inventory_id-->
<!--                 LEFT JOIN menu_material c ON c.material_id = b.material_id-->
<!--                 LEFT JOIN drp_unit e ON e.unit_id = b.unit_id-->
<!--                 LEFT JOIN drp_into_detail f ON f.detail_id = a.into_detail_id-->
<!--                 LEFT JOIN drp_into_inventory g on g.into_id = f.into_id-->
<!--                 left join menu_material_category h on h.category_id = c.category_id-->
<!--        where a.out_id = #{outId}-->
<!--    </select>-->
    <select id="listIntoDetailMaterial" resultType="com.bonus.canteen.core.drp.po.IntoDetailMaterialModel">
        SELECT a.fetch_num,
               b.material_id,
               b.supplier_id,
               b.unit_id,
               b.size,
               b.unit_price
        FROM drp_out_detail a
                 LEFT JOIN drp_into_detail b ON b.detail_id = a.into_detail_id
        WHERE a.out_id = #{outId}
          AND a.inventory_id = #{inventoryId}
        ORDER BY a.id
    </select>

    <!-- 获取指定出库记录详情列表(安卓) -->
<!--    <select id="selectAndroidListByOutIdList" resultType="net.xnzn.core.drp.vo.AndroidOutDetailPageVO">-->
<!--        select dod.detail_id detailId,-->
<!--        dod.inventory_id,-->
<!--        dod.out_id,-->
<!--        di.material_id materialId,-->
<!--        mm.material_name materialName,-->
<!--        did.supplier_id,-->
<!--        ds.supplier_name,-->
<!--        did.inventory_num inventoryNum,-->
<!--        dod.fetch_num fetchNum,-->
<!--        di.unit_id unitId,-->
<!--        du.unit_name unitName,-->
<!--        dod.into_detail_id intoDetailId,-->
<!--        did.unit_price unitPrice,-->
<!--        dod.total_price totalPrice,-->
<!--        dod.material_url materialUrl-->
<!--        from drp_out_detail dod-->
<!--        left join drp_inventory di on dod.inventory_id = di.inventory_id-->
<!--        left join menu_material mm on di.material_id = mm.material_id-->
<!--        left join drp_unit du on di.unit_id = du.unit_id-->
<!--        left join drp_into_detail did on dod.into_detail_id = did.detail_id-->
<!--        left join drp_supplier ds on ds.supplier_id = did.supplier_id-->
<!--        where dod.out_id IN-->
<!--        <foreach collection="outIdList" item="outId" open="(" separator="," close=")">-->
<!--            #{outId}-->
<!--        </foreach>-->
<!--    </select>-->
<!--    <select id="listOutIdByIntoId" resultType="net.xnzn.core.drp.model.OutModel">-->
<!--        SELECT DISTINCT a.out_id,-->
<!--                        b.out_date-->
<!--        FROM drp_out_detail a-->
<!--                 LEFT JOIN drp_out_inventory b ON b.out_id = a.out_id-->
<!--                 LEFT JOIN drp_into_detail c ON c.detail_id = a.into_detail_id-->
<!--        WHERE c.into_id = #{intoId}-->
<!--          and b.`status` = #{outStatus}-->
<!--    </select>-->
<!--    <select id="listOutDetailByOutId" resultType="net.xnzn.core.drp.vo.DrpOutDetailListVO">-->
<!--        SELECT a.detail_id,-->
<!--               a.material_url,-->
<!--               b.material_id,-->
<!--               c.material_code,-->
<!--               c.material_name,-->
<!--               c.category_id,-->
<!--               d.category_name,-->
<!--               a.inventory_id,-->
<!--               b.unit_id,-->
<!--               e.unit_name,-->
<!--               f.unit_price,-->
<!--               a.fetch_num,-->
<!--               a.total_price,-->
<!--               f.inventory_num,-->
<!--               a.into_detail_id,-->
<!--               f.into_id,-->
<!--               g.into_date,-->
<!--               f.expire_time,-->
<!--               c.bar_code,-->
<!--               c.sales_mode,-->
<!--               e.rate-->
<!--        FROM drp_out_detail a-->
<!--                 LEFT JOIN drp_inventory b ON b.inventory_id = a.inventory_id-->
<!--                 LEFT JOIN menu_material c ON c.material_id = b.material_id-->
<!--                 LEFT JOIN menu_material_category d ON d.category_id = c.category_id-->
<!--                 LEFT JOIN drp_unit e ON e.unit_id = b.unit_id-->
<!--                 LEFT JOIN drp_into_detail f ON f.detail_id = a.into_detail_id-->
<!--                 LEFT JOIN drp_into_inventory g ON g.into_id = f.into_id-->
<!--        where a.out_id = #{outId}-->
<!--    </select>-->
<!--    <select id="listOutDetail" resultType="net.xnzn.core.drp.po.OutDetailModel">-->
<!--        SELECT inventory_id,-->
<!--               fetch_num,-->
<!--               into_detail_id-->
<!--        FROM drp_out_detail-->
<!--        WHERE out_id = #{outId}-->
<!--    </select>-->
<!--    <select id="mqListOutDetailInfo" resultType="net.xnzn.core.drp.vo.MqDrpOutMaterialInfoVO">-->
<!--        SELECT e.material_id,-->
<!--               f.material_name,-->
<!--               f.category_id,-->
<!--               i.category_name,-->
<!--               f.unit_id,-->
<!--               g.unit_name,-->
<!--               a.fetch_num,-->
<!--               d.into_id,-->
<!--               d.into_date,-->
<!--               b.out_id,-->
<!--               b.out_date,-->
<!--               b.warehouse_id,-->
<!--               h.warehouse_name-->
<!--        FROM drp_out_detail a-->
<!--                 LEFT JOIN drp_out_inventory b ON b.out_id = a.out_id-->
<!--                 LEFT JOIN drp_into_detail c ON c.detail_id = a.into_detail_id-->
<!--                 LEFT JOIN drp_into_inventory d ON d.into_id = c.into_id-->
<!--                 LEFT JOIN drp_inventory e ON e.inventory_id = a.inventory_id-->
<!--                 LEFT JOIN menu_material f ON f.material_id = e.material_id-->
<!--                 LEFT JOIN drp_unit g ON g.unit_id = f.unit_id-->
<!--                 LEFT JOIN drp_warehouse h ON h.warehouse_id = b.warehouse_id-->
<!--                 LEFT JOIN menu_material_category i ON i.category_id = f.category_id-->
<!--        WHERE a.out_id = #{outId}-->
<!--    </select>-->
<!--    <select id="getIntoIdByMaterialIdAndOutId" resultType="net.xnzn.core.drp.vo.DrpIntoModelVO">-->
<!--        SELECT c.into_id,-->
<!--               d.into_date intoTime-->
<!--        FROM drp_out_detail a-->
<!--                 LEFT JOIN drp_out_inventory b ON b.out_id = a.out_id-->
<!--                 LEFT JOIN drp_into_detail c ON c.detail_id = a.into_detail_id-->
<!--                 Left Join drp_into_inventory d ON d.into_id = c.into_id-->
<!--        WHERE c.material_id = #{materialId}-->
<!--          AND b.out_id = #{outId}-->
<!--    </select>-->
<!--    <select id="getIntoDetailById" resultType="net.xnzn.core.drp.po.DrpIntoDetailByIdGetModel">-->
<!--        SELECT a.material_id,-->
<!--               a.supplier_id,-->
<!--               a.unit_id,-->
<!--               a.unit_price,-->
<!--               a.product_date,-->
<!--               a.expire_time,-->
<!--               b.material_num inventoryNum-->
<!--        FROM drp_into_detail a-->
<!--                 LEFT JOIN drp_inventory b ON b.inventory_id = a.inventory_id-->
<!--        WHERE detail_id = #{intoDetailId}-->
<!--    </select>-->
<!--    <select id="listCancelOutDetailMq" resultType="net.xnzn.core.drp.po.DrpMqCancelIntoAndOutModel">-->
<!--        SELECT-->
<!--            a.detail_id,-->
<!--            b.out_id recordId,-->
<!--            2 recordType,-->
<!--            b.out_date recordTime,-->
<!--            c.material_id-->
<!--        FROM-->
<!--            drp_out_detail a-->
<!--                LEFT JOIN drp_out_inventory b ON b.out_id = a.out_id-->
<!--                LEFT JOIN drp_inventory c ON c.inventory_id = a.inventory_id-->
<!--        where  a.out_id = #{recordId}-->
<!--    </select>-->
<!--    <select id="pageOutDetail" resultType="net.xnzn.core.drp.vo.DrpOutDetailListVO">-->
<!--        SELECT-->
<!--            e.material_id,-->
<!--            f.material_name,-->
<!--            f.category_id,-->
<!--            i.category_name,-->
<!--            f.unit_id,-->
<!--            g.unit_name,-->
<!--            a.fetch_num,-->
<!--            d.into_id,-->
<!--            d.into_date,-->
<!--            b.out_id,-->
<!--            b.out_date,-->
<!--            b.warehouse_id,-->
<!--            h.warehouse_name-->
<!--        FROM-->
<!--            drp_out_detail a-->
<!--                LEFT JOIN drp_out_inventory b ON b.out_id = a.out_id-->
<!--                LEFT JOIN drp_into_detail c ON c.detail_id = a.into_detail_id-->
<!--                LEFT JOIN drp_into_inventory d ON d.into_id = c.into_id-->
<!--                LEFT JOIN drp_inventory e ON e.inventory_id = a.inventory_id-->
<!--                LEFT JOIN menu_material f ON f.material_id = e.material_id-->
<!--                LEFT JOIN drp_unit g ON g.unit_id = f.unit_id-->
<!--                LEFT JOIN drp_warehouse h ON h.warehouse_id = b.warehouse_id-->
<!--                LEFT JOIN menu_material_category i ON i.category_id = f.category_id-->
<!--        WHERE-->
<!--            a.out_id = #{content.orderId}-->
<!--    </select>-->
</mapper>















































