From 7cd046d279b263efcf20a0ce3666d66ecc97d9f6 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 3 Jun 2025 16:20:25 +0800 Subject: [PATCH] =?UTF-8?q?perf(X-Pack):=20=E9=98=88=E5=80=BC=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=95=B0=E5=AD=97=E6=A0=BC=E5=BC=8F=E6=9C=AA=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E6=97=A0=E6=95=88=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/ChartViewThresholdManage.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 e9379142d9..aeb20ae848 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 @@ -20,6 +20,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -281,8 +282,15 @@ public class ChartViewThresholdManage { if (ObjectUtils.isEmpty(fieldDTO)) continue; String fieldDTOName = fieldDTO.getName(); String dataeaseName = fieldDTO.getDataeaseName(); - List valueList = rows.stream().map(row -> ObjectUtils.isEmpty(row.get(dataeaseName)) ? null : row.get(dataeaseName).toString()).collect(Collectors.toList()); - String replacement = fieldDTOName + ": " + JsonUtil.toJSONString(valueList); + String replacement = null; + if (fieldDTO.getDeType().equals(DeTypeConstants.DE_FLOAT)) { + List valueList = rows.stream().map(row -> ObjectUtils.isEmpty(row.get(dataeaseName)) ? null : stripTrailingZeros2String(row.get(dataeaseName))).collect(Collectors.toList()); + replacement = fieldDTOName + ": " + JsonUtil.toJSONString(valueList); + } else { + List valueList = rows.stream().map(row -> ObjectUtils.isEmpty(row.get(dataeaseName)) ? null : row.get(dataeaseName).toString()).collect(Collectors.toList()); + replacement = fieldDTOName + ": " + JsonUtil.toJSONString(valueList); + } + // 替换文本 matcher.appendReplacement(sb, replacement); } @@ -297,6 +305,14 @@ public class ChartViewThresholdManage { } } + private String stripTrailingZeros2String(Object value) { + if (ObjectUtils.isEmpty(value)) { + return null; + } + if (!(value instanceof BigDecimal)) return value.toString(); + return ((BigDecimal) value).stripTrailingZeros().toString(); + } + private void chartDynamicMap(List> rows, FilterTreeObj conditionTree, Map fieldMap) { List items = conditionTree.getItems(); items.forEach(item -> {