diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java index d133b38be..2ca357da4 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -5134,7 +5134,7 @@ public class EmisBaseService { // 检查第一级是否至少有一个节点匹配 boolean hasFirstLevelMatch = false; - // 收集所有第一级节点的子节点(第二级) + // 收集第一级节点的子节点(第二级) Set secondLevelRules = new HashSet<>(); for (EmisTransPlanRule firstLevelRule : firstLevelRules) { @@ -5148,18 +5148,26 @@ public class EmisBaseService { && !batch.getEtd().before(firstLevelRule.getStartDate())) { firstLevelMatch = true; list.add(firstLevelRule); - // 收集当前第一级节点的所有子节点到第二级集合中 - if (!CollectionUtil.isEmpty(firstLevelRule.getChildren())) { - secondLevelRules.addAll(firstLevelRule.getChildren()); - } break; } } if (firstLevelMatch) { hasFirstLevelMatch = true; + // 如果当前节点匹配,则只收集该节点的子节点 + if (!CollectionUtil.isEmpty(firstLevelRule.getChildren())) { + secondLevelRules.addAll(firstLevelRule.getChildren()); + } } + } + // 如果第一级都不满足,则收集所有第一级节点的子节点 + if (!hasFirstLevelMatch) { + for (EmisTransPlanRule firstLevelRule : firstLevelRules) { + if (!CollectionUtil.isEmpty(firstLevelRule.getChildren())) { + secondLevelRules.addAll(firstLevelRule.getChildren()); + } + } } // 如果第二级为空,说明已经到底了,返回当前节点匹配且第一级至少有一个匹配的结果 @@ -5183,18 +5191,26 @@ public class EmisBaseService { && !batch.getEtd().before(secondLevelRule.getStartDate())) { secondLevelMatch = true; list.add(secondLevelRule); - // 收集当前第二级节点的所有子节点到第三级集合中 - if (!CollectionUtil.isEmpty(secondLevelRule.getChildren())) { - thirdLevelRules.addAll(secondLevelRule.getChildren()); - } break; } } if (secondLevelMatch) { hasSecondLevelMatch = true; + // 如果当前节点匹配,则只收集该节点的子节点 + if (!CollectionUtil.isEmpty(secondLevelRule.getChildren())) { + thirdLevelRules.addAll(secondLevelRule.getChildren()); + } } + } + // 如果第二级都不满足,则收集所有第二级节点的子节点 + if (!hasSecondLevelMatch) { + for (EmisTransPlanRule secondLevelRule : secondLevelRules) { + if (!CollectionUtil.isEmpty(secondLevelRule.getChildren())) { + thirdLevelRules.addAll(secondLevelRule.getChildren()); + } + } } // 递归处理下一级,并收集结果 @@ -5236,14 +5252,19 @@ public class EmisBaseService { if (currentLevelMatch) { hasCurrentLevelMatch = true; - if (CollectionUtil.isEmpty(currentLevelRule.getChildren())) { - return true; + // 如果当前节点匹配,则只收集该节点的子节点 + if (!CollectionUtil.isEmpty(currentLevelRule.getChildren())) { + nextLevelRules.addAll(currentLevelRule.getChildren()); } } + } - // 收集当前级节点的所有子节点到下一级集合中 - if (!CollectionUtil.isEmpty(currentLevelRule.getChildren())) { - nextLevelRules.addAll(currentLevelRule.getChildren()); + // 如果当前级都不满足,则收集所有当前级节点的子节点 + if (!hasCurrentLevelMatch) { + for (EmisTransPlanRule currentLevelRule : currentLevelRules) { + if (!CollectionUtil.isEmpty(currentLevelRule.getChildren())) { + nextLevelRules.addAll(currentLevelRule.getChildren()); + } } }