From 28cddfe7a3d39e36af03199f46d9e704476fca33 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 09 五月 2026 15:54:25 +0800
Subject: [PATCH] feat(stock): 完善采购入库和退货出库的库存批次处理
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 76 ++++++++++++++++++++++++++------------
1 files changed, 52 insertions(+), 24 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 6768d17..5356500 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper;
-import com.ruoyi.stock.dto.StockInRecordDto;
import com.ruoyi.stock.dto.StockInventoryDto;
import com.ruoyi.stock.dto.StockUninventoryDto;
import com.ruoyi.stock.mapper.StockInventoryMapper;
@@ -14,15 +13,11 @@
import com.ruoyi.stock.service.StockInventoryService;
import com.ruoyi.stock.service.StockOutRecordService;
import com.ruoyi.stock.service.StockUninventoryService;
-import com.ruoyi.stock.service.impl.StockInRecordServiceImpl;
-import com.ruoyi.stock.service.impl.StockOutRecordServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
@Component
@RequiredArgsConstructor
@@ -37,28 +32,30 @@
/**
* 涓嶅悎鏍煎叆搴�
+ *
* @param productModelId
* @param quantity
* @param recordType
* @param recordId
*/
- public void addUnStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
+ public void addUnStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
stockUninventoryDto.setRecordType(String.valueOf(recordType));
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
- stockUninventoryService.addStockUninventory(stockUninventoryDto);
+ stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
}
/**
* 涓嶅悎鏍煎嚭搴�
+ *
* @param productModelId
* @param quantity
* @param recordType
* @param recordId
*/
- public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+ public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType, Long recordId) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
stockUninventoryDto.setRecordType(String.valueOf(recordType));
@@ -74,28 +71,56 @@
* @param recordType
* @param recordId
*/
- public void addStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
+ public void addStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
- stockInventoryService.addstockInventory(stockInventoryDto);
+ stockInventoryService.addStockInRecordOnly(stockInventoryDto);
}
/**
- * 鍚堟牸鍑哄簱
+ * 鍚堟牸鍏ュ簱甯︽壒娆″彿
* @param productModelId
* @param quantity
* @param recordType
* @param recordId
*/
- public void substractStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
+ public void addStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryDto.setBatchNo(batchNo);
+ stockInventoryService.addStockInRecordOnly(stockInventoryDto);
+ }
+
+ /**
+ * 鍚堟牸鍑哄簱
+ *
+ * @param productModelId
+ * @param quantity
+ * @param recordType
+ * @param recordId
+ */
+ public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId) {
+ StockInventoryDto stockInventoryDto = new StockInventoryDto();
+ stockInventoryDto.setRecordId(recordId);
+ stockInventoryDto.setRecordType(String.valueOf(recordType));
+ stockInventoryDto.setQualitity(quantity);
+ stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryService.subtractStockInventory(stockInventoryDto);
+ }
+
+ public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) {
+ StockInventoryDto stockInventoryDto = new StockInventoryDto();
+ stockInventoryDto.setRecordId(recordId);
+ stockInventoryDto.setRecordType(String.valueOf(recordType));
+ stockInventoryDto.setQualitity(quantity);
+ stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryDto.setBatchNo(batchNo);
stockInventoryService.subtractStockInventory(stockInventoryDto);
}
@@ -106,26 +131,29 @@
.eq(StockInRecord::getRecordType, recordType));
if (ObjectUtils.isNotEmpty(one)) {
stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+ //灏嗗簱瀛樺噺鍥炴潵
+ StockInventoryDto stockInventoryDto = new StockInventoryDto();
+ stockInventoryDto.setRecordId(recordId);
+ stockInventoryDto.setRecordType(recordType);
+ stockInventoryDto.setQualitity(one.getStockInNum());
+ stockInventoryMapper.updateSubtractStockInventory((stockInventoryDto));
}
- //灏嗗簱瀛樺噺鍥炴潵
- StockInventoryDto stockInventoryDto = new StockInventoryDto();
- stockInventoryDto.setRecordId(recordId);
- stockInventoryDto.setRecordType(recordType);
- stockInventoryDto.setQualitity(one.getStockInNum());
- stockInventoryMapper.updateSubtractStockInventory((stockInventoryDto));
+
}
+
public void deleteStockOutRecord(Long recordId, String recordType) {
StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>()
.lambda().eq(StockOutRecord::getRecordId, recordId)
.eq(StockOutRecord::getRecordType, recordType));
if (ObjectUtils.isNotEmpty(one)) {
stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
+ //灏嗗簱瀛樺姞鍥炴潵
+ StockInventoryDto stockInventoryDto = new StockInventoryDto();
+ stockInventoryDto.setRecordId(recordId);
+ stockInventoryDto.setRecordType(recordType);
+ stockInventoryDto.setQualitity(one.getStockOutNum());
+ stockInventoryMapper.updateAddStockInventory((stockInventoryDto));
}
- //灏嗗簱瀛樺姞鍥炴潵
- StockInventoryDto stockInventoryDto = new StockInventoryDto();
- stockInventoryDto.setRecordId(recordId);
- stockInventoryDto.setRecordType(recordType);
- stockInventoryDto.setQualitity(one.getStockOutNum());
- stockInventoryMapper.updateAddStockInventory((stockInventoryDto));
+
}
}
--
Gitblit v1.9.3