Browse Source

bug修复

master
luogw 1 month ago
parent
commit
de3d3d74d8
  1. 6
      src/main/java/com/project/interaction/domain/dto/GenerateQuestionRequestDTO.java
  2. 16
      src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java
  3. 6
      src/main/java/com/project/interaction/utils/NotifyUtil.java

6
src/main/java/com/project/interaction/domain/dto/GenerateQuestionRequestDTO.java

@ -56,6 +56,12 @@ public class GenerateQuestionRequestDTO {
@JsonProperty("task_id")
private Long taskId;
/**
* 文件名称
*/
@JsonProperty("products")
private String products;
/**
* 知识点内容数组
*/

16
src/main/java/com/project/interaction/domain/service/impl/PostToGenerateQuestionDomainServiceImpl.java

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

6
src/main/java/com/project/interaction/utils/NotifyUtil.java

@ -1,5 +1,6 @@
package com.project.interaction.utils;
import cn.hutool.core.date.DateUtil;
import com.github.tingyugetc520.ali.dingtalk.api.DtService;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMessage;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgSendResult;
@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -48,10 +50,12 @@ public class NotifyUtil {
try {
String now = DateUtil.now();
String markdown = String.format("### 【告警】算法生题API调用失败通知 \n\n") +
String.format("## 核心信息\n") +
String.format("- 考试任务ID:%d\n", taskId) +
String.format("- 知识点簇ID:%d\n\n", clusterId) +
String.format("- 知识点簇ID:%d\n", clusterId) +
String.format("- 当前时间:%d\n\n", now) +
String.format("## 异常说明\n") +
String.format("算法服务生成题目时调用失败,可能导致考试题目不完整或无法正常作答,请尽快排查以下问题:\n") +
String.format("- 算法服务是否正常运行\n");

Loading…
Cancel
Save