|
|
|
@ -186,7 +186,7 @@ public class RegenerateQuestionDomainServiceImpl implements RegenerateQuestionDo |
|
|
|
log.info(">>> [经典套题-重新生题-异步][备用池] 直接替换成功, paperQuestionId={}, newQuestionId={}", |
|
|
|
paperQuestionId, spareQuestion.getId()); |
|
|
|
} |
|
|
|
return; // 直接返回,前端通过 getDetail 刷新
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 1. 前置校验(快速失败,不占用异步线程)
|
|
|
|
@ -218,7 +218,11 @@ public class RegenerateQuestionDomainServiceImpl implements RegenerateQuestionDo |
|
|
|
taskEntity.setStatus(0); // 进行中
|
|
|
|
regenerateQuestionTaskBaseService.save(taskEntity); |
|
|
|
|
|
|
|
// 4. 异步执行重新生题逻辑
|
|
|
|
// 4. 清空 questionId,让回调走提拔分支
|
|
|
|
paperQuestion.setQuestionId(null); |
|
|
|
classicPaperQuestionBaseService.updateById(paperQuestion); |
|
|
|
|
|
|
|
// 5. 异步执行重新生题逻辑(回调会提拔新题 + 更新 task 状态)
|
|
|
|
CompletableFuture.runAsync(() -> doRegenerateAsync(taskId, paperQuestionId), regenerateExecutor); |
|
|
|
|
|
|
|
log.info(">>> [经典套题-重新生题-异步] 任务已提交, taskId={}, paperId={}, paperQuestionId={}", taskId, paperId, paperQuestionId); |
|
|
|
@ -242,11 +246,7 @@ public class RegenerateQuestionDomainServiceImpl implements RegenerateQuestionDo |
|
|
|
throw new BusinessErrorException("关联知识点数据不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 清空 questionId,让回调走提拔分支
|
|
|
|
paperQuestion.setQuestionId(null); |
|
|
|
classicPaperQuestionBaseService.updateById(paperQuestion); |
|
|
|
|
|
|
|
// 4. 异步提交生题任务(回调会提拔新题 + 更新 task 状态)
|
|
|
|
// 异步提交生题任务(回调会提拔新题 + 更新 task 状态)
|
|
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(originalQuestion.getQuestionType()); |
|
|
|
Long clusterId = knowledgePoints.get(0).getClusterId(); |
|
|
|
classicPaperQuestionGenerator.generateAsync( |
|
|
|
@ -256,31 +256,37 @@ public class RegenerateQuestionDomainServiceImpl implements RegenerateQuestionDo |
|
|
|
taskId, paperQuestionId, questionType); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(">>> [经典套题-重新生题-异步] 提交失败, taskId={}", taskId, e); |
|
|
|
RegenerateQuestionTaskEntity taskEntity = regenerateQuestionTaskBaseService.getOne( |
|
|
|
new LambdaQueryWrapper<RegenerateQuestionTaskEntity>() |
|
|
|
.eq(RegenerateQuestionTaskEntity::getTaskId, taskId)); |
|
|
|
if (taskEntity != null) { |
|
|
|
taskEntity.setStatus(2); |
|
|
|
taskEntity.setErrorMessage(e.getMessage()); |
|
|
|
regenerateQuestionTaskBaseService.updateById(taskEntity); |
|
|
|
try { |
|
|
|
RegenerateQuestionTaskEntity taskEntity = regenerateQuestionTaskBaseService.getOne( |
|
|
|
new LambdaQueryWrapper<RegenerateQuestionTaskEntity>() |
|
|
|
.eq(RegenerateQuestionTaskEntity::getTaskId, taskId) |
|
|
|
.last("LIMIT 1")); |
|
|
|
if (taskEntity != null) { |
|
|
|
taskEntity.setStatus(2); |
|
|
|
taskEntity.setErrorMessage(e.getMessage()); |
|
|
|
regenerateQuestionTaskBaseService.updateById(taskEntity); |
|
|
|
} |
|
|
|
} catch (Exception dbError) { |
|
|
|
log.error(">>> [经典套题-重新生题-异步] 更新任务状态失败, taskId={}", taskId, dbError); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> getTaskStatus(Long paperQuestionId) { |
|
|
|
RegenerateQuestionTaskEntity taskEntity = regenerateQuestionTaskBaseService.getOne( |
|
|
|
new LambdaQueryWrapper<RegenerateQuestionTaskEntity>() |
|
|
|
.eq(RegenerateQuestionTaskEntity::getPaperQuestionId, paperQuestionId) |
|
|
|
.orderByDesc(RegenerateQuestionTaskEntity::getCreateTime) |
|
|
|
.last("LIMIT 1")); |
|
|
|
if (taskEntity == null) { |
|
|
|
ClassicPaperQuestionEntity paperQuestion = classicPaperQuestionBaseService.getById(paperQuestionId); |
|
|
|
if (paperQuestion == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
Map<String, Object> result = new java.util.HashMap<>(); |
|
|
|
result.put("status", taskEntity.getStatus()); |
|
|
|
result.put("newQuestionId", taskEntity.getNewQuestionId()); |
|
|
|
result.put("errorMessage", taskEntity.getErrorMessage()); |
|
|
|
if (paperQuestion.getQuestionId() != null) { |
|
|
|
result.put("status", 1); // 成功
|
|
|
|
result.put("newQuestionId", paperQuestion.getQuestionId()); |
|
|
|
} else { |
|
|
|
result.put("status", 0); // 进行中
|
|
|
|
result.put("newQuestionId", null); |
|
|
|
} |
|
|
|
result.put("errorMessage", null); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@ -372,7 +378,7 @@ public class RegenerateQuestionDomainServiceImpl implements RegenerateQuestionDo |
|
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(original.getQuestionType()); |
|
|
|
|
|
|
|
classicPaperQuestionGenerator.generateAsync( |
|
|
|
paperQuestionId, kps, questionType, replenishCount, null); |
|
|
|
paperQuestionId, kps, questionType, replenishCount, kps.get(0).getClusterId()); |
|
|
|
log.info(">>> [备用补充] 已提交补充任务, paperQuestionId={}, 数量={}", |
|
|
|
paperQuestionId, replenishCount); |
|
|
|
} catch (Exception e) { |
|
|
|
|