From a02789977e52ea046fbdeb042c63c34c39d6d529 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 20 四月 2026 10:49:03 +0800
Subject: [PATCH] feat(technology): 添加技术路由DTO和VO类

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

diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index a42e43b..5c4f384 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -1,16 +1,21 @@
 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;
 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;
 
@@ -27,21 +32,8 @@
     private final StockUninventoryService stockUninventoryService;
     private final StockInventoryService stockInventoryService;
     private final StockInRecordService stockInRecordService;
-
-    // 鑾峰彇鍟嗗搧鍏ュ簱鏁伴噺,鍑哄簱鏁伴噺,鍓╀綑搴撳瓨
-//    public Map<String, BigDecimal> getStockQuantity(Long productModelId) {
-//        // 鍏ュ簱鏁伴噺
-//        BigDecimal sumQuantity = procurementRecordMapper.getSumQuantity(productModelId);
-//        // 鍑哄簱鏁伴噺
-//        BigDecimal outQuantity = procurementRecordOutMapper.getSumQuantity(productModelId);
-//        // 鍓╀綑搴撳瓨
-//        BigDecimal stockQuantity = outQuantity.compareTo(sumQuantity) > 0 ? BigDecimal.ZERO : sumQuantity.subtract(outQuantity);
-//        Map<String, BigDecimal> stockMap = new HashMap<>();
-//        stockMap.put("inboundNum", sumQuantity);
-//        stockMap.put("outboundNum", outQuantity);
-//        stockMap.put("stockQuantity", stockQuantity);
-//        return stockMap;
-//    }
+    private final StockOutRecordService stockOutRecordService;
+    private final StockInventoryMapper stockInventoryMapper;
 
     /**
      * 涓嶅悎鏍煎叆搴�
@@ -108,11 +100,34 @@
     }
 
     //涓嶅悎鏍煎簱瀛樺垹闄�
-    public void deleteStockRecord(Long recordId, String recordType) {
+    public void deleteStockInRecord(Long recordId, String recordType) {
         StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>()
                 .lambda().eq(StockInRecord::getRecordId, recordId)
                 .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));
+        }
 
-        stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+    }
+    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));
+        }
+
     }
 }

--
Gitblit v1.9.3