From 6a2bc48c4117e5dfc675d3be90b8ad256f85a37f Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期四, 30 四月 2026 14:55:14 +0800
Subject: [PATCH] fix(stock): 修复库存盘点单号生成中的产品型号字段错误
---
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 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 73b3a42..4d3ca12 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -4,8 +4,8 @@
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.StockInQualifiedRecordTypeEnum;
import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.EnumUtil;
import com.ruoyi.common.utils.OrderUtils;
@@ -52,12 +52,17 @@
// 鏂板鍏ュ簱
@Override
@Transactional(rollbackFor = Exception.class)
- public int add(StockInRecordDto stockInRecordDto) {
+ public Long add(StockInRecordDto stockInRecordDto) {
String no = OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK");
stockInRecordDto.setInboundBatches(no);
StockInRecord stockInRecord = new StockInRecord();
BeanUtils.copyProperties(stockInRecordDto, stockInRecord);
- return stockInRecordMapper.insert(stockInRecord);
+
+ int insertRows = stockInRecordMapper.insert(stockInRecord);
+
+ Long insertId = stockInRecord.getId();
+
+ return insertRows > 0 ? insertId : null;
}
@Override
@@ -80,7 +85,11 @@
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()));
+ StockInventory stockInventory = stockInventoryMapper.selectOne(
+ new LambdaQueryWrapper<StockInventory>()
+ .eq(StockInventory::getProductModelId, stockInRecord.getProductModelId())
+ .eq(StockInventory::getBatchNo, stockInRecord.getBatchNo())
+ );
if (stockInventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
} else {
@@ -90,7 +99,10 @@
stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto);
}
} else if (stockInRecord.getType().equals("1")) {
- StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId()));
+ StockUninventory stockUninventory = stockUninventoryMapper.selectOne(
+ new LambdaQueryWrapper<StockUninventory>()
+ .eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())
+ .eq(StockUninventory::getBatchNo, stockInRecord.getBatchNo()));
if (stockUninventory == null) {
throw new BaseException("搴撳瓨璁板綍涓病鏈夊搴旂殑浜у搧,鏃犳硶鍒犻櫎!!!");
} else {
@@ -109,7 +121,7 @@
List<StockInRecordExportData> list = stockInRecordMapper.listStockInRecordExportData(stockInRecordDto);
for (StockInRecordExportData stockInRecordExportData : list) {
if (stockInRecordExportData.getType().equals("0")) {
- stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockOutQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
+ stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockInQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
} else {
stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockInUnQualifiedRecordTypeEnum.class, Integer.parseInt(stockInRecordExportData.getRecordType())).getValue());
}
@@ -127,11 +139,11 @@
public int updateStockInRecord(StockInRecordDto stockInRecordDto) {
LoginUser loginUser = SecurityUtils.getLoginUser();
try {
- stockInventoryService.addApproveByPurchase(loginUser, stockInRecordDto);
+ stockInventoryService.addApproveByPurchase(loginUser, stockInRecordDto,stockInRecordDto.getId());
} catch (Exception e) {
e.printStackTrace();
}
- stockInRecordDto.setApproveStatus(2);
+ stockInRecordDto.setApproveStatus(1);
return stockInRecordMapper.updateById(stockInRecordDto);
}
}
--
Gitblit v1.9.3