feat: 拆分记录上下文与内容归属并把报告改为结构化
This commit is contained in:
+17
-19
@@ -36,9 +36,8 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
private final ReviewStandardMindMapMapper standardMindMapMapper;
|
||||
private final ReviewRecallRecordMapper recallRecordMapper;
|
||||
private final TasksMapper tasksMapper;
|
||||
private final StudyReportsMapper studyReportsMapper;
|
||||
private final TaskApplicationMapper taskApplicationMapper;
|
||||
private final StudySessionsMapper studySessionsMapper;
|
||||
private final StudyReportFragmentsMapper studyReportFragmentsMapper;
|
||||
|
||||
private final List<MindMapAiClient> aiClients;
|
||||
private final ObjectMapper objectMapper;
|
||||
@@ -415,22 +414,18 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
throw new OperationFailedException("这个任务不存在或已被删除");
|
||||
}
|
||||
|
||||
// 收集学习数据
|
||||
List<String> sessionNums = studySessionsMapper.selectList(
|
||||
Wrappers.<StudySessionsEntity>lambdaQuery()
|
||||
.eq(StudySessionsEntity::getTaskNum, taskNum)
|
||||
.select(StudySessionsEntity::getSessionNum))
|
||||
.stream().map(StudySessionsEntity::getSessionNum).collect(Collectors.toList());
|
||||
|
||||
List<StudyReportsEntity> reports = sessionNums.isEmpty() ? List.of()
|
||||
: studyReportsMapper.selectList(Wrappers.<StudyReportsEntity>lambdaQuery()
|
||||
.in(StudyReportsEntity::getSessionNum, sessionNums));
|
||||
// 素材按**内容归属**取:该任务名下的知识碎片(归属-01)。
|
||||
// 不再按「任务的会话里的报告」取,否则学 A 时记录的旁支知识会错误地进入 A 的导图。
|
||||
List<StudyReportFragmentsEntity> fragments = studyReportFragmentsMapper.selectList(
|
||||
Wrappers.<StudyReportFragmentsEntity>lambdaQuery()
|
||||
.eq(StudyReportFragmentsEntity::getOwnerTaskNum, taskNum)
|
||||
.orderByAsc(StudyReportFragmentsEntity::getCreatedTime));
|
||||
List<TaskApplicationEntity> applications = taskApplicationMapper.selectList(
|
||||
Wrappers.<TaskApplicationEntity>lambdaQuery().eq(TaskApplicationEntity::getTaskNum, taskNum));
|
||||
|
||||
if (reports.isEmpty()) {
|
||||
log.warn("任务[{}]没有学习报告,无法生成思维导图", taskNum);
|
||||
throw new OperationFailedException("这个任务还没开始学习哦,学习后产生学习报告后再来吧");
|
||||
if (fragments.isEmpty()) {
|
||||
log.warn("任务[{}]没有归属到它的知识碎片,无法生成思维导图", taskNum);
|
||||
throw new OperationFailedException("这个任务还没开始学习哦,学习后产生知识碎片后再来吧");
|
||||
}
|
||||
|
||||
// 优先选 AI 客户端(非 BUILTIN),其次内置生成器
|
||||
@@ -444,7 +439,7 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
throw new OperationFailedException("思维导图暂时生成不了,请稍后再试");
|
||||
}
|
||||
|
||||
Optional<MindMapNode> optRoot = client.generate(task, reports, applications, null);
|
||||
Optional<MindMapNode> optRoot = client.generate(task, fragments, applications, null);
|
||||
// AI 生成失败时尝试降级到内置生成器
|
||||
if (optRoot.isEmpty() && !"BUILTIN".equals(client.generatorName())) {
|
||||
log.info("AI 思维导图生成失败,降级到内置生成器");
|
||||
@@ -452,7 +447,7 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
.filter(c -> "BUILTIN".equals(c.generatorName()) && c.isAvailable())
|
||||
.findFirst().orElse(null);
|
||||
if (fallback != null) {
|
||||
optRoot = fallback.generate(task, reports, applications, null);
|
||||
optRoot = fallback.generate(task, fragments, applications, null);
|
||||
}
|
||||
}
|
||||
if (optRoot.isEmpty()) {
|
||||
@@ -479,9 +474,12 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
entity.setSummary("共 " + nodeCount + " 个节点,最大层级 " + depth);
|
||||
entity.setGenerator(client.generatorName());
|
||||
entity.setGeneratorVersion("1.0");
|
||||
entity.setSourceReportCount(reports.size());
|
||||
entity.setSourceFragmentCount(0);
|
||||
entity.setSourceReportCount(0);
|
||||
entity.setSourceFragmentCount(fragments.size());
|
||||
entity.setGeneratedTime(LocalDateTime.now());
|
||||
// 重建完成后清除「待更新」标记
|
||||
entity.setNeedsUpdate(false);
|
||||
entity.setNeedsUpdateTime(null);
|
||||
|
||||
if (create) {
|
||||
standardMindMapMapper.insert(entity);
|
||||
|
||||
Reference in New Issue
Block a user