|
|
|
@ -1,19 +1,17 @@
|
|
|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.crypto.digest.MD5;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.model.*;
|
|
|
|
|
import com.supervision.model.Process;
|
|
|
|
|
import com.supervision.model.*;
|
|
|
|
|
import com.supervision.pojo.vo.TalkReqVO;
|
|
|
|
|
import com.supervision.pojo.vo.TalkResultResVO;
|
|
|
|
|
import com.supervision.pojo.vo.TalkVideoReqVO;
|
|
|
|
|
import com.supervision.service.*;
|
|
|
|
|
import com.supervision.util.*;
|
|
|
|
|
import io.minio.MinioClient;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
@ -24,7 +22,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
@ -196,11 +193,12 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException {
|
|
|
|
|
public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException {
|
|
|
|
|
// 根据processId找到对应的病人
|
|
|
|
|
Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程"));
|
|
|
|
|
// 调用rasa获取文字内容
|
|
|
|
|
String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId(), process.getPatientId());
|
|
|
|
|
log.info("rasa的回复是:{}",rasaResult);
|
|
|
|
|
// 如果rasa没有识别出来,则返回默认值
|
|
|
|
|
if (StrUtil.isBlank(rasaResult)) {
|
|
|
|
|
downloadTalkVideo(defaultNoMatchId, response);
|
|
|
|
@ -221,7 +219,6 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
return talkResultResVO;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken());
|
|
|
|
|
AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult);
|
|
|
|
|
if (ObjectUtil.isEmpty(library)) {
|
|
|
|
|
log.info("{}:未从问题库中找到,回答未识别语句", rasaResult);
|
|
|
|
@ -242,7 +239,7 @@ public class AskServiceImpl implements AskService {
|
|
|
|
|
log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText());
|
|
|
|
|
} else {
|
|
|
|
|
log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult);
|
|
|
|
|
HumanUtil.textDriven("您好,我没有听懂您说什么", roomId);
|
|
|
|
|
downloadTalkVideo(library.getDefaultAnswerResourceId(), response);
|
|
|
|
|
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|