From 441dfbd1908affc1accc52006a2fe81a5067052d Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 22 六月 2026 09:28:09 +0800
Subject: [PATCH] 废品库存的批号如果有多个,则需要展示多个
---
src/main/resources/mapper/stock/StockUninventoryMapper.xml | 121 +++++++++++++++++++++++++++++++++++++---
1 files changed, 112 insertions(+), 9 deletions(-)
diff --git a/src/main/resources/mapper/stock/StockUninventoryMapper.xml b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
index 5aa3b9a..0af20f6 100644
--- a/src/main/resources/mapper/stock/StockUninventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -30,6 +30,7 @@
from stock_uninventory su
left join product_model pm on su.product_model_id = pm.id
left join product p on pm.product_id = p.id
+ left join manufacturer m on su.manufacturer_id = m.id
</sql>
<sql id="WastePageColumns">
@@ -38,13 +39,17 @@
su.type,
COALESCE(su.locked_quantity, 0) as locked_quantity,
su.product_model_id,
+ p.id as product_id,
+ su.batch_no,
su.create_time,
su.update_time,
su.version,
(su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
pm.model,
pm.unit,
- p.product_name
+ p.product_name,
+ m.name as manufacturer_name,
+ su.source
</sql>
<update id="updateSubtractStockUnInventory">
@@ -61,6 +66,9 @@
</if>
<if test="ew.type != null and ew.type != ''">
type = #{ew.type},
+ </if>
+ <if test="ew.source != null and ew.source != ''">
+ source = #{ew.source},
</if>
update_time = now()
</set>
@@ -95,6 +103,9 @@
<if test="ew.type != null and ew.type != ''">
type = #{ew.type},
</if>
+ <if test="ew.source != null and ew.source != ''">
+ source = #{ew.source},
+ </if>
update_time = now()
</set>
where product_model_id = #{ew.productModelId}
@@ -123,7 +134,8 @@
(su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
pm.model,
pm.unit,
- p.product_name
+ p.product_name,
+ su.source
<include refid="BaseWasteFromClause" />
<where>
<if test="ew.type != null and ew.type != ''">
@@ -138,7 +150,22 @@
<select id="pageWasteQuery" resultType="com.ruoyi.stock.dto.StockUninventoryDto">
<include refid="WasteQueryRecursiveTree" />
select
- <include refid="WastePageColumns" />
+ max(su.id) as id,
+ sum(su.qualitity) as qualitity,
+ su.type,
+ sum(COALESCE(su.locked_quantity, 0)) as locked_quantity,
+ su.product_model_id,
+ p.id as product_id,
+ GROUP_CONCAT(DISTINCT su.batch_no ORDER BY su.batch_no SEPARATOR ',') as batch_no,
+ min(su.create_time) as create_time,
+ max(su.update_time) as update_time,
+ max(su.version) as version,
+ (sum(su.qualitity) - sum(COALESCE(su.locked_quantity, 0))) as un_locked_quantity,
+ pm.model,
+ pm.unit,
+ p.product_name,
+ m.name as manufacturer_name,
+ su.source
<include refid="BaseWasteFromClause" />
<where>
and su.type = 'waste'
@@ -155,8 +182,8 @@
and p.id in (select id from product_tree)
</if>
</where>
-
- order by su.update_time desc, su.id desc
+ group by su.product_model_id
+ order by max(su.update_time) desc, su.product_model_id desc
</select>
<select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockUnInventoryExportData">
@@ -164,7 +191,8 @@
su.*,
pm.model,
pm.unit,
- p.product_name
+ p.product_name,
+ m.name as manufacturer_name
<include refid="BaseWasteFromClause" />
<where>
<if test="ew.type != null and ew.type != ''">
@@ -179,11 +207,18 @@
<select id="listWasteQueryExportData" resultType="com.ruoyi.stock.execl.StockUnInventoryExportData">
<include refid="WasteQueryRecursiveTree" />
select
- su.*,
pm.model,
pm.unit,
p.product_name,
- (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity
+ m.name as manufacturer_name,
+ su.source,
+ su.type,
+ GROUP_CONCAT(DISTINCT su.batch_no ORDER BY su.batch_no SEPARATOR ',') as batch_no,
+ sum(su.qualitity) as qualitity,
+ sum(COALESCE(su.locked_quantity, 0)) as locked_quantity,
+ (sum(su.qualitity) - sum(COALESCE(su.locked_quantity, 0))) as un_locked_quantity,
+ GROUP_CONCAT(DISTINCT su.remark ORDER BY su.batch_no SEPARATOR '锛�') as remark,
+ max(su.update_time) as update_time
<include refid="BaseWasteFromClause" />
<where>
and su.type = 'waste'
@@ -200,7 +235,75 @@
and p.id in (select id from product_tree)
</if>
</where>
- order by su.update_time desc, su.id desc
+ group by su.product_model_id, su.type, pm.model, pm.unit, p.id, p.product_name, m.name, su.source
+ order by max(su.update_time) desc, su.product_model_id desc
+ </select>
+
+ <select id="getWasteBatchNoQty" resultType="com.ruoyi.stock.dto.StockUninventoryDto">
+ select
+ su.id,
+ p.product_name,
+ pm.model,
+ m.name as manufacturer_name,
+ su.source,
+ pm.unit,
+ su.batch_no,
+ su.qualitity,
+ COALESCE(su.locked_quantity, 0) as locked_quantity,
+ (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
+ su.remark,
+ su.update_time,
+ su.product_model_id
+ from stock_uninventory su
+ left join product_model pm on su.product_model_id = pm.id
+ left join product p on pm.product_id = p.id
+ left join manufacturer m on su.manufacturer_id = m.id
+ <where>
+ and su.type = 'waste'
+ <if test="ew.productModelId != null and ew.productModelId > 0">
+ and su.product_model_id = #{ew.productModelId}
+ </if>
+ <if test="ew.productId != null and ew.productId > 0">
+ and p.id = #{ew.productId}
+ </if>
+ </where>
+ order by su.batch_no
+ </select>
+
+ <select id="getWasteByModelId" resultType="com.ruoyi.stock.dto.StockUninventoryDto">
+ select
+ su.id,
+ su.batch_no,
+ COALESCE(su.locked_quantity, 0) as locked_quantity,
+ (su.qualitity - IFNULL(sd.qualitity, 0)) as qualitity,
+ p.product_name,
+ pm.model,
+ pm.unit,
+ su.product_model_id
+ from stock_uninventory su
+ left join (
+ select
+ sor.product_model_id,
+ sor.batch_no,
+ sum(spd.quantity) as qualitity
+ from shipping_product_detail spd
+ inner join stock_out_record sor
+ on sor.record_id = spd.shipping_info_id
+ and sor.record_type = '13'
+ and sor.type = '1'
+ and sor.approval_status in (0, 3)
+ and sor.product_model_id = spd.product_model_id
+ and (sor.batch_no = spd.batch_no or (sor.batch_no is null and spd.batch_no is null))
+ where spd.stock_type = 'waste'
+ group by sor.product_model_id, sor.batch_no
+ ) sd on sd.product_model_id = su.product_model_id
+ and (sd.batch_no = su.batch_no or (sd.batch_no is null and su.batch_no is null))
+ left join product_model pm on su.product_model_id = pm.id
+ left join product p on pm.product_id = p.id
+ where su.product_model_id = #{productModelId}
+ and su.type = 'waste'
+ and su.qualitity > IFNULL(sd.qualitity, 0)
+ order by su.batch_no
</select>
<select id="selectPendingOutQuantity" resultType="java.math.BigDecimal">
--
Gitblit v1.9.3