From 5b73f899c41957496ee0e4257a8e8bd38fc51d37 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 24 九月 2026 14:50:10 +0800
Subject: [PATCH] 天津-智科电子 1.协同办公-协同审批:待审批节点,第三人账号不可进行修改 2.营销管理-销售台账:勾选单个导出会出现整个导出的情况,但只能显示父项、不能显示子项 3.营销管理-销售台账:点击下拉没有价格,点击详情有价格

---
 src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java |   81 ++++++++++++++++++++++++++++++++--------
 1 files changed, 65 insertions(+), 16 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 5da3984..89041e6 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
@@ -184,6 +184,10 @@
         if (approvalInstanceDto == null || approvalInstanceDto.getId() == null) {
             return false;
         }
+        ApprovalInstance existing = this.getById(approvalInstanceDto.getId());
+        if (existing == null) {
+            return false;
+        }
         // 鍒ゆ柇鏄惁鏈夋鍦ㄨ繘琛岀殑瀹℃壒浠诲姟锛屾湁鍒欎笉鍏佽淇敼
         long pendingTaskCount = approvalTaskService.count(
                 Wrappers.<ApprovalTask>lambdaQuery()
@@ -194,9 +198,47 @@
         if (pendingTaskCount > 0) {
             throw new ServiceException("璇ュ鎵瑰崟鏈夋鍦ㄨ繘琛岀殑瀹℃壒浠诲姟锛屼笉鍏佽淇敼");
         }
+
+        // 鏈�氳繃涓斿綋鍓嶆病鏈夊緟澶勭悊鑺傜偣锛岃鏄庢祦绋嬪凡缁堟锛堝凡椹冲洖锛夛紝
+        // 淇敼淇濆瓨鍗宠涓洪噸鏂版彁浜わ紝娴佺▼浠庣涓�绾ч噸鏂板紑濮�
+        boolean resubmit = !"APPROVED".equals(existing.getStatus())
+                && approveProcessConfigNodeUtils.getCurrentNode(existing.getId()) == null;
+        if (resubmit) {
+            // 杞垹闄ゆ棫鐨勮妭鐐逛笌浠诲姟锛堝鎵硅褰曚繚鐣欙紝鏃堕棿绾垮彔鍔狅級
+            LambdaUpdateWrapper<ApprovalInstanceNode> nodeUpdateWrapper = Wrappers.lambdaUpdate();
+            nodeUpdateWrapper.eq(ApprovalInstanceNode::getInstanceId, approvalInstanceDto.getId())
+                    .eq(ApprovalInstanceNode::getDeleted, 0)
+                    .set(ApprovalInstanceNode::getDeleted, (byte) 1);
+            approvalInstanceNodeService.update(nodeUpdateWrapper);
+
+            LambdaUpdateWrapper<ApprovalTask> taskUpdateWrapper = Wrappers.lambdaUpdate();
+            taskUpdateWrapper.eq(ApprovalTask::getInstanceId, approvalInstanceDto.getId())
+                    .eq(ApprovalTask::getDeleted, 0)
+                    .set(ApprovalTask::getDeleted, (byte) 1);
+            approvalTaskService.update(taskUpdateWrapper);
+
+            approvalInstanceDto.setStatus("PENDING");
+            approvalInstanceDto.setCurrentLevel(1);
+            approvalInstanceDto.setFinishTime(null);
+            approvalInstanceDto.setInstanceNo(existing.getInstanceNo());
+            approvalInstanceDto.setApplicantId(existing.getApplicantId());
+            approvalInstanceDto.setApplicantName(existing.getApplicantName());
+        }
+
         boolean updated = this.updateById(approvalInstanceDto);
         if (!updated) {
             return false;
+        }
+        if (resubmit) {
+            // updateById 蹇界暐 null锛宖inishTime 闇�鐢ㄦ樉寮� set 鎵嶈兘娓呯┖
+            this.update(
+                    Wrappers.<ApprovalInstance>lambdaUpdate()
+                            .eq(ApprovalInstance::getId, approvalInstanceDto.getId())
+                            .set(ApprovalInstance::getFinishTime, null)
+            );
+            // 閲嶅缓绗竴绾ц妭鐐逛笌瀹℃壒浠诲姟锛屽苟杩藉姞涓�鏉″彂璧峰鎵硅褰�
+            approveProcessConfigNodeUtils.createCurrentNodeAndTasks(approvalInstanceDto, true);
+            sendApproveNotice(approvalInstanceDto, approveProcessConfigNodeUtils.getCurrentPendingTasks(approvalInstanceDto.getId()));
         }
         fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVAL_INSTANCE, approvalInstanceDto.getId(), approvalInstanceDto.getStorageBlobDTOs());
         return true;
