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 | 41 +++++++++++++++++++++++++++++++++++++----
1 files changed, 37 insertions(+), 4 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 81e6ae9..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();
@@ -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,8 +281,12 @@
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 {
@@ -287,7 +301,6 @@
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);
}});
@@ -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