2 天以前 81592a7a4822b10c592d1d46193cf8f3becfc5be
src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -72,20 +72,27 @@
    </select>
    <select id="listPageAccountPurchase" resultType="com.ruoyi.account.bean.vo.PurchaseInboundVo">
        SELECT
        sir.id,
        sir.inbound_batches,
        pl.supplier_name,
        DATE(sir.create_time) AS inboundDate,
        p.product_name,
        slp.specification_model,
        sor.stock_in_num * slp.tax_inclusive_unit_price as InboundAmount,
        pl.purchase_contract_number
        FROM stock_in_record sir
        LEFT JOIN purchase_ledger pl ON sir.record_id = pl.id
        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = pl.id and slp.type = 2
        left join product_model pm on slp.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        WHERE sir.approval_status=1 and sir.record_type='7'
            sir.id,
            sir.inbound_batches,
            pl.supplier_name,
            DATE(sir.create_time) AS inboundDate,
            p.product_name,
            pm.model as specification_model,
            sor.stock_in_num * slp.tax_inclusive_unit_price AS InboundAmount,
            pl.purchase_contract_number
            FROM stock_in_record sir
            -- 10 类型才关联质检表
            LEFT JOIN quality_inspect qi ON sir.record_type = 10 AND sir.record_id = qi.id
            -- 动态关联采购(自动适配 7 和 10)
            LEFT JOIN purchase_ledger pl
            ON pl.id = IF(sir.record_type = 7, sir.record_id, qi.purchase_ledger_id)
            -- 产品关联不动
            LEFT JOIN sales_ledger_product slp ON slp.type = 2 AND pl.id = slp.product_id
            LEFT JOIN product_model pm ON slp.product_model_id = pm.id
            LEFT JOIN product p ON pm.product_id = p.id
            -- 条件
        WHERE sir.approval_status = 1
        AND sir.record_type IN ('7','10')
        <if test="req.inboundBatches != null and req.inboundBatches != ''">
            AND sir.inbound_batches LIKE CONCAT('%',#{req.inboundBatches},'%')
        </if>