From b7760ab3eec64c9c23db976ec104e7d09cfae041 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 20 四月 2026 10:22:59 +0800
Subject: [PATCH] fix(customer): 解决客户档案删除时私海数据未清理问题

---
 src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 819ce65..5c4f384 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -7,6 +7,7 @@
 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;
@@ -32,6 +33,7 @@
     private final StockInventoryService stockInventoryService;
     private final StockInRecordService stockInRecordService;
     private final StockOutRecordService stockOutRecordService;
+    private final StockInventoryMapper stockInventoryMapper;
 
     /**
      * 涓嶅悎鏍煎叆搴�
@@ -104,7 +106,14 @@
                 .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) {
         StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>()
@@ -112,6 +121,13 @@
                 .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