From cd0984bff3ac9c4480685671d4e033c8b082bfed Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 04 六月 2026 17:04:39 +0800
Subject: [PATCH] 发货去除库存数量限制,产品库存不足也可以发货,库存数量可以展示为负
---
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 2a1b94a..6dc6802 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -8,30 +8,34 @@
SELECT
T1.*,
CASE
- WHEN t2.qualitity > T1.quantity THEN 1
+ WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >= IFNULL(T1.quantity, 0) THEN 1
ELSE 0
- END as has_sufficient_stock
+ END as has_sufficient_stock,
+ CASE
+ WHEN t2.id IS NOT NULL THEN 1
+ ELSE 0
+ END as has_stock_inventory
FROM
sales_ledger_product T1
LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id
<where>
- 1=1
- <if test="salesLedgerProduct.salesLedgerId != null and salesLedgerProduct.salesLedgerId != '' ">
+ <if test="salesLedgerProduct.salesLedgerId != null">
AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId}
</if>
- <if test="salesLedgerProduct.type != null and salesLedgerProduct.type != '' ">
+ <if test="salesLedgerProduct.type != null">
AND T1.type = #{salesLedgerProduct.type}
</if>
</where>
ORDER BY T1.register_date DESC
</select>
+
<select id="selectSalesLedgerProductByMainId" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
select slp.*
from quality_inspect qi
left join production_product_main ppm on qi.product_main_id = ppm.id
left join product_work_order pwo on ppm.work_order_id = pwo.id
left join product_order po on pwo.product_order_id = po.id
- left join sales_ledger_product slp on po.sale_ledger_product_id = slp.id
+ left join sales_ledger_product slp on po.sale_ledger_product_id = slp.id and slp.type = 1
where qi.product_main_id = #{productMainId}
@@ -97,7 +101,7 @@
AND slp.product_category like concat('%',#{req.productCategory},'%')
</if>
<if test="req.status != null and req.status ">
- AND slp.pending_invoice_total > 0
+ AND slp.pending_tickets_total > 0
</if>
</where>
order by slp.register_date desc
@@ -128,7 +132,7 @@
AND slp.product_category = #{req.productCategory}
</if>
<!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
- GROUP BY slp.product_category
+ GROUP BY slp.product_category,slp.specification_model,sl.supplier_name
<!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
ORDER BY slp.product_category
</select>
@@ -144,7 +148,7 @@
p.product_name,
ps.unit_quantity * slp.quantity AS single_quantity
FROM sales_ledger sl
- LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id
+ LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id and slp.type = 1
LEFT JOIN product_model pm ON pm.id = slp.product_model_id
LEFT JOIN product_bom pb ON pb.product_model_id = pm.id
LEFT JOIN product_structure ps ON pb.id = ps.bom_id
@@ -153,11 +157,14 @@
WHERE sl.id = #{salesLedegerId}) A
group by a.model, a.product_name, a.unit
</select>
- <select id="selectProduct" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct">
+ <select id="selectProduct" resultType="com.ruoyi.sales.dto.SimpleProductDto">
select
+ pm.id,
p.product_name as product_category,
pm.model as specification_model,
- pm.id as product_model_id
+ pm.id as product_model_id,
+ pm.unit,
+ pm.sub_unit
from product_model pm
left join product p on pm.product_id = p.id
</select>
@@ -196,11 +203,15 @@
</select>
<select id="selectProductCountByTypeAndDate" resultType="int">
- SELECT COUNT(*)
+ SELECT IFNULL(COUNT(*), 0)
FROM sales_ledger_product
WHERE type = #{type}
- AND register_date >= #{startDate}
- AND register_date <= #{endDate}
+ <if test="startDate != null">
+ AND register_date >= #{startDate}
+ </if>
+ <if test="endDate != null">
+ AND register_date <= #{endDate}
+ </if>
</select>
<select id="selectRawMaterialExpense" resultType="java.math.BigDecimal">
@@ -220,4 +231,4 @@
FROM product_tree);
</select>
-</mapper>
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.3