tree2List

GroupTreeVo.java
@Data
@Accessors(chain=true)
public class GroupTreeVo {
    @ApiModelProperty("Id")
    private String id;

    @ApiModelProperty("分组名称")
    private String groupName;

    @ApiModelProperty("分组编码")
    private String groupCode;

    @ApiModelProperty("工厂Id")
    private String factoryId;
    @ApiModelProperty("设备Id")
    private String deviceId;

    @ApiModelProperty("类型: 1 工艺类  2 能耗类")
    private Integer metaType;

    private List<GroupTreeVo> children = new ArrayList<>();

    @ApiModelProperty("是否允许点击")
    private Boolean disabled = true;
}

Tree 转 Lisst

    // tree 转 Lisst
   // treeVos为树状结构
private List<String> tree2List(List<GroupTreeVo> treeVos){ List<String> list = new ArrayList<>(); for (GroupTreeVo vo : treeVos) { list.add(vo.getDeviceId()); List<GroupTreeVo> child = vo.getChildren(); if(CollUtil.isNotEmpty(child)){ list.addAll(tree2List(child)); vo.setChildren(null); } } return list; }

 

posted @ 2021-09-19 09:41  真某人  阅读(51)  评论(0编辑  收藏  举报