@@ -420,20 +462,8 @@
         instance.setStatus("REJECTED");
         instance.setFinishTime(now);
         this.updateById(instance);
-        // 椹冲洖瀵瑰簲鐨勪紒涓氭柊闂伙紝 宸梾鎶ラ攢
-        if (instance.getBusinessType().equals(TypeEnums.ENTERPRISE_NEWS_APPROVAL.getCode())) {
-            enterpriseNewsMapper.update(
-                    new LambdaUpdateWrapper<EnterpriseNews>()
-                            .eq(EnterpriseNews::getId, instance.getBusinessId())
-                            .set(EnterpriseNews::getStatus, "REJECTED")
-            );
-        }else if (instance.getBusinessType().equals(TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode())||instance.getBusinessType().equals(TypeEnums.EXPENSE_APPROVAL.getCode())) {
-            finReimbursementMapper.update(
-                    new LambdaUpdateWrapper<FinReimbursement>()
-                            .eq(FinReimbursement::getId, instance.getBusinessId())
-                            .set(FinReimbursement::getBillStatus, "REJECTED")
-            );
-        }
+        // 缁熶竴澶勭悊涓氬姟鐘舵�佹洿鏂�
+        handleBusinessAfterApprovalFinished(instance);
         return R.ok("瀹℃壒宸查┏鍥�");
     }
 
@@ -682,7 +712,7 @@
     private void handleShippingApprovalFinished(ApprovalInstance instance, String status) {
         ShippingInfo shippingInfo = shippingInfoMapper.selectOne(
                 new LambdaQueryWrapper<ShippingInfo>()
-                        .eq(ShippingInfo::getId, instance.getTitle())
+                        .eq(ShippingInfo::getShippingNo, instance.getTitle())
                         .orderByDesc(ShippingInfo::getCreateTime)
                         .last("limit 1")
         );
@@ -757,10 +787,29 @@
 
         String title = StringUtils.hasText(instance.getTemplateName()) ? instance.getTemplateName() : "瀹℃壒鎻愰啋";
         String message = "瀹℃壒鍗曞彿 " + instance.getInstanceNo() + " 闇�瑕佹偍瀹℃壒";
-        String jumpPath = "/officeProcessAutomation/ApproveManage/approve-list?id=" + instance.getId();
+        String jumpPath = getJumpPathByBusinessType(instance.getBusinessType(), instance.getId());
         sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath);
     }
 
+    private String getJumpPathByBusinessType(Long businessType, Long instanceId) {
+        if (businessType == null) {
+            return "/collaborativeApproval/approve-list?id=" + instanceId;
+        }
+        if (TypeEnums.LEAVE_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/AttendManage/leave-apply?id=" + instanceId;
+        }
+        if (TypeEnums.OVERTIME_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/AttendManage/overtime-apply?id=" + instanceId;
+        }
+        if (TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/ReimburseManage/travel-reimburse?id=" + instanceId;
+        }
+        if (TypeEnums.EXPENSE_APPROVAL.getCode().equals(businessType)) {
+            return "/collaborativeApproval/ReimburseManage/cost-reimburse?id=" + instanceId;
+        }
+        return "/collaborativeApproval/approve-list?id=" + instanceId;
+    }
+
     private void sendEnterpriseNewsNotice(Long newsId) {
         EnterpriseNews enterpriseNews = enterpriseNewsMapper.selectById(newsId);
         if (enterpriseNews == null) {

--
Gitblit v1.9.3