activiti节点撤回

activiti节点撤回

最近项目的需求是对已审批的节点进行撤回操作,核心的思路是:

  1. 校验任务和流程信息
  2. 处理已经完成审批的节点信息,做删除操作
  3. 处理下一节点未审批信息,做删除操作
public Boolean processWithdraw(ProcessWithdrawParam processWithdrawParam) {

        String taskId = processWithdrawParam.getTaskId();
        String userId = processWithdrawParam.getUserId();

        HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).taskAssignee(userId).singleResult();
        if (null == task) {
            throw new ApplicationException("撤回失败,失败原因:未查到任务信息或者你没有权限撤回该任务");
        }

        //获取流程模型
        BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
        if (null == bpmnModel) {
            throw new ApplicationException("撤回失败,失败原因:未查到流程信息!");
        }

        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        if (null == processInstance) {
            throw new ApplicationException("撤回失败,失败原因:流程已经结束,或者最后节点已经审批过,不支持撤回!");
        }

        if (processInstance.isSuspended()) {
            throw new ApplicationException("撤回失败,失败原因:流程已经被禁用,不支持撤回!");
        }

        UserTask currentUserTask = (UserTask)bpmnModel.getFlowElement(task.getTaskDefinitionKey());

        if(currentUserTask == null){
            throw new ApplicationException("撤回失败,失败原因:当前节点不存在,不支持撤回!");
        }

        List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstan
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值