From 802796c22d7d21a6d572cd4c11844e6865521666 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 22 六月 2026 11:53:05 +0800
Subject: [PATCH] 新增库存,采购入库关联供应商,外协入库关联厂家
---
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 43 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 f86c0cb..e6fb860 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.stock.enums.StockInventorySourceEnum;
import java.time.LocalDateTime;
import com.ruoyi.stock.dto.StockInRecordDto;
@@ -60,6 +61,9 @@
@Override
@Transactional(rollbackFor = Exception.class)
public int add(StockInRecordDto stockInRecordDto) {
+ if (stockInRecordDto.getCreateTime() == null) {
+ stockInRecordDto.setCreateTime(LocalDateTime.now());
+ }
String no = OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK","inbound_batches", stockInRecordDto.getCreateTime() != null ? stockInRecordDto.getCreateTime() : LocalDateTime.now());
stockInRecordDto.setInboundBatches(no);
StockInRecord stockInRecord = new StockInRecord();
@@ -104,8 +108,8 @@
stockInRecordDto.setQualitity(stockInRecord.getStockInNum());
stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto);
}
- }else if (stockInRecord.getType().equals("1")) {
- String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getRecordType());
+ }else if (stockInRecord.getType().equals("1") || stockInRecord.getType().equals("2")) {
+ String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getType());
LambdaQueryWrapper<StockUninventory> eq = new LambdaQueryWrapper<StockUninventory>()
.eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())
.eq(StockUninventory::getType, uninventoryType);
@@ -237,6 +241,12 @@
throw new BaseException("鍙湁寰呭鎵圭姸鎬佺殑璁板綍鎵嶈兘瀹℃壒,鍏ュ簱鎵规:" + stockInRecord.getInboundBatches());
}
+ // 鍏煎鍘嗗彶鏁版嵁鎴栦笂娓告紡浼犲満鏅紝瀹℃壒鏃惰ˉ榻愭潵婧愶紝閬垮厤搴熷搧搴撳瓨鍙拌处鏉ユ簮涓虹┖
+ String resolvedSource = resolveStockSource(stockInRecord);
+ if (StringUtils.isNotEmpty(resolvedSource)) {
+ stockInRecord.setSource(resolvedSource);
+ }
+
// 鑾峰彇瀹℃壒鏃朵慨鏀圭殑鍏ュ簱鏁伴噺锛屽鏋滄病鏈変慨鏀瑰垯浣跨敤鍘熸暟閲�
final BigDecimal finalStockInNum;
if (item.getStockInNum() != null && item.getStockInNum().compareTo(BigDecimal.ZERO) > 0) {
@@ -271,23 +281,26 @@
setBatchNo(stockInRecord.getBatchNo());
setRemark(stockInRecord.getRemark());
setWarnNum(stockInRecord.getWarnNum());
- setManufacturerId(stockInRecord.getManufacturerId());
setSource(stockInRecord.getSource());
+ if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInRecord.getSource())) {
+ setSupplierId(stockInRecord.getSupplierId());
+ } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInRecord.getSource())) {
+ setManufacturerId(stockInRecord.getManufacturerId());
+ }
setVersion(1);
}});
} else {
stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
}
- } else if ("1".equals(stockInRecord.getType())) {
+ } else if ("1".equals(stockInRecord.getType()) || "2".equals(stockInRecord.getType())) {
// 涓嶅悎鏍煎叆搴� -> 鍏堟煡搴撳瓨锛屽瓨鍦ㄥ垯鏇存柊锛屼笉瀛樺湪鍒欐柊澧�
- String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getRecordType());
+ String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getType());
StockUninventory stockUninventory = getStockUninventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo(), uninventoryType);
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setProductModelId(stockInRecord.getProductModelId());
stockUninventoryDto.setBatchNo(stockInRecord.getBatchNo());
stockUninventoryDto.setQualitity(finalStockInNum);
stockUninventoryDto.setRemark(stockInRecord.getRemark());
- stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
stockUninventoryDto.setSource(stockInRecord.getSource());
stockUninventoryDto.setType(uninventoryType);
if (stockUninventory == null) {
@@ -297,7 +310,6 @@
setBatchNo(stockInRecord.getBatchNo());
setType(uninventoryType);
setRemark(stockInRecord.getRemark());
- setManufacturerId(stockInRecord.getManufacturerId());
setSource(stockInRecord.getSource());
setVersion(1);
}});
@@ -310,8 +322,8 @@
return items.size();
}
- private String resolveUninventoryTypeByInRecordType(String recordType) {
- if (StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(recordType)) {
+ private String resolveUninventoryTypeByInRecordType(String stockInType) {
+ if ("2".equals(stockInType)) {
return WASTE_TYPE;
}
return UNQUALIFIED_TYPE;
@@ -345,11 +357,32 @@
stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
stockInventoryDto.setRemark(stockInRecord.getRemark());
- stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
stockInventoryDto.setSource(stockInRecord.getSource());
+ if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInRecord.getSource())) {
+ stockInventoryDto.setSupplierId(stockInRecord.getSupplierId());
+ } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInRecord.getSource())) {
+ stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
+ }
return stockInventoryDto;
}
+ private String resolveStockSource(StockInRecord stockInRecord) {
+ if (stockInRecord == null || StringUtils.isNotEmpty(stockInRecord.getSource())) {
+ return stockInRecord == null ? null : stockInRecord.getSource();
+ }
+ if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType())
+ || StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(stockInRecord.getRecordType())) {
+ if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType())) {
+ return StockInventorySourceEnum.DEFECTIVE_SCRAP.getCode();
+ }
+ return StockInventorySourceEnum.PROD_GENERATED.getCode();
+ }
+ if (StockInQualifiedRecordTypeEnum.RETURN_WASTE_IN.getCode().equals(stockInRecord.getRecordType())) {
+ return StockInventorySourceEnum.RETURN_GENERATED.getCode();
+ }
+ return stockInRecord.getSource();
+ }
+
@Override
@Transactional(rollbackFor = Exception.class)
public int batchReAudit(List<Long> ids) {
--
Gitblit v1.9.3