|
|
|
@ -2,7 +2,6 @@ package com.supervision.util;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
@ -28,6 +27,8 @@ public class PredefinedAnswerAssistant {
|
|
|
|
|
*/
|
|
|
|
|
private static final Map<String,TtsResultDTO> predefinedAnswerMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
private static final Map<String,Integer> selectedAnswerMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 阈值时间,超过这个阈值就开始调换出一个预置回答 单位毫秒 默认1000毫秒
|
|
|
|
|
*/
|
|
|
|
@ -93,8 +94,9 @@ public class PredefinedAnswerAssistant {
|
|
|
|
|
* @return 预定义答案
|
|
|
|
|
*/
|
|
|
|
|
public String getPredefinedAnswer() {
|
|
|
|
|
List<String> collect = predefinedAnswerMap.keySet().stream().toList();
|
|
|
|
|
return collect.get(RandomUtil.randomInt(0, collect.size() - 1));
|
|
|
|
|
String text = selectedAnswerMap.entrySet().stream().min(Comparator.comparingInt(Map.Entry::getValue)).map(Map.Entry::getKey).orElse(null);
|
|
|
|
|
selectedAnswerMap.put(text,selectedAnswerMap.get(text) + 1);
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPredefinedAnswerAudio(String text) {
|
|
|
|
@ -132,15 +134,17 @@ public class PredefinedAnswerAssistant {
|
|
|
|
|
}
|
|
|
|
|
log.info("问候答案加载完成....");
|
|
|
|
|
|
|
|
|
|
List<String> predefinedAnswerList = List.of("您好,我是您的康养顾问小陈,很高兴接到您的电话", "我会结合最新的资料,为您提供最贴心的解答",
|
|
|
|
|
"结合最新的信息,为您提供最合适的建议", "结合最新的资料为您提供详细的解答", "根据掌握的高黎贡勐赫小镇信息,为您提供最准确的服务与建议",
|
|
|
|
|
"根据最新动态,为您提供最精准的解答与建议", "结合最新情况,为您提供最贴心的服务与支持");
|
|
|
|
|
List<String> predefinedAnswerList = List.of("针对您的需求,我已全面梳理相关信息,确保内容准确、清晰,为您提供高效支持。", "依托最新勐赫小镇数据和资源,我将为您量身定制解答,确保每一个细节都贴心到位。",
|
|
|
|
|
"基于最新动态和数据分析,我将为您提供最科学、最实用的建议,助您轻松决策。", "结合最新的资料为您提供详细的解答", "通过整合最新资料,我将为您呈现全面、细致的解答,确保您的疑问得到彻底解决。",
|
|
|
|
|
"依托对高黎贡勐赫小镇的深入了解,我将为您提供精准的服务与建议,满足您的需求。", "紧跟最新动态,我将为您提供最及时、最精准的解答与建议,助您把握先机。","根据最新情况,我将为您提供全方位的贴心服务与支持,确保您的体验无忧无虑。",
|
|
|
|
|
"根据最新信息,为您量身定制最合适的建议,助您轻松决策。","基于高黎贡勐赫小镇信息,为您提供最准确的服务与实用建议。","结合最新情况,为您提供贴心服务与全面支持,确保您无忧无虑。");
|
|
|
|
|
|
|
|
|
|
log.info("开始加载预定义答案....");
|
|
|
|
|
for (String text : predefinedAnswerList) {
|
|
|
|
|
if (predefinedAnswerMap.containsKey(text)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
selectedAnswerMap.put(text,0);
|
|
|
|
|
TtsResultDTO ttsResultDTO = TtsUtil.ttsTransform(text);
|
|
|
|
|
predefinedAnswerMap.put(text,ttsResultDTO);
|
|
|
|
|
}
|
|
|
|
|