From 4295247f77b9ae0c64db3977b5717b68f86c1273 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 09 四月 2026 14:14:05 +0800
Subject: [PATCH] fix: 销售产品开始生产不能删除和编辑
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 3031652..4bb3a84 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -1,23 +1,29 @@
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.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.List;
import java.util.Map;
+import java.util.stream.Collectors;
@Component
@RequiredArgsConstructor
@@ -27,15 +33,17 @@
private final StockUninventoryService stockUninventoryService;
private final StockInventoryService stockInventoryService;
private final StockInRecordService stockInRecordService;
+ private final StockOutRecordService stockOutRecordService;
/**
* 涓嶅悎鏍煎叆搴�
+ *
* @param productModelId
* @param quantity
* @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) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
stockUninventoryDto.setRecordType(String.valueOf(recordType));
@@ -46,12 +54,13 @@
/**
* 涓嶅悎鏍煎嚭搴�
+ *
* @param productModelId
* @param quantity
* @param recordType
* @param recordId
*/
- public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+ public void subtractUnStock(Long productModelId, BigDecimal quantity, Integer recordType, Long recordId) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(recordId);
stockUninventoryDto.setRecordType(String.valueOf(recordType));
@@ -62,12 +71,13 @@
/**
* 鍚堟牸鍏ュ簱
+ *
* @param productModelId
* @param quantity
* @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) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
@@ -78,12 +88,13 @@
/**
* 鍚堟牸鍑哄簱
+ *
* @param productModelId
* @param quantity
* @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) {
StockInventoryDto stockInventoryDto = new StockInventoryDto();
stockInventoryDto.setRecordId(recordId);
stockInventoryDto.setRecordType(String.valueOf(recordType));
@@ -93,11 +104,24 @@
}
//涓嶅悎鏍煎簱瀛樺垹闄�
- public void deleteStockRecord(Long recordId, String recordType) {
- StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>()
+ public void deleteStockInRecord(Long recordId, String recordType) {
+ List<StockInRecord> stockInRecords = stockInRecordService.list(new QueryWrapper<StockInRecord>()
.lambda().eq(StockInRecord::getRecordId, recordId)
.eq(StockInRecord::getRecordType, recordType));
+ if (ObjectUtils.isNotEmpty(stockInRecords)) {
+ List<Long> collect = stockInRecords.stream().map(StockInRecord::getId).collect(Collectors.toList());
+ stockInRecordService.batchDelete(collect);
+ }
+ }
- stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+ public void deleteStockOutRecord(Long recordId, String recordType) {
+ List<StockOutRecord> stockOutRecords = stockOutRecordService.list(new QueryWrapper<StockOutRecord>()
+ .lambda().eq(StockOutRecord::getRecordId, recordId)
+ .eq(StockOutRecord::getRecordType, recordType));
+
+ if (ObjectUtils.isNotEmpty(stockOutRecords)) {
+ List<Long> collect = stockOutRecords.stream().map(StockOutRecord::getId).collect(Collectors.toList());
+ stockOutRecordService.batchDelete(collect);
+ }
}
}
--
Gitblit v1.9.3