From 648d51b7459e32a35d82844fafcfebd51b6f9c9e Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 5 Sep 2024 10:33:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(X-Pack):=20=E9=98=88=E5=80=BC=E5=91=8A?= =?UTF-8?q?=E8=AD=A6-=E5=9B=BE=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=AF=BC=E8=87=B4=E7=9A=84NPE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/chart/manage/ChartViewThresholdManage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java index 09277f7381..d6f0ed85c7 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartViewThresholdManage.java @@ -3,6 +3,7 @@ package io.dataease.chart.manage; import io.dataease.api.chart.request.ThresholdCheckRequest; import io.dataease.api.chart.vo.ThresholdCheckVO; import io.dataease.engine.constant.DeTypeConstants; +import io.dataease.exception.DEException; import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO; import io.dataease.extensions.view.dto.ChartViewDTO; import io.dataease.extensions.view.dto.ChartViewFieldDTO; @@ -13,6 +14,7 @@ import io.dataease.utils.JsonUtil; import io.dataease.utils.LogUtil; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @@ -193,7 +195,10 @@ public class ChartViewThresholdManage { Long chartId = request.getChartId(); try { ChartViewDTO chart = chartViewManege.getChart(chartId); - Map data = chart.getData(); + Map data = null; + if (ObjectUtils.isEmpty(chart) || MapUtils.isEmpty(data = chart.getData())) { + return new ThresholdCheckVO(false, null, "查询图表异常!", null); + } thresholdTemplate = thresholdTemplate.replace("[检测时间]", DateUtils.time2String(System.currentTimeMillis())); String s = convertThresholdRules(chart, thresholdRules); thresholdTemplate = convertStyle(thresholdTemplate.replace("[触发告警]", s));