工作流实战_10_flowable 流程实例的删除
生活随笔
收集整理的這篇文章主要介紹了
工作流实战_10_flowable 流程实例的删除
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
| 代碼分支 | flowable-base |
| 視頻講解地址 | https://space.bilibili.com/485524575/channel/detail?cid=94579 |
| 0000001 | test |
| 0000002 | test |
| 0000003 | test |
| 0000004 | test |
文章目錄
- 1. 演示
- 2. 代碼
- 2.1. 刪除實(shí)例命令
- 2.2. 執(zhí)行刪除動作
1. 演示
2. 代碼
2.1. 刪除實(shí)例命令
public class DeleteFlowableProcessInstanceCmd implements Command<Void>, Serializable {private static final long serialVersionUID = 1L;protected String processInstanceId;protected String deleteReason;protected boolean cascade = false;public DeleteFlowableProcessInstanceCmd(String processInstanceId, String deleteReason) {this.processInstanceId = processInstanceId;this.deleteReason = deleteReason;}public DeleteFlowableProcessInstanceCmd(String processInstanceId, String deleteReason,boolean cascade) {this.processInstanceId = processInstanceId;this.deleteReason = deleteReason;this.cascade = cascade;}@Overridepublic Void execute(CommandContext commandContext) {if (processInstanceId == null) {throw new FlowableIllegalArgumentException("processInstanceId is null");}ExecutionEntity processInstanceEntity = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);if (processInstanceEntity == null) {throw new FlowableObjectNotFoundException("No process instance found for id '" + processInstanceId + "'", ProcessInstance.class);}if (processInstanceEntity.isDeleted()) {return null;}if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processInstanceEntity.getProcessDefinitionId())) {Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();compatibilityHandler.deleteProcessInstance(processInstanceId, deleteReason);} else {CommandContextUtil.getExecutionEntityManager(commandContext).deleteProcessInstance(processInstanceEntity.getProcessInstanceId(), deleteReason, cascade);}return null;}}2.2. 執(zhí)行刪除動作
public ReturnVo<String> deleteProcessInstanceById(String processInstanceId) {ReturnVo<String> returnVo = null;long count = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).count();if (count > 0) {DeleteFlowableProcessInstanceCmd cmd = new DeleteFlowableProcessInstanceCmd(processInstanceId, "刪除流程實(shí)例", true);managementService.executeCommand(cmd);returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "刪除成功");} else {historyService.deleteHistoricProcessInstance(processInstanceId);returnVo = new ReturnVo<>(ReturnCode.SUCCESS, "刪除成功");}return returnVo;}總結(jié)
以上是生活随笔為你收集整理的工作流实战_10_flowable 流程实例的删除的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jdk 安装 linux环境
- 下一篇: Oracle查询所有序列