|
|
@ -1,6 +1,8 @@ |
|
|
package com.project.interaction.domain.service.impl; |
|
|
package com.project.interaction.domain.service.impl; |
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
|
|
import com.project.information.domain.entity.KnowledgePointEntity; |
|
|
|
|
|
import com.project.information.domain.service.KnowledgePointBaseService; |
|
|
import com.project.interaction.domain.dto.GenerateQuestionRequestDTO; |
|
|
import com.project.interaction.domain.dto.GenerateQuestionRequestDTO; |
|
|
import com.project.interaction.domain.dto.GenerateQuestionResponseDTO; |
|
|
import com.project.interaction.domain.dto.GenerateQuestionResponseDTO; |
|
|
import com.project.interaction.domain.service.PostToGenerateQuestionDomainService; |
|
|
import com.project.interaction.domain.service.PostToGenerateQuestionDomainService; |
|
|
@ -41,6 +43,9 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
@Autowired |
|
|
@Autowired |
|
|
private QuestionGenerationRateLimiter rateLimiter; |
|
|
private QuestionGenerationRateLimiter rateLimiter; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private KnowledgePointBaseService knowledgePointBaseService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private NotifyUtil notifyUtil; |
|
|
private NotifyUtil notifyUtil; |
|
|
|
|
|
|
|
|
@ -62,6 +67,9 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
Long clusterId = Optional.of(dtoList.stream().findFirst()) |
|
|
Long clusterId = Optional.of(dtoList.stream().findFirst()) |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getClusterId(); |
|
|
.get().orElse(new TaskKnowledgePointDTO()).getClusterId(); |
|
|
|
|
|
|
|
|
|
|
|
KnowledgePointEntity knowledgePoint = knowledgePointBaseService.getById(Optional.of(dtoList.stream().findFirst()) |
|
|
|
|
|
.get().orElse(new TaskKnowledgePointDTO()).getAtomId()); |
|
|
|
|
|
|
|
|
log.info(">>> [题目生成] 开始生成题目, TaskId: {}, ClusterId: {}, 题型: {}, 数量: {}", |
|
|
log.info(">>> [题目生成] 开始生成题目, TaskId: {}, ClusterId: {}, 题型: {}, 数量: {}", |
|
|
taskId, clusterId, questionType.getDescription(), num); |
|
|
taskId, clusterId, questionType.getDescription(), num); |
|
|
|
|
|
|
|
|
@ -75,11 +83,12 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//尝试调用算法服务生成题目
|
|
|
//尝试调用算法服务生成题目
|
|
|
GenerateQuestionResponseDTO response = callAlgorithmService(dtoList, questionType, num); |
|
|
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(">>> [题目生成] 算法服务接受任务成功, 任务: {}, 状态: {}, 信息:{}", |
|
|
response.getTaskId(), response.getStatus(),response.getMessage()); |
|
|
response.getTaskId(), response.getStatus(),response.getMessage()); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -97,9 +106,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
/** |
|
|
/** |
|
|
* 调用算法服务生成题目 |
|
|
* 调用算法服务生成题目 |
|
|
*/ |
|
|
*/ |
|
|
private GenerateQuestionResponseDTO callAlgorithmService(List<TaskKnowledgePointDTO> dtoList, |
|
|
private GenerateQuestionResponseDTO callAlgorithmService(List<TaskKnowledgePointDTO> dtoList, QuestionTypeEnum questionType, int num,String parseName){ |
|
|
QuestionTypeEnum questionType, |
|
|
|
|
|
int num) { |
|
|
|
|
|
// 获取知识点内容
|
|
|
// 获取知识点内容
|
|
|
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()); |
|
|
@ -112,6 +119,7 @@ public class PostToGenerateQuestionDomainServiceImpl implements PostToGenerateQu |
|
|
.cluster(GenerateQuestionRequestDTO.ClusterInfo.builder() |
|
|
.cluster(GenerateQuestionRequestDTO.ClusterInfo.builder() |
|
|
.clusterId(clusterId) |
|
|
.clusterId(clusterId) |
|
|
.taskId(taskId) |
|
|
.taskId(taskId) |
|
|
|
|
|
.products(parseName) |
|
|
.sourceText(sourceTexts) |
|
|
.sourceText(sourceTexts) |
|
|
.sourceId(kpIds) |
|
|
.sourceId(kpIds) |
|
|
.build()) |
|
|
.build()) |
|
|
|