项目地址:https://gitee.com/lwj/flowable.git 分支flowable-base
视频讲解地址
https://space.bilibili.com/485524575/channel/detail?cid=94579
1、演示
2、代码分享
public ReturnVo<String> stopProcessInstanceById(EndVo endVo) {
ReturnVo<String> returnVo = null;
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(endVo.getProcessInstanceId()).singleResult();
if (processInstance != null) {
//1、添加审批记录
this.addComment(endVo.getUserCode(), endVo.getProcessInstanceId(), CommentTypeEnum.LCZZ.toString(),
endVo.getMessage());
List<EndEvent> endNodes = flowableBpmnModelService.findEndFlowElement(processInstance.getProcessDefinitionId());
String endId = endNodes.get(0).getId();
String processInstanceId = endVo.getProcessInstanceId();
//2、执行终止
List<Execution> executions = runtimeService.createExecutionQuery().parentId(processInstanceId).list();
List<String> executionIds = new ArrayList<>();
executions.forEach(execution -> executionIds.add(execution.getId()));
this.moveExecutionsToSingleActivityId(executionIds, endId);
returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "终止成功");
}else {
returnVo = new ReturnVo<>(ReturnCode.FAIL, "不存在运行的流程实例,请确认!");
}
return returnVo;
}