src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -257,4 +257,30 @@
        ORDER BY pm.id
    </select>
    <select id="getMaterials" resultType="com.ruoyi.stock.dto.StockInventoryDto">
        SELECT
            si.id,
            si.qualitity,
            COALESCE(si.locked_quantity, 0) AS locked_quantity,
            si.product_model_id,
            si.create_time,
            si.update_time,
            COALESCE(si.warn_num, 0) AS warn_num,
            si.version,
            (si.qualitity - COALESCE(si.locked_quantity, 0)) AS un_locked_quantity,
            pm.model,
            si.remark,
            pm.unit,
            pm.uid_no AS uidNo,
            p.product_name,
            p1.product_name AS parentName
        FROM
            stock_inventory si
                LEFT JOIN product_model pm ON si.product_model_id = pm.id
                LEFT JOIN product p ON pm.product_id = p.id
                LEFT JOIN product p1 ON p1.id = p.parent_id
        WHERE
            p1.product_name = '原材料';
    </select>
</mapper>