mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-30 07:06:39 +08:00
update 修改流程启动后重新覆盖流程变量,删除并行流程驳回,撤销后,垃圾数据
This commit is contained in:
parent
6347f11b52
commit
31c4a9fd06
@ -0,0 +1,32 @@
|
|||||||
|
package org.dromara.workflow.flowable.cmd;
|
||||||
|
|
||||||
|
import org.flowable.common.engine.impl.interceptor.Command;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
|
||||||
|
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除执行数据
|
||||||
|
*
|
||||||
|
* @author may
|
||||||
|
*/
|
||||||
|
public class DeleteExecutionCmd implements Command<String>, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行id
|
||||||
|
*/
|
||||||
|
private final String executionId;
|
||||||
|
|
||||||
|
public DeleteExecutionCmd(String executionId) {
|
||||||
|
this.executionId = executionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(CommandContext commandContext) {
|
||||||
|
ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
|
||||||
|
executionEntityManager.delete(executionId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package org.dromara.workflow.flowable.cmd;
|
||||||
|
|
||||||
|
import org.flowable.common.engine.impl.interceptor.Command;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||||
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
|
||||||
|
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取并行网关执行后保留的执行实例数据
|
||||||
|
*
|
||||||
|
* @author may
|
||||||
|
*/
|
||||||
|
public class ExecutionChildByExecutionIdCmd implements Command<List<ExecutionEntity>>, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前任务执行实例id
|
||||||
|
*/
|
||||||
|
private final String executionId;
|
||||||
|
|
||||||
|
public ExecutionChildByExecutionIdCmd(String executionId) {
|
||||||
|
this.executionId = executionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExecutionEntity> execute(CommandContext commandContext) {
|
||||||
|
ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
|
||||||
|
// 获取当前执行数据
|
||||||
|
ExecutionEntity executionEntity = executionEntityManager.findById(executionId);
|
||||||
|
// 通过当前执行数据的父执行,查询所有子执行数据
|
||||||
|
List<ExecutionEntity> allChildrenExecution =
|
||||||
|
executionEntityManager.collectChildren(executionEntity.getParent());
|
||||||
|
return allChildrenExecution.stream().filter(e -> !e.isActive()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -25,16 +25,16 @@ import org.dromara.workflow.domain.vo.GraphicInfoVo;
|
|||||||
import org.dromara.workflow.domain.vo.ProcessInstanceVo;
|
import org.dromara.workflow.domain.vo.ProcessInstanceVo;
|
||||||
import org.dromara.workflow.domain.vo.TaskVo;
|
import org.dromara.workflow.domain.vo.TaskVo;
|
||||||
import org.dromara.workflow.flowable.CustomDefaultProcessDiagramGenerator;
|
import org.dromara.workflow.flowable.CustomDefaultProcessDiagramGenerator;
|
||||||
|
import org.dromara.workflow.flowable.cmd.DeleteExecutionCmd;
|
||||||
|
import org.dromara.workflow.flowable.cmd.ExecutionChildByExecutionIdCmd;
|
||||||
import org.dromara.workflow.service.IActHiProcinstService;
|
import org.dromara.workflow.service.IActHiProcinstService;
|
||||||
import org.dromara.workflow.service.IActProcessInstanceService;
|
import org.dromara.workflow.service.IActProcessInstanceService;
|
||||||
import org.flowable.bpmn.model.*;
|
import org.flowable.bpmn.model.*;
|
||||||
import org.flowable.engine.HistoryService;
|
import org.flowable.engine.*;
|
||||||
import org.flowable.engine.RepositoryService;
|
|
||||||
import org.flowable.engine.RuntimeService;
|
|
||||||
import org.flowable.engine.TaskService;
|
|
||||||
import org.flowable.engine.history.HistoricActivityInstance;
|
import org.flowable.engine.history.HistoricActivityInstance;
|
||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||||
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
||||||
import org.flowable.engine.task.Comment;
|
import org.flowable.engine.task.Comment;
|
||||||
@ -66,6 +66,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
private final HistoryService historyService;
|
private final HistoryService historyService;
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
private final IActHiProcinstService iActHiProcinstService;
|
private final IActHiProcinstService iActHiProcinstService;
|
||||||
|
private final ManagementService managementService;
|
||||||
|
|
||||||
@Value("${flowable.activity-font-name}")
|
@Value("${flowable.activity-font-name}")
|
||||||
private String activityFontName;
|
private String activityFontName;
|
||||||
@ -471,6 +472,14 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
.moveActivityIdsToSingleActivityId(nodeIds, historicTaskInstance.getTaskDefinitionKey()).changeState();
|
.moveActivityIdsToSingleActivityId(nodeIds, historicTaskInstance.getTaskDefinitionKey()).changeState();
|
||||||
Task task = taskService.createTaskQuery().taskTenantId(TenantHelper.getTenantId()).processInstanceId(processInstanceId).list().get(0);
|
Task task = taskService.createTaskQuery().taskTenantId(TenantHelper.getTenantId()).processInstanceId(processInstanceId).list().get(0);
|
||||||
taskService.setAssignee(task.getId(), historicTaskInstance.getAssignee());
|
taskService.setAssignee(task.getId(), historicTaskInstance.getAssignee());
|
||||||
|
//获取并行网关执行后保留的执行实例数据
|
||||||
|
ExecutionChildByExecutionIdCmd childByExecutionIdCmd = new ExecutionChildByExecutionIdCmd(task.getExecutionId());
|
||||||
|
List<ExecutionEntity> executionEntities = managementService.executeCommand(childByExecutionIdCmd);
|
||||||
|
//删除流程实例垃圾数据
|
||||||
|
for (ExecutionEntity executionEntity : executionEntities) {
|
||||||
|
DeleteExecutionCmd deleteExecutionCmd = new DeleteExecutionCmd(executionEntity.getId());
|
||||||
|
managementService.executeCommand(deleteExecutionCmd);
|
||||||
|
}
|
||||||
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -19,9 +19,7 @@ import org.dromara.workflow.common.enums.TaskStatusEnum;
|
|||||||
import org.dromara.workflow.domain.bo.*;
|
import org.dromara.workflow.domain.bo.*;
|
||||||
import org.dromara.workflow.domain.vo.MultiInstanceVo;
|
import org.dromara.workflow.domain.vo.MultiInstanceVo;
|
||||||
import org.dromara.workflow.domain.vo.TaskVo;
|
import org.dromara.workflow.domain.vo.TaskVo;
|
||||||
import org.dromara.workflow.flowable.cmd.AddSequenceMultiInstanceCmd;
|
import org.dromara.workflow.flowable.cmd.*;
|
||||||
import org.dromara.workflow.flowable.cmd.DeleteSequenceMultiInstanceCmd;
|
|
||||||
import org.dromara.workflow.flowable.cmd.UpdateBusinessStatusCmd;
|
|
||||||
import org.dromara.workflow.service.IActTaskService;
|
import org.dromara.workflow.service.IActTaskService;
|
||||||
import org.dromara.workflow.utils.WorkflowUtils;
|
import org.dromara.workflow.utils.WorkflowUtils;
|
||||||
import org.flowable.common.engine.impl.identity.Authentication;
|
import org.flowable.common.engine.impl.identity.Authentication;
|
||||||
@ -29,6 +27,7 @@ import org.flowable.engine.*;
|
|||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
||||||
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.task.api.Task;
|
import org.flowable.task.api.Task;
|
||||||
import org.flowable.task.api.TaskQuery;
|
import org.flowable.task.api.TaskQuery;
|
||||||
@ -80,6 +79,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||||
List<Task> taskResult = taskQuery.processInstanceBusinessKey(startProcessBo.getBusinessKey()).taskTenantId(TenantHelper.getTenantId()).list();
|
List<Task> taskResult = taskQuery.processInstanceBusinessKey(startProcessBo.getBusinessKey()).taskTenantId(TenantHelper.getTenantId()).list();
|
||||||
if (CollUtil.isNotEmpty(taskResult)) {
|
if (CollUtil.isNotEmpty(taskResult)) {
|
||||||
|
if (CollUtil.isNotEmpty(startProcessBo.getVariables())) {
|
||||||
|
taskService.setVariables(taskResult.get(0).getId(), startProcessBo.getVariables());
|
||||||
|
}
|
||||||
map.put("processInstanceId", taskResult.get(0).getProcessInstanceId());
|
map.put("processInstanceId", taskResult.get(0).getProcessInstanceId());
|
||||||
map.put("taskId", taskResult.get(0).getId());
|
map.put("taskId", taskResult.get(0).getId());
|
||||||
return map;
|
return map;
|
||||||
@ -550,6 +552,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
try {
|
try {
|
||||||
String processInstanceId = task.getProcessInstanceId();
|
String processInstanceId = task.getProcessInstanceId();
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
|
||||||
|
//获取并行网关执行后保留的执行实例数据
|
||||||
|
ExecutionChildByExecutionIdCmd childByExecutionIdCmd = new ExecutionChildByExecutionIdCmd(task.getExecutionId());
|
||||||
|
List<ExecutionEntity> executionEntities = managementService.executeCommand(childByExecutionIdCmd);
|
||||||
//校验单据
|
//校验单据
|
||||||
BusinessStatusEnum.checkStatus(processInstance.getBusinessStatus());
|
BusinessStatusEnum.checkStatus(processInstance.getBusinessStatus());
|
||||||
//判断是否有多个任务
|
//判断是否有多个任务
|
||||||
@ -573,6 +578,11 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|||||||
for (Task t : list) {
|
for (Task t : list) {
|
||||||
taskService.setAssignee(t.getId(), historicTaskInstance.getAssignee());
|
taskService.setAssignee(t.getId(), historicTaskInstance.getAssignee());
|
||||||
}
|
}
|
||||||
|
//删除流程实例垃圾数据
|
||||||
|
for (ExecutionEntity executionEntity : executionEntities) {
|
||||||
|
DeleteExecutionCmd deleteExecutionCmd = new DeleteExecutionCmd(executionEntity.getId());
|
||||||
|
managementService.executeCommand(deleteExecutionCmd);
|
||||||
|
}
|
||||||
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user