From 6dfef298342cfb2a87e52ac3189a8e7b7d0f0ace Mon Sep 17 00:00:00 2001 From: kehaiyou <71740796@qq.com> Date: Sat, 21 Oct 2023 18:31:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A7=E5=88=B6=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=AD=90=E4=BB=BB=E5=8A=A1=E6=AC=A1=E6=95=B0=E5=92=8C=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E9=80=92=E5=BD=92=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/service/task/BpmTaskServiceImpl.java | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index 986205d5f..e195608a0 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -900,37 +900,26 @@ public class BpmTaskServiceImpl implements BpmTaskService { Stack stack = new Stack<>(); // 1.1 将根任务ID入栈 stack.push(parentTaskId); - while (!stack.isEmpty()) { + //控制遍历的次数不超过 Byte.MAX_VALUE,避免脏数据造成死循环 + int count = 0; + while (!stack.isEmpty() && count childrenTaskIdList = getChildrenTaskIdList(taskId); - if (childrenTaskIdList != null && !childrenTaskIdList.isEmpty()) { + if (CollUtil.isNotEmpty(childrenTaskIdList)) { for (String childTaskId : childrenTaskIdList) { // 1.5 将子任务ID入栈,以便后续处理 stack.push(childTaskId); } } + count++; } return allChildTaskIds; } - /** - * 递归处理子级任务 - * - * @param taskId 当前任务ID - * @param taskIds 结果 - */ - private void recursiveGetChildTaskIds(String taskId, List taskIds) { - List childrenTaskIdList = getChildrenTaskIdList(taskId); - for (String childTaskId : childrenTaskIdList) { - taskIds.add(childTaskId); // 将子任务的ID添加到集合中 - recursiveGetChildTaskIds(childTaskId, taskIds); // 递归获取子任务的子任务 - } - } - /** * 获取指定父级任务的所有子任务 ID 集合