From 8137acfd50143d0405b060ecbb75f65199911c60 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 28 Mar 2022 15:17:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=BD=E5=8F=96=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E8=A7=86=E5=9B=BE=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/chart/ChartViewService.java | 1 + .../chart/ViewPluginBaseServiceImpl.java | 50 +++++++++++-------- 2 files changed, 29 insertions(+), 22 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 02c11d0164..8ba30de0d4 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -784,6 +784,7 @@ public class ChartViewService { PluginViewParam pluginViewParam = new PluginViewParam(); PluginViewSet pluginViewSet = BeanUtils.copyBean(new PluginViewSet(), table); pluginViewSet.setDsType(ds.getType()); + pluginViewSet.setTabelId(table.getId()); PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view); diff --git a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java index f86de14af9..2b7bb783ee 100644 --- a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java +++ b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java @@ -93,29 +93,35 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { public PluginViewSQL getTableObj(PluginViewSet pluginViewSet) { String tableName = null; DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(pluginViewSet.getInfo(), DataTableInfoDTO.class); - switch (pluginViewSet.getType()) { - case "db": - tableName = dataTableInfoDTO.getTable(); - break; - case "sql": - tableName = dataTableInfoDTO.getSql(); - break; - case "custom": - List list = dataSetTableUnionService.listByTableId(dataTableInfoDTO.getList().get(0).getTableId()); - Datasource ds = new Datasource(); - ds.setType(pluginViewSet.getDsType()); - tableName = dataSetTableService.getCustomSQLDatasource(dataTableInfoDTO, list, ds); - break; - case "union": - Datasource datasource = new Datasource(); - datasource.setType(pluginViewSet.getDsType()); - Map sqlMap = dataSetTableService.getUnionSQLDatasource(dataTableInfoDTO, datasource); - tableName = (String) sqlMap.get("sql"); - break; - default: - break; - } + if (ObjectUtils.isNotEmpty(pluginViewSet.getMode()) && 1 == pluginViewSet.getMode()) { + tableName = "ds_" + pluginViewSet.getTabelId().replaceAll("-", "_"); + + }else { + switch (pluginViewSet.getType()) { + case "db": + tableName = dataTableInfoDTO.getTable(); + break; + case "sql": + tableName = dataTableInfoDTO.getSql(); + break; + case "custom": + List list = dataSetTableUnionService.listByTableId(dataTableInfoDTO.getList().get(0).getTableId()); + Datasource ds = new Datasource(); + ds.setType(pluginViewSet.getDsType()); + tableName = dataSetTableService.getCustomSQLDatasource(dataTableInfoDTO, list, ds); + break; + case "union": + Datasource datasource = new Datasource(); + datasource.setType(pluginViewSet.getDsType()); + Map sqlMap = dataSetTableService.getUnionSQLDatasource(dataTableInfoDTO, datasource); + tableName = (String) sqlMap.get("sql"); + break; + default: + tableName = dataTableInfoDTO.getTable(); + break; + } + } String keyword = ConstantsUtil.constantsValue(pluginViewSet.getDsType(), "KEYWORD_TABLE"); String tabelName = (tableName.startsWith("(") && tableName.endsWith(")")) ? tableName : String.format(keyword, tableName); String tabelAlias = String.format(TABLE_ALIAS_PREFIX, 0);