package com.qiwu.inference.common; import com.qiwu.inference.common.utils.YamlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @Component public class TimingAcquisition { static Logger log = LoggerFactory.getLogger(TimingAcquisition.class); /** * 询问模块话术 */ public volatile static Map>> askSpeechMap = new ConcurrentHashMap<>(); /** * 任务模块话术 */ public volatile static Map>> taskSpeechMap = new ConcurrentHashMap<>(); /** * 查看模块话术 */ public volatile static Map>> checkSpeechMap = new ConcurrentHashMap<>(); /** * 通过yaml文件加载所有话术到缓存中 */ public static void speechLoading() { log.info("---------开始加载话术到缓存中---------"); Map>> askSpeech = new HashMap<>(); Map>> taskSpeech = new HashMap<>(); Map>> checkSpeech = new HashMap<>(); try { askSpeech = YamlUtil.loadSpeechToMap("ask.yaml"); taskSpeech = YamlUtil.loadSpeechToMap("task.yaml"); checkSpeech = YamlUtil.loadSpeechToMap("check.yaml"); } catch (Exception e) { e.printStackTrace(); } //JSON转map对象 askSpeechMap.putAll(askSpeech); taskSpeechMap.putAll(taskSpeech); checkSpeechMap.putAll(checkSpeech); log.info("---------加载话术到缓存的操作完成---------"); } }