Pr@dev v2@fixds (#15339)

* fix:校验excel数据源失败

* fix:处理csv空文件异常

---------

Co-authored-by: taojinlong <jinlong@fit2cloud.com>
This commit is contained in:
taojinlong
2025-03-13 10:21:19 +08:00
committed by GitHub
parent 58724fab74
commit 7a89995262
2 changed files with 19 additions and 17 deletions

View File

@@ -668,21 +668,23 @@ public class ExcelUtils {
List<TableField> fields = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
String s = reader.readLine();// first line
String[] split = s.split(",");
for (int i = 0; i < split.length; i++) {
String filedName = split[i];
if (StringUtils.isEmpty(filedName)) {
DEException.throwException(Translator.get("i18n_excel_error_first_row"));
if(StringUtils.isNotEmpty(s)){
String[] split = s.split(",");
for (int i = 0; i < split.length; i++) {
String filedName = split[i];
if (StringUtils.isEmpty(filedName)) {
DEException.throwException(Translator.get("i18n_excel_error_first_row"));
}
if (filedName.startsWith(UFEFF)) {
filedName = filedName.replace(UFEFF, "");
}
TableField tableFiled = new TableField();
tableFiled.setName(filedName);
tableFiled.setOriginName(filedName);
tableFiled.setFieldType(null);
tableFiled.setChecked(true);
fields.add(tableFiled);
}
if (filedName.startsWith(UFEFF)) {
filedName = filedName.replace(UFEFF, "");
}
TableField tableFiled = new TableField();
tableFiled.setName(filedName);
tableFiled.setOriginName(filedName);
tableFiled.setFieldType(null);
tableFiled.setChecked(true);
fields.add(tableFiled);
}
List<String[]> data = csvData(reader, isPreview, fields.size());
@@ -734,7 +736,7 @@ public class ExcelUtils {
return excelSheetDataList;
}
private static Map<String, String> downLoadFromFtp(ExcelConfiguration remoteExcelRequest) {
public static Map<String, String> downLoadFromFtp(ExcelConfiguration remoteExcelRequest) {
Map<String, String> fileNames = new HashMap<>();
String username = "";
String password = "";

View File

@@ -399,8 +399,8 @@ const doValidateDs = request => {
let excelRequest = JSON.parse(JSON.stringify(form2.configuration))
excelRequest.datasourceId = form2.id || 0
excelRequest.editType = form2.editType
excelRequest.userName = Base64.encode(request.userName)
excelRequest.passwd = Base64.encode(request.passwd)
excelRequest.userName = Base64.encode(excelRequest.userName)
excelRequest.passwd = Base64.encode(excelRequest.passwd)
return loadRemoteFile(excelRequest)
.then(res => {
dsLoading.value = false