mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix: 【数据源】数据源新增对远程 Excel/CSV 的支持 #14681
This commit is contained in:
@@ -115,6 +115,8 @@ public class DatasourceServer implements DatasourceApi {
|
||||
all_scope, add_scope
|
||||
}
|
||||
|
||||
public static final List<String> notFullDs = List.of("folder", "Excel", "API");
|
||||
|
||||
private TypeReference<List<ApiDefinition>> listTypeReference = new TypeReference<List<ApiDefinition>>() {
|
||||
};
|
||||
@Resource
|
||||
@@ -152,7 +154,7 @@ public class DatasourceServer implements DatasourceApi {
|
||||
DatasourceConfiguration configuration = JsonUtil.parseObject(dataSourceDTO.getConfiguration(), DatasourceConfiguration.class);
|
||||
boolean hasRepeat = false;
|
||||
for (CoreDatasource datasource : datasources) {
|
||||
if (Arrays.asList("API", "Excel", "folder").contains(datasource.getType())) {
|
||||
if (notFullDs.stream().anyMatch(e -> datasource.getType().contains(e))) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isEmpty(datasource.getConfiguration())) {
|
||||
@@ -699,9 +701,8 @@ public class DatasourceServer implements DatasourceApi {
|
||||
|
||||
datasourceTaskServer.deleteByDSId(datasourceId);
|
||||
}
|
||||
|
||||
datasourceMapper.deleteById(datasourceId);
|
||||
if (!Arrays.asList("API", "Excel", "folder", "APILark", "ExcelRemote").contains(coreDatasource.getType())) {
|
||||
if (notFullDs.stream().allMatch(e -> !coreDatasource.getType().contains(e))) {
|
||||
calciteProvider.delete(coreDatasource);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class HttpClientUtil {
|
||||
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static CloseableHttpClient buildHttpClient(boolean ssl) {
|
||||
try {
|
||||
if (ssl) {
|
||||
@@ -381,17 +382,13 @@ public class HttpClientUtil {
|
||||
String tranName = UUID.randomUUID().toString() + "." + suffix;
|
||||
name.put("fileName", fileName);
|
||||
name.put("tranName", tranName);
|
||||
try {
|
||||
FileOutputStream outputStream = new FileOutputStream(path + tranName);
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} finally {
|
||||
|
||||
File localFile = new File(path + tranName);
|
||||
FileOutputStream outputStream = new FileOutputStream(localFile);
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("HttpClient查询失败", e);
|
||||
throw new RuntimeException("HttpClient查询失败: " + e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user