Browse Source

数据回调

master
luoweijian 2 months ago
parent
commit
02ada6fec5
  1. 4
      src/main/java/com/project/interaction/controller/InteractionController.java
  2. 25
      src/main/java/com/project/interaction/domain/service/impl/SaveDataExtractResultDomainServiceImpl.java

4
src/main/java/com/project/interaction/controller/InteractionController.java

@ -98,7 +98,7 @@ public class InteractionController {
* 每个子文件解析完成后回调检查批次是否全部完成
*/
@PostMapping("/dataExtractCallback")
public Result<String> dataExtractCallback(DataExtractCallbackDTO dto) {
public Result<String> dataExtractCallback(@RequestBody DataExtractCallbackDTO dto) {
dataExtractCallbackApplicationService.handleCallback(dto);
return Result.success("回调处理成功");
}
@ -108,7 +108,7 @@ public class InteractionController {
* 算法服务返回草稿知识点写入草稿表
*/
@PostMapping("/aiExtractCallback")
public Result<String> aiExtractCallback(AiExtractCallbackDTO dto) {
public Result<String> aiExtractCallback(@RequestBody AiExtractCallbackDTO dto) {
aiExtractCallbackApplicationService.handleCallback(dto);
return Result.success("回调处理成功");
}

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

@ -48,13 +48,7 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe
}
informationFileBaseService.updateById(file);
// 2. 解析失败则记录日志
if (!FileParseStatusEnum.Success.getValue().equals(callback.getParseStatus())) {
log.warn(">>> [数据服务回调] 子文件解析失败, fileId={}, error={}", fileId, callback.getErrorMsg());
return;
}
// 3. 检查该虚拟资料下所有子文件是否全部完成
// 2. 检查该虚拟资料下所有子文件是否全部到达终态(Success 或 Failed)
List<InformationFileEntity> allFiles = informationFileBaseService.list(
new LambdaQueryWrapper<InformationFileEntity>()
.eq(InformationFileEntity::getInformationId, informationId));
@ -68,12 +62,21 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe
return;
}
// 4. 全部完成 → 调用算法服务知识点提取
log.info(">>> [数据服务回调] 虚拟资料 {} 下所有子文件解析完成,开始调用算法服务", informationId);
// 3. 所有子文件均已到达终态
boolean allSuccess = allFiles.stream()
.allMatch(f -> FileParseStatusEnum.Success.getValue().equals(f.getParseStatus()));
if (!allSuccess) {
log.warn(">>> [数据服务回调] 虚拟资料 {} 下存在解析失败的子文件,跳过算法调用", informationId);
return;
}
// 4. 全部成功 → 调用算法服务知识点提取
log.info(">>> [数据服务回调] 虚拟资料 {} 下所有子文件解析成功,开始调用算法服务", informationId);
List<AiExtractRequestDTO.FileContent> fileContents = new ArrayList<>();
for (InformationFileEntity f : allFiles) {
if (FileParseStatusEnum.Success.getValue().equals(f.getParseStatus()) && f.getParsedText() != null) {
if (f.getParsedText() != null) {
AiExtractRequestDTO.FileContent fc = new AiExtractRequestDTO.FileContent();
fc.setFileName(f.getFileName());
fc.setContentCategory(String.valueOf(f.getContentCategory()));
@ -83,7 +86,7 @@ public class SaveDataExtractResultDomainServiceImpl implements SaveDataExtractRe
}
if (fileContents.isEmpty()) {
log.warn(">>> [数据服务回调] 虚拟资料 {} 下没有成功解析的子文件", informationId);
log.warn(">>> [数据服务回调] 虚拟资料 {} 下所有子文件已解析成功但 parsedText 均为空", informationId);
return;
}

Loading…
Cancel
Save