Merge pull request #10178 from dataease/pr@dev@fixExportdata

Pr@dev@fix exportdata
This commit is contained in:
taojinlong 2024-06-11 13:16:54 +08:00 committed by GitHub
commit b87445d914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 13 deletions

View File

@ -54,6 +54,10 @@ public class AuthUtils {
return userDto;
}
public static void setUser(CurrentUserDto user) {
USER_INFO.set(user);
}
public static void setProxyUser(Long userId) {
CurrentUserDto currentUserDto = proxyAuthService.queryCacheUserDto(userId);
USER_INFO.set(currentUserDto);

View File

@ -951,7 +951,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
break;
case pg:
PgConfiguration pgConfiguration = new Gson().fromJson(datasource.getConfiguration(), PgConfiguration.class);
if (!pgConfiguration.getDataBase().matches("^[0-9a-zA-Z_]{1,}$")) {
if (!pgConfiguration.getDataBase().matches("^[0-9a-zA-Z_.-]{1,}$")) {
throw new Exception("Invalid database name");
}
break;

View File

@ -988,13 +988,7 @@ public class PgQueryProvider extends QueryProvider {
}
public String getTotalCount(boolean isTable, String sql, Datasource ds) {
if (isTable) {
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
String tableWithSchema = String.format(PgConstants.KEYWORD_TABLE, schema) + "." + String.format(PgConstants.KEYWORD_TABLE, sql);
return "SELECT COUNT(*) from " + tableWithSchema;
} else {
return null;
}
return null;
}
@Override
@ -1007,7 +1001,7 @@ public class PgQueryProvider extends QueryProvider {
if (ds != null) {
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), tableWithSchema);
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), tableWithSchema);
} else {
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), table);
}

View File

@ -181,7 +181,7 @@ public class DatasourceService {
});
if (!datasourceDTO.getType().equalsIgnoreCase(DatasourceTypes.api.toString())) {
JdbcConfiguration configuration = new Gson().fromJson(datasourceDTO.getConfiguration(), JdbcConfiguration.class);
if (StringUtils.isNotEmpty(configuration.getCustomDriver()) && !configuration.getCustomDriver().equalsIgnoreCase("default")) {
if (StringUtils.isNotEmpty(configuration.getCustomDriver()) && !configuration.getCustomDriver().startsWith("default-")) {
datasourceDTO.setCalculationMode(DatasourceCalculationMode.DIRECT);
}
JSONObject jsonObject = JSONObject.parseObject(datasourceDTO.getConfiguration());

View File

@ -322,7 +322,7 @@ public class ExportCenterService {
ChartViewDTO chartViewInfo = chartViewService.getData(request.getViewId(), componentFilterInfo);
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
request.setDetails(tableRow);
if("dataset".equals(request.getDownloadType())){
if ("dataset".equals(request.getDownloadType())) {
request.setHeader((String[]) chartViewInfo.getData().get("header"));
request.setExcelTypes((Integer[]) chartViewInfo.getData().get("dsTypes"));
}
@ -388,7 +388,9 @@ public class ExportCenterService {
String dataPath = exportData_path + exportTask.getId();
File directory = new File(dataPath);
boolean isCreated = directory.mkdir();
CurrentUserDto currentUserDto = AuthUtils.getUser();
Future future = scheduledThreadPoolExecutor.submit(() -> {
AuthUtils.setUser(currentUserDto);
try {
exportTask.setExportStatus("IN_PROGRESS");
exportTaskMapper.updateByPrimaryKey(exportTask);
@ -414,7 +416,7 @@ public class ExportCenterService {
cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
//设置单元格填充样式(使用纯色背景颜色填充)
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
if ("table-info".equals(request.getViewType())||"dataset".equals(request.getDownloadType())) {
if ("table-info".equals(request.getViewType()) || "dataset".equals(request.getDownloadType())) {
exportTableDetails(request, wb, cellStyle, detailsSheet);
} else {
Boolean mergeHead = false;
@ -542,7 +544,7 @@ public class ExportCenterService {
}
wb.close();
if (ObjectUtils.isNotEmpty(AuthUtils.getUser())) {
if (ObjectUtils.isNotEmpty(currentUserDto)) {
String viewId = request.getViewId();
ChartViewWithBLOBs chartViewWithBLOBs = chartViewService.get(viewId);
String pid = chartViewWithBLOBs.getSceneId();
@ -1342,6 +1344,7 @@ public class ExportCenterService {
map.put("data", jsonArray);
return map;
}
private static final String LOG_RETENTION = "30";
public void cleanLog() {