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 | 95 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 84 insertions(+), 11 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 c82ac34..31d8a34 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.stock.enums.StockInventorySourceEnum;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
@@ -68,7 +69,25 @@
@Override
public IPage<StockInventoryDto> pageListCombinedStockInventory(Page page, StockInventoryDto stockInventoryDto) {
- return stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto);
+ IPage<StockInventoryDto> result = stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto);
+ // 杞崲鏉ユ簮缂栫爜涓烘潵婧愬悕绉�
+ for (StockInventoryDto dto : result.getRecords()) {
+ // 鍚堟牸搴撳瓨鏉ユ簮
+ if (StringUtils.isNotBlank(dto.getQualifiedSource())) {
+ StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource());
+ if (qualifiedSourceEnum != null) {
+ dto.setQualifiedSourceText(qualifiedSourceEnum.getValue());
+ }
+ }
+ // 涓嶅悎鏍煎簱瀛樻潵婧�
+ if (StringUtils.isNotBlank(dto.getUnQualifiedSource())) {
+ StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource());
+ if (unQualifiedSourceEnum != null) {
+ dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue());
+ }
+ }
+ }
+ return result;
}
//鍏ュ簱璋冪敤
@@ -86,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);
//鍐嶈繘琛屾柊澧炲簱瀛樻暟閲忓簱瀛�
//鍏堟煡璇㈠簱瀛樿〃涓殑浜у搧鏄惁瀛樺湪锛屼笉瀛樺湪鏂板锛屽瓨鍦ㄦ洿鏂�
@@ -105,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;
@@ -161,16 +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());
- stockInRecordService.add(stockInRecordDto);
- return true;
+ stockInRecordDto.setSource(stockInventoryDto.getSource());
+ 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
@@ -438,6 +488,29 @@
@Override
public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) {
- return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto);
+ IPage<StockInventoryDto> resultPage = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto);
+
+ // 閬嶅巻缁撴灉锛岃缃潵婧愪腑鏂囧悕
+ resultPage.getRecords().forEach(dto -> {
+ // 璁剧疆鍚堟牸搴撳瓨鏉ユ簮涓枃鍚�
+ if (StringUtils.isNotEmpty(dto.getQualifiedSource())) {
+ System.out.println("鍚堟牸搴撳瓨鏉ユ簮锛�" + dto.getQualifiedSource());
+ StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource());
+ if (qualifiedSourceEnum != null) {
+ dto.setQualifiedSourceText(qualifiedSourceEnum.getValue());
+ System.out.println("鍚堟牸搴撳瓨鏉ユ簮鍊硷細" + qualifiedSourceEnum.getValue());
+ }
+ }
+
+ // 璁剧疆涓嶅悎鏍煎簱瀛樻潵婧愪腑鏂囧悕
+ if (StringUtils.isNotEmpty(dto.getUnQualifiedSource())) {
+ StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource());
+ if (unQualifiedSourceEnum != null) {
+ dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue());
+ }
+ }
+ });
+
+ return resultPage;
}
}
--
Gitblit v1.9.3