<?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.supply.purchase.mapper.DrpIntoDetailMapper">

    <!-- 获取指定入库记录详情列表 -->
<!--    <select id="selectListByIntoId" resultType="net.xnzn.core.drp.vo.DrpIntoDetailPageVO">-->
<!--        SELECT-->
<!--            did.detail_id,-->
<!--            did.into_id,-->
<!--            did.material_id,-->
<!--            mm.material_name,-->
<!--            did.inventory_id,-->
<!--            mm.category_id,-->
<!--            mm.material_code,-->
<!--            mmc.category_name,-->
<!--            did.supplier_id,-->
<!--            ds.supplier_name,-->
<!--            did.unit_id,-->
<!--            du.unit_name,-->
<!--            did.size,-->
<!--            did.unit_price,-->
<!--            did.total_price,-->
<!--            did.delivery_num,-->
<!--            did.pur_num,-->
<!--            did.inventory_num,-->
<!--            did.product_date,-->
<!--            did.expire_time,-->
<!--            did.material_url,-->
<!--            did.if_fill_inventory-->
<!--        FROM drp_into_detail did-->
<!--                 left join menu_material mm on mm.material_id = did.material_id-->
<!--                 LEFT JOIN drp_supplier ds ON did.supplier_id = ds.supplier_id-->
<!--                 LEFT JOIN drp_unit du ON did.unit_id = du.unit_id-->
<!--                 LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id-->
<!--        where did.into_id = #{intoId}-->
<!--    </select>-->

<!--    &lt;!&ndash; 获取当前库存的所有批次 &ndash;&gt;-->
<!--    <select id="selectNoOutInventory" resultType="net.xnzn.core.drp.vo.NoOutInventoryVO">-->
<!--        select did.detail_id     detailId,-->
<!--               did.inventory_num inventoryNum-->
<!--        from drp_into_inventory dii-->
<!--                 left join drp_into_detail did on dii.into_id = did.into_id-->
<!--        where did.config_id = #{configId}-->
<!--          and did.inventory_num > 0-->
<!--        order by dii.into_date-->
<!--    </select>-->

<!--    &lt;!&ndash; 获取指定入库记录详情列表(安卓) &ndash;&gt;-->
<!--    <select id="selectAndroidListByIntoId"-->
<!--            resultType="net.xnzn.core.drp.vo.AndroidIntoDetailPageVO">-->
<!--        SELECT-->
<!--            did.detail_id,-->
<!--            did.material_id,-->
<!--            mm.material_name,-->
<!--            did.unit_price,-->
<!--            did.total_price,-->
<!--            did.pur_num,-->
<!--            did.unit_id,-->
<!--            du.unit_name,-->
<!--            did.supplier_id,-->
<!--            ds.supplier_name,-->
<!--            did.expire_time,-->
<!--            did.material_url-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--            LEFT JOIN menu_material mm ON did.material_id = mm.material_id-->
<!--            LEFT JOIN drp_unit du ON did.unit_id = du.unit_id-->
<!--            LEFT JOIN drp_supplier ds ON did.supplier_id = ds.supplier_id-->
<!--        WHERE-->
<!--            did.into_id = #{intoId}-->
<!--    </select>-->

<!--    <select id="listExcelDetail" resultType="net.xnzn.core.drp.vo.DrpExcelIntoDetailVO">-->
<!--        SELECT-->
<!--            B.material_code,-->
<!--            B.material_name,-->
<!--            E.category_name,-->
<!--            D.unit_name,-->
<!--            A.pur_num,-->
<!--            A.unit_price as neUnitPrice,-->
<!--            A.total_price as neTotalPrice,-->
<!--            C.supplier_name,-->
<!--            A.product_date,-->
<!--            A.expire_time-->
<!--        FROM drp_into_detail A-->
<!--        left join menu_material B on B.material_id = A.material_id-->
<!--        LEFT JOIN drp_supplier C ON A.supplier_id = C.supplier_id-->
<!--        LEFT JOIN drp_unit D ON A.unit_id = D.unit_id-->
<!--        LEFT JOIN menu_material_category E ON E.category_id = B.category_id-->
<!--        where A.into_id = #{intoId}-->
<!--    </select>-->
    <select id="selectLastIntoDetail" resultType="com.bonus.canteen.core.supply.purchase.domain.bo.MaterialIntoDetailModel">
        SELECT
            a.material_id,
            a.supplier_id,
            b.supplier_name,
            a.unit_id,
            c.unit_name,
            a.unit_price,
            a.pur_num
        FROM
            drp_into_detail a
            LEFT JOIN drp_supplier b ON b.supplier_id = a.supplier_id
            LEFT JOIN drp_unit c ON c.unit_id = a.unit_id
            LEFT JOIN drp_into_inventory d ON d.into_id = a.into_id
        WHERE
            a.material_id = #{materialId}
            AND d.warehouse_id = #{warehouseId}
            AND d.`status` = #{status}
        LIMIT 1
    </select>
