From 2d94ddd240fca69ebbc4b0570abb30c803db7754 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 13 三月 2026 11:33:44 +0800
Subject: [PATCH] fix: 区分基础数据与生产计划数据查询

---
 src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java |   27 ++++++++++-----------------
 1 files changed, 10 insertions(+), 17 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 86d6439..b04cf5a 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -166,6 +166,7 @@
             if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) {
                 // 鏈�鍚庝竴涓鍒掞紝鍒嗛厤鍓╀綑鏂规暟
                 BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
+                plan.setStatus(1);
                 plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
                 productOrderPlan.setAssignedQuantity(lastRemainingVolume);
                 productionPlanMapper.updateById(plan);
@@ -174,6 +175,7 @@
             }
 
             // 鍒嗛厤褰撳墠璁″垝鏂规暟
+            plan.setStatus(1);
             plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume));
             productOrderPlan.setAssignedQuantity(remainingVolume);
             // 鏇存柊鐢熶骇璁″垝
@@ -196,6 +198,10 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean update(ProductionPlanDto productionPlanDto) {
+        // 宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫
+        if (productionPlanDto.getStatus() == 1) {
+            throw new BaseException("宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫");
+        }
         // 鏌ヨ鏄惁鏈夊叧鑱旇鍗�
         boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null);
         if (hasProductOrderPlan) {
@@ -212,6 +218,10 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean delete(List<Long> ids) {
+        // 濡傛灉瀛樺湪宸蹭笅鍙戠殑璁″垝锛屽垯涓嶈兘鍒犻櫎
+        if (productionPlanMapper.selectList(Wrappers.<ProductionPlan>lambdaQuery().in(ProductionPlan::getId, ids).eq(ProductionPlan::getStatus, 1)).stream().anyMatch(p -> p.getStatus() == 1)) {
+            throw new BaseException("鍒犻櫎澶辫触锛屽瓨鍦ㄥ凡涓嬪彂鐨勮鍒�");
+        }
         // 濡傛灉鏈夊叧鑱旇鍗曪紝鍒欎笉鑳藉垹闄�
         if (productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductionPlanId, ids)).stream().anyMatch(p -> p.getProductOrderId() != null)) {
             throw new BaseException("鍒犻櫎澶辫触锛屽瓨鍦ㄥ叧鑱旇鍗�");
@@ -389,7 +399,6 @@
                 plan.setCustomerName(formData.getString("textField_lbkozohg"));
 
                 String materialCode = row.getString("textField_l9xo62q5");
-                plan.setMaterialCode(materialCode);
                 // 鏍规嵁鐗╂枡缂栫爜鏌ヨ鐗╂枡淇℃伅琛紝鍏宠仈鐗╂枡ID
                 if (StringUtils.isNotEmpty(materialCode)) {
                     LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>();
@@ -397,15 +406,6 @@
                     ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper);
                     if (sku != null) {
                         plan.setProductMaterialSkuId(sku.getId());
-                        if (sku.getMaterialId() != null) {
-                            // 璁剧疆浜у搧鍚嶇О
-                            ProductMaterial material = productMaterialService.getById(sku.getMaterialId());
-                            if (material != null) {
-                                plan.setProductName(material.getMaterialName());
-                            }
-                        }
-                        // 璁剧疆瑙勬牸鍨嬪彿
-                        plan.setProductSpec(sku.getSpecification());
                     }
                 }
 
@@ -563,13 +563,6 @@
                 ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper);
                 if (sku != null) {
                     entity.setProductMaterialSkuId(sku.getId());
-                    if (sku.getMaterialId() != null) {
-                        ProductMaterial material = productMaterialService.getById(sku.getMaterialId());
-                        if (material != null) {
-                            entity.setProductName(material.getMaterialName());
-                        }
-                    }
-                    entity.setProductSpec(sku.getSpecification());
                 }
             }
 

--
Gitblit v1.9.3