@RequestMapping(value = "/listChildren", method = RequestMethod.GET) public Result<List<RepConfigTree>> list(RepConfigInfo repConfigInfo, @RequestParam(name = "repLx", defaultValue = "") String repLx) { long start = System.currentTimeMillis(); Result<List<RepConfigTree>> result = new Result<>(); try { LambdaQueryWrapper<RepConfigInfo> query = new LambdaQueryWrapper<RepConfigInfo>(); query.orderByAsc(RepConfigInfo::getXh); if(!repLx.isEmpty()){ query.like(RepConfigInfo::getRepLx, repLx); } List<RepConfigInfo> list = repConfigService.list(query); List<RepConfigTree> treeList = new ArrayList<>(); getTreeList(treeList, list, null); result.setResult(treeList); result.setSuccess(true); log.info("======获取全部报表配置数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒"); } catch (Exception e) { log.error(e.getMessage(), e); } return result; } private void getTreeList(List<RepConfigTree> treeList, List<RepConfigInfo> metaList, RepConfigTree temp) { for (RepConfigInfo rep : metaList) { String tempPid = rep.getParentNodeId(); RepConfigTree tree = new RepConfigTree(rep); if (temp == null && oConvertUtils.isEmpty(tempPid)) { treeList.add(tree); if (tree.getNodeVisible()) { getTreeList(treeList, metaList, tree); } }else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) { temp.getChildren().add(tree); if (tree.getNodeVisible()) { getTreeList(treeList, metaList, tree); } } } }