|
|
|
@ -137,86 +137,6 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|
|
|
|
return build;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
List<SelectVO> voList = assembleSelectVOList();
|
|
|
|
|
// 判断是否满足删除条件
|
|
|
|
|
for (int i = voList.size() - 1; i >= 0; i--) {
|
|
|
|
|
if(Integer.parseInt(voList.get(i).getValue())>5){
|
|
|
|
|
voList.remove(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<SelectVO> collect = voList.stream().filter(SelectVO->Integer.parseInt(SelectVO.getValue())>5).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TreeDataVO build;
|
|
|
|
|
int num = 1;
|
|
|
|
|
List<Integer> list = new ArrayList<>();
|
|
|
|
|
list.add(num);
|
|
|
|
|
|
|
|
|
|
List<ChartChildrensVO> childList4 = new ArrayList<>();
|
|
|
|
|
ChartChildrensVO chart5 = null;
|
|
|
|
|
chart5 = chart5.builder().id("1111").label("aaaa").pid("11111").childrens(null).build();
|
|
|
|
|
ChartChildrensVO chart6 = null;
|
|
|
|
|
chart6 = chart6.builder().id("2222").label("bbbb").pid("22222").childrens(null).build();
|
|
|
|
|
ChartChildrensVO chart7 = null;
|
|
|
|
|
chart7 = chart7.builder().id("2222").label("bbbb").pid("22222").childrens(null).build();
|
|
|
|
|
|
|
|
|
|
childList4.add(chart5);
|
|
|
|
|
childList4.add(chart6);
|
|
|
|
|
childList4.add(chart7);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ChartChildrensVO> childList3 = new ArrayList<>();
|
|
|
|
|
ChartChildrensVO chart3 = null;
|
|
|
|
|
chart3 = chart3.builder().id("1111").label("aaaa").pid("11111").childrens(null).build();
|
|
|
|
|
ChartChildrensVO chart4 = null;
|
|
|
|
|
chart4 = chart4.builder().id("2222").label("bbbb").pid("22222").childrens(null).build();
|
|
|
|
|
|
|
|
|
|
childList3.add(chart3);
|
|
|
|
|
childList3.add(chart4);
|
|
|
|
|
|
|
|
|
|
List<ChartChildrensVO> childList2 = new ArrayList<>();
|
|
|
|
|
ChartChildrensVO chart1 = null;
|
|
|
|
|
chart1 = chart1.builder().id("111").label("aaa").pid("1111").childrens(childList3).build();
|
|
|
|
|
ChartChildrensVO chart2 = null;
|
|
|
|
|
chart2 = chart2.builder().id("222").label("bbb").pid("2222").childrens(childList3).build();
|
|
|
|
|
|
|
|
|
|
childList2.add(chart1);
|
|
|
|
|
childList2.add(chart2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ChartChildrensVO> childList1 = new ArrayList<>();
|
|
|
|
|
ChartChildrensVO chartChildrensVO1 = null;
|
|
|
|
|
chartChildrensVO1 = chartChildrensVO1.builder().id("11").label("aa").pid("111").childrens(childList2).build();
|
|
|
|
|
ChartChildrensVO chartChildrensVO2 = null;
|
|
|
|
|
chartChildrensVO2 = chartChildrensVO2.builder().id("22").label("bb").pid("222").childrens(childList2).build();
|
|
|
|
|
ChartChildrensVO chartChildrensVO3 = null;
|
|
|
|
|
chartChildrensVO3 = chartChildrensVO3.builder().id("33").label("cc").pid("333").childrens(childList2).build();
|
|
|
|
|
ChartChildrensVO chartChildrensVO4 = null;
|
|
|
|
|
chartChildrensVO4 = chartChildrensVO4.builder().id("44").label("dd").pid("444").childrens(childList2).build();
|
|
|
|
|
childList1.add(chartChildrensVO1);
|
|
|
|
|
childList1.add(chartChildrensVO2);
|
|
|
|
|
childList1.add(chartChildrensVO3);
|
|
|
|
|
childList1.add(chartChildrensVO4);
|
|
|
|
|
|
|
|
|
|
build = TreeDataVO.builder()
|
|
|
|
|
.id("11")
|
|
|
|
|
.label("aa")
|
|
|
|
|
.childrens(childList1)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
if(null!=build.getChildrens()&&build.getChildrens().size()>0){
|
|
|
|
|
for (ChartChildrensVO children : build.getChildrens()) {
|
|
|
|
|
num = maxDepth(children)+1;
|
|
|
|
|
list.add(num);
|
|
|
|
|
}
|
|
|
|
|
build.setNum(Collections.max(list)+1);
|
|
|
|
|
}else{
|
|
|
|
|
build.setNum(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 遍历n叉树最大深度
|
|
|
|
|
* @param root
|
|
|
|
|