根据节点递归出子集
根据节点,查询出所有子节点(递归)
public List<BudgetCbs> treeBudgetCbsList(List<BudgetCbs> budgetCbsList, String pid) { //子节点 List<BudgetCbs> childBudgetCbs = new ArrayList<BudgetCbs>(); treeBudgetCbsList1(childBudgetCbs, budgetCbsList, pid); return childBudgetCbs; } public List<BudgetCbs> treeBudgetCbsList1(List<BudgetCbs> childBudgetCbs, List<BudgetCbs> budgetCbsList, String pid) { for (BudgetCbs bc : budgetCbsList) { //遍历出父id等于参数的id,add进子节点集合 if (org.apache.commons.lang3.StringUtils.isNotBlank(bc.getParent())) { if (bc.getParent().equals(pid)) { //递归遍历下一级 treeBudgetCbsList1(childBudgetCbs, budgetCbsList, bc.getDataId()); childBudgetCbs.add(bc); } } } return childBudgetCbs; }