|
|
@ -61,7 +61,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
* 2. 如果算法服务失败,使用熔断降级方案生成默认题目 |
|
|
* 2. 如果算法服务失败,使用熔断降级方案生成默认题目 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void postToGenerateQuestion(List<TaskKnowledgePointDTO> dtoList, List<QuestionTypeEnum> questionTypeEnumList, int num) throws Exception { |
|
|
public void postToGenerateQuestion(List<TaskKnowledgePointDTO> dtoList, QuestionTypeEnum questionType, int num) throws Exception { |
|
|
Long taskId = Optional.of(dtoList.stream().findFirst()) |
|
|
Long taskId = Optional.of(dtoList.stream().findFirst()) |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getTaskId(); |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getTaskId(); |
|
|
Long clusterId = Optional.of(dtoList.stream().findFirst()) |
|
|
Long clusterId = Optional.of(dtoList.stream().findFirst()) |
|
|
@ -71,7 +71,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getAtomId()); |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getAtomId()); |
|
|
|
|
|
|
|
|
log.info(">>> [题目生成] 开始生成题目, TaskId: {}, ClusterId: {}, 题型: {}, 数量: {}", |
|
|
log.info(">>> [题目生成] 开始生成题目, TaskId: {}, ClusterId: {}, 题型: {}, 数量: {}", |
|
|
taskId, clusterId, questionTypeEnumList, num); |
|
|
taskId, clusterId, questionType, num); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
// 应用限流:获取令牌,超过限流速率则等待
|
|
|
// 应用限流:获取令牌,超过限流速率则等待
|
|
|
@ -83,7 +83,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//尝试调用算法服务生成题目
|
|
|
//尝试调用算法服务生成题目
|
|
|
GenerateQuestionResponseDTO response = callAlgorithmService(dtoList, questionTypeEnumList, num, knowledgePoint.getParseName()); |
|
|
GenerateQuestionResponseDTO response = callAlgorithmService(dtoList, questionType, num, knowledgePoint.getParseName()); |
|
|
|
|
|
|
|
|
if (response != null && StringUtils.isNotBlank(response.getMessage()) && response.getMessage().contains("success")) { |
|
|
if (response != null && StringUtils.isNotBlank(response.getMessage()) && response.getMessage().contains("success")) { |
|
|
log.info(">>> [题目生成] 算法服务接受任务成功, 任务: {}, 状态: {}, 信息:{}", |
|
|
log.info(">>> [题目生成] 算法服务接受任务成功, 任务: {}, 状态: {}, 信息:{}", |
|
|
@ -106,9 +106,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
/** |
|
|
/** |
|
|
* 调用算法服务生成题目 |
|
|
* 调用算法服务生成题目 |
|
|
*/ |
|
|
*/ |
|
|
private GenerateQuestionResponseDTO callAlgorithmService(List<TaskKnowledgePointDTO> dtoList, List<QuestionTypeEnum> questionTypeEnumList, int num,String parseName){ |
|
|
private GenerateQuestionResponseDTO callAlgorithmService(List<TaskKnowledgePointDTO> dtoList, QuestionTypeEnum questionType, int num,String parseName){ |
|
|
List<String> questionTypeEnumStringList = questionTypeEnumList.stream().map(QuestionTypeEnum::getDescription).toList(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取知识点内容
|
|
|
// 获取知识点内容
|
|
|
List<Long> kpIds = dtoList.stream().map(TaskKnowledgePointDTO::getId).collect(Collectors.toList()); |
|
|
List<Long> kpIds = dtoList.stream().map(TaskKnowledgePointDTO::getId).collect(Collectors.toList()); |
|
|
List<String> sourceTexts = dtoList.stream().map(TaskKnowledgePointDTO::getContent).collect(Collectors.toList()); |
|
|
List<String> sourceTexts = dtoList.stream().map(TaskKnowledgePointDTO::getContent).collect(Collectors.toList()); |
|
|
@ -126,7 +124,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
.sourceId(kpIds) |
|
|
.sourceId(kpIds) |
|
|
.build()) |
|
|
.build()) |
|
|
.numQuestions(num) |
|
|
.numQuestions(num) |
|
|
.questionTypes(questionTypeEnumStringList) |
|
|
.questionTypes(Collections.singletonList(questionType.name().toLowerCase())) |
|
|
.build(); |
|
|
.build(); |
|
|
|
|
|
|
|
|
// 调用算法服务
|
|
|
// 调用算法服务
|
|
|
|