From 4a62db8224fb751e1364922ac8cd9ab851c61817 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 1 Jun 2022 11:15:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AC=A6=E5=8F=B7=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=AF=BC=E5=87=BAexcel=E7=BC=BA=E5=B0=91=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/service/chart/ChartViewService.java | 2 +- .../service/chart/util/ChartDataBuild.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 25190fb6c8..d5d2bb2e6b 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -787,7 +787,7 @@ public class ChartViewService { data = datasourceProvider.getData(datasourceRequest); Map mapChart = pluginViewResult(pluginViewParam, view, data, isDrill); - Map mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList); + Map mapTableNormal = ChartDataBuild.transTableNormal(fieldMap, view, data, desensitizationList); return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters); // 如果是插件到此结束 diff --git a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java index 6fa1d9a3f0..4daf0ce137 100644 --- a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java +++ b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java @@ -859,9 +859,7 @@ public class ChartDataBuild { // 表格 public static Map transTableNormal(List xAxis, List yAxis, ChartViewWithBLOBs view, List data, List extStack, List desensitizationList) { - Map map = new TreeMap<>(); List fields = new ArrayList<>(); - List> tableRow = new ArrayList<>(); if (ObjectUtils.isNotEmpty(xAxis)) { fields.addAll(xAxis); } @@ -871,6 +869,18 @@ public class ChartDataBuild { } } fields.addAll(yAxis); + return transTableNormal(fields, view, data, desensitizationList); + } + + // 表格 + public static Map transTableNormal(Map> fieldMap, ChartViewWithBLOBs view, List data, List desensitizationList) { + List fields = fieldMap.entrySet().stream().map(Map.Entry::getValue).flatMap(List::stream).collect(Collectors.toList()); + return transTableNormal(fields, view, data, desensitizationList); + } + + private static Map transTableNormal(List fields, ChartViewWithBLOBs view, List data, List desensitizationList) { + Map map = new TreeMap<>(); + List> tableRow = new ArrayList<>(); data.forEach(ele -> { Map d = new HashMap<>(); for (int i = 0; i < fields.size(); i++) { @@ -880,7 +890,7 @@ public class ChartDataBuild { } ChartViewFieldDTO chartViewFieldDTO = fields.get(i); - if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1) { + if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1 || chartViewFieldDTO.getDeType() == 5) { d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? "" : ele[i]); } else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) { d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP));