From 77f54141258c6713ec40758c7563cc90174c0a25 Mon Sep 17 00:00:00 2001 From: junjie Date: Tue, 6 Jul 2021 16:32:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E9=A2=84=E8=A7=88=E6=95=B0=E6=8D=AE=E4=BB=8Edoris?= =?UTF-8?q?=E4=B8=AD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 132 ++++++++++++------ .../resources/i18n/messages_en_US.properties | 3 +- .../resources/i18n/messages_zh_CN.properties | 1 + .../resources/i18n/messages_zh_TW.properties | 3 +- .../components/shape-attr/LabelSelector.vue | 2 +- frontend/src/views/dataset/data/ViewTable.vue | 10 +- 6 files changed, 101 insertions(+), 50 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index a616ef3c06..2365207c18 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -282,52 +282,101 @@ public class DataSetTableService { realSize = Integer.parseInt(dataSetTableRequest.getRow()) % pageSize; } if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) { - Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); - if (ObjectUtils.isEmpty(ds)) { - throw new RuntimeException(Translator.get("i18n_datasource_delete")); + if (datasetTable.getMode() == 0) { + Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); + if (ObjectUtils.isEmpty(ds)) { + throw new RuntimeException(Translator.get("i18n_datasource_delete")); + } + DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDatasource(ds); + String table = dataTableInfoDTO.getTable(); + QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); + datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize)); + try { + data.addAll(datasourceProvider.getData(datasourceRequest)); + } catch (Exception e) { + e.printStackTrace(); + } + try { + datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()))); + dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size()); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + // check doris table + if (!checkDorisTableIsExists(dataSetTableRequest.getId())) { + throw new RuntimeException(Translator.get("i18n_data_not_sync")); + } + Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); + JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDatasource(ds); + String table = DorisTableUtils.dorisName(dataSetTableRequest.getId()); + QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); + datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize)); + try { + data.addAll(jdbcProvider.getData(datasourceRequest)); + } catch (Exception e) { + e.printStackTrace(); + } + try { + datasourceRequest.setQuery(qp.createQueryCountSQL(table)); + dataSetPreviewPage.setTotal(Integer.valueOf(jdbcProvider.getData(datasourceRequest).get(0)[0])); + } catch (Exception e) { + e.printStackTrace(); + } } - DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); - DatasourceRequest datasourceRequest = new DatasourceRequest(); - datasourceRequest.setDatasource(ds); - String table = dataTableInfoDTO.getTable(); - QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); - datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize)); - try { - data.addAll(datasourceProvider.getData(datasourceRequest)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()))); - dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size()); - } catch (Exception e) { - e.printStackTrace(); - } } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) { - Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); - if (ObjectUtils.isEmpty(ds)) { - throw new RuntimeException(Translator.get("i18n_datasource_delete")); - } - DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); - DatasourceRequest datasourceRequest = new DatasourceRequest(); - datasourceRequest.setDatasource(ds); + if (datasetTable.getMode() == 0) { + Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); + if (ObjectUtils.isEmpty(ds)) { + throw new RuntimeException(Translator.get("i18n_datasource_delete")); + } + DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDatasource(ds); - String sql = dataTableInfoDTO.getSql(); - QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); - datasourceRequest.setQuery(qp.createQuerySQLAsTmpWithPage(sql, fields, page, pageSize, realSize)); - System.out.println(datasourceRequest.getQuery()); - try { - data.addAll(datasourceProvider.getData(datasourceRequest)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()))); + String sql = dataTableInfoDTO.getSql(); + QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); + datasourceRequest.setQuery(qp.createQuerySQLAsTmpWithPage(sql, fields, page, pageSize, realSize)); System.out.println(datasourceRequest.getQuery()); - dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size()); - } catch (Exception e) { - e.printStackTrace(); + try { + data.addAll(datasourceProvider.getData(datasourceRequest)); + } catch (Exception e) { + e.printStackTrace(); + } + try { + datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()))); + dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size()); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + // check doris table + if (!checkDorisTableIsExists(dataSetTableRequest.getId())) { + throw new RuntimeException(Translator.get("i18n_data_not_sync")); + } + Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); + JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDatasource(ds); + String table = DorisTableUtils.dorisName(dataSetTableRequest.getId()); + QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); + datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize)); + try { + data.addAll(jdbcProvider.getData(datasourceRequest)); + } catch (Exception e) { + e.printStackTrace(); + } + try { + datasourceRequest.setQuery(qp.createQueryCountSQL(table)); + dataSetPreviewPage.setTotal(Integer.valueOf(jdbcProvider.getData(datasourceRequest).get(0)[0])); + } catch (Exception e) { + e.printStackTrace(); + } } } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { if (StringUtils.isEmpty(datasetTable.getSyncStatus()) || datasetTable.getSyncStatus().equalsIgnoreCase(JobStatus.Underway.name())) { @@ -363,7 +412,6 @@ public class DataSetTableService { e.printStackTrace(); } } - } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) { Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 94eca1339f..daa0be9874 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -265,4 +265,5 @@ i18n_schema_is_empty=Database schema is empty 站内消息=Internal Messages 所有消息=All Messages 未读消息=Unread Messages -已读消息=Read Messages \ No newline at end of file +已读消息=Read Messages +i18n_data_not_sync=Please sync data first \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index dcdbac9974..0871efe0cd 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -265,3 +265,4 @@ i18n_schema_is_empty=数据库 Schema 为空 所有消息=所有消息 未读消息=未读消息 已读消息=已读消息 +i18n_data_not_sync=请先完成数据同步 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 6ec405edc3..1dccd068c1 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -267,4 +267,5 @@ i18n_schema_is_empty=數據庫 Schema 為空 站内消息=站內消息 所有消息=所有消息 未读消息=未讀消息 -已读消息=已讀消息 \ No newline at end of file +已读消息=已讀消息 +i18n_data_not_sync=請先完成數據同步 \ No newline at end of file diff --git a/frontend/src/views/chart/components/shape-attr/LabelSelector.vue b/frontend/src/views/chart/components/shape-attr/LabelSelector.vue index a370f053f6..e50f47093f 100644 --- a/frontend/src/views/chart/components/shape-attr/LabelSelector.vue +++ b/frontend/src/views/chart/components/shape-attr/LabelSelector.vue @@ -34,7 +34,7 @@ {{ $t('chart.content_formatter') }}
- 字符串支持用 \n 换行
字符串模板 模板变量有:
{a}:系列名。
{b}:数据名。
{c}:数据值。
{d}:百分比(用于饼图等)。 + 字符串模板 模板变量有:
{a}:系列名。
{b}:数据名。
{c}:数据值。
{d}:百分比(用于饼图等)。
diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index 0330cb80a4..8502181d73 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -1,6 +1,6 @@