From 2f5639bf0a6c43c134acf63d951ad9c7cf11cd44 Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 27 Jun 2024 11:31:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=BF=87=E6=BB=A4=E7=BB=84=E4=BB=B6):?= =?UTF-8?q?=20=E8=BF=87=E6=BB=A4=E7=BB=84=E4=BB=B6=E4=B8=8D=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=A9=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/manage/DatasetDataManage.java | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetDataManage.java b/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetDataManage.java index f299ff71d2..562f3f5b3f 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/manage/DatasetDataManage.java @@ -2,7 +2,10 @@ package io.dataease.dataset.manage; import io.dataease.api.chart.dto.ColumnPermissionItem; import io.dataease.api.chart.dto.DeSortField; -import io.dataease.api.dataset.dto.*; +import io.dataease.api.dataset.dto.BaseTreeNodeDTO; +import io.dataease.api.dataset.dto.EnumValueRequest; +import io.dataease.api.dataset.dto.PreviewSqlDTO; +import io.dataease.api.dataset.dto.SqlLogDTO; import io.dataease.api.dataset.union.DatasetGroupInfoDTO; import io.dataease.api.dataset.union.DatasetTableInfoDTO; import io.dataease.api.permissions.dataset.dto.DataSetRowPermissionsTreeDTO; @@ -11,7 +14,10 @@ import io.dataease.chart.manage.ChartViewManege; import io.dataease.chart.utils.ChartDataBuild; import io.dataease.commons.utils.SqlparserUtils; import io.dataease.dataset.constant.DatasetTableType; -import io.dataease.dataset.utils.*; +import io.dataease.dataset.utils.DatasetUtils; +import io.dataease.dataset.utils.FieldUtils; +import io.dataease.dataset.utils.SqlUtils; +import io.dataease.dataset.utils.TableUtils; import io.dataease.datasource.dao.auto.entity.CoreDatasource; import io.dataease.datasource.dao.auto.mapper.CoreDatasourceMapper; import io.dataease.datasource.manage.EngineManage; @@ -486,6 +492,16 @@ public class DatasetDataManage { datasourceRequest.setDsList(dsMap); Map data = calciteProvider.fetchResultField(datasourceRequest); List dataList = (List) data.get("data"); + dataList = dataList.stream().filter(row -> { + boolean hasEmpty = false; + for (String s : row) { + if (StringUtils.isBlank(s)) { + hasEmpty = true; + break; + } + } + return !hasEmpty; + }).toList(); List previewData = new ArrayList<>(); if (ObjectUtils.isNotEmpty(dataList)) { List tmpData = dataList.stream().map(ele -> (ObjectUtils.isNotEmpty(ele) && ele.length > 0) ? ele[0] : null).collect(Collectors.toList()); @@ -701,6 +717,16 @@ public class DatasetDataManage { datasourceRequest.setDsList(dsMap); Map data = calciteProvider.fetchResultField(datasourceRequest); List dataList = (List) data.get("data"); + dataList = dataList.stream().filter(row -> { + boolean hasEmpty = false; + for (String s : row) { + if (StringUtils.isBlank(s)) { + hasEmpty = true; + break; + } + } + return !hasEmpty; + }).toList(); Map distinctData = new LinkedHashMap<>(); for (String[] arr : dataList) { String key = Arrays.toString(arr); @@ -812,13 +838,14 @@ public class DatasetDataManage { // 重新构造data Set pkSet = new HashSet<>(); rows = rows.stream().filter(row -> { - boolean allEmpty = true; + boolean hasEmpty = false; for (String s : row) { - if (StringUtils.isNotBlank(s)) { - allEmpty = false; + if (StringUtils.isBlank(s)) { + hasEmpty = true; + break; } } - return !allEmpty; + return !hasEmpty; }).toList(); List treeNodes = rows.stream().map(row -> buildTreeNode(row, pkSet)).flatMap(Collection::stream).collect(Collectors.toList()); List tree = DatasetUtils.mergeDuplicateTree(treeNodes, "root");