From b02190451a5ad1b7ce3a1429395227e625d68fa9 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 14 四月 2026 09:25:13 +0800
Subject: [PATCH] fix(stock): 修复删除出入库记录时库存数据一致性问题
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 25 +++++++++++++++++++++----
1 files changed, 21 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 9d87223..6768d17 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -1,11 +1,13 @@
package com.ruoyi.procurementrecord.utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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;
import com.ruoyi.stock.pojo.StockInRecord;
import com.ruoyi.stock.pojo.StockOutRecord;
import com.ruoyi.stock.service.StockInRecordService;
@@ -31,6 +33,7 @@
private final StockInventoryService stockInventoryService;
private final StockInRecordService stockInRecordService;
private final StockOutRecordService stockOutRecordService;
+ private final StockInventoryMapper stockInventoryMapper;
/**
* 涓嶅悎鏍煎叆搴�
@@ -101,14 +104,28 @@
StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>()
.lambda().eq(StockInRecord::getRecordId, recordId)
.eq(StockInRecord::getRecordType, recordType));
-
- stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+ 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) {
StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>()
.lambda().eq(StockOutRecord::getRecordId, recordId)
.eq(StockOutRecord::getRecordType, recordType));
-
- stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
+ 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