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/StockInventoryServiceImpl.java | 49 +++++++++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
index 687837e..31d8a34 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -105,12 +105,7 @@
eq.eq(StockInventory::getBatchNo, stockInventoryDto.getBatchNo());
//鏂板鍏ュ簱璁板綍鍐嶆坊鍔犲簱瀛�
StockInRecordDto stockInRecordDto = new StockInRecordDto();
- stockInRecordDto.setRecordId(stockInventoryDto.getRecordId());
- stockInRecordDto.setRecordType(stockInventoryDto.getRecordType());
- stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity());
- stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
- stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
- stockInRecordDto.setType("0");
+ populateStockInRecord(stockInventoryDto, stockInRecordDto);
stockInRecordService.add(stockInRecordDto);
//鍐嶈繘琛屾柊澧炲簱瀛樻暟閲忓簱瀛�
//鍏堟煡璇㈠簱瀛樿〃涓殑浜у搧鏄惁瀛樺湪锛屼笉瀛樺湪鏂板锛屽瓨鍦ㄦ洿鏂�
@@ -124,8 +119,10 @@
newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
+ applySourceBindingFields(newStockInventory, stockInventoryDto);
stockInventoryMapper.insert(newStockInventory);
} else {
+ applySourceBindingFields(stockInventoryDto, stockInventoryDto);
stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
}
return true;
@@ -180,18 +177,50 @@
stockInventoryDto.setBatchNo(batchNo);
StockInRecordDto stockInRecordDto = new StockInRecordDto();
+ populateStockInRecord(stockInventoryDto, stockInRecordDto);
+ stockInRecordService.add(stockInRecordDto);
+ return true;
+ }
+
+ private void applySourceBindingFields(StockInventory target, StockInventoryDto source) {
+ if (target == null || source == null) {
+ return;
+ }
+ target.setSource(source.getSource());
+ if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(source.getSource())) {
+ target.setSupplierId(source.getSupplierId());
+ target.setManufacturerId(null);
+ return;
+ }
+ if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(source.getSource())) {
+ target.setManufacturerId(source.getManufacturerId());
+ target.setSupplierId(null);
+ return;
+ }
+ target.setManufacturerId(null);
+ target.setSupplierId(null);
+ }
+
+ private void populateStockInRecord(StockInventoryDto stockInventoryDto, StockInRecordDto stockInRecordDto) {
stockInRecordDto.setRecordId(stockInventoryDto.getRecordId());
stockInRecordDto.setRecordType(stockInventoryDto.getRecordType());
stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity());
- stockInRecordDto.setBatchNo(batchNo);
+ stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
stockInRecordDto.setType("0");
stockInRecordDto.setRemark(stockInventoryDto.getRemark());
stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
- stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId());
stockInRecordDto.setSource(stockInventoryDto.getSource());
- stockInRecordService.add(stockInRecordDto);
- return true;
+ if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInventoryDto.getSource())) {
+ stockInRecordDto.setSupplierId(stockInventoryDto.getSupplierId());
+ } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInventoryDto.getSource())) {
+ stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId());
+ }
+ // 璁剧疆鍚按閲忕浉鍏充俊鎭�
+ stockInRecordDto.setIsContainsWater(stockInventoryDto.getIsContainsWater());
+ stockInRecordDto.setWaterContent(stockInventoryDto.getWaterContent());
+ stockInRecordDto.setTheoryStockInNum(stockInventoryDto.getTheoryStockInNum());
+ stockInRecordDto.setDifferenceNum(stockInventoryDto.getDifferenceNum());
}
//瑙勫垯鐢熸垚锛�20260424-浜у搧缂栧彿-001
--
Gitblit v1.9.3