给层级目录添加分类父类(父类为临时组合节点,非数据库数据)
@Data
public class Tree implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点主键 */
private Long pkId;
/** 节点ID */
private String id;
/** 节点父ID */
private String pId;
/** 节点名称 */
private String name;
/** 节点标题 */
private String title;
//子节点
private List<Tree> children;
//节点默认展开
private Boolean spread = true;
/** 部门编号*/
private String organNo;
//与上一层关系
private String upperAffiliatedRelation;
//持股比例
private BigDecimal upperHoldStockPercent;
}
{
//创建分类节点
//按父id分组
Map<String, List
for (Map.Entry<String, List
String mapKey = entry.getKey();
List
//按同一分类目录分组
Map<String, List
for (Map.Entry<String, List
String key = item.getKey();
List
setNode(trees, key ,value, mapKey);//调用方法创造节点
}
}
//组成目录
List
.peek(menu -> menu.setChildren(getChildList(menu, trees))).collect(Collectors.toList());
return collect;
}
private List
return trees.stream().filter(item -> item.getPId().equals(menu.getId()))
.peek(child -> child.setChildren(getChildList(child, trees))).collect(Collectors.toList());
}
//创造节点
List
//创建分类目录
Tree node = new Tree();
String pid = UUID.randomUUID().toString();//目录id
if (other113.equals(key)) {
node.setTitle(other113Display+"("+value.size()+")");
}
if(mapKey.equals("0")){
node.setTitle(AccessorHelper.getAccessor().getOrgan().getName());
}
node.setId(pid);
node.setPId(mapKey);//设置临时节点父级
value.forEach(t->{t.setPId(pid);});//设置子类
if(!mapKey.equals("0")){
value.forEach(item->{
item.setTitle(item.getTitle()+"[持股"+item.getUpperHoldStockPercent().toString()+"%]");
});
}
trees.add(node);
return trees;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?