<!--    <select id="listIntoByMaterial" resultType="net.xnzn.core.drp.vo.DrpIntoByMaterialListVO">-->
<!--        SELECT DISTINCT-->
<!--        b.into_id,-->
<!--        b.warehouse_id,-->
<!--        c.warehouse_name,-->
<!--        b.into_type,-->
<!--        b.into_date,-->
<!--        a.supplier_id,-->
<!--        e.supplier_name,-->
<!--        b.crby-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--        JOIN drp_into_inventory b ON a.into_id = b.into_id-->
<!--        LEFT JOIN drp_warehouse c ON c.warehouse_id = b.warehouse_id-->
<!--        LEFT JOIN drp_supplier e on e.supplier_id = a.supplier_id-->
<!--        WHERE-->
<!--        a.material_id = #{content.materialId}-->
<!--        AND b.`status` = #{status}-->
<!--        AND b.into_date <![CDATA[ >= ]]> #{content.beginTime}-->
<!--        AND b.into_date <![CDATA[ <= ]]> #{content.endTime}-->
<!--        order by b.into_date desc-->
<!--    </select>-->
<!--    <select id="listIntoDetailByInventoryId" resultType="net.xnzn.core.drp.model.DrpIntoDetail">-->
<!--        SELECT-->
<!--            did.*-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--            LEFT JOIN drp_into_inventory dii ON dii.into_id = did.into_id-->
<!--        WHERE-->
<!--            did.inventory_id = #{inventoryId}-->
<!--            AND dii.`status` = #{intoStatus}-->
<!--            AND did.inventory_num > #{leastNum}-->
<!--        ORDER BY-->
<!--            dii.into_date ASC-->
<!--    </select>-->

