activiti流程节点驳回处理方式

String userId = SecurityUtils.getUsername();
        //通过传过来的任务id去查找流程实例id
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        //流程实例id
        String processid = task.getProcessInstanceId();
        //通过流程实例id获取业务id,BUSINESS_KEY
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processid).singleResult();
//           对businessKey做处理,拿到业务id
        String businessKey = processInstance.getBusinessKey();
        String deptNo = auditService.queryDeptNoByProcessInstanceId(processid).replace("[\"", "").replace("\"]", "");
        String businessId = businessKey + ":" + deptNo;
        //添加审批意见及填写审批意见人员
        Authentication.setAuthenticatedUserId(userId);
        taskService.addComment(taskId, processid, opin);
        //  获取所有历史任务(按创建时间升序)
        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
                .processInstanceId(processid)
                .orderByTaskCreateTime()
                .asc()
                .list();
        if (null == hisTaskList || hisTaskList.size() < 2) {
            CommUtils.throwClientException("退回评分失败!");
        }
        //  填报节点任务
        HistoricTaskInstance startTask = hisTaskList.get(0);
        //  部门审批节点任务
        HistoricTaskInstance currentTask = hisTaskList.get(hisTaskList.size() - 1);

        BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());

        logger.info(startTask.getTaskDefinitionKey());
        //  获取填报活动节点
        FlowNode startFlowNode = (FlowNode) bpmnModel.getFlowElement(startTask.getTaskDefinitionKey());
        //  获取部门审批活动节点
        FlowNode currentFlowNode = (FlowNode) bpmnModel.getFlowElement(currentTask.getTaskDefinitionKey());

        //  临时保存当前活动的原始方向
        List<SequenceFlow> originalSequenceFlowList = new ArrayList<>();
        originalSequenceFlowList.addAll(currentFlowNode.getOutgoingFlows());
        //  清理活动方向
        currentFlowNode.getOutgoingFlows().clear();
        //  建立新方向
        SequenceFlow newSequenceFlow = new SequenceFlow();
        newSequenceFlow.setId("newSequenceFlowId");
        newSequenceFlow.setSourceFlowElement(currentFlowNode);
        newSequenceFlow.setTargetFlowElement(startFlowNode);
        List<SequenceFlow> newSequenceFlowList = new ArrayList<>();
        newSequenceFlowList.add(newSequenceFlow);
        //  当前节点指向新的方向
        currentFlowNode.setOutgoingFlows(newSequenceFlowList);

        taskService.complete(taskId);

        //  重新查询当前任务
        Task nextTask = taskService.createTaskQuery().processInstanceId(processid).singleResult();
        if (null != nextTask) {
            taskService.setAssignee(nextTask.getId(), startTask.getAssignee());
        }

        //  恢复原始方向
        currentFlowNode.setOutgoingFlows(originalSequenceFlowList);
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值