generateGraph功能优化
parent
3f8643b7a0
commit
9a45ed30cc
@ -0,0 +1,6 @@
|
||||
package com.supervision.pdfqaserver.service;
|
||||
|
||||
public interface TaskService {
|
||||
|
||||
void submitGenerateTask(Integer pdfId);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.supervision.pdfqaserver.service.impl;
|
||||
|
||||
import com.supervision.pdfqaserver.service.KnowledgeGraphService;
|
||||
import com.supervision.pdfqaserver.service.PdfInfoService;
|
||||
import com.supervision.pdfqaserver.service.TaskService;
|
||||
import com.supervision.pdfqaserver.thread.KnowledgeGraphGenerateTreadPool;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TaskServiceImpl implements TaskService {
|
||||
|
||||
private final PdfInfoService pdfInfoService;
|
||||
|
||||
private final KnowledgeGraphService knowledgeGraphService;
|
||||
public void submitGenerateTask(Integer pdfId) {
|
||||
// 提交生成图任务
|
||||
log.info("submitGenerateTask:提交知识图谱生成任务,pdfId:{}", pdfId);
|
||||
KnowledgeGraphGenerateTreadPool.executorService.execute(() -> {
|
||||
try {
|
||||
pdfInfoService.pdfToGraphStart(pdfId);
|
||||
knowledgeGraphService.generateGraph(String.valueOf(pdfId));
|
||||
pdfInfoService.pdfToGraphComplete(pdfId);
|
||||
} catch (Exception e) {
|
||||
log.error("生成知识图谱失败,documentId:{}", pdfId, e);
|
||||
pdfInfoService.pdfToGraphFail(pdfId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue