From 67bdaf2e0f8b84d7c5312ec71a6b0312eeb29310 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 11 六月 2026 19:30:35 +0800
Subject: [PATCH] feat: 所有入库出库审批默认通过
---
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java | 70 ++++++++++++++++++++++++----------
1 files changed, 49 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index 1434db6..f6c8d64 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -3,11 +3,14 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.common.enums.ReviewStatusEnum;
+import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
+import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper;
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;
@@ -29,7 +32,6 @@
private final StockInventoryService stockInventoryService;
private final StockInRecordService stockInRecordService;
private final StockOutRecordService stockOutRecordService;
- private final StockInventoryMapper stockInventoryMapper;
/**
* 涓嶅悎鏍煎叆搴�
@@ -45,6 +47,24 @@
stockUninventoryDto.setRecordType(String.valueOf(recordType));
stockUninventoryDto.setQualitity(quantity);
stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
+ }
+
+ /**
+ * 涓嶅悎鏍煎叆搴撳甫鎵规鍙�
+ *
+ * @param productModelId
+ * @param quantity
+ * @param recordType
+ * @param recordId
+ */
+ public void addUnStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) {
+ StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
+ stockUninventoryDto.setRecordId(recordId);
+ stockUninventoryDto.setRecordType(String.valueOf(recordType));
+ stockUninventoryDto.setQualitity(quantity);
+ stockUninventoryDto.setProductModelId(productModelId);
+ stockUninventoryDto.setBatchNo(batchNo);
stockUninventoryService.addStockInRecordOnly(stockUninventoryDto);
}
@@ -94,6 +114,11 @@
stockInventoryDto.setProductModelId(productModelId);
stockInventoryDto.setBatchNo(batchNo);
stockInventoryService.addStockInRecordOnly(stockInventoryDto);
+ //StockInRecord stockInRecord = stockInRecordService.getOne(Wrappers.<StockInRecord>lambdaQuery()
+ // .eq(StockInRecord::getRecordId, stockInventoryDto.getRecordId())
+ // .eq(StockInRecord::getRecordType, stockInventoryDto.getRecordType())
+ //);
+ //stockInRecordService.batchApprove(Collections.singletonList(stockInRecord.getId()),1);
}
/**
@@ -112,6 +137,11 @@
stockInventoryDto.setProductModelId(productModelId);
stockInventoryDto.setBatchNo(batchNo);
stockInventoryService.addStockOutRecordOnly(stockInventoryDto);
+ StockOutRecord stockOutRecord = stockOutRecordService.getOne(Wrappers.<StockOutRecord>lambdaQuery()
+ .eq(StockOutRecord::getRecordId, stockInventoryDto.getRecordId())
+ .eq(StockOutRecord::getRecordType, stockInventoryDto.getRecordType())
+ );
+ stockOutRecordService.batchApprove(Collections.singletonList(stockOutRecord.getId()),1);
}
/**
@@ -122,40 +152,38 @@
public void shipmentStatus(String recordType, Long recordId) {
LambdaQueryWrapper<StockOutRecord> queryWrapper = new LambdaQueryWrapper<StockOutRecord>().eq(StockOutRecord::getRecordType, recordType)
.eq(StockOutRecord::getRecordId, recordId);
- StockOutRecord stockOutRecord = stockOutRecordService.getOne(queryWrapper);
- stockOutRecord.setApprovalStatus(0);
- stockOutRecordService.updateById(stockOutRecord);
+ stockOutRecordService.list(queryWrapper).stream().forEach(stockOutRecord -> {
+ stockOutRecord.setApprovalStatus(0);
+ stockOutRecordService.updateById(stockOutRecord);
+ });
}
//涓嶅悎鏍煎簱瀛樺垹闄�
public void deleteStockInRecord(Long recordId, String recordType) {
StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>()
.lambda().eq(StockInRecord::getRecordId, recordId)
- .eq(StockInRecord::getRecordType, recordType));
+ .eq(StockInRecord::getRecordType, recordType), false);
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));
+ if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) {
+ stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+ } else {
+ stockInRecordService.removeById(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));
+ .eq(StockOutRecord::getRecordType, recordType), false);
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));
+ if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) {
+ stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
+ } else {
+ stockOutRecordService.removeById(one.getId());
+ }
}
}
--
Gitblit v1.9.3