<!--    &lt;!&ndash; 获取指定入库记录详情列表(安卓) &ndash;&gt;-->
<!--    <select id="selectAndroidListByIntoIdList" resultType="net.xnzn.core.drp.vo.AndroidIntoDetailPageVO">-->
<!--        SELECT did.detail_id,-->
<!--               did.material_id,-->
<!--               did.into_id,-->
<!--               mm.material_name,-->
<!--               did.unit_price,-->
<!--               did.total_price,-->
<!--               did.pur_num,-->
<!--               did.unit_id,-->
<!--               du.unit_name,-->
<!--               did.supplier_id,-->
<!--               ds.supplier_name,-->
<!--               did.expire_time,-->
<!--               did.material_url-->
<!--        FROM drp_into_detail did-->
<!--                 LEFT JOIN menu_material mm ON did.material_id = mm.material_id-->
<!--                 LEFT JOIN drp_unit du ON did.unit_id = du.unit_id-->
<!--                 LEFT JOIN drp_supplier ds ON did.supplier_id = ds.supplier_id-->
<!--        WHERE did.into_id IN-->
<!--        <foreach collection="intoIdList" item="intoId" open="(" close=")" separator=",">-->
<!--            #{intoId}-->
<!--        </foreach>-->
<!--    </select>-->
<!--    <select id="getDeliveryQualifiedRate" resultType="java.math.BigDecimal">-->
<!--        SELECT-->
<!--        ROUND( SUM( pur_num ) / SUM( delivery_num ) * 100, 2 )-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--        LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--        WHERE-->
<!--        a.supplier_id = #{supplierId}-->
<!--        and b.`status` = #{intoStatus}-->
<!--        AND DATE_FORMAT( b.into_date, '%Y-%m-%d' ) <![CDATA[ >= ]]> #{startTime}-->
<!--        AND DATE_FORMAT( b.into_date, '%Y-%m-%d' ) <![CDATA[ <= ]]> #{endTime}-->
<!--        AND b.relate_delivery_goods_id is not null-->
<!--    </select>-->
<!--    <select id="getDeliveryQualifiedRate" resultType="java.math.BigDecimal" databaseId="kb">-->
<!--        SELECT-->
<!--        ROUND( SUM( pur_num ) / SUM( delivery_num ) * 100, 2 )-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--        LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--        WHERE-->
<!--        a.supplier_id = #{supplierId}-->
<!--        and b.`status` = #{intoStatus}-->
<!--        AND DATE_FORMAT( b.into_date, '%Y-%m-%d' ) <![CDATA[ >= ]]> to_date( #{startTime}, 'YYYY-MM-DD' )-->
<!--        AND DATE_FORMAT( b.into_date, '%Y-%m-%d' ) <![CDATA[ <= ]]> to_date( #{endTime}, 'YYYY-MM-DD' )-->
<!--        AND b.relate_delivery_goods_id is not null-->
<!--    </select>-->
<!--    <select id="pageEachBatchInventory" resultType="net.xnzn.core.drp.vo.DrpEachBatchInventoryPageVO">-->
<!--        SELECT-->
<!--            a.material_id,-->
<!--            CASE WHEN a.material_url IS NULL then b.image_url-->
<!--            when a.material_url = '' THEN b.image_url-->
<!--            ELSE a.material_url END AS imageUrl,-->
<!--            b.material_code,-->
<!--            b.material_name,-->
<!--            b.material_type,-->
<!--            b.category_id,-->
<!--            c.category_name,-->
<!--            a.unit_id,-->
<!--            d.unit_name,-->
<!--            a.unit_price,-->
<!--            a.inventory_num,-->
<!--            b.bar_code,-->
<!--            a.supplier_id,-->
<!--            e.supplier_name,-->
<!--            a.detail_id intoDetailId,-->
<!--            a.into_id,-->
<!--            a.inventory_id,-->
<!--            a.expire_time,-->
<!--            f.into_date,-->
<!--            b.sales_mode-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--            LEFT JOIN menu_material b ON b.material_id = a.material_id-->
<!--            LEFT JOIN menu_material_category c ON c.category_id = b.category_id-->
<!--            LEFT JOIN drp_unit d ON d.unit_id = a.unit_id-->
<!--            LEFT JOIN drp_supplier e ON e.supplier_id = a.supplier_id-->
<!--            LEFT JOIN drp_into_inventory f ON f.into_id = a.into_id-->
<!--        WHERE-->
<!--            a.inventory_num != 0-->
<!--            AND f.`status` = #{intoStatus}-->
<!--            <if test="content.materialCode != null and content.materialCode != ''">-->
<!--                and b.material_code like #{content.materialCode}-->
<!--            </if>-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and (-->
<!--                b.material_name like concat('%', #{content.materialName}, '%')-->
<!--                or b.pinyin_initials like concat(#{pinyinInitials}, '%')-->
<!--                or b.pinyin_full like concat('%', #{pinyinFull}, '%')-->
<!--                )-->
<!--            </if>-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                and b.bar_code = #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--                and b.category_id in-->
<!--                <foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")" >-->
<!--                    #{categoryId}-->
<!--                </foreach>-->
<!--            </if>-->
<!--            <if test="content.supplierId != null">-->
<!--                and a.supplier_id = #{content.supplierId}-->
<!--            </if>-->
<!--            <if test="content.warehouseId != null">-->
<!--                and f.warehouse_id = #{content.warehouseId}-->
<!--            </if>-->
<!--        ORDER BY-->
<!--            a.material_id,-->
<!--            a.unit_id-->
<!--    </select>-->
<!--    <select id="selectCountAndAmount" resultType="net.xnzn.core.drp.vo.IntoOutOverviewVO">-->

<!--        SELECT-->
<!--            sum( did.inventory_num ) count,-->
<!--            sum( did.total_price ) amount-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--                LEFT JOIN drp_into_inventory dii ON did.into_id = dii.into_id-->
<!--        WHERE-->
<!--            dii.del_flag = 2-->
<!--          AND dii.`status` = 2-->
<!--        <if test="warehouseIdList != null and warehouseIdList.size() > 0">-->
<!--            and dii.warehouse_id in-->
<!--            <foreach collection="warehouseIdList" item="warehouseId" separator="," open="(" close=")">-->
<!--                #{warehouseId}-->
<!--            </foreach>-->
<!--        </if>-->
<!--        GROUP BY-->
<!--            did.material_id-->
<!--    </select>-->

<!--    <select id="getCategoryDistribute" resultType="net.xnzn.core.drp.vo.IntoCategoryDistributeVO">-->
<!--        SELECT-->
<!--            mm.category_id,-->
<!--            mmc.category_name,-->
<!--            sum(did.inventory_num) count-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--                LEFT JOIN drp_into_inventory dii ON did.into_id = dii.into_id-->
<!--                LEFT JOIN menu_material mm ON did.material_id = mm.material_id-->
<!--                LEFT JOIN menu_material_category mmc ON mm.category_id = mmc.category_id-->
<!--        WHERE-->
<!--            dii.del_flag = 2-->
<!--          AND dii.`status` = 2-->
<!--        <if test="warehouseId != null and warehouseId != ''">-->
<!--            AND dii.warehouse_id = #{warehouseId}-->
<!--        </if>-->
<!--        GROUP BY-->
<!--            mm.category_id,-->
<!--            mmc.category_name-->
<!--    </select>-->
<!--    <select id="outActivity" resultType="net.xnzn.core.drp.vo.IntoCategoryDistributeVO">-->
<!--        SELECT-->
<!--        mmc.category_id,-->
<!--        mmc.category_name,-->
<!--        sum(dod.fetch_num ) count-->
<!--        FROM-->
<!--        drp_out_detail dod-->
<!--        LEFT JOIN drp_out_inventory doi ON doi.out_id = dod.out_id-->
<!--        LEFT JOIN drp_into_detail did ON did.detail_id = dod.into_detail_id-->
<!--        LEFT JOIN menu_material mm ON mm.material_id = did.material_id-->
<!--        LEFT JOIN menu_material_category mmc ON mm.category_id = mmc.category_id-->
<!--        WHERE-->
<!--        dod.del_flag = 2-->
<!--        AND doi.`status` = 2-->
<!--        and doi.del_flag = 2-->
<!--        <if test="content.warehouseId != null and content.warehouseId != ''">-->
<!--            AND doi.warehouse_id = #{content.warehouseId}-->
<!--        </if>-->
<!--        <if test="content.startDate != null  ">-->
<!--           and  doi.out_date <![CDATA[ >= ]]> #{content.startDate}-->
<!--        </if>-->
<!--        <if test="content.endDate != null  ">-->
<!--           and  doi.out_date <![CDATA[ <= ]]> #{content.endDate}-->
<!--        </if>-->
<!--        GROUP BY-->
<!--        mmc.category_id,-->
<!--        mmc.category_name-->

<!--    </select>-->


<!--    <select id="listIntoIdAndOutIdByMaterialId"-->
<!--            resultType="net.xnzn.core.drp.po.IntoIdAndOutIdByMaterialIdListModel">-->
<!--        SELECT DISTINCT-->
<!--        c.material_id,-->
<!--        d.material_code,-->
<!--        d.material_name,-->
<!--        d.image_url,-->
<!--        a.out_id,-->
<!--        b.out_date outTime-->
<!--        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-->
<!--        LEFT JOIN menu_material d ON d.material_id = c.material_id-->
<!--        LEFT JOIN drp_into_detail e ON e.detail_id = a.into_detail_id-->
<!--        WHERE-->
<!--        c.material_id = #{content.materialId}-->
<!--        AND b.out_date <![CDATA[ >= ]]> #{content.startTime}-->
<!--        AND b.out_date <![CDATA[ <= ]]> #{content.endTime}-->
<!--        AND b.`status` = #{status}-->
<!--        <if test="content.warehouseId != null">-->
<!--            AND b.warehouse_id = #{content.warehouseId}-->
<!--        </if>-->
<!--        <if test="content.supplierId != null">-->
<!--            AND e.supplier_id = #{content.supplierId}-->
<!--        </if>-->
<!--    </select>-->
<!--    <select id="listIntoIdByMaterialId" resultType="net.xnzn.core.drp.model.IntoModel">-->
<!--        SELECT-->
<!--        distinct b.into_id,b.into_date-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--        LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--        WHERE-->
<!--        a.material_id = #{content.materialId}-->
<!--        AND b.`status` = #{status}-->
<!--        <if test="content.warehouseId != null">-->
<!--            AND b.warehouse_id = #{content.warehouseId}-->
<!--        </if>-->
<!--        <if test="content.supplierId != null">-->
<!--            AND a.supplier_id = #{content.supplierId}-->
<!--        </if>-->
<!--    </select>-->
<!--    <select id="listLeastPriceAndDate" resultType="net.xnzn.core.drp.po.LeastPriceAndDateModel">-->
<!--        SELECT-->
<!--        a.material_id,-->
<!--        a.unit_price leastIntoPrice,-->
<!--        b.rate,-->
<!--        a.unit_id,-->
<!--        c.into_date leastIntoDate-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--            left join drp_into_inventory c on a.into_id = c.into_id-->
<!--        LEFT JOIN drp_unit b ON a.unit_id = b.unit_id-->
<!--        WHERE-->
<!--        a.id IN (-->
<!--        SELECT-->
<!--        MAX( did.id )-->
<!--        FROM-->
<!--        drp_into_detail did-->
<!--        LEFT JOIN drp_into_inventory dii ON did.into_id = dii.into_id-->
<!--        WHERE-->
<!--        dii.`status` = 2-->
<!--        AND did.material_id IN-->
<!--        <foreach collection="materialIdList" item="materialId" separator="," open="(" close=")">-->
<!--            #{materialId}-->
<!--        </foreach>-->
<!--        GROUP BY-->
<!--        did.material_id-->
<!--        )-->
<!--        AND a.material_id IN-->
<!--        <foreach collection="materialIdList" item="materialId" separator="," open="(" close=")">-->
<!--            #{materialId}-->
<!--        </foreach>-->

<!--    </select>-->
<!--    <select id="listMonthPrice" resultType="net.xnzn.core.drp.po.LeastPriceAndDateModel">-->
<!--        SELECT-->
<!--        a.material_id,-->
<!--        c.rate,-->
<!--        mm.unit_id,-->
<!--        ROUND(sum( a.unit_price )/ count( a.id )) monthAvgPrice-->
<!--        FROM-->
<!--        drp_into_detail a-->
<!--        LEFT JOIN drp_into_inventory b ON a.into_id = b.into_id-->
<!--        LEFT JOIN menu_material mm on a.material_id = mm.material_id-->
<!--        LEFT JOIN drp_unit c ON c.unit_id = mm.unit_id-->
<!--        WHERE-->
<!--        b.`status` = #{status}-->
<!--        AND a.material_id IN-->
<!--        <foreach collection="materialIdList" item="materialId" separator="," open="(" close=")">-->
<!--            #{materialId}-->
<!--        </foreach>-->
<!--        and b.into_date <![CDATA[ >= ]]> #{startTime}-->
<!--        and b.into_date <![CDATA[ <= ]]> #{endTime}-->
<!--        GROUP BY-->
<!--        a.material_id,-->
<!--        c.rate,-->
<!--        mm.unit_id-->
<!--    </select>-->
<!--    <select id="checkIfOut" resultType="java.lang.Integer">-->
<!--        select count(*) from drp_into_detail where into_id = #{intoId} and pur_num != inventory_num-->
<!--    </select>-->
<!--    <select id="listCancelInventoryDetail" resultType="net.xnzn.core.drp.po.CancelInventoryDetailModel">-->
<!--        SELECT detail_id,-->
<!--               inventory_id,-->
<!--               pur_num refundNum,-->
<!--               relate_order_goods_detail_id,-->
<!--               material_id,-->
<!--               unit_id-->
<!--        FROM drp_into_detail-->
<!--        WHERE into_id = #{intoId}-->
<!--    </select>-->


<!--    <select id="listIntoDetailByIntoId" resultType="net.xnzn.core.drp.vo.DrpIntoDetailListVO">-->
<!--        SELECT-->
<!--            a.detail_id,-->
<!--            a.into_id,-->
<!--            a.material_id,-->
<!--            b.material_name,-->
<!--            b.material_code,-->
<!--            a.inventory_id,-->
<!--            b.category_id,-->
<!--            c.category_name,-->
<!--            a.unit_price,-->
<!--            a.total_price,-->
<!--            a.delivery_num,-->
<!--            a.pur_num,-->
<!--            a.inventory_num,-->
<!--            a.unit_id,-->
<!--            d.unit_name,-->
<!--            a.supplier_id,-->
<!--            e.supplier_name,-->
<!--            a.product_date,-->
<!--            a.expire_time,-->
<!--            a.material_url,-->
<!--            b.bar_code,-->
<!--            b.sales_mode,-->
<!--            d.rate-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--            LEFT JOIN menu_material b ON b.material_id = a.material_id-->
<!--            LEFT JOIN menu_material_category c ON c.category_id = b.category_id-->
<!--            LEFT JOIN drp_unit d ON d.unit_id = a.unit_id-->
<!--            LEFT JOIN drp_supplier e ON e.supplier_id = a.supplier_id-->
<!--        WHERE-->
<!--            into_id = #{intoId}-->
<!--    </select>-->
<!--    <select id="pageOrderGoodsIntoDetail" resultType="net.xnzn.core.drp.v2.vo.DrpOrderGoodsIntoDetailPageVO">-->
<!--        SELECT-->
<!--            a.detail_id intoDetailId,-->
<!--            a.into_id,-->
<!--            a.material_id,-->
<!--            c.material_code,-->
<!--            c.material_name,-->
<!--            c.category_id,-->
<!--            e.category_name,-->
<!--            c.unit_id,-->
<!--            d.unit_name,-->
<!--            a.unit_price,-->
<!--            a.inventory_id,-->
<!--            a.inventory_num,-->
<!--            a.total_price,-->
<!--            a.material_url,-->
<!--            a.pur_num intoNum-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--            LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--            LEFT JOIN menu_material c ON c.material_id = a.material_id-->
<!--            LEFT JOIN drp_unit d ON d.unit_id = c.unit_id-->
<!--            LEFT JOIN menu_material_category e ON e.category_id = c.category_id-->
<!--        WHERE-->
<!--            b.warehouse_id = #{content.warehouseId}-->
<!--            AND b.relate_order_goods_id = #{content.orderGoodsId}-->
<!--            AND b.status = 2-->
<!--            AND a.inventory_num != 0-->
<!--    </select>-->
<!--    <select id="pageDrpIntoDetail" resultType="net.xnzn.core.drp.vo.DrpInventoryIntoDetailPageVO">-->
<!--        SELECT-->
<!--            a.*,-->
<!--            b.unit_name,-->
<!--            c.into_date,-->
<!--            d.material_name,-->
<!--            d.material_code,-->
<!--            d.category_id,-->
<!--            e.category_name,-->
<!--            f.supplier_name-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--                LEFT JOIN drp_unit b ON b.unit_id = a.unit_id-->
<!--                LEFT JOIN drp_into_inventory c ON c.into_id = a.into_id-->
<!--                LEFT JOIN menu_material d ON d.material_id = a.material_id-->
<!--                LEFT JOIN menu_material_category e ON e.category_id = d.category_id-->
<!--                LEFT JOIN drp_supplier f ON f.supplier_id = a.supplier_id-->
<!--        where-->
<!--            a.inventory_id = #{content.inventoryId}-->
<!--            and c.`status` = #{status}-->
<!--            <if test="content.minInventoryNum != null">-->
<!--                and a.inventory_num > #{content.minInventoryNum}-->
<!--            </if>-->
<!--            <if test="content.intoId != null and content.intoId != ''">-->
<!--                and c.into_id = #{content.intoId}-->
<!--            </if>-->
<!--        ORDER BY-->
<!--            a.expire_time ASC,-->
<!--            a.inventory_num DESC-->
<!--    </select>-->
<!--    <select id="listMaterialIntoDetailInfo" resultType="net.xnzn.core.drp.vo.MaterialIntoDetailInfoListVO">-->
<!--        SELECT-->
<!--            a.material_id,-->
<!--            c.material_code,-->
<!--            c.material_name,-->
<!--            c.category_id,-->
<!--            d.category_name,-->
<!--            b.warehouse_id,-->
<!--            e.warehouse_name,-->
<!--            b.into_date,-->
<!--            a.into_id,-->
<!--            a.unit_id,-->
<!--            f.unit_name-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--                LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--                LEFT JOIN menu_material c ON c.material_id = a.material_id-->
<!--                LEFT JOIN menu_material_category d ON d.category_id = c.category_id-->
<!--                LEFT JOIN drp_warehouse e ON e.warehouse_id = b.warehouse_id-->
<!--                LEFT JOIN drp_unit f ON f.unit_id = a.unit_id-->
<!--        WHERE-->
<!--        b.`status` = #{status}-->
<!--        AND a.inventory_num > 0-->
<!--        <if test="content.startTime != null and content.endTime != null">-->
<!--            AND ( b.into_date BETWEEN #{content.startTime} AND #{content.endTime} )-->
<!--        </if>-->
<!--        <if test="content.key != null and content.key != ''">-->
<!--            AND ( c.material_code LIKE #{content.key} OR c.material_name LIKE #{content.key} )-->
<!--        </if>-->
<!--        <if test="content.warehouseId != null">-->
<!--            AND b.warehouse_id = #{content.warehouseId}-->
<!--        </if>-->
<!--        <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--            AND c.category_id IN-->
<!--            <foreach collection="content.categoryIdList" item="item" separator="," open="(" close=")">-->
<!--              #{item}-->
<!--            </foreach>-->
<!--        </if>-->
<!--        <if test="content.intoId != null and content.intoId != ''">-->
<!--            AND b.into_id LIKE #{content.intoId}-->
<!--        </if>-->
<!--    </select>-->
<!--    <select id="listCancelIntoDetailMq" resultType="net.xnzn.core.drp.po.DrpMqCancelIntoAndOutModel">-->
<!--        SELECT-->
<!--            a.detail_id,-->
<!--            b.into_id recordId,-->
<!--            1 AS recordType,-->
<!--            b.into_date recordTime,-->
<!--            a.material_id-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--                LEFT JOIN drp_into_inventory b ON b.into_id = a.into_id-->
<!--        where-->
<!--            a.into_id = #{recordId}-->
<!--    </select>-->
<!--    <select id="listBackFieldIntoDetail" resultType="net.xnzn.core.drp.vo.DrpBackFieldIntoDetailVO">-->
<!--        SELECT-->
<!--            did.material_id,-->
<!--            mm.material_name,-->
<!--            did.pur_num intoNum,-->
<!--            did.unit_id,-->
<!--            du.unit_name,-->
<!--            did.unit_price,-->
<!--            dii.warehouse_id,-->
<!--            dw.warehouse_name,-->
<!--            did.material_url imageUrl-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--                LEFT JOIN drp_into_inventory dii ON dii.into_id = did.into_id-->
<!--                LEFT JOIN menu_material mm ON mm.material_id = did.material_id-->
<!--                LEFT JOIN drp_unit du ON du.unit_id = did.unit_id-->
<!--                LEFT JOIN drp_warehouse dw ON dw.warehouse_id = dii.warehouse_id-->
<!--        WHERE-->
<!--            dii.`status` = #{status}-->
<!--            and dii.into_date BETWEEN #{content.startTime} and #{content.endTime}-->
<!--    </select>-->
<!--    <select id="pageIntoDetailByIntoId" resultType="net.xnzn.core.drp.vo.DrpIntoDetailListVO">-->
<!--        SELECT-->
<!--            a.detail_id,-->
<!--            a.into_id,-->
<!--            a.material_id,-->
<!--            b.material_name,-->
<!--            b.material_code,-->
<!--            a.inventory_id,-->
<!--            b.category_id,-->
<!--            c.category_name,-->
<!--            a.unit_price,-->
<!--            a.total_price,-->
<!--            a.delivery_num,-->
<!--            a.pur_num,-->
<!--            a.inventory_num,-->
<!--            a.unit_id,-->
<!--            d.unit_name,-->
<!--            a.supplier_id,-->
<!--            e.supplier_name,-->
<!--            a.product_date,-->
<!--            a.expire_time,-->
<!--            a.material_url,-->
<!--            b.bar_code,-->
<!--            b.sales_mode,-->
<!--            d.rate-->
<!--        FROM-->
<!--            drp_into_detail a-->
<!--                LEFT JOIN menu_material b ON b.material_id = a.material_id-->
<!--                LEFT JOIN menu_material_category c ON c.category_id = b.category_id-->
<!--                LEFT JOIN drp_unit d ON d.unit_id = a.unit_id-->
<!--                LEFT JOIN drp_supplier e ON e.supplier_id = a.supplier_id-->
<!--        WHERE-->
<!--            into_id = #{content.orderId}-->
<!--    </select>-->
<!--    <select id="selectFirstDetailSupplierName" resultType="java.lang.String">-->
<!--        SELECT-->
<!--            ds.supplier_name-->
<!--        FROM-->
<!--            drp_into_detail did-->
<!--                LEFT JOIN drp_supplier ds ON ds.supplier_id = did.supplier_id-->
<!--        WHERE-->
<!--            did.into_id = #{intoId}-->
<!--            LIMIT 1-->
<!--    </select>-->
</mapper>


