From ab4767af08870c339969311dda28b017d354140b Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 09 六月 2026 16:55:28 +0800
Subject: [PATCH] 废品退货后,入废品库
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 78 +++++++++++++++++++++++++++++++++++---
1 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 95537c8..e367385 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -18,6 +18,7 @@
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
+import java.time.LocalDateTime;
import java.util.Collections;
@Component
@@ -44,6 +45,7 @@
stockUninventoryDto.setRecordType(String.valueOf(recordType));
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryDto.setType(resolveUninventoryType(recordType));
stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
}
@@ -62,6 +64,27 @@
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
stockUninventoryDto.setBatchNo(batchNo);
+ stockUninventoryDto.setType(resolveUninventoryType(recordType));
+ stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
+ }
+
+ /**
+ * 搴熷搧鍏ュ簱甯︽壒娆″彿
+ *
+ * @param productModelId 浜у搧瑙勬牸ID
+ * @param quantity 鏁伴噺
+ * @param recordType 璁板綍绫诲瀷
+ * @param recordId 涓氬姟ID
+ * @param batchNo 鎵规鍙�
+ */
+ public void addWasteStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) {
+ StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
+ stockUninventoryDto.setRecordId(recordId);
+ stockUninventoryDto.setRecordType(String.valueOf(recordType));
+ stockUninventoryDto.setQualitity(quantity);
+ stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryDto.setBatchNo(batchNo);
+ stockUninventoryDto.setType("waste");
stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
}
@@ -79,6 +102,7 @@
stockUninventoryDto.setRecordType(String.valueOf(recordType));
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryDto.setType("unqualified");
stockUninventoryService.subtractStockUninventory(stockUninventoryDto);
}
@@ -88,11 +112,21 @@
* @param recordId
*/
public void addStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId) {
+ addStock(productModelId, quantity, recordType, recordId, null);
+ }
+
+ /**
+ * 鍚堟牸鍏ュ簱
+ * @param recordType
+ * @param recordId
+ */
+ public void addStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId, LocalDateTime createTime) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryDto.setCreateTime(createTime);
stockInventoryService.addStockInRecordOnly(stockInventoryDto);
}
@@ -104,12 +138,22 @@
* @param recordId
*/
public void addStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) {
+ addStockWithBatchNo(productModelId, quantity, recordType, recordId, batchNo, null);
+ }
+
+ /**
+ * 鍚堟牸鍏ュ簱甯︽壒娆″彿
+ * @param recordType
+ * @param recordId
+ */
+ public void addStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo, LocalDateTime createTime) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
stockInventoryDto.setBatchNo(batchNo);
+ stockInventoryDto.setCreateTime(createTime);
stockInventoryService.addStockInRecordOnly(stockInventoryDto);
}
@@ -135,6 +179,9 @@
stockInventoryDto.setIsContainsWater(isContainsWater);
stockInventoryDto.setWaterContent(waterContent);
stockInventoryDto.setTheoryStockInNum(theoryStockInNum);
+ if (theoryStockInNum != null && actualStockInNum != null) {
+ stockInventoryDto.setDifferenceNum(theoryStockInNum.subtract(actualStockInNum));
+ }
stockInventoryService.addStockInRecordOnly(stockInventoryDto);
}
@@ -187,16 +234,33 @@
//鍒犻櫎鍑哄簱璁板綍
public void deleteStockOutRecord(Long recordId, String recordType) {
- StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>()
+ java.util.List<StockOutRecord> list = stockOutRecordService.list(new QueryWrapper<StockOutRecord>()
.lambda().eq(StockOutRecord::getRecordId, recordId)
- .eq(StockOutRecord::getRecordType, recordType), false);
- if (ObjectUtils.isNotEmpty(one)) {
- if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) {
- stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
- } else {
- stockOutRecordService.removeById(one.getId());
+ .eq(StockOutRecord::getRecordType, recordType));
+ if (ObjectUtils.isNotEmpty(list)) {
+ java.util.List<Long> approvedIds = new java.util.ArrayList<>();
+ java.util.List<Long> pendingIds = new java.util.ArrayList<>();
+ for (StockOutRecord stockOutRecord : list) {
+ if (ReviewStatusEnum.APPROVED.getCode().equals(stockOutRecord.getApprovalStatus())) {
+ approvedIds.add(stockOutRecord.getId());
+ } else {
+ pendingIds.add(stockOutRecord.getId());
+ }
+ }
+ if (!approvedIds.isEmpty()) {
+ stockOutRecordService.batchDelete(approvedIds);
+ }
+ if (!pendingIds.isEmpty()) {
+ stockOutRecordService.removeByIds(pendingIds);
}
}
}
+
+ private String resolveUninventoryType(String recordType) {
+ if (com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(recordType)) {
+ return "waste";
+ }
+ return "unqualified";
+ }
}
--
Gitblit v1.9.3