feat: 支持知识库 CSV 大文件导入

- 增加 CSV 流式解析、表格语义分块和分页预览

- 增加快照两阶段清理、失败重试和格式校验

- 补充批量入口、管理端交互和回归测试
This commit is contained in:
2026-08-07 13:11:59 +08:00
parent 13dec6c216
commit 0d14f1c165
32 changed files with 5672 additions and 156 deletions

View File

@@ -4,6 +4,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
public class FileUtil {
@@ -33,23 +34,34 @@ public class FileUtil {
}
/**
* 按文件名提取平台支持的文档扩展名。
*
* @param fileName 文件名或文件路径
* @return 小写扩展名;无法识别时返回 {@code null}
*/
public static String getFileTypeByExtension(String fileName) {
if (fileName.endsWith(".txt")) {
return "txt";
} else if (fileName.endsWith(".pdf")) {
return "pdf";
} else if (fileName.endsWith(".md")) {
return "md";
} else if (fileName.endsWith(".docx")) {
return "docx";
} else if (fileName.endsWith(".xlsx")) {
return "xlsx";
} else if (fileName.endsWith(".ppt")) {
return "ppt";
} else if (fileName.endsWith(".pptx")) {
return "pptx";
if (fileName == null) {
return null;
}
else {
String normalizedFileName = fileName.toLowerCase(Locale.ROOT);
if (normalizedFileName.endsWith(".txt")) {
return "txt";
} else if (normalizedFileName.endsWith(".pdf")) {
return "pdf";
} else if (normalizedFileName.endsWith(".md")) {
return "md";
} else if (normalizedFileName.endsWith(".docx")) {
return "docx";
} else if (normalizedFileName.endsWith(".xlsx")) {
return "xlsx";
} else if (normalizedFileName.endsWith(".csv")) {
return "csv";
} else if (normalizedFileName.endsWith(".ppt")) {
return "ppt";
} else if (normalizedFileName.endsWith(".pptx")) {
return "pptx";
} else {
return null;
}
}