fix:远程excel后台信息国际化

This commit is contained in:
taojinlong
2025-03-12 16:45:16 +08:00
committed by 王嘉豪
parent a0c675cc8c
commit 7df7a4f460
4 changed files with 25 additions and 8 deletions

View File

@@ -22,11 +22,10 @@ import io.dataease.extensions.datasource.dto.DatasourceDTO;
import io.dataease.extensions.datasource.dto.DatasourceRequest;
import io.dataease.extensions.datasource.dto.TableField;
import io.dataease.api.ds.vo.ExcelConfiguration;
import io.dataease.i18n.Translator;
import io.dataease.utils.*;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -435,7 +434,7 @@ public class ExcelUtils {
} else if (remoteExcelRequest.getUrl().trim().startsWith("ftp")) {
fileNames = downLoadFromFtp(remoteExcelRequest);
} else {
DEException.throwException("不支持的协议!");
DEException.throwException(Translator.get("i18n_unsupported_protocol"));
}
return fileNames;
}
@@ -671,7 +670,7 @@ public class ExcelUtils {
for (int i = 0; i < split.length; i++) {
String filedName = split[i];
if (StringUtils.isEmpty(filedName)) {
DEException.throwException("首行行中不允许有空单元格!");
DEException.throwException(Translator.get("i18n_excel_error_first_row"));
}
if (filedName.startsWith(UFEFF)) {
filedName = filedName.replace(UFEFF, "");
@@ -749,7 +748,7 @@ public class ExcelUtils {
serverAddress = matcher.group(3);
filePath = matcher.group(4);
} else {
DEException.throwException("无效的地址!");
DEException.throwException(Translator.get("i18n_invalid_address"));
}
} else {
String regex = "ftp://([^/]+)(.*)";
@@ -759,13 +758,13 @@ public class ExcelUtils {
serverAddress = matcher.group(1);
filePath = matcher.group(2);
} else {
DEException.throwException("无效的地址!");
DEException.throwException(Translator.get("i18n_invalid_address"));
}
}
filePath = filePath.startsWith("/") ? filePath.substring(1) : filePath;
String suffix = filePath.substring(filePath.lastIndexOf(".") + 1);
if (!Arrays.asList("csv", "xlsx", "xls").contains(suffix)) {
DEException.throwException("不支持的文件格式!");
DEException.throwException(Translator.get("i18n_unsupported_file_format"));
}
String tranName = UUID.randomUUID().toString() + "." + suffix;
String localFilePath = path + tranName;
@@ -781,7 +780,7 @@ public class ExcelUtils {
Process process = Runtime.getRuntime().exec(command);
int exitValue = process.waitFor();
if (exitValue != 0) {
DEException.throwException("文件下载失败!");
DEException.throwException(Translator.get("i18n_file_download_failed"));
}
} catch (IOException e) {
e.printStackTrace();

View File

@@ -203,3 +203,9 @@ i18n_user_new_pwd_error=Password format: 8-20 characters and must include at lea
i18n_user_pwd_same_error=Old and new passwords cannot be the same
i18n_copilot_ds=Only supports MySQL datasource
i18n_file_download_failed=File download failed!
i18n_unsupported_file_format=Unsupported file format!
i18n_invalid_address=Invalid address!
i18n_unsupported_protocol=Unsupported protocol!
i18n_excel_error_first_row=Empty cells are not allowed in the middle of the first row!

View File

@@ -202,3 +202,9 @@ i18n_user_new_pwd_error=\u5BC6\u7801\u683C\u5F0F\uFF1A8-20\u4F4D\u4E14\u81F3\u5C
i18n_user_pwd_same_error=\u65B0\u65E7\u5BC6\u7801\u4E0D\u80FD\u76F8\u540C
i18n_copilot_ds=\u5F53\u524D\u4EC5\u652F\u6301MySQL\u6570\u636E\u6E90
i18n_file_download_failed=\u4e0b\u8f7d\u6587\u4ef6\u5931\u8d25\uff01
i18n_unsupported_file_format=\u4e0d\u652f\u6301\u7684\u6587\u4ef6\u683c\u5f0f\uff01
i18n_invalid_address=\u65e0\u6548\u7684\u5730\u5740\uff01
i18n_unsupported_protocol=\u4e0d\u652f\u6301\u7684\u534f\u8bae\uff01
i18n_excel_error_first_row=\u9996\u884c\u884c\u4e2d\u4e0d\u5141\u8bb8\u6709\u7a7a\u5355\u5143\u683c\uff01

View File

@@ -202,3 +202,9 @@ i18n_user_new_pwd_error=\u5BC6\u78BC\u683C\u5F0F\uFF1A8-20\u4F4D\u4E14\u81F3\u5C
i18n_user_pwd_same_error=\u65B0\u820A\u5BC6\u78BC\u4E0D\u80FD\u76F8\u540C
i18n_copilot_ds=\u7576\u524D\u50C5\u652F\u6301MySQL\u6578\u64DA\u6E90
i18n_file_download_failed=\u6587\u4ef6\u4e0b\u8f09\u5931\u6557\uff01
i18n_unsupported_file_format=\u4e0d\u652f\u63f4\u7684\u6587\u4ef6\u683c\u5f0f\uff01
i18n_invalid_address=\u7121\u6548\u7684\u5730\u5740\uff01
i18n_unsupported_protocol=\u4e0d\u652f\u63f4\u7684\u5354\u8b70\uff01
i18n_excel_error_first_row=\u9996\u884c\u884c\u4e2d\u4e0d\u5141\u8a31\u6709\u7a7a\u5132\u5b58\u683c\uff01