From ff361539e3ffd6e62100e392ddda2f4ab9dfee62 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期三, 27 五月 2026 13:15:42 +0800
Subject: [PATCH] 工序调整, 报工反改订单数量,判断是最后一道工序才修改订单完成数量

---
 src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java |   27 ++++++++-----
 src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java        |   38 +++++++++---------
 2 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
index 71bf805..60b3dc2 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
@@ -84,18 +84,18 @@
             throw new ServiceException("鏂板澶辫触,璁″垝宸ユ椂涓嶈兘涓虹┖");
         }
         // 鍒ゆ柇浜у搧鏄惁瀛樺湪
-        if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) {
-            throw new ServiceException("鏂板澶辫触,閮ㄤ欢涓嶈兘涓虹┖");
-        }
-        ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId());
-        if (productModel == null) {
-            throw new ServiceException("鏂板澶辫触,璇ラ儴浠朵笉瀛樺湪");
-        }
-        validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null);
+//        if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) {
+//            throw new ServiceException("鏂板澶辫触,閮ㄤ欢涓嶈兘涓虹┖");
+//        }
+//        ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId());
+//        if (productModel == null) {
+//            throw new ServiceException("鏂板澶辫触,璇ラ儴浠朵笉瀛樺湪");
+//        }
+//        validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null);
 
         ProductProcess productProcess = new ProductProcess();
         BeanUtils.copyProperties(productProcessDto, productProcess);
-        productProcess.setProductModelId(productModel.getId());
+//        productProcess.setProductModelId(productModel.getId());
 
         validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null);
 
@@ -129,17 +129,17 @@
         if (oldProductProcess == null) {
             throw new ServiceException("淇敼澶辫触锛屽伐搴忎笉瀛樺湪");
         }
-        Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId())
-                ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId();
-        Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType())
-                ? productProcessDto.getType() : oldProductProcess.getType();
-
+//        Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId())
+//                ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId();
+//        Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType())
+//                ? productProcessDto.getType() : oldProductProcess.getType();
+//
         // 鍒ゆ柇鍏宠仈浜у搧鏄惁瀛樺湪
-        ProductModel productModel = productModelService.getById(finalProductModelId);
-        if (productModel == null) {
-            throw new ServiceException("淇敼澶辫触锛屽叧鑱旈儴浠朵笉瀛樺湪");
-        }
-        validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId());
+//        ProductModel productModel = productModelService.getById(finalProductModelId);
+//        if (productModel == null) {
+//            throw new ServiceException("淇敼澶辫触锛屽叧鑱旈儴浠朵笉瀛樺湪");
+//        }
+//        validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId());
 
         // 鏍¢獙璁″垝浜哄憳
         validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null);
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index 08a24aa..c2d2292 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -19,11 +19,7 @@
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.procurementrecord.utils.StockUtils;
-import com.ruoyi.production.dto.ProductionProductMainDetailExportDto;
-import com.ruoyi.production.dto.ProductionProductMainDto;
-import com.ruoyi.production.dto.ProductionProductMainSummaryExportDto;
-import com.ruoyi.production.dto.ProductionReportDailySummaryDto;
-import com.ruoyi.production.dto.ProductionReportStateDto;
+import com.ruoyi.production.dto.*;
 import com.ruoyi.production.mapper.ProductionProductReportDailyMapper;
 import com.ruoyi.production.pojo.ProductionProductReportDaily;
 import com.ruoyi.production.mapper.*;
@@ -351,6 +347,7 @@
         LocalDateTime endTime = LocalDateTime.now();
         long durationSeconds = Duration.between(productionProductMain.getReportStartTime(), endTime).getSeconds();
         BigDecimal durationMinutes = secondsToMinutesExact(durationSeconds);
+
         int finishRows = productionProductMainMapper.update(
                 null,
                 Wrappers.<ProductionProductMain>lambdaUpdate()
@@ -437,18 +434,26 @@
             }
 
             // 鏃犲伐鑹鸿矾绾垮満鏅細鎶ュ伐鍗宠鍏ョ敓浜ц鍗曞畬鎴愭暟閲�
+//            int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty);
+//            if (poRows <= 0) {
+//                ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
+//                throw new ServiceException("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬璁㈠崟鍓╀綑鏁伴噺锛屽墿浣欐暟閲�: "
+//                        + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity())));
+//            }
+            List<ProductProcessRouteItemDto> productProcessRouteItemDtos = productProcessRouteItemMapper.listItem(productOrder.getId());
+            ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
+            if (productProcessRouteItemDtos.get(productProcessRouteItemDtos.size() - 1).getId().equals(dto.getProductProcessRouteItemId())) {
             int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty);
             if (poRows <= 0) {
-                ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
                 throw new ServiceException("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬璁㈠崟鍓╀綑鏁伴噺锛屽墿浣欐暟閲�: "
                         + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity())));
             }
-            ProductOrder latestOrder = productOrderMapper.selectById(productOrder.getId());
+            }
             if (needQuality
-                    && latestOrder != null
-                    && latestOrder.getCompleteQuantity() != null
-                    && latestOrder.getQuantity() != null
-                    && latestOrder.getCompleteQuantity().compareTo(latestOrder.getQuantity()) >= 0) {
+                    && currentOrder != null
+                    && currentOrder.getCompleteQuantity() != null
+                    && currentOrder.getQuantity() != null
+                    && currentOrder.getCompleteQuantity().compareTo(currentOrder.getQuantity()) >= 0) {
                 // 璁㈠崟瀹屾垚鏃舵柊澧炲嚭鍘傛
                 createQualityInspect(productionProductMain.getId(), outputProductModelId, productQty, 2, null);
             }

--
Gitblit v1.9.3