From 579d785db5254ad64b02eb58cb696c2447821dd3 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 27 五月 2026 11:25:44 +0800
Subject: [PATCH] feat(stock): 完善成品库存维度解析和生产投料扣减逻辑 - 在电压参数解析中增加非成品情况下的空值返回 - 在工艺路线成品类别判断中增加非成品情况下的空值返回 - 添加光检外观和包装工序跳过库存扣减的功能 - 修改生产投料环节仅对非光检包装工序执行库存扣减
---
src/main/java/com/ruoyi/stock/support/FinishedProductStockDimensionResolver.java | 82 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/support/FinishedProductStockDimensionResolver.java b/src/main/java/com/ruoyi/stock/support/FinishedProductStockDimensionResolver.java
index 5ca047b..0f06f28 100644
--- a/src/main/java/com/ruoyi/stock/support/FinishedProductStockDimensionResolver.java
+++ b/src/main/java/com/ruoyi/stock/support/FinishedProductStockDimensionResolver.java
@@ -5,6 +5,10 @@
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.ruoyi.basic.mapper.ProductMapper;
+import com.ruoyi.basic.mapper.ProductModelMapper;
+import com.ruoyi.basic.pojo.Product;
+import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.production.mapper.ProductProcessMapper;
@@ -35,15 +39,21 @@
private final ProductionProductOutputMapper productionProductOutputMapper;
private final ProductProcessRouteItemMapper productProcessRouteItemMapper;
private final ProductProcessMapper productProcessMapper;
+ private final ProductMapper productMapper;
+ private final ProductModelMapper productModelMapper;
public FinishedProductStockDimensionResolver(ProductionProductMainMapper productionProductMainMapper,
ProductionProductOutputMapper productionProductOutputMapper,
ProductProcessRouteItemMapper productProcessRouteItemMapper,
- ProductProcessMapper productProcessMapper) {
+ ProductProcessMapper productProcessMapper,
+ ProductMapper productMapper,
+ ProductModelMapper productModelMapper) {
this.productionProductMainMapper = productionProductMainMapper;
this.productionProductOutputMapper = productionProductOutputMapper;
this.productProcessRouteItemMapper = productProcessRouteItemMapper;
this.productProcessMapper = productProcessMapper;
+ this.productMapper = productMapper;
+ this.productModelMapper = productModelMapper;
}
/**
@@ -64,13 +74,27 @@
*/
public String resolveVoltage(Long productMainId) {
List<ProductionProductOutput> outputs = loadOutputs(productMainId);
+
+ Long productModelId = outputs.stream()
+ .map(ProductionProductOutput::getProductModelId)
+ .filter(id -> id != null)
+ .findFirst()
+ .orElse(null);
+
+ boolean isFinishedProduct = isFinishedProduct(productModelId);
+
for (ProductionProductOutput output : outputs) {
String voltage = resolveVoltageValue(output.getOtherData());
if (StringUtils.isNotBlank(voltage)) {
return voltage;
}
}
- throw new ServiceException("璇烽厤缃弬鏁扮數鍘�");
+
+ if (isFinishedProduct) {
+ throw new ServiceException("璇烽厤缃弬鏁扮數鍘�");
+ }
+
+ return null;
}
private ProductionProductMain loadProductionMain(Long productMainId) {
@@ -114,6 +138,15 @@
if (CollectionUtils.isEmpty(routeItems)) {
throw new ServiceException("璁㈠崟宸ヨ壓璺嚎鏈厤缃伐搴忥紝鏃犳硶纭畾鎴愬搧绫诲埆");
}
+
+ Long productModelId = routeItems.stream()
+ .map(ProductProcessRouteItem::getProductModelId)
+ .filter(id -> id != null)
+ .findFirst()
+ .orElse(null);
+
+ boolean isFinishedProduct = isFinishedProduct(productModelId);
+
Set<Long> processIds = routeItems.stream()
.map(ProductProcessRouteItem::getProcessId)
.filter(id -> id != null)
@@ -126,12 +159,19 @@
.map(ProductProcess::getName)
.filter(name -> PROCESS_COPPER.equals(name) || PROCESS_SILVER.equals(name))
.collect(Collectors.toCollection(LinkedHashSet::new));
- if (matchedCategories.isEmpty()) {
+
+ if (matchedCategories.isEmpty() && isFinishedProduct) {
throw new ServiceException("璁㈠崟宸ヨ壓璺嚎鏈厤缃嵃閾�/鍗伴摱宸ュ簭锛屾棤娉曠‘瀹氭垚鍝佺被鍒�");
}
+
if (matchedCategories.size() > 1) {
throw new ServiceException("璁㈠崟宸ヨ壓璺嚎鍚屾椂閰嶇疆浜嗗嵃閾滃拰鍗伴摱锛屾棤娉曠‘瀹氭垚鍝佺被鍒�");
}
+
+ if (matchedCategories.isEmpty()) {
+ return null;
+ }
+
String matchedProcess = matchedCategories.iterator().next();
if (PROCESS_COPPER.equals(matchedProcess)) {
return PROCESS_CATEGORY_COPPER;
@@ -181,4 +221,38 @@
}
return null;
}
-}
+
+ private boolean isFinishedProduct(Long productModelId) {
+ if (productModelId == null) {
+ return false;
+ }
+
+ ProductModel productModel = productModelMapper.selectById(productModelId);
+ if (productModel == null || productModel.getProductId() == null) {
+ return false;
+ }
+
+ return isFinishedProductRecursive(productModel.getProductId());
+ }
+
+ private boolean isFinishedProductRecursive(Long productId) {
+ if (productId == null) {
+ return false;
+ }
+
+ Product product = productMapper.selectById(productId);
+ if (product == null) {
+ return false;
+ }
+
+ if ("鎴愬搧".equals(product.getProductName())) {
+ return true;
+ }
+
+ if (product.getParentId() == null) {
+ return false;
+ }
+
+ return isFinishedProductRecursive(product.getParentId());
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3