From 4ff3c6bf314ecb2c9471b636b4618af29253c345 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 25 Dec 2023 15:45:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=86=E9=A2=91=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/AskTemplateQuestionLibraryMapper.xml | 3 ++- .../com/supervision/controller/AskController.java | 3 ++- .../com/supervision/pojo/vo/TalkVideoReqVO.java | 15 +++++++++++++++ .../java/com/supervision/service/AskService.java | 3 ++- .../supervision/service/impl/AskServiceImpl.java | 13 +++++-------- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application-local.yml | 2 +- 7 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java diff --git a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml index 737a70a1..921b6c16 100644 --- a/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml +++ b/virtual-patient-model/src/main/resources/mapper/AskTemplateQuestionLibraryMapper.xml @@ -12,6 +12,7 @@ + @@ -21,7 +22,7 @@ id ,dict_id,code,description, - question,default_answer,create_user_id, + question,default_answer,default_answer_resources_id,create_user_id, create_time,update_user_id,update_time diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java index c7a226ea..fcc2d7e7 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java @@ -2,6 +2,7 @@ package com.supervision.controller; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import com.supervision.service.AskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -36,7 +37,7 @@ public class AskController { @ApiOperation("使用本地视频的形式来做") @PostMapping("/talkByVideo") - public TalkResultResVO talkByVideo(@RequestBody TalkReqVO talkReqVO, HttpServletResponse response) throws IOException { + public TalkResultResVO talkByVideo(@RequestBody TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException { return askService.talkByVideo(talkReqVO,response); } diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java new file mode 100644 index 00000000..1389f56c --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/TalkVideoReqVO.java @@ -0,0 +1,15 @@ +package com.supervision.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class TalkVideoReqVO { + + @ApiModelProperty("对话内容") + private String text; + + @ApiModelProperty("流程ID") + private String processId; + +} diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java index 290e5585..176584fe 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java @@ -2,6 +2,7 @@ package com.supervision.service; import com.supervision.pojo.vo.TalkReqVO; import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -16,7 +17,7 @@ public interface AskService { TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException; - TalkResultResVO talkByVideo(TalkReqVO talkReqVO, HttpServletResponse response) throws IOException; + TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO, HttpServletResponse response) throws IOException; } diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 4639a2bf..ad09b833 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -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 { diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml index 08c6b22f..5ba49b31 100644 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ b/virtual-patient-web/src/main/resources/application-dev.yml @@ -84,4 +84,4 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-local.yml b/virtual-patient-web/src/main/resources/application-local.yml index d4c0220e..46883679 100644 --- a/virtual-patient-web/src/main/resources/application-local.yml +++ b/virtual-patient-web/src/main/resources/application-local.yml @@ -85,4 +85,4 @@ ws: nginx-ip: 192.168.10.138 nginx-port: 443 # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID -defaultNoMatchId: 1 \ No newline at end of file +defaultNoMatchId: 1739173836351885313 \ No newline at end of file