优化代码
This commit is contained in:
parent
815bf60b65
commit
0a75c9c773
|
|
@ -114,12 +114,9 @@ public class ChatService {
|
|||
}
|
||||
case "xls", "xlsx" -> {
|
||||
String filePath = elePropertyConfig.getEleTmpPath() + File.separator + fileMd5 + "." + fileType;
|
||||
List<PageFile> pageInfo;
|
||||
if (StrUtil.equals("xlsx", filePath)) {
|
||||
pageInfo = OfficeFileUtil.parseXlsxByPage(filePath);
|
||||
} else {
|
||||
pageInfo = OfficeFileUtil.parseXlsByPage(filePath);
|
||||
}
|
||||
List<PageFile> pageInfo = StrUtil.equals("xlsx", filePath) ?
|
||||
OfficeFileUtil.parseXlsxByPage(filePath) :
|
||||
OfficeFileUtil.parseXlsByPage(filePath);
|
||||
for (PageFile pageFile : pageInfo) {
|
||||
Map<String, Object> metaData = Map.of("page_number", pageFile.getPageNumber(), "file_name", file.getOriginalFilename());
|
||||
Document document = new Document(pageFile.getContent(), metaData);
|
||||
|
|
@ -157,7 +154,8 @@ public class ChatService {
|
|||
documents = documents.subList(0, Math.min(elePropertyConfig.getAiMaxDocs(), documents.size()));
|
||||
vectorStore.write(documents);
|
||||
for (Document document : documents) {
|
||||
aiFileUploadRecordMapper.insert(new AiFileUploadRecord().setId(IdWorker.getSnowFlakeIdString())
|
||||
aiFileUploadRecordMapper.insert(new AiFileUploadRecord()
|
||||
.setId(IdWorker.getSnowFlakeIdString())
|
||||
.setVectorId(document.getId())
|
||||
.setFileSize(file.getSize())
|
||||
.setFileMd5(fileMd5)
|
||||
|
|
|
|||
Loading…
Reference in New Issue