首页 > 编程学习 > Activiti:获取节点走向
20155 月18

Activiti:获取节点走向

 @At
    public String test5(@Param("taskId") String taskId) {
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        if (task == null)
            return "null";
        ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
        List<ActivityImpl> activitiList = def.getActivities();
        System.out.println("getTaskDefinitionKey:::" + task.getTaskDefinitionKey());
        NutMap map = new NutMap();
        int type = 0;
        getTaskActivitys(task.getTaskDefinitionKey(), activitiList, type, map);
        return Json.toJson(map);
    }

    public static List<PvmActivity> getTaskActivitys(String activityId, List<ActivityImpl> activityList, int type, NutMap map) {
        List<PvmActivity> activitiyIds = new ArrayList<>();
        for (ActivityImpl activityImpl : activityList) {
            String id = activityImpl.getId();

            if (activityId.equals(id)) {
                List<PvmTransition> outgoingTransitions = activityImpl.getOutgoingTransitions();//获取某节点所有线路
                List<NutMap> list = new ArrayList<>();
                for (PvmTransition tr : outgoingTransitions) {
                    NutMap map1 = new NutMap();
                    PvmActivity ac = tr.getDestination();//获取线路的终点节点
                    if (ac.getProperty("type").equals("userTask")) {
                        map.setv("type", type++);
                        map1.setv("id", ac.getId());
                        map1.setv("name", ac.getProperty("name"));
                        String conditionText=Strings.sNull(tr.getProperty("conditionText"));
                        if(!Strings.isEmpty(conditionText)){
                            map1.setv("conditionText",conditionText );
                        }
                        list.add(map1);
                    } else if (ac.getProperty("type").equals("exclusiveGateway")) {
                        getTaskActivitys(ac.getId(), activityList, type, map);
                    } else {
                        map.setv("type", type++);
                        break;
                    }
                }
                if (list.size() > 0)
                    map.addv("list", list);
                break;
            }
        }
        return activitiyIds;
    }

本文地址:https://wizzer.cn/archives/3144 , 转载请保留.

本文目前尚无任何评论.

发表评论