public List<String> orgIdsList(String id){ AbstractOrganizationBO organizationTree = organizationService.getOrganizationTree(); //首先通过根节点获取子节点 OrganizationBO organizationBO = (OrganizationBO) organizationTree.locateNode(id); List<AbstractOrganizationBO> subNodes = organizationBO.getChildren(); //创建新集合 List<String> orgIdsAll= new ArrayList<>(); orgIdsAll.add(id); //对子节点循环遍历 for(int i=0;i<subNodes.size();i++){ //加入集合 orgIdsAll.add(subNodes.get(i).getSysOrgId()); //再次获取子节点下的子节点 OrganizationBO organizationBOO = (OrganizationBO) organizationTree.locateNode(subNodes.get(i).getSysOrgId()); List<AbstractOrganizationBO> subNodess = organizationBOO.getChildren(); for(int j=0;j<subNodess.size();j++){ //循环 orgIdsList(subNodess.get(j).getSysOrgId()); } } return orgIdsAll; }
通过根节点遍历子节点集合
最新推荐文章于 2022-03-31 11:21:45 发布