From 22e8a676ee42c0d78b3526bcd9a635abbe8dca03 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 28 六月 2022 11:28:21 +0800
Subject: [PATCH] 优化databus bug

---
 service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java b/service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java
old mode 100644
new mode 100755
index 4a3d6d9..477482e
--- a/service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java
+++ b/service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java
@@ -12,6 +12,7 @@
 import com.java110.dto.user.UserDto;
 import com.java110.dto.workflow.WorkflowDto;
 import com.java110.entity.audit.AuditUser;
+import com.java110.utils.cache.MappingCache;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.StringUtil;
 import org.activiti.engine.HistoryService;
@@ -27,6 +28,8 @@
 import org.activiti.engine.task.Comment;
 import org.activiti.engine.task.Task;
 import org.activiti.engine.task.TaskQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -40,6 +43,9 @@
 @RestController
 public class ComplaintUserInnerServiceSMOImpl extends BaseServiceSMO implements IComplaintUserInnerServiceSMO {
 
+
+    private final static Logger logger = LoggerFactory.getLogger(ComplaintUserInnerServiceSMOImpl.class);
+
     @Autowired
     private ProcessEngine processEngine;
 
@@ -48,6 +54,9 @@
 
     @Autowired
     private TaskService taskService;
+
+    @Autowired
+    private HistoryService historyService;
 
     @Autowired
     private IComplaintInnerServiceSMO complaintInnerServiceSMOImpl;
@@ -89,11 +98,11 @@
         workflowDto.setCommunityId(communityId);
         List<WorkflowDto> workflowDtos = workflowInnerServiceSMOImpl.queryWorkflows(workflowDto);
 
-        Assert.listOnlyOne(workflowDtos, "鏈壘鍒� 鎶曡瘔寤鸿娴佺▼鎴栨壘鍒板鏉�");
+        Assert.listOnlyOne(workflowDtos, "鏈壘鍒� 鎶曡瘔寤鸿娴佺▼鎴栨壘鍒板鏉★紝璇峰湪鐗╀笟璐﹀彿绯荤粺绠$悊涓嬫祦绋嬬鐞嗕腑閰嶇疆娴佺▼");
 
         WorkflowDto tmpWorkflowDto = workflowDtos.get(0);
         if (StringUtil.isEmpty(tmpWorkflowDto.getProcessDefinitionKey())) {
-            throw new IllegalArgumentException("娴佺▼杩樻湭閮ㄧ讲");
+            throw new IllegalArgumentException("鎶曡瘔寤鸿娴佺▼杩樻湭閮ㄧ讲");
         }
         return WorkflowDto.DEFAULT_PROCESS + tmpWorkflowDto.getFlowId();
     }
@@ -194,7 +203,8 @@
 
         HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                 .processDefinitionKey(getWorkflowDto(user.getCommunityId()))
-                .taskAssignee(user.getUserId());
+                .taskAssignee(user.getUserId())
+                .finished();
         if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
             historicTaskInstanceQuery.taskName("complaint");
         } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
@@ -202,6 +212,7 @@
         }
 
         Query query = historicTaskInstanceQuery;
+
         return query.count();
     }
 
@@ -215,7 +226,8 @@
 
         HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                 .processDefinitionKey(getWorkflowDto(user.getCommunityId()))
-                .taskAssignee(user.getUserId());
+                .taskAssignee(user.getUserId())
+                .finished();
         if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
             historicTaskInstanceQuery.taskName("complaint");
         } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
@@ -296,6 +308,26 @@
     }
 
     /**
+     * 鍒犻櫎鎸囧畾浠诲姟
+     */
+    public boolean deleteTask(@RequestBody ComplaintDto complaintDto){
+        String taskId = complaintDto.getTaskId();
+        Task task = taskService.createTaskQuery().taskId(complaintDto.getTaskId()).singleResult();
+        String processInstanceId = task.getProcessInstanceId();
+        ProcessInstance pi = runtimeService.createProcessInstanceQuery()
+                .processInstanceId(processInstanceId)
+                .singleResult();
+        logger.info("鍒犻櫎id涓猴細{}锛屾姇璇夊缓璁换鍔�");
+        if (null != pi) {
+            //璇ユ祦绋嬪疄渚嬫湭缁撴潫鐨�
+            runtimeService.deleteProcessInstance(processInstanceId, "鍒犻櫎浠诲姟");
+        }
+        historyService.deleteHistoricProcessInstance(processInstanceId);
+        return true;
+    }
+
+
+    /**
      * 鑾峰彇浠诲姟褰撳墠澶勭悊浜�
      *
      * @param complaintDto

--
Gitblit v1.8.0