Activit 流程撤回功能

/**

     * 流程撤回功能

     * @param taskId 要撤回的任务id,可为空,为空的情况下根据流程实例去获取当前的任务

     * @param processInstanceId 流程实例id

     */

    public void revoke(String taskId,String processInstanceId) throws Exception{

        List<Task> tasks = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstanceId).list();

        if (StringUtil.isEmpty(taskId) && tasks != null && tasks.size() > 0) {

            taskId = tasks.get(0).getId();

        }

        // 取得当前任务

        HistoricTaskInstance currTask = processEngine.getHistoryService()

                .createHistoricTaskInstanceQuery().taskId(taskId)

                .singleResult();

        //根据流程id查询代办任务中流程信息

        Execution execution = processEngine.getRuntimeService().createExecutionQuery().executionId(currTask.getExecutionId()).singleResult();

        String activityId = execution.getActivityId();

        //取回流程接点 当前任务id 取回任务id

        callBackProcess(currTask.getId(),activityId);

        //删除历史流程走向记录

        processEngine.getHistoryService().deleteHistoricTaskInstance(currTask.getId());

        processEngine.getHistoryService().deleteHistoricTaskInstance(currTask.getId());

    }

     /** 

     * 取回流程 

     * @param taskId  当前任务ID 

     * @param activityId   取回节点ID 

     * @throws Exception 

     */   

    public void callBackProcess(String taskId, String activityId)   

            throws Exception {   

        if (StringUtil.isEmpty(activityId)) {   

            throw new Exception("目标节点ID为空!");   

        }   

        //注意这里,要对所有的通过人数,不通过人数置空,否则下次审批会有问题

        Map<String, Object> variables = new HashMap<String, Object>();                

        HistoricTaskInstance currTask = processEngine.getHistoryService()

                 .createHistoricTaskInstanceQuery().taskId(taskId)

                 .singleResult();

 

        Map<String, Object> map = processEngine.getRuntimeService().getVariables(currTask.getExecutionId());

         for (Map.Entry<String, Object> entry : map.entrySet()) {

         if (entry.getKey().contains("passCount") ||

             entry.getKey().contains("noPassCount") ||

             entry.getKey().contains("totalCount")) {

             variables.put(entry.getKey(), null);

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值