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 0038e6b9..60bd9ee1 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 @@ -161,52 +161,22 @@ public class AskServiceImpl implements AskService { talkResultResVO.setAnswerMessage(defaultNoMatchAnswerMessage); saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); } else { + AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId()) .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); - // 如果没有找到回答,去默认回答里面看看有没有 - if (ObjectUtil.isEmpty(askPatientAnswer)) { - log.info("{}:病历配置,未从AskPatientAnswer中找到回答结果,尝试回答默认答案", rasaResult); - // 首先看看default里面是不是存在,如果存在,就从default里面去找 - if (StrUtil.isNotEmpty(library.getDefaultAnswer()) && StrUtil.isNotBlank(library.getDefaultAnswerResourceId())) { - String resText = library.getDefaultAnswer(); - talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId())); - talkResultResVO.setAnswerMessage(library.getDefaultAnswer()); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); - log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); - } else { - log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult); - talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId())); - talkResultResVO.setAnswerMessage(library.getDefaultAnswer()); - saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); - } - } else { - if (StrUtil.isEmpty(askPatientAnswer.getAnswer())) { - log.info("{}:病历配置的回答:{}:不为空,但在获取的时候,答案为空,尝试回复默认语句", rasaResult, askPatientAnswer.getId()); - if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { - String resText = library.getDefaultAnswer(); - log.info("{}:病历配置的回答:{}:不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText); - // 这里返回视频 - talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId())); - talkResultResVO.setAnswerMessage(library.getDefaultAnswer()); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); - } else { - log.info("{}:病历配置的回答:{}:不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); - talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId)); - talkResultResVO.setAnswerMessage(defaultNoMatchAnswerMessage); - saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); - } - - } else { - String resText = askPatientAnswer.getAnswer(); - log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); - talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(askPatientAnswer.getAnswerResourceId())); - talkResultResVO.setAnswerMessage(askPatientAnswer.getAnswer()); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); - } + if (ObjectUtil.isNotEmpty(askPatientAnswer) && StrUtil.isNotEmpty(askPatientAnswer.getAnswerResourceId())){ + String resText = askPatientAnswer.getAnswer(); + log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); + talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(askPatientAnswer.getAnswerResourceId())); + talkResultResVO.setAnswerMessage(askPatientAnswer.getAnswer()); + // 保存记录 + saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); + }else { + log.info("{}:病历配置,从AskPatientAnswer中未找到回答结果,回复未识别到语句", rasaResult); + talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId())); + talkResultResVO.setAnswerMessage(library.getDefaultAnswer()); + saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); } } } diff --git a/virtual-patient-web/src/test/java/com/supervision/AskTemplateIdTest.java b/virtual-patient-web/src/test/java/com/supervision/AskTemplateIdTest.java index 0660732f..f98cdb2d 100644 --- a/virtual-patient-web/src/test/java/com/supervision/AskTemplateIdTest.java +++ b/virtual-patient-web/src/test/java/com/supervision/AskTemplateIdTest.java @@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSON; -import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.hutool.poi.excel.ExcelReader; @@ -16,10 +13,12 @@ import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.supervision.model.AskPatientAnswer; import com.supervision.model.AskTemplateQuestionLibrary; import com.supervision.model.CommonDic; +import com.supervision.pojo.vo.TalkResultResVO; +import com.supervision.pojo.vo.TalkVideoReqVO; import com.supervision.service.AskPatientAnswerService; +import com.supervision.service.AskService; import com.supervision.service.AskTemplateQuestionLibraryService; import com.supervision.service.CommonDicService; -import com.supervision.util.RedisSequenceUtil; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -119,5 +119,18 @@ public class AskTemplateIdTest { } + @Autowired + private AskService askService; + + @Test + public void testRasa() throws IOException { + TalkVideoReqVO talkVideoReqVO = new TalkVideoReqVO(); + talkVideoReqVO.setText("你现在感觉怎么样?"); + talkVideoReqVO.setProcessId("1749312510591934465"); + TalkResultResVO talkResultResVO = askService.talkByVideo(talkVideoReqVO); + + System.out.println(JSONUtil.toJsonStr(talkResultResVO)); + } + } diff --git a/virtual-patient-web/src/test/java/com/supervision/VideoUpdateTest.java b/virtual-patient-web/src/test/java/com/supervision/VideoUpdateTest.java index 354209c5..bece1323 100644 --- a/virtual-patient-web/src/test/java/com/supervision/VideoUpdateTest.java +++ b/virtual-patient-web/src/test/java/com/supervision/VideoUpdateTest.java @@ -101,7 +101,7 @@ public class VideoUpdateTest { public void talkTest() throws Exception { TalkVideoReqVO talkVideoReqVO = new TalkVideoReqVO(); - talkVideoReqVO.setProcessId("1748165303767572481"); + talkVideoReqVO.setProcessId("1749312510591934462"); talkVideoReqVO.setText("你哪里不舒服"); TalkResultResVO talkResultResVO = askService.talkByVideo(talkVideoReqVO);