美文网首页
Activiti在当前节点获取下一个节点的候选人(下一个节点是会

Activiti在当前节点获取下一个节点的候选人(下一个节点是会

作者: 宋雨轩同学 | 来源:发表于2018-11-21 11:22 被阅读266次
  ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(delegateTask.getProcessDefinitionId());
  List<ActivityImpl> activitiList = def.getActivities();  //rs是指RepositoryService的实例
      ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(delegateTask.getExecutionId()).singleResult();
      String activitiId = execution.getActivityId();
    for(ActivityImpl activityImpl:activitiList){
    String id = activityImpl.getId();
    if(activitiId.equals(id)){
        System.out.println("当前任务:"+activityImpl.getProperty("name")); //输出某个节点的某种属性
        List<PvmTransition> outTransitions = activityImpl.getOutgoingTransitions();//获取从某个节点出来的所有线路
        for(PvmTransition tr:outTransitions){
        PvmActivity ac = tr.getDestination(); //获取线路的终点节点
                String s=(String) ac.getProperty("multiInstance");
         if("parallel".equals(s)){
             String targetUserTaskId= ac.getId();
             BpmnModel bpmnModel = repositoryService.getBpmnModel(def.getId());
                List<Process> processes = bpmnModel.getProcesses();
                for (Process process : processes) {
                    List<UserTask> userTaskList = process.findFlowElementsOfType(UserTask.class);
                    for (UserTask userTask : userTaskList) {
                        if(userTask.getId().equals(targetUserTaskId)){
                            List<String> candidateUsers = userTask.getCandidateUsers();
                           /*String[] assingneeArray=complateDto.getUserIds().split(",");
                           variables.put("assigneeList", Arrays.asList(assingneeArray));*/
                            System.out.println(candidateUsers);
                        }
                    }
                }
          }
        }
    }
    }

}

相关文章

网友评论

      本文标题:Activiti在当前节点获取下一个节点的候选人(下一个节点是会

      本文链接:https://www.haomeiwen.com/subject/ynbqqqtx.html