From 7f366dd9dbc892b609de76baa51649dd34f63f9c Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 25 Nov 2024 19:02:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=81=9C=E6=AD=A2=E4=B8=BB=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1049500 --user=王旭 【任务中心】停止主任务-状态和执行结果更新错误 https://www.tapd.cn/55049933/s/1617099 --- .../system/service/BaseTaskHubService.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java index 29c30805b6..5a55938057 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java @@ -626,7 +626,7 @@ public class BaseTaskHubService { handleK8STask(taskIds, testResourcePoolDTO); } else { Map> nodeItem = list.stream().collect(Collectors.groupingBy(ExecTaskItem::getResourcePoolNode)); - handleNodeTask(nodeItem); + handleNodeTask(nodeItem, false); } } catch (Exception e) { LogUtils.error(e); @@ -634,15 +634,24 @@ public class BaseTaskHubService { }); } - private void handleNodeTask(Map> nodeItem) { + private void handleNodeTask(Map> nodeItem, boolean isItem) { //通过任务向节点发起停止 nodeItem.forEach((node, items) -> { String endpoint = "http://".concat(node); - List itemIds = items.stream().map(ExecTaskItem::getId).toList(); + List itemIds = new ArrayList<>(); + if (isItem) { + itemIds = items.stream().map(ExecTaskItem::getId).toList(); + } else { + itemIds = items.stream().map(ExecTaskItem::getTaskId).toList(); + } SubListUtils.dealForSubList(itemIds, 100, subList -> { try { LogUtils.info(String.format("开始发送停止请求到 %s 节点执行", endpoint), subList.toString()); - MsHttpClient.stopApiTaskItem(endpoint, subList); + if (isItem) { + MsHttpClient.stopApiTaskItem(endpoint, subList); + } else { + MsHttpClient.stopApiTask(endpoint, subList); + } } catch (Exception e) { } }); @@ -743,7 +752,7 @@ public class BaseTaskHubService { handleK8STaskItem(itemIds, testResourcePoolDTO); } else { Map> nodeItem = execTaskItems.stream().collect(Collectors.groupingBy(ExecTaskItem::getResourcePoolNode)); - handleNodeTask(nodeItem); + handleNodeTask(nodeItem, true); } } catch (Exception e) { LogUtils.error(e);