From a10ad9f551382673bc6af5a1d6d92edd9fee3680 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 13 三月 2026 12:01:04 +0800
Subject: [PATCH] 主生产计划:增加部分下发状态

---
 src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java                    |    4 ++--
 src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java |   19 +++++++++++++------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java b/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
index fa7c613..e47eac5 100644
--- a/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
+++ b/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
@@ -106,8 +106,8 @@
     @Excel(name = "寮哄害")
     private String strength;
 
-    @ApiModelProperty("鐘舵�� 0鏈笅鍙� 1宸蹭笅鍙�")
-    @Excel(name = "鐘舵��", readConverterExp = "0=鏈笅鍙�,1=宸蹭笅鍙�")
+    @ApiModelProperty("鐘舵�� 0鏈笅鍙� 1閮ㄥ垎涓嬪彂 2宸蹭笅鍙�")
+    @Excel(name = "鐘舵��", readConverterExp = "0=鏈笅鍙�,1=閮ㄥ垎涓嬪彂,2=宸蹭笅鍙�")
     private Integer status;
 
     /**
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 b04cf5a..e9dd43f 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -120,13 +120,13 @@
 
         //  鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佸悕绉�
         String firstProductName = plans.get(0).getProductName();
-        if (plans.stream().anyMatch(p -> !p.getProductName().equals(firstProductName))) {
+        if (plans.stream().anyMatch(p -> p.getProductName() == null || !p.getProductName().equals(firstProductName))) {
             throw new BaseException("鍚堝苟澶辫触锛屽瓨鍦ㄤ笉鍚岀殑浜у搧鍚嶇О");
         }
 
         // 鏍¢獙鏄惁瀛樺湪涓嶅悓鐨勪骇鍝佽鏍�
         String firstProductSpec = plans.get(0).getSpecification();
-        if (plans.stream().anyMatch(p -> !p.getSpecification().equals(firstProductSpec))) {
+        if (plans.stream().anyMatch(p -> p.getSpecification() == null || !p.getSpecification().equals(firstProductSpec))) {
             throw new BaseException("鍚堝苟澶辫触锛屽瓨鍦ㄤ笉鍚岀殑浜у搧瑙勬牸");
         }
 
@@ -167,6 +167,9 @@
                 // 鏈�鍚庝竴涓鍒掞紝鍒嗛厤鍓╀綑鏂规暟
                 BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume);
                 plan.setStatus(1);
+                if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
+                    plan.setStatus(2);
+                }
                 plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume));
                 productOrderPlan.setAssignedQuantity(lastRemainingVolume);
                 productionPlanMapper.updateById(plan);
@@ -176,6 +179,9 @@
 
             // 鍒嗛厤褰撳墠璁″垝鏂规暟
             plan.setStatus(1);
+            if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) {
+                plan.setStatus(2);
+            }
             plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume));
             productOrderPlan.setAssignedQuantity(remainingVolume);
             // 鏇存柊鐢熶骇璁″垝
@@ -191,6 +197,7 @@
     @Transactional(rollbackFor = Exception.class)
     public boolean add(ProductionPlanDto productionPlanDto) {
         productionPlanDto.setDataSourceType(PRODUCTION_FORECAST.getCode());
+        productionPlanDto.setStatus(0);
         productionPlanMapper.insert(productionPlanDto);
         return true;
     }
@@ -199,8 +206,8 @@
     @Transactional(rollbackFor = Exception.class)
     public boolean update(ProductionPlanDto productionPlanDto) {
         // 宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫
-        if (productionPlanDto.getStatus() == 1) {
-            throw new BaseException("宸蹭笅鍙戠姸鎬侊紝涓嶈兘缂栬緫");
+        if (productionPlanDto.getStatus() != 0) {
+            throw new BaseException("宸蹭笅鍙戞垨閮ㄥ垎涓嬪彂鐘舵�侊紝涓嶈兘缂栬緫");
         }
         // 鏌ヨ鏄惁鏈夊叧鑱旇鍗�
         boolean hasProductOrderPlan = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().eq(ProductOrderPlan::getProductionPlanId, productionPlanDto.getId())).stream().anyMatch(p -> p.getProductOrderId() != null);
@@ -219,8 +226,8 @@
     @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 (productionPlanMapper.selectList(Wrappers.<ProductionPlan>lambdaQuery().in(ProductionPlan::getId, ids)).stream().anyMatch(p -> p.getStatus() == 1 || p.getStatus() == 2)) {
+            throw new BaseException("鍒犻櫎澶辫触锛屽瓨鍦ㄥ凡涓嬪彂鎴栭儴鍒嗕笅鍙戠殑璁″垝");
         }
         // 濡傛灉鏈夊叧鑱旇鍗曪紝鍒欎笉鑳藉垹闄�
         if (productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductionPlanId, ids)).stream().anyMatch(p -> p.getProductOrderId() != null)) {

--
Gitblit v1.9.3