From 7782a7e1191a0e98ffb20bca8b59248e98c556a8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 24 四月 2026 14:38:13 +0800
Subject: [PATCH] feat(stock): 添加库存位置功能支持
---
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java | 2 +
src/main/resources/mapper/stock/StockOutRecordMapper.xml | 6 +++
src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java | 2 +
src/main/resources/mapper/stock/StockInventoryMapper.xml | 18 ++++++++
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java | 9 +++-
src/main/resources/mapper/stock/StockUninventoryMapper.xml | 11 +++++
src/main/resources/mapper/stock/StockInRecordMapper.xml | 8 +++
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java | 18 ++++++--
src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java | 2 +
9 files changed, 67 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java b/src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java
index d705110..f3f83ed 100644
--- a/src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java
+++ b/src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java
@@ -22,6 +22,8 @@
private String recordType;
@Excel(name = "鍏ュ簱鏁伴噺")
private String stockInNum;
+ @Excel(name = "Location")
+ private String stockLocation;
@Excel(name = "鍏ュ簱鏃堕棿")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
diff --git a/src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java b/src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java
index f120817..33d2253 100644
--- a/src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java
+++ b/src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java
@@ -21,6 +21,8 @@
private String recordType;
@Excel(name = "鍑哄簱鏁伴噺")
private String stockInNum;
+ @Excel(name = "Location")
+ private String stockLocation;
@Excel(name = "鍑哄簱鏃堕棿")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
diff --git a/src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java b/src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
index 7fd6e36..c89468d 100644
--- a/src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
+++ b/src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
@@ -27,6 +27,8 @@
@Excel(name = "澶囨敞")
private String remark;
+ @Excel(name = "Location")
+ private String stockLocation;
//
// @Excel(name = "鏈�鏂版洿鏂版椂闂�")
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
index 82d526e..456a999 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -80,17 +80,22 @@
for (Long id : ids) {
StockInRecord stockInRecord = stockInRecordMapper.selectById(id);
if (stockInRecord.getType().equals("0")) {
- StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockInRecord.getProductModelId()));
+ StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>()
+ .eq(StockInventory::getProductModelId, stockInRecord.getProductModelId())
+ .eq(StockInventory::getStockLocation, stockInRecord.getStockLocation()));
if (stockInventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
StockInventoryDto stockInRecordDto = new StockInventoryDto();
stockInRecordDto.setProductModelId(stockInventory.getProductModelId());
stockInRecordDto.setQualitity(stockInRecord.getStockInNum());
+ stockInRecordDto.setStockLocation(stockInRecord.getStockLocation());
stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto);
}
}else if (stockInRecord.getType().equals("1")) {
- StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId()));
+ StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>()
+ .eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())
+ .eq(StockUninventory::getStockLocation, stockInRecord.getStockLocation()));
if (stockUninventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
@@ -136,9 +141,12 @@
if (ObjectUtils.isEmpty(oldStockInventory)) {
stockInventoryMapper.insert(newStockInventory);
}else {
- StockInventoryDto oldStockInventoryDto = new StockInventoryDto();
- BeanUtils.copyProperties(oldStockInventory, oldStockInventoryDto);
- stockInventoryMapper.updateAddStockInventory(oldStockInventoryDto);
+ StockInventoryDto stockInventoryDto = new StockInventoryDto();
+ stockInventoryDto.setProductModelId(stockInRecordDto.getProductModelId());
+ stockInventoryDto.setQualitity(stockInRecordDto.getActualStockInNum() == null ? stockInRecordDto.getWaitAuditNum() : stockInRecordDto.getActualStockInNum());
+ stockInventoryDto.setRemark(stockInRecordDto.getRemark());
+ stockInventoryDto.setStockLocation(stockInRecordDto.getStockLocation());
+ stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
}
stockInRecordDto.setStatus(2);
stockInRecordDto.setStockInNum(stockInRecordDto.getActualStockInNum() == null ? stockInRecordDto.getWaitAuditNum() : stockInRecordDto.getActualStockInNum());
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
index f0fb538..8a1e6d0 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
@@ -76,17 +76,22 @@
for (Long id : ids) {
StockOutRecord stockOutRecord = stockOutRecordMapper.selectById(id);
if (stockOutRecord.getType().equals("0")) {
- StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockOutRecord.getProductModelId()));
+ StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>()
+ .eq(StockInventory::getProductModelId, stockOutRecord.getProductModelId())
+ .eq(StockInventory::getStockLocation, stockOutRecord.getStockLocation()));
if (stockInventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
StockInventoryDto stockInRecordDto = new StockInventoryDto();
stockInRecordDto.setProductModelId(stockInventory.getProductModelId());
stockInRecordDto.setQualitity(stockOutRecord.getStockOutNum());
+ stockInRecordDto.setStockLocation(stockOutRecord.getStockLocation());
stockInventoryMapper.updateAddStockInventory(stockInRecordDto);
}
}else if (stockOutRecord.getType().equals("1")) {
- StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockOutRecord.getProductModelId()));
+ StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>()
+ .eq(StockUninventory::getProductModelId, stockOutRecord.getProductModelId())
+ .eq(StockUninventory::getStockLocation, stockOutRecord.getStockLocation()));
if (stockUninventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index 70737b7..cd239c8 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -30,6 +30,9 @@
<if test="params.recordType != null and params.recordType != ''">
and sir.record_type = #{params.recordType}
</if>
+ <if test="params.stockLocation != null and params.stockLocation != ''">
+ and sir.stock_location = #{params.stockLocation}
+ </if>
</where>
order by sir.id desc
</select>
@@ -57,7 +60,10 @@
<if test="params.recordType != null and params.recordType != ''">
and sir.record_type = #{params.recordType}
</if>
+ <if test="params.stockLocation != null and params.stockLocation != ''">
+ and sir.stock_location = #{params.stockLocation}
+ </if>
</where>
order by sir.id desc
</select>
-</mapper>
\ No newline at end of file
+</mapper>
diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index 44d0941..25fa872 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -12,6 +12,8 @@
<result column="version" property="version"/>
<result column="locked_quantity" property="lockedQuantity"/>
<result column="warn_num" property="warnNum"/>
+ <result column="remark" property="remark"/>
+ <result column="stock_location" property="stockLocation"/>
</resultMap>
<update id="updateAddStockInventory">
update stock_inventory
@@ -34,6 +36,7 @@
update_time = now()
</set>
where product_model_id = #{ew.productModelId}
+ and stock_location = #{ew.stockLocation}
</update>
<update id="updateSubtractStockInventory">
update stock_inventory
@@ -49,7 +52,9 @@
</if>
update_time = now()
</set>
- where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
+ where product_model_id = #{ew.productModelId}
+ and stock_location = #{ew.stockLocation}
+ and qualitity >= #{ew.qualitity}
</update>
<select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
select si.id,
@@ -76,6 +81,9 @@
<if test="ew.productModelId != null">
and pm.id = #{ew.productModelId}
</if>
+ <if test="ew.stockLocation != null and ew.stockLocation != ''">
+ and si.stock_location = #{ew.stockLocation}
+ </if>
</select>
<select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
select si.qualitity,
@@ -85,6 +93,7 @@
coalesce(si.warn_num, 0) as warn_num,
coalesce(si.locked_quantity, 0) as locked_quantity,
si.remark,
+ si.stock_location,
si.update_time
from stock_inventory si
left join product_model pm on si.product_model_id = pm.id
@@ -92,6 +101,9 @@
where 1 = 1
<if test="ew.productName != null and ew.productName !=''">
and p.product_name like concat('%',#{ew.productName},'%')
+ </if>
+ <if test="ew.stockLocation != null and ew.stockLocation != ''">
+ and si.stock_location = #{ew.stockLocation}
</if>
</select>
<select id="stockInventoryPage" resultType="com.ruoyi.stock.dto.StockInRecordDto">
@@ -103,6 +115,7 @@
from
stock_in_record sir
left join stock_inventory si on sir.product_model_id = si.product_model_id
+ and sir.stock_location = si.stock_location
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
@@ -117,6 +130,9 @@
<if test="ew.endMonth != null">
and sir.create_time <= #{ew.endMonth}
</if>
+ <if test="ew.stockLocation != null and ew.stockLocation != ''">
+ and sir.stock_location = #{ew.stockLocation}
+ </if>
</where>
</select>
diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index 122bb4c..5fc1b3f 100644
--- a/src/main/resources/mapper/stock/StockOutRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -42,6 +42,9 @@
<if test="params.recordType != null and params.recordType != ''">
and sor.record_type = #{params.recordType}
</if>
+ <if test="params.stockLocation != null and params.stockLocation != ''">
+ and sor.stock_location = #{params.stockLocation}
+ </if>
</where>
order by sor.id desc
</select>
@@ -69,6 +72,9 @@
<if test="params.recordType != null and params.recordType != ''">
and sor.record_type = #{params.recordType}
</if>
+ <if test="params.stockLocation != null and params.stockLocation != ''">
+ and sor.stock_location = #{params.stockLocation}
+ </if>
</where>
order by sor.id desc
</select>
diff --git a/src/main/resources/mapper/stock/StockUninventoryMapper.xml b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
index 3265879..db13390 100644
--- a/src/main/resources/mapper/stock/StockUninventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -10,6 +10,9 @@
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="version" property="version" />
+ <result column="remark" property="remark" />
+ <result column="locked_quantity" property="lockedQuantity" />
+ <result column="stock_location" property="stockLocation" />
</resultMap>
<update id="updateSubtractStockUnInventory">
update stock_uninventory
@@ -53,6 +56,8 @@
su.version,
su.update_time,
(su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
+ su.remark,
+ su.stock_location,
pm.model,
pm.unit,
p.product_name
@@ -62,6 +67,9 @@
where pm.product_type = #{ew.productType}
<if test="ew.productName != null and ew.productName !=''">
and p.product_name like concat('%',#{ew.productName},'%')
+ </if>
+ <if test="ew.stockLocation != null and ew.stockLocation != ''">
+ and su.stock_location = #{ew.stockLocation}
</if>
</select>
<select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockUnInventoryExportData">
@@ -76,6 +84,9 @@
<if test="ew.productName != null and ew.productName !=''">
and p.product_name like concat('%',#{ew.productName},'%')
</if>
+ <if test="ew.stockLocation != null and ew.stockLocation != ''">
+ and su.stock_location = #{ew.stockLocation}
+ </if>
</select>
</mapper>
--
Gitblit v1.9.3