From 3c54f403c6c9756725f9d016e7ff05c5b64327d0 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期二, 22 十月 2024 14:36:53 +0800
Subject: [PATCH] 关于修改可靠性产品重复
---
zt/common/src/main/java/com/zt/common/utils/TreeUtils2.java | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/zt/common/src/main/java/com/zt/common/utils/TreeUtils2.java b/zt/common/src/main/java/com/zt/common/utils/TreeUtils2.java
index 64a8f34..b277660 100644
--- a/zt/common/src/main/java/com/zt/common/utils/TreeUtils2.java
+++ b/zt/common/src/main/java/com/zt/common/utils/TreeUtils2.java
@@ -43,7 +43,7 @@
*/
private static <T extends TreeNode2> T findChildren(List<T> treeNodes, T rootNode) {
for (T treeNode : treeNodes) {
- if (rootNode.getId().equals(treeNode.getPid())) {
+ if (rootNode.getIid().equals(treeNode.getPid())) {
rootNode.getChildren().add(findChildren(treeNodes, treeNode));
}
}
@@ -57,14 +57,14 @@
List<T> result = new ArrayList<>();
// list杞琺ap
- Map<String, T> nodeMap = new LinkedHashMap<>(treeNodes.size());
+ Map<Long, T> nodeMap = new LinkedHashMap<>(treeNodes.size());
for (T treeNode : treeNodes) {
- nodeMap.put(treeNode.getId(), treeNode);
+ nodeMap.put(treeNode.getIid(), treeNode);
}
for (T node : nodeMap.values()) {
T parent = nodeMap.get(node.getPid());
- if (parent != null && !(node.getId().equals(parent.getId()))) {
+ if (parent != null && !(node.getIid().equals(parent.getIid()))) {
parent.getChildren().add(node);
continue;
}
@@ -153,7 +153,7 @@
* @return
*/
public static <T extends TreeNode2> List<T> getAncestor(List<T> allNodes, Long id) {
- Map<String, T> map = allNodes.stream().collect(Collectors.toMap(dept -> dept.getId(), dept -> dept));
+ Map<Long, T> map = allNodes.stream().collect(Collectors.toMap(item -> item.getIid(), item -> item));
List<T> list = new ArrayList<>();
TreeNode2 node = map.get(id);
if (node != null) {
@@ -167,7 +167,7 @@
}
public static <T extends TreeNode2> T getTreeRoot(List<T> allNodes, Long id, Long rootParentId) {
- Map<String, T> map = allNodes.stream().collect(Collectors.toMap(type -> type.getId(), type -> type));
+ Map<Long, T> map = allNodes.stream().collect(Collectors.toMap(type -> type.getIid(), type -> type));
T parent = map.get(id);
while (parent != null) {
if (rootParentId.equals(parent.getPid())) {
@@ -191,10 +191,10 @@
if (id == 0) {
list.addAll(allNodes);
} else {
- if (allNodes.stream().filter(n -> n.getId().equals(id)).count() > 0) {
- T node = allNodes.stream().filter(n -> n.getId().equals(id)).findFirst().get();
+ if (allNodes.stream().filter(n -> n.getIid().equals(id)).count() > 0) {
+ T node = allNodes.stream().filter(n -> n.getIid().equals(id)).findFirst().get();
list.add(node);
- queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, node.getId());
+ queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, node.getIid());
}
}
return list;
@@ -207,7 +207,7 @@
* @param id
* @return
*/
- public static <T extends TreeNode2> List<T> getDescendant(List<T> allNodes, String id) {
+ public static <T extends TreeNode2> List<T> getDescendant(List<T> allNodes, Long id) {
List<T> list = new ArrayList<>();
queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, id);
return list;
@@ -216,10 +216,10 @@
/**
* 閫掑綊鏌ヨ瀛愯妭鐐�
*/
- private static void queryChildrenDepartmentRecursion(List<TreeNode2> list, List<TreeNode2> allNodes, String id) {
+ private static void queryChildrenDepartmentRecursion(List<TreeNode2> list, List<TreeNode2> allNodes, Long id) {
for (TreeNode2 node : allNodes.stream().filter(n -> n.getPid().equals(id)).collect(Collectors.toList())) {
list.add(node);
- queryChildrenDepartmentRecursion(list, allNodes, node.getId());
+ queryChildrenDepartmentRecursion(list, allNodes, node.getIid());
}
}
@@ -235,18 +235,18 @@
throw new RenException("鏌ヨ淇℃伅澶辫触");
}
// 涓婄骇鑿滃崟涓嶈兘涓鸿嚜韬�
- if (node.getId().equals(node.getPid())) {
+ if (node.getIid().equals(node.getPid())) {
throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR);
}
// 涓婄骇涓嶈兘涓轰笅绾�
if (!dbNode.getPid().equals(node.getPid())) {// 灞傜骇鏀瑰彉浜�
- if (node.getId().equals(node.getPid())) {
+ if (node.getIid().equals(node.getPid())) {
throw new RenException("涓婄骇涓嶈兘璁剧疆涓哄叾鏈韩锛�");
}
- List<T> list = TreeUtils2.getDescendant(allNodes, node.getId());
+ List<T> list = TreeUtils2.getDescendant(allNodes, node.getIid());
for (T d : list) {
- if (d.getId().equals(node.getPid())) {
+ if (d.getIid().equals(node.getPid())) {
throw new RenException("涓婄骇涓嶈兘璁剧疆涓哄叾涓嬬骇锛�");
}
}
--
Gitblit v1.9.1