6.4.0 added the rejection method, which is really a good news for Chinese process. Thank the founder of flowable.
Don't worry about the rejection process anymore. Those videos and source code changes on the Internet are really demo level and can't be used commercially.
Only the study of heart like water is the eternal generator. Don't imagine that others can give you the system well.
Any node can jump
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(processInstanceId)
.moveActivityIdsToSingleActivityId("Node of current task id", "Target node to jump to")
.changeState();
Of course, there are many methods. You can go to the ChangeActivityStateBuilder class here.
1. Go to the code directly. It's always dry goods. It's not hidden. Ha ha.
public ReturnVo<String> backToStep(BackVo backVo) throws Exception { ReturnVo<String> returnVo = new ReturnVo<>(FlowConstant.SUCCESS, "OK"); Task task = taskService.createTaskQuery().taskId(backVo.getTaskId()).singleResult(); String processInstanceId = task.getProcessInstanceId(); FlowElement distActivity = processDefinitionUtils.findFlowElementById(task.getProcessDefinitionId(), backVo.getDistFlowElementId()); //1. Save task information task.setAssignee(backVo.getUserCode()); taskService.saveTask(task); //2. If the previous node is the submitter, you need to deal with it if (FlowConstant.FLOW_SUBMITTER.equals(distActivity.getName())) { //The search initiator is set to a variable so that it can stay in the submitter node when it returns to the submitter ExtendProcinst extendProcinst = this.extendProcinstService.findExtendProcinstByProcessInstanceId(processInstanceId); String creator = null; if (extendProcinst != null) { creator = extendProcinst.getCreator(); if (StringUtils.isBlank(creator)) { creator = extendProcinst.getCurrentUserCode(); } } else { ExtendHisprocinst extendHisprocinst = extendHisprocinstService.getExtendHisprocinstByProcessInstanceId(processInstanceId); creator = extendHisprocinst.getCreator(); if (StringUtils.isBlank(creator)) { creator = extendHisprocinst.getCurrentUserCode(); } } if (StringUtils.isNotBlank(creator)) { runtimeService.setVariable(processInstanceId, FlowConstant.FLOW_SUBMITTER_VAR, creator); } } List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstanceId).list(); List<String> currentActivityIds = new ArrayList<>(); tasks.forEach(t -> currentActivityIds.add(t.getTaskDefinitionKey())); //3. Delete node information if (!(distActivity instanceof EndEvent)) { this.deleteHisActivities((Activity) distActivity, processInstanceId); } //4. Add approval comments and modify process status this.addCommentAndUpdateProcessStatus(backVo, processInstanceId); //5.Execute reject operation runtimeService.createChangeActivityStateBuilder() .processInstanceId(processInstanceId) .moveActivityIdsToSingleActivityId(currentActivityIds, backVo.getDistFlowElementId()) .changeState(); return returnVo; }
2. After testing, there are no problems in multi instance nodes, parallel gateways and judging gateways. Even a node jump of subprocesses has corresponding methods
How to use it can be seen from the official test cases