Browse Source

bug修复

master
luoweijian 2 months ago
parent
commit
082b90b32c
  1. 9
      src/main/java/com/project/interaction/domain/service/impl/SaveAiExtractDraftDomainServiceImpl.java
  2. 27
      src/main/java/com/project/interaction/domain/service/impl/SaveDataExtractResultDomainServiceImpl.java

9
src/main/java/com/project/interaction/domain/service/impl/SaveAiExtractDraftDomainServiceImpl.java

@ -4,6 +4,7 @@ import com.project.information.domain.entity.InformationEntity;
import com.project.information.domain.entity.KnowledgePointDraftEntity; import com.project.information.domain.entity.KnowledgePointDraftEntity;
import com.project.information.domain.enums.AuditStatusEnum; import com.project.information.domain.enums.AuditStatusEnum;
import com.project.information.domain.enums.DraftStatusEnum; import com.project.information.domain.enums.DraftStatusEnum;
import com.project.information.domain.enums.InformationParseStatusEnum;
import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.InformationBaseService;
import com.project.information.domain.service.KnowledgePointDraftBaseService; import com.project.information.domain.service.KnowledgePointDraftBaseService;
import com.project.interaction.domain.dto.AiExtractCallbackDTO; import com.project.interaction.domain.dto.AiExtractCallbackDTO;
@ -57,7 +58,13 @@ public class SaveAiExtractDraftDomainServiceImpl implements SaveAiExtractDraftDo
} }
knowledgePointDraftBaseService.saveBatch(draftEntities); knowledgePointDraftBaseService.saveBatch(draftEntities);
// 2. 更新虚拟资料 draftStatus = PENDING(1) // 2. 更新虚拟资料解析状态 = 成功
informationBaseService.lambdaUpdate()
.eq(InformationEntity::getId, informationId)
.set(InformationEntity::getParseStatus, InformationParseStatusEnum.Success.getValue())
.update();
// 3. 更新虚拟资料 draftStatus = PENDING(1)
informationBaseService.lambdaUpdate() informationBaseService.lambdaUpdate()
.eq(InformationEntity::getId, informationId) .eq(InformationEntity::getId, informationId)
.set(InformationEntity::getDraftStatus, DraftStatusEnum.PENDING.getValue()) .set(InformationEntity::getDraftStatus, DraftStatusEnum.PENDING.getValue())

27
src/main/java/com/project/interaction/domain/service/impl/SaveDataExtractResultDomainServiceImpl.java

@ -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());
} }

Loading…
Cancel
Save