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);