From a97eb69a7233fc36a794832210fb1b0de037f2bb Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 15 四月 2026 16:39:53 +0800
Subject: [PATCH] fix:生产核算-对应工序
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 37 +++++++++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 26578a0..2a47d02 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -6,6 +6,7 @@
import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper;
import com.ruoyi.stock.dto.StockInventoryDto;
import com.ruoyi.stock.dto.StockUninventoryDto;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
import com.ruoyi.stock.pojo.StockInRecord;
import com.ruoyi.stock.pojo.StockOutRecord;
import com.ruoyi.stock.service.StockInRecordService;
@@ -16,6 +17,7 @@
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
+import java.time.LocalDate;
import java.util.Collections;
@Component
@@ -27,6 +29,7 @@
private final StockInventoryService stockInventoryService;
private final StockInRecordService stockInRecordService;
private final StockOutRecordService stockOutRecordService;
+ private final StockInventoryMapper stockInventoryMapper;
/**
* 涓嶅悎鏍煎叆搴�
@@ -35,12 +38,15 @@
* @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, String batchNo, String customer, LocalDate productionDate) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
stockUninventoryDto.setRecordType(String.valueOf(recordType));
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryDto.setBatchNo(batchNo);
+ stockUninventoryDto.setCustomer(customer);
+ stockUninventoryDto.setProductionDate(productionDate);
stockUninventoryService.addStockUninventory(stockUninventoryDto);
}
@@ -67,7 +73,7 @@
* @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, String batchNo, String customer, LocalDate productionDate) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
if (recordType != null) {
@@ -75,6 +81,13 @@
}
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryDto.setBatchNo(batchNo);
+ stockInventoryDto.setCustomer(customer);
+ if (stockInventoryDto.getProductionDate() == null) {
+ stockInventoryDto.setProductionDate(LocalDate.now());
+ }else {
+ stockInventoryDto.setProductionDate(productionDate);
+ }
stockInventoryService.addstockInventory(stockInventoryDto);
}
@@ -85,12 +98,16 @@
* @param recordType
* @param recordId
*/
- public void substractStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
+ public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId,String batchNo,String customer) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
- stockInventoryDto.setRecordType(String.valueOf(recordType));
+ if (recordType != null) {
+ stockInventoryDto.setRecordType(recordType);
+ }
stockInventoryDto.setQualitity(quantity);
stockInventoryDto.setProductModelId(productModelId);
+ stockInventoryDto.setBatchNo(batchNo);
+ stockInventoryDto.setCustomer(customer);
stockInventoryService.subtractStockInventory(stockInventoryDto);
}
@@ -101,6 +118,12 @@
.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));
}
}
public void deleteStockOutRecord(Long recordId, String recordType) {
@@ -109,6 +132,12 @@
.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));
}
}
}
--
Gitblit v1.9.3