diff --git a/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java b/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java index 3166702f2..fc91493af 100644 --- a/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java +++ b/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java @@ -382,15 +382,17 @@ public class SemanticService { Optional lastDayOp = result.getResultList().stream().filter(r -> r.containsKey(dateField)) .map(r -> r.get(dateField).toString()) .sorted(Comparator.reverseOrder()).findFirst(); - if (lastDayOp.isPresent()) { - Optional> lastValue = result.getResultList().stream() - .filter(r -> r.get(dateField).toString().equals(lastDayOp.get())).findFirst(); - if (lastValue.isPresent() && lastValue.get().containsKey(ratioMetric.get().getBizName())) { - DecimalFormat df = new DecimalFormat("#.####"); - metricInfo.setValue(df.format(lastValue.get().get(ratioMetric.get().getBizName()))); - } - metricInfo.setDate(lastValue.get().get(dateField).toString()); + if (!lastDayOp.isPresent()) { + return new AggregateInfo(); } + Optional> lastValue = result.getResultList().stream() + .filter(r -> r.get(dateField).toString().equals(lastDayOp.get())).findFirst(); + if (lastValue.isPresent() && lastValue.get().containsKey(ratioMetric.get().getBizName())) { + DecimalFormat df = new DecimalFormat("#.####"); + metricInfo.setValue(df.format(lastValue.get().get(ratioMetric.get().getBizName()))); + } + metricInfo.setDate(lastValue.get().get(dateField).toString()); + CompletableFuture metricInfoRoll = CompletableFuture .supplyAsync(() -> { return queryRatio(user, semanticParseInfo, ratioMetric.get(), AggOperatorEnum.RATIO_ROLL,