From cd079ba388c160caa8c9836b9bf16fd25a589909 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 20 三月 2026 15:56:05 +0800
Subject: [PATCH] fix: 和并下发状态未修改
---
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java | 53 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
index 698199c..9fccff8 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -14,8 +14,10 @@
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.config.AliDingConfig;
import com.ruoyi.framework.util.AliDingUtils;
+import com.ruoyi.production.enums.ProductOrderStatusEnum;
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.production.pojo.ProductOrder;
+import com.ruoyi.production.service.IProductionOrderAppendixService;
import com.ruoyi.production.service.ProductMaterialService;
import com.ruoyi.production.service.ProductMaterialSkuService;
import com.ruoyi.production.service.ProductOrderService;
@@ -76,6 +78,9 @@
@Autowired
private ProductMaterialService productMaterialService;
+ @Autowired
+ private IProductionOrderAppendixService productionOrderAppendixService;
+
/**
* 鍚屾閿侊紝纭繚鎵嬪姩鍜屽畾鏃朵换鍔′笉鍚屾椂鎵ц
*/
@@ -122,8 +127,8 @@
}
// 鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佽鏍�
- String firstProductSpec = plans.get(0).getSpecification();
- if (plans.stream().anyMatch(p -> p.getSpecification() == null || !p.getSpecification().equals(firstProductSpec))) {
+ String firstProductSpec = plans.get(0).getModel();
+ if (plans.stream().anyMatch(p -> p.getModel() == null || !p.getModel().equals(firstProductSpec))) {
throw new BaseException("鍚堝苟澶辫触锛屽瓨鍦ㄤ笉鍚岀殑浜у搧瑙勬牸");
}
@@ -141,7 +146,20 @@
ProductOrder productOrder = new ProductOrder();
productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity());
productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime());
- productOrderService.addProductOrder(productOrder);
+ productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode());
+ productOrder.setStrength(productionPlanDto.getStrength());
+
+ Long orderId = productOrderService.insertProductOrder(productOrder);
+
+ // 褰撲笅鍙戠殑浜у搧涓虹爩鍧楁垨鏉挎潗锛屽氨鎷夊彇BOM瀛愰泦涓庡伐鑹鸿矾绾垮瓙闆嗘暟鎹瓨鍏ュ埌闄勮〃涓�
+ if ("鐮屽潡".equals(productionPlanDto.getProductName())) {
+ productOrder.setRouteId(productionOrderAppendixService.populateBlocks(orderId, productionPlanDto));
+ }
+ if ("鏉挎潗".equals(productionPlanDto.getProductName())) {
+ productOrder.setRouteId(productionOrderAppendixService.populatePlates(orderId, productionPlanDto));
+ }
+ // 鏇存柊缁戝畾鐨勫伐鑹鸿矾绾�
+ productOrderService.updateById(productOrder);
// 鏍规嵁涓嬪彂鏁伴噺锛屼粠绗竴涓敓浜ц鍒掑紑濮嬪垎閰嶆柟鏁�
BigDecimal assignedVolume = BigDecimal.ZERO;
@@ -163,11 +181,9 @@
if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) {
// 鏈�鍚庝竴涓鍒掞紝鍒嗛厤鍓╀綑鏂规暟
BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
- plan.setStatus(1);
- if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
- plan.setStatus(2);
- }
- plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
+ BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO).add(lastRemainingVolume);
+ plan.setAssignedQuantity(assignedQuantity);
+ plan.setStatus(assignedQuantity.compareTo(plan.getVolume()) >= 0 ? 2 : 1);
productOrderPlan.setAssignedQuantity(lastRemainingVolume);
productionPlanMapper.updateById(plan);
productOrderPlanMapper.insert(productOrderPlan);
@@ -175,11 +191,9 @@
}
// 鍒嗛厤褰撳墠璁″垝鏂规暟
- plan.setStatus(1);
- if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
- plan.setStatus(2);
- }
- plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume));
+ BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO).add(remainingVolume);
+ plan.setAssignedQuantity(assignedQuantity);
+ plan.setStatus(assignedQuantity.compareTo(plan.getVolume()) >= 0 ? 2 : 1);
productOrderPlan.setAssignedQuantity(remainingVolume);
// 鏇存柊鐢熶骇璁″垝
productionPlanMapper.updateById(plan);
@@ -187,6 +201,19 @@
productOrderPlanMapper.insert(productOrderPlan);
assignedVolume = assignedVolume.add(remainingVolume);
}
+
+ for (ProductionPlan plan : plans) {
+ BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO);
+ BigDecimal volume = Optional.ofNullable(plan.getVolume()).orElse(BigDecimal.ZERO);
+ if (assignedQuantity.compareTo(BigDecimal.ZERO) <= 0) {
+ plan.setStatus(0);
+ } else if (assignedQuantity.compareTo(volume) >= 0) {
+ plan.setStatus(2);
+ } else {
+ plan.setStatus(1);
+ }
+ productionPlanMapper.updateById(plan);
+ }
return true;
}
--
Gitblit v1.9.3