From 8d4922d88a1fd800bb63bb07716603ca76b93243 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 5 Mar 2025 15:03:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E3=80=91=E6=95=B0=E6=8D=AE=E6=BA=90=E6=96=B0=E5=A2=9E=E5=AF=B9?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=20Excel/CSV=20=E7=9A=84=E6=94=AF=E6=8C=81=20?= =?UTF-8?q?#14681?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/server/DatasourceServer.java | 7 ++++--- .../java/io/dataease/utils/HttpClientUtil.java | 17 +++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java index 3f59d2509c..0df75f36db 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java @@ -115,6 +115,8 @@ public class DatasourceServer implements DatasourceApi { all_scope, add_scope } + public static final List notFullDs = List.of("folder", "Excel", "API"); + private TypeReference> listTypeReference = new TypeReference>() { }; @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); } diff --git a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java index 1f8b91707d..7a23d6bd25 100755 --- a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java +++ b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java @@ -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);