| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Component; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.entity.Tag; |
| | | import zy.cloud.wms.manager.service.NodeService; |
| | | import zy.cloud.wms.manager.service.TagService; |
| | | |
| | | import java.util.*; |
| | |
| | | |
| | | @Autowired |
| | | private TagService tagService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | |
| | | /** |
| | | * 获取树图数据结构 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取树图数据结构 |
| | | */ |
| | | @Cacheable(cacheNames="nodeTree",key="#id") |
| | | public ArrayList<Map> getNodeTree(String id){ |
| | | ArrayList<Map> result = new ArrayList<>(); |
| | | Node node = nodeService.selectById(id); |
| | | // 主节点 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("title", node.getName()); |
| | | map.put("id", node.getId()); |
| | | map.put("spread", true); |
| | | List<Map> childrens = new ArrayList<>(); |
| | | map.put("children", childrens); |
| | | dealNode(node, childrens); |
| | | result.add(map); |
| | | // 开始处理字节点 |
| | | // deal(tag, childrens); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 递归获取子节点数据 |
| | | */ |
| | | public void deal(Tag parent, List<Map> list) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 递归获取子节点数据 |
| | | */ |
| | | public void dealNode(Node parent, List<Map> list) { |
| | | List<Node> nodes = nodeService.selectList( |
| | | new EntityWrapper<Node>() |
| | | .eq("parent_id", parent.getId()) |
| | | .eq("status", "1")); |
| | | for (Node node : nodes) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("title", node.getName()); |
| | | map.put("id", node.getId()); |
| | | map.put("spread", true); |
| | | List<Map> childrens = new ArrayList<>(); |
| | | map.put("children", childrens); |
| | | dealNode(node, childrens); |
| | | list.add(map); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |