From 6704ac5c511854cae6138edce435eaa1e352132c Mon Sep 17 00:00:00 2001 From: tony <846249920@qq.com> Date: Mon, 26 Dec 2022 15:10:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=96=E6=B6=88=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/service/IFlowTaskService.java | 1 + .../service/impl/FlowTaskServiceImpl.java | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java index 8f8c1ba5..87817efa 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java @@ -89,6 +89,7 @@ public interface IFlowTaskService { /** * 取消申请 + * 目前实现方式: 直接将当前流程变更为已完成 * @param flowTaskVo * @return */ diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java index ac5db254..e69f11ff 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java @@ -44,6 +44,7 @@ import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstanceQuery; import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ActivityInstance; import org.flowable.engine.runtime.Execution; import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.task.Comment; @@ -54,6 +55,7 @@ import org.flowable.task.api.Task; import org.flowable.task.api.TaskQuery; import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstanceQuery; +import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -515,7 +517,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask /** * 取消申请 - * + * 目前实现方式: 直接将当前流程变更为已完成 * @param flowTaskVo * @return */ @@ -525,9 +527,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask if (CollectionUtils.isEmpty(task)) { throw new CustomException("流程未启动或已执行完成,取消申请失败"); } - // 获取当前需撤回的流程实例 - ProcessInstance processInstance = - runtimeService.createProcessInstanceQuery() + // 获取当前流程实例 + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() .processInstanceId(flowTaskVo.getInstanceId()) .singleResult(); BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); @@ -535,14 +536,16 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask Process process = bpmnModel.getMainProcess(); List endNodes = process.findFlowElementsOfType(EndEvent.class, false); if (CollectionUtils.isNotEmpty(endNodes)) { - SysUser loginUser = SecurityUtils.getLoginUser().getUser(); - Authentication.setAuthenticatedUserId(loginUser.getUserId().toString()); + // TODO 取消流程为什么要设置流程发起人? +// SysUser loginUser = SecurityUtils.getLoginUser().getUser(); +// Authentication.setAuthenticatedUserId(loginUser.getUserId().toString()); + // taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(), // StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment()); // 获取当前流程最后一个节点 String endId = endNodes.get(0).getId(); - List executions = - runtimeService.createExecutionQuery().parentId(processInstance.getProcessInstanceId()).list(); + List executions = runtimeService.createExecutionQuery() + .parentId(processInstance.getProcessInstanceId()).list(); List executionIds = new ArrayList<>(); executions.forEach(execution -> executionIds.add(execution.getId())); // 变更流程为已结束状态