From 751f8b198ef1f7988d3de17516b752aeaa7f4ea4 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 30 四月 2026 10:46:04 +0800
Subject: [PATCH] 采购退货后,仓储物流生成对应的采购退货记录
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 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..c25001d 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -1,36 +1,32 @@
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;
import java.math.BigDecimal;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
@Component
@RequiredArgsConstructor
public class StockUtils {
- private final ProcurementRecordOutMapper procurementRecordOutMapper;
- private final ProcurementRecordMapper procurementRecordMapper;
private final StockUninventoryService stockUninventoryService;
private final StockInventoryService stockInventoryService;
private final StockInRecordService stockInRecordService;
private final StockOutRecordService stockOutRecordService;
+ private final StockInventoryMapper stockInventoryMapper;
/**
* 涓嶅悎鏍煎叆搴�
@@ -55,10 +51,10 @@
* @param recordType
* @param recordId
*/
- public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+ public void subtractUnStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
- stockUninventoryDto.setRecordType(String.valueOf(recordType));
+ stockUninventoryDto.setRecordType(recordType);
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
stockUninventoryService.subtractStockUninventory(stockUninventoryDto);
@@ -101,14 +97,30 @@
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));
+ }
- stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
}
}
--
Gitblit v1.9.3