From 04b4a574d87fdaa8b21ebbc0e8fc196eb37da53a Mon Sep 17 00:00:00 2001 From: wisonic Date: Wed, 5 Nov 2025 17:45:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E8=A1=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E6=B1=87?= =?UTF-8?q?=E6=80=BB=E7=A9=BA=E5=80=BC=E5=AF=BC=E8=87=B4=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charts/impl/table/TableNormalHandler.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/table/TableNormalHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/table/TableNormalHandler.java index 59fa541b89..bcd7846dc4 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/table/TableNormalHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/table/TableNormalHandler.java @@ -28,7 +28,9 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @author jianneng @@ -220,6 +222,7 @@ public class TableNormalHandler extends DefaultChartHandler { if (CollectionUtils.isNotEmpty(fieldList)) { var customCalcFields = new ArrayList(); var seriesList = JsonUtil.parseList(JsonUtil.toJSONString(fieldList).toString(), new TypeReference>(){}); + var quotaIds = allFields.stream().map(DatasetTableFieldDTO::getDataeaseName).collect(Collectors.toSet()); seriesList.forEach(field -> { if (!BooleanUtils.isTrue(field.getShow()) || !"custom".equalsIgnoreCase(field.getSummary())) { return; @@ -227,6 +230,9 @@ public class TableNormalHandler extends DefaultChartHandler { if (StringUtils.isBlank(field.getOriginName())) { return; } + if (!quotaIds.contains(field.getField())) { + return; + } field.setSummary(""); field.setDeType(DeTypeConstants.DE_FLOAT); field.setId(IDUtils.snowID()); @@ -248,12 +254,16 @@ public class TableNormalHandler extends DefaultChartHandler { customSumReq.setQuery(customSumSql); var customSumData = (List) provider.fetchResultField(customSumReq).get("data"); if (CollectionUtils.isNotEmpty(customSumData)) { - var customSumResult = new HashMap(); + var customSumResult = new HashMap(); // 只取第一行结果 var customSumArr = customSumData.get(0); for (int i = 0; i < customSumArr.length; i++) { - if (customCalcFields.get(i) != null) { - customSumResult.put(customCalcFields.get(i).getField(), Double.valueOf(customSumArr[i])); + if (customCalcFields.get(i) != null && customSumArr[i] != null) { + try { + customSumResult.put(customCalcFields.get(i).getField(), new BigDecimal(customSumArr[i])); + } catch (Exception e) { + customSumResult.put(customCalcFields.get(i).getField(), new BigDecimal(0)); + } } } result.put("customSumResult", customSumResult);