From e44ef607883e18222fa4df1959325f95542544e0 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 26 五月 2026 16:03:14 +0800
Subject: [PATCH] 审批更新 添加采购,报价,发货的审批提交,审批审核通过之后的处理

---
 src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java b/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
index 251ff05..6bb732e 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
@@ -25,6 +25,7 @@
 import com.ruoyi.collaborativeApproval.pojo.EnterpriseNewsScopeDept;
 import com.ruoyi.collaborativeApproval.pojo.EnterpriseNewsScopeUser;
 import com.ruoyi.common.enums.*;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.OrderUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.framework.security.LoginUser;
@@ -158,6 +159,16 @@
     public Boolean update(ApprovalInstanceDto approvalInstanceDto) {
         if (approvalInstanceDto == null || approvalInstanceDto.getId() == null) {
             return false;
+        }
+        // 鍒ゆ柇鏄惁鏈夋鍦ㄨ繘琛岀殑瀹℃壒浠诲姟锛屾湁鍒欎笉鍏佽淇敼
+        long pendingTaskCount = approvalTaskService.count(
+                Wrappers.<ApprovalTask>lambdaQuery()
+                        .eq(ApprovalTask::getInstanceId, approvalInstanceDto.getId())
+                        .eq(ApprovalTask::getTaskStatus, "PENDING")
+                        .eq(ApprovalTask::getDeleted, 0)
+        );
+        if (pendingTaskCount > 0) {
+            throw new ServiceException("璇ュ鎵瑰崟鏈夋鍦ㄨ繘琛岀殑瀹℃壒浠诲姟锛屼笉鍏佽淇敼");
         }
         boolean updated = this.updateById(approvalInstanceDto);
         if (!updated) {
@@ -496,7 +507,7 @@
     private void handlePurchaseApprovalFinished(ApprovalInstance instance, String status) {
         PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(
                 new LambdaQueryWrapper<PurchaseLedger>()
-                        .eq(PurchaseLedger::getPurchaseContractNumber, instance.getTitle())
+                        .eq(PurchaseLedger::getId, instance.getBusinessId())
                         .last("limit 1")
         );
         if (purchaseLedger == null) {
@@ -534,7 +545,7 @@
     private void handleSalesQuotationApprovalFinished(ApprovalInstance instance, String status) {
         SalesQuotation salesQuote = salesQuotationMapper.selectOne(
                 new LambdaQueryWrapper<SalesQuotation>()
-                        .eq(SalesQuotation::getQuotationNo, instance.getTitle())
+                        .eq(SalesQuotation::getId, instance.getBusinessId())
                         .last("limit 1")
         );
         if (salesQuote == null) {
@@ -554,7 +565,7 @@
     private void handleShippingApprovalFinished(ApprovalInstance instance, String status) {
         ShippingInfo shippingInfo = shippingInfoMapper.selectOne(
                 new LambdaQueryWrapper<ShippingInfo>()
-                        .eq(ShippingInfo::getShippingNo, instance.getTitle())
+                        .eq(ShippingInfo::getId, instance.getTitle())
                         .orderByDesc(ShippingInfo::getCreateTime)
                         .last("limit 1")
         );

--
Gitblit v1.9.3