flowable流程实例删除

	import org.flowable.engine.RuntimeService;
	import org.flowable.engine.HistoryService;
	
    @Autowired
    private RuntimeService runtimeService;
    
    @Autowired
    private HistoryService historyService;
    
    @Transactional
    @Override
    public Object deleteProcessInstanceById(String processInstanceId) {
    
    
        if (StringUtils.isBlank(processInstanceId)) {
    
    
            return failure("流程实例id不能为空,请检查!!!");
        }
        try {
    
    
            //根据流程实例id 去ACT_RU_EXECUTION与ACT_RE_PROCDEF关联查询流程实例数据
            ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            if (null != processInstance) {
    
    
                runtimeService.deleteProcessInstance(processInstanceId, "流程实例删除");
            } else {
    
    
                historyService.deleteHistoricProcessInstance(processInstanceId);
            }
            return success(CommonConstants.DELETE_SUCCESS_MSG);
        } catch (Exception e) {
    
    
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failure(CommonConstants.DELETE_FAILURE_MSG + ":失败原因为" + e.getMessage());
        }

    }

猜你喜欢

转载自blog.csdn.net/qq_36213455/article/details/114824478