From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板
---
src/main/resources/mapper/stock/StockInventoryMapper.xml | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 107 insertions(+), 4 deletions(-)
diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 9acd557..72f6e6f 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -12,6 +12,9 @@
<result column="version" property="version"/>
<result column="locked_quantity" property="lockedQuantity"/>
<result column="warn_num" property="warnNum"/>
+ <result column="process_category" property="processCategory"/>
+ <result column="voltage" property="voltage"/>
+ <result column="batch_no" property="batchNo"/>
</resultMap>
<update id="updateAddStockInventory">
update stock_inventory
@@ -64,6 +67,8 @@
(si.qualitity - COALESCE(si.locked_quantity, 0)) AS un_locked_quantity,
pm.model,
si.remark,
+ si.process_category as processCategory,
+ si.voltage,
pm.unit,
pm.material_code as materialCode,
p.product_name,
@@ -79,6 +84,13 @@
<if test="ew.productName != null and ew.productName != ''">
AND p.product_name LIKE CONCAT('%', #{ew.productName}, '%')
</if>
+ <if test="ew.processCategory != null and ew.processCategory != ''">
+ AND si.process_category = #{ew.processCategory}
+ </if>
+ <if test="ew.voltage != null and ew.voltage != ''">
+ AND si.voltage = #{ew.voltage}
+ </if>
+ order by si.create_time desc
</select>
<select id="pageListCombinedStockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
@@ -109,6 +121,8 @@
MAX(version) as version,
model,
MAX(remark) as remark,
+ processCategory,
+ voltage,
unit,
product_name,
product_id,
@@ -133,6 +147,8 @@
(si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
pm.model,
si.remark,
+ si.process_category as processCategory,
+ si.voltage as voltage,
pm.unit,
p.product_name,
p.id as product_id,
@@ -161,6 +177,8 @@
(su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
pm.model,
su.remark,
+ '' as processCategory,
+ '' as voltage,
pm.unit,
p.product_name,
p.id as product_id,
@@ -184,7 +202,7 @@
and combined.product_id in (select id from product_tree)
</if>
</where>
- group by product_model_id, model, unit, product_name, product_id, qualifiedBatchNo, unQualifiedBatchNo, materialCode, product_id, qualifiedBatchNo, unQualifiedBatchNo
+ group by product_model_id, model, unit, product_name, product_id, unQualifiedBatchNo, materialCode, processCategory, voltage
</select>
<select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
@@ -207,6 +225,8 @@
model,
unit,
product_name,
+ processCategory,
+ voltage,
MAX(warn_num) as warn_num,
MAX(remark) as remark,
MAX(update_time) as update_time,
@@ -227,6 +247,8 @@
pm.model,
pm.unit,
p.product_name,
+ si.process_category as processCategory,
+ si.voltage as voltage,
p.id as product_id,
si.batch_no as qualifiedBatchNo,
null as unQualifiedBatchNo,
@@ -250,6 +272,8 @@
pm.model,
pm.unit,
p.product_name,
+ '' as processCategory,
+ '' as voltage,
p.id as product_id,
null as qualifiedBatchNo,
su.batch_no as unQualifiedBatchNo,
@@ -271,18 +295,32 @@
and combined.product_id in (select id from product_tree)
</if>
</where>
- group by product_model_id, model, unit, product_name, qualifiedBatchNo, unQualifiedBatchNo, materialCode
+ group by product_model_id, model, unit, product_name, unQualifiedBatchNo, materialCode, processCategory, voltage
</select>
<select id="stockInventoryPage" resultType="com.ruoyi.stock.dto.StockInRecordDto">
select sir.*,si.qualitity as current_stock,
pm.model,
+ sir.process_category as processCategory,
+ sir.voltage,
pm.unit,
pm.material_code as materialCode,
p.product_name,
su.nick_name as create_by
from
stock_in_record sir
- left join stock_inventory si on sir.product_model_id = si.product_model_id
+ left join stock_inventory si
+ on sir.product_model_id = si.product_model_id
+ and (
+ (ifnull(sir.process_category, '') != '' or ifnull(sir.voltage, '') != '')
+ and ifnull(sir.process_category, '') = ifnull(si.process_category, '')
+ and ifnull(sir.voltage, '') = ifnull(si.voltage, '')
+ or
+ ifnull(sir.process_category, '') = ''
+ and ifnull(sir.voltage, '') = ''
+ and ifnull(si.process_category, '') = ''
+ and ifnull(si.voltage, '') = ''
+ and si.product_model_id = sir.product_model_id
+ )
left join product_model pm on sir.product_model_id = pm.id
left join product p on pm.product_id = p.id
left join sys_user su on sir.create_user = su.user_id
@@ -432,6 +470,8 @@
(si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
pm.model,
si.remark,
+ si.process_category as processCategory,
+ si.voltage,
pm.unit,
p.product_name,
p.id as product_id
@@ -440,4 +480,67 @@
left join product p on pm.product_id = p.id
</select>
-</mapper>
\ No newline at end of file
+ <select id="selectFinishedProductInventoryList" resultType="com.ruoyi.stock.dto.StockInventoryDto">
+ select si.id,
+ si.product_model_id,
+ si.process_category as processCategory,
+ si.voltage,
+ pm.model,
+ pm.material_code as materialCode,
+ pm.unit,
+ p.product_name,
+ p.id as product_id
+ 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 pp on p.parent_id = pp.id
+ <where>
+ pp.product_name = '鎴愬搧'
+ <if test="ew.productName != null and ew.productName != ''">
+ and (p.product_name like concat('%', #{ew.productName}, '%')
+ or pm.model like concat('%', #{ew.productName}, '%')
+ or pm.material_code like concat('%', #{ew.productName}, '%'))
+ </if>
+ <if test="ew.processCategory != null and ew.processCategory != ''">
+ and si.process_category = #{ew.processCategory}
+ </if>
+ <if test="ew.voltage != null and ew.voltage != ''">
+ and si.voltage = #{ew.voltage}
+ </if>
+ </where>
+ order by p.id asc, pm.id asc, si.id asc
+ </select>
+
+ <select id="selectFinishedProductList" resultType="com.ruoyi.stock.dto.FinishedProductTreeDto">
+ select si.id as stockId,
+ p.id as productId,
+ p.product_name as productName,
+ p.product_name as label,
+ pm.id as productModelId,
+ pm.model,
+ si.process_category as processCategory,
+ si.voltage,
+ pm.material_code as materialCode,
+ pm.unit
+ from stock_inventory si
+ inner join product_model pm on si.product_model_id = pm.id
+ inner join product p on pm.product_id = p.id
+ inner join product pp on p.parent_id = pp.id
+ <where>
+ pp.product_name = '鎴愬搧'
+ <if test="ew.productName != null and ew.productName != ''">
+ and (p.product_name like concat('%', #{ew.productName}, '%')
+ or pm.model like concat('%', #{ew.productName}, '%')
+ or pm.material_code like concat('%', #{ew.productName}, '%'))
+ </if>
+ <if test="ew.processCategory != null and ew.processCategory != ''">
+ and si.process_category = #{ew.processCategory}
+ </if>
+ <if test="ew.voltage != null and ew.voltage != ''">
+ and si.voltage = #{ew.voltage}
+ </if>
+ </where>
+ order by p.id asc, pm.id asc, si.id asc
+ </select>
+
+</mapper>
--
Gitblit v1.9.3