# demo32 **Repository Path**: FlowableDemo/demo32 ## Basic Information - **Project Name**: demo32 - **Description**: 用户任务节点之间任务跳转 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-01-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ------ 环境: [jkd8+]() [mysql5.6+]() ## 一、自定义命令类 - CustomJumpCmd ```java public Void execute(CommandContext commandContext) { TaskEntityManager taskEntityManager = org.flowable.task.service.impl.util.CommandContextUtil .getTaskEntityManager(commandContext); ExecutionEntityManager executionEntityManager = org.flowable.engine.impl.util.CommandContextUtil .getExecutionEntityManager(commandContext); // 查询任务 TaskEntity taskEntity = taskEntityManager.findById(taskId); String executionId = taskEntity.getExecutionId(); String processDefinitionId = taskEntity.getProcessDefinitionId(); // 查询执行实例 ExecutionEntity executionEntity = executionEntityManager.findById(executionId); // 查询流程 org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); // 获取目标节点 FlowElement currentFlowElement = process.getFlowElement(targetNode); // 指定当前节点为目标节点 executionEntity.setCurrentFlowElement(currentFlowElement); // 让流程实例运转 FlowableEngineAgenda flowableEngineAgenda = org.flowable.engine.impl.util.CommandContextUtil.getAgenda(); flowableEngineAgenda.planContinueProcessInCompensation(executionEntity); // 删除跳转前的任务节点 taskEntityManager.delete(taskId); //更新历史任务中endtime HistoryManager historyManager = org.flowable.engine.impl.util.CommandContextUtil.getHistoryManager(); historyManager.recordTaskEnd(taskEntity, executionEntity, "delete resaon"); return null; } ``` ## 二、实践测试 - 运行demo - 查看数据库表 ``` ACT_RU_EXECUTION:ACT_ID_(活动节点id,对应xml中节点)为当前活动任务 ACT_RU_TASK:TASK_DEF_KEY_(活动节点id,对应xml中节点)为当前活动任务 ```