forked from github/dataease
Merge pull request #1352 from dataease/pr@v1.5@refactor_error_tip
refactor(数据集): 优化数据集数据预览报错信息
This commit is contained in:
commit
47203613d9
@ -7,6 +7,7 @@ import io.dataease.base.mapper.*;
|
||||
import io.dataease.base.mapper.ext.ExtDataSetGroupMapper;
|
||||
import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
|
||||
import io.dataease.base.mapper.ext.UtilMapper;
|
||||
import io.dataease.commons.constants.DatasourceTypes;
|
||||
import io.dataease.commons.constants.JobStatus;
|
||||
import io.dataease.commons.constants.ScheduleType;
|
||||
import io.dataease.commons.constants.TaskStatus;
|
||||
@ -15,16 +16,16 @@ import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTaskRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.commons.constants.DatasourceTypes;
|
||||
import io.dataease.dto.datasource.TableFiled;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.controller.request.datasource.DatasourceRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.dto.dataset.*;
|
||||
import io.dataease.dto.datasource.TableFiled;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.loader.ClassloaderResponsity;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.provider.query.DDLProvider;
|
||||
import io.dataease.provider.query.QueryProvider;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -39,6 +40,8 @@ import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -93,6 +96,8 @@ public class DataSetTableService {
|
||||
@Value("${upload.file.path}")
|
||||
private String path;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class);
|
||||
|
||||
public void batchInsert(List<DataSetTableRequest> datasetTable) throws Exception {
|
||||
for (DataSetTableRequest table : datasetTable) {
|
||||
save(table);
|
||||
@ -469,8 +474,8 @@ public class DataSetTableService {
|
||||
datasourceRequest.setPageable(true);
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -478,8 +483,8 @@ public class DataSetTableService {
|
||||
datasourceRequest.setPageable(false);
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
} else {
|
||||
// check doris table
|
||||
@ -497,15 +502,15 @@ public class DataSetTableService {
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,16 +537,16 @@ public class DataSetTableService {
|
||||
datasourceRequest.setPageable(true);
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
} else {
|
||||
// check doris table
|
||||
@ -559,15 +564,15 @@ public class DataSetTableService {
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
|
||||
@ -586,15 +591,15 @@ public class DataSetTableService {
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
|
||||
if (datasetTable.getMode() == 0) {
|
||||
@ -609,7 +614,13 @@ public class DataSetTableService {
|
||||
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
List<DataSetTableUnionDTO> list = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId());
|
||||
|
||||
String sql = getCustomSQLDatasource(dt, list, ds);
|
||||
String sql = "";
|
||||
try {
|
||||
sql = getCustomSQLDatasource(dt, list, ds);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
@ -622,16 +633,16 @@ public class DataSetTableService {
|
||||
datasourceRequest.setPageable(true);
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
} else {
|
||||
Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
|
||||
@ -645,16 +656,16 @@ public class DataSetTableService {
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,4 +288,5 @@ i18n_Stopped=END
|
||||
i18n_Exec=Running
|
||||
i18n_no_trigger=The current setting does not trigger task generation.
|
||||
i18n_dataset_field_delete=Union field deleted,please set again and redo.
|
||||
i18n_es_limit=Elasticsearch version cannot be less than 6.3
|
||||
i18n_es_limit=Elasticsearch version cannot be less than 6.3
|
||||
i18n_ds_error=Preview fail:Execute SQL error。Cause field、table、dataset changed,please check
|
@ -288,3 +288,4 @@ i18n_Exec=运行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成
|
||||
i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重新确认关联关系并重做该数据集
|
||||
i18n_es_limit=Elasticsearch 版本不能小于6.3
|
||||
i18n_ds_error=预览数据错误:执行SQL失败。可能因相关字段、表、数据集等元素发生变更,请检查
|
||||
|
@ -290,4 +290,5 @@ i18n_Stopped=執行結束
|
||||
i18n_Exec=運行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成 當前設置沒有觸發任務生成.
|
||||
i18n_dataset_field_delete=該自定義數據集有關聯字段被刪除,請重新確認關聯關系並重做該數據集
|
||||
i18n_es_limit=Elasticsearch 版本不能小於6.3
|
||||
i18n_es_limit=Elasticsearch 版本不能小於6.3
|
||||
i18n_ds_error=預覽數據錯誤:執行SQL失敗。可能因相關字段、表、數據集等元素發生變更,請檢查
|
Loading…
Reference in New Issue
Block a user