|
@@ -21,6 +21,7 @@ import com.platform.dao.vo.query.qykh.InformationVO;
|
|
|
import com.platform.dao.vo.query.qykh.PlanVO;
|
|
|
import com.platform.dao.vo.query.qykh.ProductVO;
|
|
|
import com.platform.dao.vo.query.store.StoreVO;
|
|
|
+import com.platform.dao.vo.sb.SbPositionVO;
|
|
|
import com.platform.dao.vo.sb.SbTypeVO;
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
@@ -91,6 +92,41 @@ public class TreeUtil {
|
|
|
return trees;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 多层两次循环实现建树
|
|
|
+ * 当没有父节点的时候,当前节点也要显示
|
|
|
+ * @param treeNodes 传入的树节点列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public <T extends TreeNode> List<T> buildByLoopWithNoParent(List<T> treeNodes, Object root) {
|
|
|
+
|
|
|
+ List<T> trees = new ArrayList<>();
|
|
|
+ Map<String, T> treeNodeMap = MapUtils.newHashMap(treeNodes.size());
|
|
|
+ treeNodes.forEach(treeNode -> {
|
|
|
+ treeNodeMap.put(treeNode.getId(), treeNode);
|
|
|
+ });
|
|
|
+
|
|
|
+ treeNodes.forEach(treeNode -> {
|
|
|
+ if (StringUtils.isBlank(treeNode.getParentId()) || "0".equals(treeNode.getParentId())) {
|
|
|
+ trees.add(treeNode);
|
|
|
+ } else if (treeNode.getParentId().equals(root)) {
|
|
|
+ trees.add(treeNode);
|
|
|
+ } else {
|
|
|
+ T t = treeNodeMap.get(treeNode.getParentId());
|
|
|
+ if (t != null) {
|
|
|
+ t.setGroup(true);
|
|
|
+ if (t.getChildren() == null) {
|
|
|
+ t.setChildren(new ArrayList<>());
|
|
|
+ }
|
|
|
+ t.getChildren().add(treeNode);
|
|
|
+ }else{
|
|
|
+ trees.add(treeNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return trees;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 多层两次循环实现建树
|
|
|
* 不包括root节点
|
|
@@ -337,7 +373,7 @@ public class TreeUtil {
|
|
|
* @param root
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<CommonTree> buildSbPositionTree(List<SbPosition> types, String root) {
|
|
|
+ public List<CommonTree> buildSbPositionTree(List<SbPositionVO> types, String root) {
|
|
|
List<CommonTree> trees = new LinkedList<>();
|
|
|
types.forEach(type -> {
|
|
|
CommonTree node = new CommonTree();
|
|
@@ -345,12 +381,35 @@ public class TreeUtil {
|
|
|
node.setKey(type.getId());
|
|
|
node.setParentId(type.getParentId());
|
|
|
node.setTitle(type.getName());
|
|
|
+ node.setImg(type.getOpcImg());
|
|
|
node.setValue(type.getId());
|
|
|
trees.add(node);
|
|
|
});
|
|
|
return TreeUtil.buildByLoop(trees, root);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建设备位置树
|
|
|
+ *
|
|
|
+ * @param types
|
|
|
+ * @param root
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<CommonTree> buildSbPositionTreeWithNoParent(List<SbPositionVO> types, String root) {
|
|
|
+ List<CommonTree> trees = new LinkedList<>();
|
|
|
+ types.forEach(type -> {
|
|
|
+ CommonTree node = new CommonTree();
|
|
|
+ node.setId(type.getId());
|
|
|
+ node.setKey(type.getId());
|
|
|
+ node.setParentId(type.getParentId());
|
|
|
+ node.setTitle(type.getName());
|
|
|
+ node.setImg(type.getOpcImg());
|
|
|
+ node.setValue(type.getId());
|
|
|
+ trees.add(node);
|
|
|
+ });
|
|
|
+ return TreeUtil.buildByLoopWithNoParent(trees, root);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建设备基本信息类型树
|
|
|
*
|