|
|
@ -83,17 +83,14 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe |
|
|
boolean allSuccess = allFiles.stream() |
|
|
boolean allSuccess = allFiles.stream() |
|
|
.allMatch(f -> FileParseStatusEnum.Success.getValue().equals(f.getParseStatus())); |
|
|
.allMatch(f -> FileParseStatusEnum.Success.getValue().equals(f.getParseStatus())); |
|
|
|
|
|
|
|
|
// 更新虚拟资料的解析状态(无论成功或失败都更新)
|
|
|
if (!allSuccess) { |
|
|
|
|
|
// 更新虚拟资料的解析状态为失败
|
|
|
InformationEntity information = informationBaseService.getById(informationId); |
|
|
InformationEntity information = informationBaseService.getById(informationId); |
|
|
if (information != null) { |
|
|
if (information != null) { |
|
|
information.setParseStatus(allSuccess |
|
|
information.setParseStatus(InformationParseStatusEnum.Fail.getValue()); |
|
|
? InformationParseStatusEnum.Success.getValue() |
|
|
|
|
|
: InformationParseStatusEnum.Fail.getValue()); |
|
|
|
|
|
informationBaseService.updateById(information); |
|
|
informationBaseService.updateById(information); |
|
|
log.info(">>> [数据服务回调] 虚拟资料 {} 解析状态已更新为: {}", informationId, information.getParseStatus()); |
|
|
log.info(">>> [数据服务回调] 虚拟资料 {} 解析状态已更新为: 失败", informationId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!allSuccess) { |
|
|
|
|
|
log.warn(">>> [数据服务回调] 虚拟资料 {} 下存在解析失败的子文件,跳过算法调用", informationId); |
|
|
log.warn(">>> [数据服务回调] 虚拟资料 {} 下存在解析失败的子文件,跳过算法调用", informationId); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -125,16 +122,19 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe |
|
|
// 解析 parsed_text JSON: {"segments": [[{"content": "...", "supplement": "", "chapter": "...", "content_type": "..."}]]}
|
|
|
// 解析 parsed_text JSON: {"segments": [[{"content": "...", "supplement": "", "chapter": "...", "content_type": "..."}]]}
|
|
|
// segments 是双层数组:外层=每个子文件,内层=该文件的段落列表
|
|
|
// segments 是双层数组:外层=每个子文件,内层=该文件的段落列表
|
|
|
try { |
|
|
try { |
|
|
Map<String, List<List<Map<String, String>>>> parsed = objectMapper.readValue( |
|
|
// 1. 将 TypeReference 改为单层 List: List<Map<String, String>>
|
|
|
f.getParsedText(), new TypeReference<>() { |
|
|
Map<String, List<Map<String, String>>> parsed = objectMapper.readValue( |
|
|
|
|
|
f.getParsedText(), new TypeReference<Map<String, List<Map<String, String>>>>() { |
|
|
}); |
|
|
}); |
|
|
List<List<Map<String, String>>> fileGroups = parsed.get("segments"); |
|
|
|
|
|
if (fileGroups == null || fileGroups.isEmpty()) { |
|
|
List<Map<String, String>> segments = parsed.get("segments"); |
|
|
|
|
|
if (segments == null || segments.isEmpty()) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
String fileName = f.getFileName(); |
|
|
String fileName = f.getFileName(); |
|
|
for (List<Map<String, String>> group : fileGroups) { |
|
|
|
|
|
for (Map<String, String> seg : group) { |
|
|
// 2. 去掉双层循环,直接遍历单层 List
|
|
|
|
|
|
for (Map<String, String> seg : segments) { |
|
|
AiExtractRequestDTO.Segment segment = new AiExtractRequestDTO.Segment(); |
|
|
AiExtractRequestDTO.Segment segment = new AiExtractRequestDTO.Segment(); |
|
|
segment.setContent(seg.get("content")); |
|
|
segment.setContent(seg.get("content")); |
|
|
segment.setSupplement(seg.get("supplement")); |
|
|
segment.setSupplement(seg.get("supplement")); |
|
|
@ -143,7 +143,6 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe |
|
|
segment.setContentType(seg.get("content_type")); |
|
|
segment.setContentType(seg.get("content_type")); |
|
|
allSegments.add(segment); |
|
|
allSegments.add(segment); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error(">>> [数据服务] 解析 parsedText 失败, fileId={}, error={}", f.getId(), e.getMessage()); |
|
|
log.error(">>> [数据服务] 解析 parsedText 失败, fileId={}, error={}", f.getId(), e.getMessage()); |
|
|
} |
|
|
} |
|
|
|