package cn.thinkjoy.kidscare.utils;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import com.alibaba.fastjson.serializer.SerializeFilter;import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;import org.apache.commons.lang3.ArrayUtils;import org.springframework.util.CollectionUtils;import java.util.*;/*** * * @ClassName: TreeUtils * @Description: 组织树结构 * @author liyuhang * */public class TreeUtils { /**** * * @Title: getTreeByStack * @Description: 获取树形结构字符串 * @param jsonRootList 所有根结点 * @return String 树形字符串 */ public static String getTreeByStack(JSONArray jsonRootList, MapparentMap){ Stack stack=new Stack (); for(int i=0;i nodeAll, List selectedIds, SerializeFilter[] filters){ if (ArrayUtils.isEmpty(filters)) { SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter(); filters = new SerializeFilter[]{simplePropertyPreFilter}; } Map parentMap = new HashMap<>(); JSONArray rootList = new JSONArray(); if (!CollectionUtils.isEmpty(nodeAll)) { JSONArray jsonListAll = JSONArray.parseArray(JSON.toJSONString(nodeAll,filters)); for(int i=0;i