diff --git a/primihub-sdk/src/main/java/com/primihub/sdk/task/factory/AbstractGRPCExecuteFactory.java b/primihub-sdk/src/main/java/com/primihub/sdk/task/factory/AbstractGRPCExecuteFactory.java index 5813aa485..68308b201 100644 --- a/primihub-sdk/src/main/java/com/primihub/sdk/task/factory/AbstractGRPCExecuteFactory.java +++ b/primihub-sdk/src/main/java/com/primihub/sdk/task/factory/AbstractGRPCExecuteFactory.java @@ -10,10 +10,12 @@ import java_worker.TaskStatus; import java_worker.TaskStatusReply; import java_worker.VMNodeGrpc; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import primihub.rpc.Common; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -107,7 +109,23 @@ public void continuouslyObtainTaskStatus(Channel channel,Common.TaskContext task while (isContinue){ TaskStatusReply taskStatusReply = runVMNodeGrpc(o -> o.fetchTaskStatus(taskBuild),channel); if (taskStatusReply!=null && taskStatusReply.getTaskStatusList()!=null&&!taskStatusReply.getTaskStatusList().isEmpty()){ - List taskStatus = taskStatusReply.getTaskStatusList().stream().filter(t->t.getParty()!=null && !"".equals(t.getParty())).map(TaskStatus::getStatus).map(Enum::name).collect(Collectors.toList()); +// List taskStatus = taskStatusReply.getTaskStatusList().stream().filter(t->t.getParty()!=null && !"".equals(t.getParty())).map(TaskStatus::getStatus).map(Enum::name).collect(Collectors.toList()); + List taskStatus = new ArrayList(); + List groupKeyList = taskStatusReply.getTaskStatusList().stream().map(TaskStatus::getParty).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); + Map> taskStatusGroup = taskStatusReply.getTaskStatusList().stream().filter(t -> StringUtils.isNotBlank(t.getParty())).collect(Collectors.groupingBy(TaskStatus::getParty)); + for (String party : groupKeyList) { + List taskStatuses = taskStatusGroup.get(party); + List statusEnumList = taskStatuses.stream().map(TaskStatus::getStatus).collect(Collectors.toList()); + boolean match = statusEnumList.stream().allMatch(TaskStatus.StatusCode.SUCCESS::equals); + if (match) { + taskStatus.add(TaskStatus.StatusCode.SUCCESS.name()); + } else { + // 将未成功的状态全部传入 + List noSuccessStatue = statusEnumList.stream().map(TaskStatus.StatusCode::name).collect(Collectors.toList()); + taskStatus.addAll(noSuccessStatue); + } + } + if (!taskStatus.isEmpty()){ log.info(taskStatusReply.toString()); List getList = cacheService.get(key);