From 0fe8a027fc2e5bbcf24871b895fca12f5e2231c2 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 08 四月 2026 14:05:08 +0800
Subject: [PATCH] fix: 生成计划导入修改为手动新增,长宽高导入不成功

---
 src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 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 cd3e463..f5392c0 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -120,6 +120,10 @@
         //  鏌ヨ涓荤敓浜ц鍒�
         List<ProductionPlanDto> plans = productionPlanMapper.selectWithMaterialByIds(productionPlanDto.getIds());
 
+        if (plans == null || plans.isEmpty()) {
+            throw new ServiceException("涓嬪彂澶辫触,鐢熶骇璁″垝涓嶅瓨鍦�");
+        }
+
         //  鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佸悕绉�
         String firstProductName = plans.get(0).getProductName();
         if (plans.stream().anyMatch(p -> p.getProductName() == null || !p.getProductName().equals(firstProductName))) {
@@ -148,7 +152,7 @@
         productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime());
         productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode());
         productOrder.setStrength(productionPlanDto.getStrength());
-        productOrder.setProductMaterialSkuId(productionPlanDto.getProductMaterialSkuId());
+        productOrder.setProductMaterialSkuId(plans.get(0).getProductMaterialSkuId());
 
         Long orderId = productOrderService.insertProductOrder(productOrder);
 
@@ -230,9 +234,17 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean update(ProductionPlanDto productionPlanDto) {
+        if (productionPlanDto == null) {
+            throw new ServiceException("缂栬緫澶辫触,鏁版嵁涓嶈兘涓虹┖");
+        }
+        ProductionPlan productionPlan = getById(productionPlanDto.getId());
+        if (productionPlan == null) {
+            throw new ServiceException("缂栬緫澶辫触,涓荤敓浜ц鍒掍笉瀛樺湪");
+        }
+
         // 宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫
-        if (productionPlanDto.getStatus() != 0) {
-            throw new BaseException("宸蹭笅鍙戞垨閮ㄥ垎涓嬪彂鐘舵�侊紝涓嶈兘缂栬緫");
+        if (productionPlan.getStatus() != 0) {
+            throw new BaseException("缂栬緫澶辫触,璇ョ敓浜ц鍒掑凡涓嬪彂鎴栭儴鍒嗕笅鍙戠姸鎬�,绂佹缂栬緫");
         }
         // 鏌ヨ鏄惁鏈夊叧鑱旇鍗�
         boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null);
@@ -479,7 +491,7 @@
             entity.setAssignedQuantity(BigDecimal.ZERO);
             entity.setCreateTime(LocalDateTime.now());
             entity.setUpdateTime(LocalDateTime.now());
-            entity.setDataSourceType(DataSourceTypeEnum.DING_TALK.getCode());
+            entity.setDataSourceType(DataSourceTypeEnum.MANUAL.getCode());
 
             // 鏍规嵁鐗╂枡缂栫爜濉厖鍏宠仈ID
             if (StringUtils.isNotEmpty(dto.getMaterialCode())) {

--
Gitblit v1.9.3