From dd23c6a885d67ead6b1aef9d6c18d8dc7cbd85cd Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期六, 25 四月 2026 13:56:43 +0800
Subject: [PATCH] feat(stock): 新增出库记录批次号字段设置
---
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java | 37 +++++++++++++++++++++++++++----------
1 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
index bf64268..ef5e170 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -4,11 +4,12 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum;
+import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
+import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.EnumUtil;
import com.ruoyi.common.utils.OrderUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.stock.dto.StockInRecordDto;
@@ -26,7 +27,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@Service
@@ -46,7 +47,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
public int add(StockInRecordDto stockInRecordDto) {
- String no = OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK");
+ String no = OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK","inbound_batches");
stockInRecordDto.setInboundBatches(no);
StockInRecord stockInRecord = new StockInRecord();
BeanUtils.copyProperties(stockInRecordDto, stockInRecord);
@@ -73,24 +74,40 @@
for (Long id : ids) {
StockInRecord stockInRecord = stockInRecordMapper.selectById(id);
if (stockInRecord.getType().equals("0")) {
- StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockInRecord.getProductModelId()));
+ LambdaQueryWrapper<StockInventory> eq = new LambdaQueryWrapper<StockInventory>()
+ .eq(StockInventory::getProductModelId, stockInRecord.getProductModelId());
+ if (StringUtils.isEmpty(stockInRecord.getBatchNo())) {
+ eq.isNull(StockInventory::getBatchNo);
+ } else {
+ eq.eq(StockInventory::getBatchNo, stockInRecord.getBatchNo());
+ }
+ StockInventory stockInventory = stockInventoryMapper.selectOne(eq);
if (stockInventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
StockInventoryDto stockInRecordDto = new StockInventoryDto();
stockInRecordDto.setProductModelId(stockInventory.getProductModelId());
+ stockInRecordDto.setBatchNo(stockInventory.getBatchNo());
stockInRecordDto.setQualitity(stockInRecord.getStockInNum());
- stockInventoryMapper.updateAddStockInventory(stockInRecordDto);
+ stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto);
}
}else if (stockInRecord.getType().equals("1")) {
- StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId()));
+ LambdaQueryWrapper<StockUninventory> eq = new LambdaQueryWrapper<StockUninventory>()
+ .eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId());
+ if (StringUtils.isEmpty(stockInRecord.getBatchNo())) {
+ eq.isNull(StockUninventory::getBatchNo);
+ } else {
+ eq.eq(StockUninventory::getBatchNo, stockInRecord.getBatchNo());
+ }
+ StockUninventory stockUninventory = stockUninventoryMapper.selectOne(eq);
if (stockUninventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
}else {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setProductModelId(stockUninventory.getProductModelId());
+ stockUninventoryDto.setBatchNo(stockUninventory.getBatchNo());
stockUninventoryDto.setQualitity(stockInRecord.getStockInNum());
- stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto);
+ stockUninventoryMapper.updateSubtractStockUnInventory(stockUninventoryDto);
}
}
}
@@ -102,9 +119,9 @@
List<StockInRecordExportData> list = stockInRecordMapper.listStockInRecordExportData(stockInRecordDto);
for (StockInRecordExportData stockInRecordExportData : list) {
if (stockInRecordExportData.getType().equals("0")) {
- stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
+ stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockOutQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
}else {
- stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
+ stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockInUnQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
}
}
ExcelUtil<StockInRecordExportData> util = new ExcelUtil<>(StockInRecordExportData.class);
--
Gitblit v1.9.3