liusheng
2024-10-30 f55c563e2a0b52e4569ce6b5f81632cac598f7fe
代码提交
已修改15个文件
743 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/hanler/ChatWebSocketHandler.java 332 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/common/SendService.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/CommonTaskcallMQ.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/PhoneCallBackYQVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SocketMessage.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -1,6 +1,5 @@
package com.ruoyi.web.component;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
@@ -9,15 +8,15 @@
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.web.task.PhoneTask;
import com.smartor.common.SendService;
import com.smartor.config.RobotPhoneUtils;
import com.smartor.domain.*;
import com.smartor.mapper.ServiceSubtaskMapper;
import com.smartor.mapper.ServiceTaskMapper;
import com.smartor.mapper.SvyTaskMapper;
import com.smartor.mapper.SvyTaskSingleMapper;
import com.smartor.service.*;
import com.smartor.service.IBaseSmsaccountService;
import com.smartor.service.IIvrTaskTemplateService;
import com.smartor.service.IServiceSubtaskRecordService;
import com.smartor.service.ISvyTaskTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +26,6 @@
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
@@ -306,6 +304,8 @@
                            } else if (type == 3) {
                                sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false");
                            }
                            //短信还需要模板
                            sendMagParam.setContent("【新华医院】+<a href="+sendMagParam.getUrl()+"链接测试</a>");
                            Boolean aBoolean = sendService.sendMsg(sendMagParam);
                            if (!aBoolean) {
ruoyi-admin/src/main/java/com/ruoyi/web/controller/hanler/ChatWebSocketHandler.java
@@ -8,8 +8,8 @@
import com.smartor.domain.*;
import com.smartor.mapper.IvrLibaExtemplatescriptMapper;
import com.smartor.service.IIvrLibaTemplateService;
import com.smartor.service.IIvrTaskTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.BinaryMessage;
@@ -32,7 +32,7 @@
    private static RedisCache redisCache;
    private static IIvrTaskTemplateService ivrTaskTemplateService;
    private static IIvrLibaTemplateService ivrLibaTemplateService;
    private static IvrLibaExtemplatescriptMapper ivrLibaExtemplatescriptMapper;
@@ -45,8 +45,8 @@
    }
    @Autowired
    public void setTodayReaderService(IIvrTaskTemplateService ivrTaskTemplateService) {
        ChatWebSocketHandler.ivrTaskTemplateService = ivrTaskTemplateService;
    public void setTodayReaderService(IIvrLibaTemplateService ivrLibaTemplateService) {
        ChatWebSocketHandler.ivrLibaTemplateService = ivrLibaTemplateService;
    }
    @Autowired
@@ -116,17 +116,17 @@
        if (session != null && session.isOpen()) {
            if (socketMessage.getTemplateId() != null) {
                //通过模板ID获取模板问题
                IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO();
                ivrTaskTemplateVO.setId(socketMessage.getTemplateId());
                IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO);
                redisCache.setCacheObject(userId + "ivrTaskTemplateVO1", ivrTaskTemplateVO1, 120, TimeUnit.MINUTES);
                IvrLibaTemplateVO ivrLibaTemplateVO = new IvrLibaTemplateVO();
                ivrLibaTemplateVO.setId(socketMessage.getTemplateId());
                IvrLibaTemplateVO ivrLibaTemplateVO1 = ivrLibaTemplateService.selectInfoByCondition(ivrLibaTemplateVO);
                redisCache.setCacheObject(userId + "ivrLibaTemplateVO1", ivrLibaTemplateVO1, 120, TimeUnit.MINUTES);
                //将查出来的问题,放到全局变量中去
                List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVOList = ivrTaskTemplateVO1.getIvrTaskTemplateScriptVOList();
                List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOList = ivrLibaTemplateVO1.getIvrLibaTemplateScriptVOList();
                //根据序号进行排序
                Collections.sort(ivrTaskTemplateScriptVOList, Comparator.comparing(IvrTaskTemplateScriptVO::getTargetid));
                Collections.sort(ivrLibaTemplateScriptVOList, Comparator.comparing(IvrLibaTemplateScriptVO::getSort));
                //将查出来的数据放到redis中
                redisCache.setCacheObject(userId + "ivrTaskTemplateScriptVOList", ivrTaskTemplateScriptVOList, 120, TimeUnit.MINUTES);
                redisCache.setCacheObject(userId + "ivrLibaTemplateScriptVOList", ivrLibaTemplateScriptVOList, 120, TimeUnit.MINUTES);
                //用来返回调查的总结果
                redisCache.setCacheObject(userId + "backQuset", new ArrayList<>(), 120, TimeUnit.MINUTES);
                //用来记录无声响应次数
@@ -137,16 +137,17 @@
                redisCache.setCacheObject(userId + "isOver", 0, 120, TimeUnit.MINUTES);
                //用来返回当前需要问的问题信息
                QuestionMessage returnQues = new QuestionMessage();
                QuestionMessagePhone returnQues = new QuestionMessagePhone();
                for (IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO : ivrTaskTemplateScriptVOList) {
                    if (ivrTaskTemplateScriptVO.getTargetid() == ivrTaskTemplateVO1.getFirstQuestionNum().intValue())
                for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVOList) {
                    if (ivrLibaTemplateScriptVO.getSort() == ivrLibaTemplateVO1.getFirstQuestionNum().intValue())
                        //获取第一题的问题
                        returnQues.setNowQuestion(ivrTaskTemplateScriptVO);
                        returnQues.setNowQuestion(ivrLibaTemplateScriptVO);
//                        returnQues.setCode(ivrTaskTemplateScriptVO.getTargetid() + 1);
                }
//              设置开场白
                returnQues.setKcb(ivrTaskTemplateVO1.getRevisitBefore());
                returnQues.setKcb(ivrLibaTemplateVO1.getRevisitBefore());
                //记录响应
                redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
@@ -154,44 +155,45 @@
                //获取socketMessage里的QuestionMessage,对答案进行处理然后,再问下一道
                Gson gson = new Gson();
                if (!StringUtils.isEmpty(socketMessage.getContent())) {
                    socketMessage.setQuestionMessage(gson.fromJson(socketMessage.getContent(), QuestionMessage.class));
                    socketMessage.setQuestionMessage(gson.fromJson(socketMessage.getContent(), QuestionMessagePhone.class));
                }
                QuestionMessage questionMessage = socketMessage.getQuestionMessage();
                List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVOList = redisCache.getCacheObject(userId + "ivrTaskTemplateScriptVOList");
                QuestionMessagePhone questionMessage = socketMessage.getQuestionMessage();
                List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOList = redisCache.getCacheObject(userId + "ivrLibaTemplateScriptVOList");
                //根据前端传回的条件,获取当前题目
                IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO = questionMessage.getNowQuestion();
                if (ivrTaskTemplateScriptVO.getId() == null) {
                    QuestionMessage returnQues = redisCache.getCacheObject(userId + "returnQues");
                    ivrTaskTemplateScriptVO = returnQues.getNowQuestion();
                IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = questionMessage.getNowQuestion();
                if (ivrLibaTemplateScriptVO.getId() == null) {
                    QuestionMessagePhone returnQues = redisCache.getCacheObject(userId + "returnQues");
                    ivrLibaTemplateScriptVO = returnQues.getNowQuestion();
                }
                //获取模板信息
                IvrTaskTemplateVO ivrTaskTemplateVO1 = redisCache.getCacheObject(userId + "ivrTaskTemplateVO1");
                IvrLibaTemplateVO ivrLibaTemplateVO1 = redisCache.getCacheObject(userId + "ivrLibaTemplateVO1");
                if (StringUtils.isEmpty(questionMessage.getContent())) {
                    //调用ivrTaskTemplateScriptVO中的slienceText(静默话术)
                    Integer noVoice = redisCache.getCacheObject(userId + "noVoice");
                    //实际静默次数是否 等于 模板中配置的次数
                    if (noVoice == ivrTaskTemplateVO1.getNoVoiceNum().intValue()) {
                    if (noVoice == ivrLibaTemplateVO1.getNoVoiceNum().intValue()) {
                        //用来返回调查的总结果
                        List<IvrTaskTemplateScriptVO> backQuset = new ArrayList<>();
                        backQuset.add(ivrTaskTemplateScriptVO);
                        List<IvrLibaTemplateScriptVO> backQuset = new ArrayList<>();
                        backQuset.add(ivrLibaTemplateScriptVO);
                        redisCache.setCacheObject(userId + "backQuset", backQuset, 120, TimeUnit.MINUTES);
                        //如果几次都没响应,就下一题(需要先判断是否有下一题)
                        if (ivrTaskTemplateScriptVO.getTargetid() == ivrTaskTemplateScriptVOList.size()) {
                        if (ivrLibaTemplateScriptVO.getSort() == 0) {
                            //如果下一题没有了,就结束了
                            QuestionMessage returnQues = new QuestionMessage();
                            QuestionMessagePhone returnQues = new QuestionMessagePhone();
//                            returnQues.setCode(null);
                            List<IvrTaskTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                            List<IvrLibaTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                            returnQues.setContent(JSON.toJSONString(backQusetRedis));
                            returnQues.setJsy(ivrTaskTemplateVO1.getRevisitAfter());
                            returnQues.setJsy(ivrLibaTemplateVO1.getRevisitAfter());
                            redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                            redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
                        } else {
                            //如果有下一题,就根据当前teagetID+1 获取下一题
                            QuestionMessage returnQues = getNextQuestion(ivrTaskTemplateScriptVOList, ivrTaskTemplateScriptVO);
                            QuestionMessagePhone returnQues = getNextQuestion(ivrLibaTemplateScriptVOList, ivrLibaTemplateScriptVO);
                            redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                            redisCache.setCacheObject(userId + "noVoice", 0, 120, TimeUnit.MINUTES);
                        }
@@ -203,81 +205,146 @@
                        Integer noVoice2 = redisCache.getCacheObject(userId + "noVoice");
                        noVoice2 = noVoice2 + 1;
                        //给问题加上无匹配话术
                        QuestionMessagePhone returnQues = redisCache.getCacheObject(userId + "returnQues");
                        IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
                        boolean contains = nowQuestion.getScriptContent().contains(nowQuestion.getNoMatchText());
                        if (!contains) {
                            String scriptContent = nowQuestion.getSlienceText() + "," + nowQuestion.getScriptContent();
                            nowQuestion.setScriptContent(scriptContent);
                        }
                        returnQues.setNowQuestion(nowQuestion);
                        redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                        redisCache.setCacheObject(userId + "noVoice", noVoice2, 120, TimeUnit.MINUTES);
                    }
                } else {
                    //通过valueType判断是什么题型(值类型(1 选项  2 文本  3 数值))
                    if (ivrTaskTemplateScriptVO.getValueType() == 2 || ivrTaskTemplateScriptVO.getValueType() == 3) {
                        ivrTaskTemplateScriptVO.setQuestionResult(questionMessage.getContent());
                        List<IvrTaskTemplateScriptVO> backQusetList = redisCache.getCacheObject(userId + "backQuset");
                    String extemplateID = ivrLibaTemplateVO1.getSubmoduleID();
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(extemplateID)) {
                        String[] split = extemplateID.split(",");
                        List<String> list = Arrays.asList(split);
                        List<Long> list1 = new ArrayList<>();
                        for (String str : list) {
                            list1.add(Long.valueOf(str));
                        }
                        List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
                        IvrLibaExtemplatescript les = null;
                        for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
                            Matcher matcher = null;
                            if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
                                Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
                                matcher = pattern.matcher(questionMessage.getContent());
                            }
                            Matcher matcher2 = null;
                            if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
                                Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
                                matcher2 = pattern2.matcher(questionMessage.getContent());
                            }
                            if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || org.apache.commons.lang3.StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || org.apache.commons.lang3.StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && org.apache.commons.lang3.StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
                                //将通用库匹配的,放到返回值中
                                ivrLibaTemplateScriptVO.setCommonValue(ivrLibaExtemplatescript.getSwitchText());
                                les = ivrLibaExtemplatescript;
                            }
                            break;
                        }
                        if (ObjectUtils.isNotEmpty(les)) {
                            //对匹配的结果处理一下(看看是不是需要挂机)
                            if (les.getIsEnd() != null && les.getIsEnd() == 1) {
                                //可以挂机了
                                redisCache.deleteObject(userId + "ivrLibaTemplateScriptVOList");
                                redisCache.deleteObject(userId + "backQuset");
                                redisCache.deleteObject(userId + "noVoice");
                                redisCache.deleteObject(userId + "returnQues");
                                redisCache.deleteObject(userId + "isOver");
                                redisCache.deleteObject(userId + "ivrLibaTemplateVO1");
                                QuestionMessagePhone returnQues = new QuestionMessagePhone();
                                List<IvrLibaTemplateScriptVO> backQuset = new ArrayList<>();
                                IvrLibaTemplateScriptVO ls = new IvrLibaTemplateScriptVO();
                                ls.setScriptContent(les.getSwitchText());
                                backQuset.add(ls);
                                returnQues.setQuestionList(backQuset);
                                returnQues.setNowQuestion(ls);
                                session.sendMessage(new TextMessage(JSON.toJSONString(returnQues).getBytes(StandardCharsets.UTF_8)));
                                return;
                            }
                        }
                    }
                    //通过valueType判断是什么题型(值类型(1 选项  2 文本  3 数值))
                    if (ivrLibaTemplateScriptVO.getValueType() == 2 || ivrLibaTemplateScriptVO.getValueType() == 3) {
                        ivrLibaTemplateScriptVO.setQuestionResult(questionMessage.getContent());
                        List<IvrLibaTemplateScriptVO> backQusetList = redisCache.getCacheObject(userId + "backQuset");
                        //匹配完成后,将结果保存到新的数组
                        backQusetList.add(ivrTaskTemplateScriptVO);
                        backQusetList.add(ivrLibaTemplateScriptVO);
                        redisCache.setCacheObject(userId + "backQuset", backQusetList, 120, TimeUnit.MINUTES);
                        //将静默置为0
                        redisCache.setCacheObject(userId + "noVoice", 0, 120, TimeUnit.MINUTES);
                        //获取下一题
                        Long nextQuestion = ivrTaskTemplateScriptVO.getTargetid() + 1;
                        if (nextQuestion > ivrTaskTemplateScriptVOList.size()) {
                        Long nextQuestion = Long.valueOf(ivrLibaTemplateScriptVO.getSort() + 1);
                        if (nextQuestion > ivrLibaTemplateScriptVOList.size()) {
                            //如果下一题没有了,就结束了
                            QuestionMessage returnQues = new QuestionMessage();
                            List<IvrTaskTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                            QuestionMessagePhone returnQues = new QuestionMessagePhone();
                            List<IvrLibaTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                            returnQues.setContent(JSON.toJSONString(backQusetRedis));
                            returnQues.setJsy(ivrTaskTemplateVO1.getRevisitAfter());
                            returnQues.setJsy(ivrLibaTemplateVO1.getRevisitAfter());
                            redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                            redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
                        } else {
                            for (IvrTaskTemplateScriptVO script : ivrTaskTemplateScriptVOList) {
                                if (script.getTargetid() == nextQuestion) {
                                    QuestionMessage returnQues = new QuestionMessage();
                            for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOList) {
                                if (Long.valueOf(script.getSort()) == nextQuestion) {
                                    QuestionMessagePhone returnQues = new QuestionMessagePhone();
                                    returnQues.setNowQuestion(script);
                                    redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                }
                            }
                        }
                    } else if (ivrTaskTemplateScriptVO.getValueType() == 1) {
                    } else if (ivrLibaTemplateScriptVO.getValueType() == 1) {
                        //对回答的问题,进行正则匹配(这里只针对选择题,其它题型不行)x
                        for (int j = 0; j < ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size(); j++) {
                        for (int j = 0; j < ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().size(); j++) {
                            //包含
                            Matcher matcher = null;
                            if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
                                Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
                            if (StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex())) {
                                Pattern pattern = Pattern.compile(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex());
                                matcher = pattern.matcher(questionMessage.getContent());
                            }
                            //不包含
                            Matcher matcher2 = null;
                            if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
                                Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
                            if (StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2())) {
                                Pattern pattern2 = Pattern.compile(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
                                matcher2 = pattern2.matcher(questionMessage.getContent());
                            }
                            log.info("==============================Targetregex的值为:{},   Targetregex2的值为:{}", ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex(), ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
                            log.info("==============================Targetregex的值为:{},   Targetregex2的值为:{}", ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex(), ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
                            if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
                            if (StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
                                log.error("匹配正确了");
                                //说明匹配正确了
                                ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1);
                                List<IvrTaskTemplateScriptVO> backQuset = redisCache.getCacheObject(userId + "backQuset");
                                ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).setIsUserOperation(1);
                                List<IvrLibaTemplateScriptVO> backQuset = redisCache.getCacheObject(userId + "backQuset");
                                //匹配完成后,将结果保存到新的数组
                                backQuset.add(ivrTaskTemplateScriptVO);
                                backQuset.add(ivrLibaTemplateScriptVO);
                                redisCache.setCacheObject(userId + "backQuset", backQuset, 120, TimeUnit.MINUTES);
                                //将静默置为0
                                redisCache.setCacheObject(userId + "noVoice", 0, 120, TimeUnit.MINUTES);
                                //获取下一题
                                Long nextQuestion = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getNextQuestion();
                                if (nextQuestion > ivrTaskTemplateScriptVOList.size()) {
                                Integer nextQuestion = ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion();
                                if (nextQuestion > ivrLibaTemplateScriptVOList.size()) {
                                    //如果下一题没有了,就结束了
                                    QuestionMessage returnQues = new QuestionMessage();
                                    List<IvrTaskTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                                    QuestionMessagePhone returnQues = new QuestionMessagePhone();
                                    List<IvrLibaTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                                    returnQues.setContent(JSON.toJSONString(backQusetRedis));
                                    returnQues.setJsy(ivrTaskTemplateVO1.getRevisitAfter());
                                    returnQues.setJsy(ivrLibaTemplateVO1.getRevisitAfter());
                                    redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                    redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
                                } else {
                                    for (IvrTaskTemplateScriptVO script : ivrTaskTemplateScriptVOList) {
                                        if (script.getTargetid() == nextQuestion) {
                                            QuestionMessage returnQues = new QuestionMessage();
                                    for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOList) {
                                        if (script.getSort() == nextQuestion) {
                                            QuestionMessagePhone returnQues = new QuestionMessagePhone();
                                            returnQues.setNowQuestion(script);
                                            redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                            break;
@@ -286,100 +353,113 @@
                                }
                                break;
                            } else {
                                log.error("无匹配");
                                //没有匹配到
                                Integer mateNum = redisCache.getCacheObject(userId + "mateNum");
                                //无匹配次数去判断是否到最大询问次数,并且所有的选项都匹配完了
                                if (mateNum == ivrTaskTemplateVO1.getMateNum().intValue() && j == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1) {
                                if (mateNum == ivrLibaTemplateVO1.getMateNum().intValue() && j == ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().size() - 1) {
                                    //问了最大询问次数后,还是没有匹配上,将结果保存到新的数组
                                    List<IvrTaskTemplateScriptVO> backQuset = redisCache.getCacheObject(userId + "backQuset");
                                    backQuset.add(ivrTaskTemplateScriptVO);
                                    List<IvrLibaTemplateScriptVO> backQuset = redisCache.getCacheObject(userId + "backQuset");
                                    backQuset.add(ivrLibaTemplateScriptVO);
                                    redisCache.setCacheObject(userId + "backQuset", backQuset, 120, TimeUnit.MINUTES);
                                    //如果下一题为空.则新的数据返回,并加上感谢语
                                    if (ivrTaskTemplateScriptVO.getTargetid() < ivrTaskTemplateScriptVOList.size()) {
                                        QuestionMessage returnQues = getNextQuestion(ivrTaskTemplateScriptVOList, ivrTaskTemplateScriptVO);
                                    if (ivrLibaTemplateScriptVO.getSort() == 0) {
                                        QuestionMessagePhone returnQues = getNextQuestion(ivrLibaTemplateScriptVOList, ivrLibaTemplateScriptVO);
                                        redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                        redisCache.setCacheObject(userId + "mateNum", 0, 120, TimeUnit.MINUTES);
                                    } else {
                                        QuestionMessage returnQues2 = new QuestionMessage();
                                        QuestionMessagePhone returnQues2 = new QuestionMessagePhone();
//                                    returnQues2.setCode(null);
                                        List<IvrTaskTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                                        List<IvrLibaTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
                                        returnQues2.setQuestionList(backQusetRedis);
                                        returnQues2.setJsy("感谢您的耐心回答,再见");
                                        returnQues2.setJsy(ivrLibaTemplateVO1.getRevisitAfter());
                                        redisCache.setCacheObject(userId + "returnQues", returnQues2, 120, TimeUnit.MINUTES);
                                        redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
                                        break;
                                    }
                                } else if (mateNum < ivrTaskTemplateVO1.getMateNum().intValue() && j == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1) {
                                } else if (mateNum < ivrLibaTemplateVO1.getMateNum().intValue() && j == ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().size() - 1) {
                                    //没有问到规定次数
                                    mateNum = mateNum + 1;
                                    redisCache.setCacheObject(userId + "mateNum", mateNum, 120, TimeUnit.MINUTES);
                                }
                            }
                        }
                    }
                    //选项匹配完成后,需要再去通过库再进行匹配一次
                    String extemplateID = ivrTaskTemplateVO1.getSubmoduleID();
                    String[] split = extemplateID.split(",");
                    List<String> list = Arrays.asList(split);
                    List<Long> list1 = new ArrayList<>();
                    if (StringUtils.isNotEmpty(extemplateID)) {
                        for (String str : list) {
                            list1.add(Long.valueOf(str));
                        }
                        List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
                        for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
                            Matcher matcher = null;
                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
                                Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
                                matcher = pattern.matcher(questionMessage.getContent());
                            }
                            Matcher matcher2 = null;
                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
                                Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
                                matcher2 = pattern2.matcher(questionMessage.getContent());
                            }
                            log.info("++++++++++++++++++++++++++通用库是否为空:selfRegex : {} , selfRegex2 : {}", ivrLibaExtemplatescript.getSelfRegex(), ivrLibaExtemplatescript.getSelfRegex2());
                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
                                QuestionMessage returnQues = redisCache.getCacheObject(userId + "returnQues");
                                IvrTaskTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
                                nowQuestion.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText());
                                nowQuestion.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav());
                                redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                if (ivrLibaExtemplatescript.getIsEnd() == 1) {
                                    //将问题置空
                                    IvrTaskTemplateScriptVO nowQuestion1 = returnQues.getNowQuestion();
                                    nowQuestion1.setScriptContent(null);
                                    nowQuestion1.setScriptVoice(null);
                                    returnQues.setNowQuestion(nowQuestion1);
                                    //给问题加上无匹配话术
                                    QuestionMessagePhone returnQues = redisCache.getCacheObject(userId + "returnQues");
                                    IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
                                    boolean contains = false;
                                    if (StringUtils.isNotEmpty(nowQuestion.getNoMatchText()))
                                        contains = nowQuestion.getScriptContent().contains(nowQuestion.getNoMatchText());
                                    if (!contains) {
                                        String scriptContent = nowQuestion.getNoMatchText() + "," + nowQuestion.getScriptContent();
                                        nowQuestion.setScriptContent(scriptContent);
                                    }
                                    returnQues.setNowQuestion(nowQuestion);
                                    redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                                    redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
                                }
                            }
                            break;
                        }
                    }
//                    //选项匹配完成后,需要再去通过库再进行匹配一次
//                    String extemplateID = ivrLibaTemplateVO1.getSubmoduleID();
//                    String[] split = extemplateID.split(",");
//                    List<String> list = Arrays.asList(split);
//                    List<Long> list1 = new ArrayList<>();
//                    if (StringUtils.isNotEmpty(extemplateID)) {
//                        for (String str : list) {
//                            list1.add(Long.valueOf(str));
//                        }
//                        List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
//                        for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
//                            Matcher matcher = null;
//                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
//                                Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
//                                matcher = pattern.matcher(questionMessage.getContent());
//                            }
//
//                            Matcher matcher2 = null;
//                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
//                                Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
//                                matcher2 = pattern2.matcher(questionMessage.getContent());
//                            }
//                            log.info("++++++++++++++++++++++++++通用库是否为空:selfRegex : {} , selfRegex2 : {}", ivrLibaExtemplatescript.getSelfRegex(), ivrLibaExtemplatescript.getSelfRegex2());
//
//                            if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
//                                QuestionMessagePhone returnQues = redisCache.getCacheObject(userId + "returnQues");
//                                IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
//                                nowQuestion.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText());
//                                nowQuestion.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav());
//                                redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
//                                if (ivrLibaExtemplatescript.getIsEnd() == 1) {
//                                    //将问题置空
//                                    IvrLibaTemplateScriptVO nowQuestion1 = returnQues.getNowQuestion();
//                                    nowQuestion1.setScriptContent(null);
//                                    nowQuestion1.setScriptVoice(null);
//                                    returnQues.setNowQuestion(nowQuestion1);
//                                    redisCache.setCacheObject(userId + "returnQues", returnQues, 120, TimeUnit.MINUTES);
//
//                                    redisCache.setCacheObject(userId + "isOver", 1, 120, TimeUnit.MINUTES);
//                                }
//                            }
//                            break;
//                        }
//                    }
                }
            }
            QuestionMessage returnQues = redisCache.getCacheObject(userId + "returnQues");
            List<IvrTaskTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
            QuestionMessagePhone returnQues = redisCache.getCacheObject(userId + "returnQues");
            List<IvrLibaTemplateScriptVO> backQusetRedis = redisCache.getCacheObject(userId + "backQuset");
            returnQues.setQuestionList(backQusetRedis);
            session.sendMessage(new TextMessage(JSON.toJSONString(returnQues).getBytes(StandardCharsets.UTF_8)));
            //整个流程是否结束,将redis中的该userId下的数据删除;
            Integer isOver = redisCache.getCacheObject(userId + "isOver");
            if (isOver == 1) {
                redisCache.deleteObject(userId + "ivrTaskTemplateScriptVOList");
                redisCache.deleteObject(userId + "ivrLibaTemplateScriptVOList");
                redisCache.deleteObject(userId + "backQuset");
                redisCache.deleteObject(userId + "noVoice");
                redisCache.deleteObject(userId + "returnQues");
                redisCache.deleteObject(userId + "isOver");
                redisCache.deleteObject(userId + "ivrTaskTemplateVO1");
                redisCache.deleteObject(userId + "ivrLibaTemplateVO1");
                try {
                    //断开链接
                    afterConnectionClosed(session, null);
@@ -391,12 +471,12 @@
    }
    //获取下一题(这个方法不适合选项中的nextQuestion)
    private QuestionMessage getNextQuestion(List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVOList, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO) {
        QuestionMessage returnQues = new QuestionMessage();
        for (int j = 0; j < ivrTaskTemplateScriptVOList.size(); j++) {
            if (ivrTaskTemplateScriptVOList.get(j).getTargetid() == ivrTaskTemplateScriptVO.getTargetid() + 1) {
    private QuestionMessagePhone getNextQuestion(List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOList, IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO) {
        QuestionMessagePhone returnQues = new QuestionMessagePhone();
        for (int j = 0; j < ivrLibaTemplateScriptVOList.size(); j++) {
            if (ivrLibaTemplateScriptVOList.get(j).getSort() == ivrLibaTemplateScriptVO.getSort() + 1) {
                // 对该条templateScriptVO进行处理
                returnQues.setNowQuestion(ivrTaskTemplateScriptVOList.get(j));
                returnQues.setNowQuestion(ivrLibaTemplateScriptVOList.get(j));
            }
        }
        return returnQues;
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -155,7 +155,7 @@
    }
    /**
     * 电话回调任务(雨绮)
     *  电话回调任务(雨绮)
     */
    @ApiOperation("电话回调任务(雨绮)")
    @PostMapping("/taskPull")
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceTaskController.java
@@ -11,6 +11,7 @@
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.common.SendService;
import com.smartor.domain.*;
import com.smartor.service.IServiceSubtaskService;
import com.smartor.service.IServiceTaskService;
@@ -24,6 +25,7 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.stream.Collectors;
@@ -54,6 +56,19 @@
    @Autowired
    private RSAPublicKeyExample rsaPublicKeyExample;
    @Autowired
    private SendService sendService;
    @PostMapping("/test")
    public TableDataInfo test(@RequestBody SendMagParam sendMagParam) {
        try {
            Boolean aBoolean = sendService.sendMsg(sendMagParam);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 查询语音任务列表
     */
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
@@ -40,6 +40,16 @@
    }
    @Test
    public void bb(){
        for (int j = 0; j < 5; j++) {
            if(j==5-1){
                System.out.println("11111111111111111111");
            }
        }
    }
    public void aa(MultipartFile file) throws IOException {
        System.out.println("开始Aa:" + System.currentTimeMillis());
        String filePath = "D:\\test\\Ab";
ruoyi-admin/src/main/resources/application-druid.yml
@@ -11,7 +11,6 @@
        #        username: root
        #        password: 123456
        #        公司
        ##        url: jdbc:mysql://450scrp46939.vicp.fun:59876/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://192.168.2.9:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        #        url: jdbc:mysql://192.168.191.181:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
        username: smartor
@@ -137,12 +136,12 @@
qrpath: D:\qrcode
#公司内外链请求IP和端口号
req_path: 8095
localIP: 192.168.2.10
#req_path: 8095
#localIP: 192.168.2.10
##新华医院外链请求IP和端口号
#req_path: 8093
#localIP: 218.108.11.22
#新华医院外链请求IP和端口号
req_path: 8093
localIP: 218.108.11.22
#获取患者信息URL(华卓提供)
hosp_info_url: http://esb-core-rest.wowjoy.cn/esb/exchange
@@ -151,6 +150,17 @@
uploadSwitch: 1
#  指定asr回调的url路径
ASRCallBackPath: http://192.168.2.10:8095/smartor/serviceSubtask/phoneCallBackYQ
ASRCallBackPath: http://192.168.2.13:8095/smartor/serviceSubtask/phoneCallBackYQ
#挂断IP
hangup: http://192.168.2.10:8091/hangup
#新华短信
#请求地址
xhsmsPath: http://183.134.75.159:7862/sms
#帐号
xhsmsAccount: 911124
#接口密码
xhsmsPwd: zW5eXe
#虚拟接入码
xhsmsjrm: 1069055
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -339,23 +339,28 @@
                    String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
                    for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
                        String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
                        SendMagParam sendMagParam = new SendMagParam();
                        sendMagParam.setType("4");
                        sendMagParam.setPhone(serviceSubtask.getPhone());
                        sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "&param2=" + patid + "&param5=false");
                        Boolean aBoolean = sendService.sendMsg(sendMagParam);
                        try {
                        //任务发送记录
                        ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
                        serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
                        serviceSubtaskRecord.setUuid(UUID.randomUUID().toString());
                        serviceSubtaskRecord.setTasktype(serviceSubtask.getType());
                        serviceSubtaskRecord.setPreachform("4");
                        serviceSubtaskRecord.setStartTime(System.currentTimeMillis());
                        serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败");
                        serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
                            String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
                            SendMagParam sendMagParam = new SendMagParam();
                            sendMagParam.setType("4");
                            sendMagParam.setPhone(serviceSubtask.getPhone());
                            sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "&param2=" + patid + "&param5=false");
                            Boolean aBoolean = sendService.sendMsg(sendMagParam);
                            //任务发送记录
                            ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
                            serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
                            serviceSubtaskRecord.setUuid(UUID.randomUUID().toString());
                            serviceSubtaskRecord.setTasktype(serviceSubtask.getType());
                            serviceSubtaskRecord.setPreachform("4");
                            serviceSubtaskRecord.setStartTime(System.currentTimeMillis());
                            serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败");
                            serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
                        } catch (Exception e) {
                            continue;
                        }
                    }
                } else if (descByCode.equals("公众号")) {
                    log.error("公众号进来了吗?{}", descByCode);
smartor/src/main/java/com/smartor/common/SendService.java
@@ -4,7 +4,9 @@
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.ruoyi.common.utils.http.HttpUtils;
import com.smartor.domain.*;
import com.smartor.mapper.PatWildcardMapper;
@@ -13,10 +15,16 @@
import com.smartor.service.WeChatService;
import com.smartor.service.impl.BaseSmsaccountServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -43,7 +51,19 @@
    @Autowired
    ISmsParamService iSmsParamService;
    public Boolean sendMsg(SendMagParam sendMagParam) {
    @Value("${xhsmsPath}")
    private String xhsmsPath;
    // 帐号
    @Value("${xhsmsAccount}")
    private String xhsmsAccount;
    //  接口密码
    @Value("${xhsmsPwd}")
    private String xhsmsPwd;
    // 虚拟接入码
    @Value("${xhsmsjrm}")
    private String xhsmsjrm;
    public Boolean sendMsg(SendMagParam sendMagParam) throws UnsupportedEncodingException, JsonProcessingException {
        // 1,多媒体 2,纸质  3,电话  4,短信  5.微信公众号 6.微信小程序 7.支付宝  8.智能小程序  9.钉钉
        switch (sendMagParam.getType()) {
            case ("1"):
@@ -54,11 +74,37 @@
            case ("4"):
                //短信
                int i = iSmsParamService.sendSmsInfo(sendMagParam.getUrl(), sendMagParam.getPhone());
                if (i == 1) {
                    return true;
                Map<String, String> map2 = new HashMap<>();
                map2.put("action", "send");
                map2.put("account", xhsmsAccount);
                map2.put("password", xhsmsPwd);
                map2.put("mobile", sendMagParam.getPhone());
                map2.put("content", sendMagParam.getContent());
                map2.put("extno", xhsmsjrm);
                map2.put("rt", "json");
                StringBuilder encodedParams = new StringBuilder();
                for (Map.Entry<String, String> entry : map2.entrySet()) {
                    if (encodedParams.length() > 0) {
                        encodedParams.append("&");
                    }
                    // 对键和值进行URL编码
                    String encodedKey = URLEncoder.encode(entry.getKey(), "UTF-8");
                    String encodedValue = URLEncoder.encode(entry.getValue(), "UTF-8");
                    encodedParams.append(encodedKey).append("=").append(encodedValue);
                }
                String result = HttpUtils.sendPost(xhsmsPath, encodedParams.toString());
                ObjectMapper objectMapper2 = new ObjectMapper();
                Map<String, Object> map3 = objectMapper2.readValue(result, new TypeReference<Map<String, Object>>() {
                });
                if (ObjectUtils.isNotEmpty(map3)) {
                    String status = map3.get("status").toString();
                    if (status.equals("0")) {
                        return true;
                    }
                }
                log.error("短信发送失败map:{},  返回的信息为:{}", map2, result);
                return false;
            case ("5"):
                //公众号
smartor/src/main/java/com/smartor/domain/CommonTaskcallMQ.java
@@ -35,8 +35,8 @@
    /**
     * 任务发送方式:“电话,短信,公众号,链接...”以逗号分隔
     */
    @Excel(name = "任务发送方式:电话,短信,公众号,链接...")
    @ApiModelProperty(value = "务发送方式:电话,短信,公众号...   以逗号分隔")
    @Excel(name = "任务发送方式:1,人工 2,纸质  3,电话  4,短信  5.微信公众号 6.微信小程序 7.支付宝小程序  8.智能机器人  9.钉钉")
    @ApiModelProperty(value = "务发送方式:1,人工 2,纸质  3,电话  4,短信  5.微信公众号 6.微信小程序 7.支付宝小程序  8.智能机器人  9.钉钉")
    private String preachform;
smartor/src/main/java/com/smartor/domain/IvrLibaTemplateScriptVO.java
@@ -70,6 +70,13 @@
    private String scriptContent;
    /**
     * 话术语音
     */
    @Excel(name = "话术语音")
    @ApiModelProperty(value = "话术语音")
    private String scriptVoice;
    /**
     * 话术描述
     */
    @Excel(name = "话术描述")
@@ -318,12 +325,16 @@
    @ApiModelProperty(value = "是否必填(给人工用的,AI不用遵守)")
    private String isMust;
//    /**
//     * 问题结果(给“值类型”是文本或者数值用的)
//     */
//    @Excel(name = "问题结果(给“值类型”是文本或者数值用的)")
//    @ApiModelProperty(value = "问题结果(给“值类型”是文本或者数值用的)")
//    private String questionResult;
    /**
     * 问题结果(给“值类型”是文本或者数值用的)
     */
    @Excel(name = "问题结果(给“值类型”是文本或者数值用的)")
    @ApiModelProperty(value = "问题结果(给“值类型”是文本或者数值用的)")
    private String questionResult;
    @Excel(name = "通用库匹配的值")
    @ApiModelProperty(value = "通用库匹配的值")
    private String commonValue = "";
    /**
     * 话术选项
smartor/src/main/java/com/smartor/domain/PatTaskRelevance.java
@@ -167,6 +167,13 @@
    private String phone;
    /**
     * 手机号
     */
    @Excel(name = "手机code")
    @ApiModelProperty("手机code")
    private String telcode;
    /**
     * 病历号
     */
    @Excel(name = "病历号")
smartor/src/main/java/com/smartor/domain/PhoneCallBackYQVO.java
@@ -41,4 +41,7 @@
    @ApiModelProperty(value = "不同操作类型所对应的参数值")
    private String value;
    @ApiModelProperty(value = "通过库匹配的结果")
    private String commonValue = "";
}
smartor/src/main/java/com/smartor/domain/ServiceSubtaskVO.java
@@ -387,7 +387,7 @@
     */
    @Excel(name = " 宣教形式 :文本、图片、语音、视频、混合")
    @ApiModelProperty(value = "宣教形式 : 1,文本、2,图片、3,语音、4,视频、5,混合")
    private String serviceform;
    private String preachform;
    /**
smartor/src/main/java/com/smartor/domain/SocketMessage.java
@@ -11,7 +11,7 @@
    //模板ID
    private Long templateId;
    //问题信息
    private QuestionMessage questionMessage;
    private QuestionMessagePhone questionMessage;
    //用户ID(接收放)
    private String userId;
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -327,7 +327,7 @@
                    serviceSubtask.setSendname(patTaskRelevance.getName());
                    serviceSubtask.setAge(patTaskRelevance.getAge());
                    serviceSubtask.setSfzh(patTaskRelevance.getIdcardno());
                    serviceSubtask.setPhone(patTaskRelevance.getPhone());
                    serviceSubtask.setPhone(patTaskRelevance.getTelcode());
                    serviceSubtask.setAddr(patTaskRelevance.getAddr());
                    serviceSubtask.setPatid(patTaskRelevance.getPatid());
                    serviceSubtask.setCreateTime(DateUtils.getNowDate());
@@ -646,6 +646,27 @@
     */
    @Override
    public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) {
        //判断是否挂机
        String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup");
        if (StringUtils.isNotEmpty(hangupState) && hangup.equals("1")) {
            return new PhoneCallBackYQVO();
        }
        if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
            //处理挂断
            if (phoneCallReqYQVO.getAsrtext().contains("拨叫的用户正忙")) {
                ServiceSubtask serviceSubtask2 = new ServiceSubtask();
                serviceSubtask2.setRemark("电话发送成功(患者挂断)");
                serviceSubtask2.setSenduuid(phoneCallReqYQVO.getUuid());
                serviceSubtask2.setId(Long.valueOf(phoneCallReqYQVO.getTaskid()));
                serviceSubtaskMapper.updateServiceSubtask(serviceSubtask2);
                Map<String, String> req = new HashMap<>();
                req.put("uuid", phoneCallReqYQVO.getUuid());
                req.put("caller", phoneCallReqYQVO.getPhone());
                HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- hangup", "1", 2, TimeUnit.MINUTES);
                return new PhoneCallBackYQVO();
            }
        }
        //定义一个分数的变量
        Boolean aBoolean1 = redisCache.hasKey(phoneCallReqYQVO.getUuid() + "SCORE");
        if (!aBoolean1) redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", 0.0, 120, TimeUnit.MINUTES);
@@ -669,7 +690,8 @@
                    Map<String, String> req = new HashMap<>();
                    req.put("uuid", phoneCallReqYQVO.getUuid());
                    req.put("caller", phoneCallReqYQVO.getPhone());
                    HttpUtils.sendPost(hangup, new Gson().toJson(req));
//                    HttpUtils.sendPost(hangup, new Gson().toJson(req));
                    HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
                    //删除结束语的患存
                    redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "- jsy");
                } else {
@@ -723,10 +745,11 @@
                return phoneCallBackYQVO;
            } else {
                log.error("静默次数达到,挂掉电话:{}", num);
                ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                //大与等于的话,直接挂断
                phoneCallBackYQVO.setType("text");
                phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
                phoneCallBackYQVO.setValue(serviceTask1.getJsy());
                //将结果写到detail中
                ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
                List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>();
@@ -746,29 +769,65 @@
                redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
                redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
                //在redis中保存一下结束语,在调用挂电话的方法时删除
                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
                ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
            }
            return phoneCallBackYQVO;
        } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
            //播报第一题
            Integer integer = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort");
//            if(integer==0){
//                //integer==0,表示开场白刚播报完,需要停顿一下,等患者说话
//                redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES);
//                return phoneCallBackYQVO;
//            }
            if (ivrTaskTemplateScriptVO.getSort() == 1 && integer == 1) {
                phoneCallBackYQVO.setType("text");
                phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                String scriptContent = ivrTaskTemplateScriptVO.getScriptContent();
                phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
                redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort", 2, 120, TimeUnit.MINUTES);
                return phoneCallBackYQVO;
            // 先对通话进行通用库匹配一次
            String extemplateID = ivrTaskTemplate.getSubmoduleID();
            if (StringUtils.isNotEmpty(extemplateID)) {
                String[] split = extemplateID.split(",");
                List<String> list = Arrays.asList(split);
                List<Long> list1 = new ArrayList<>();
                for (String str : list) {
                    list1.add(Long.valueOf(str));
                }
                List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
                IvrLibaExtemplatescript les = null;
                for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
                    Matcher matcher = null;
                    if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
                        Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
                        matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
                    }
                    Matcher matcher2 = null;
                    if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
                        Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
                        matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
                    }
                    if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
                        //将通用库匹配的,放到返回值中
//                        phoneCallBackYQVO.setValue(phoneCallBackYQVO.getValue() + ivrLibaExtemplatescript.getSwitchText());
                        phoneCallBackYQVO.setCommonValue(ivrLibaExtemplatescript.getSwitchText());
                        les = ivrLibaExtemplatescript;
                    }
                    break;
                }
                if (ObjectUtils.isNotEmpty(les)) {
                    //对匹配的结果处理一下(看看是不是需要挂机)
                    if (les.getIsEnd() != null && les.getIsEnd() == 1) {
                        //可以挂机了
                        redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
                        redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
                        redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
                        redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "noVoice");
                        //在redis中保存一下结束语,在调用挂电话的方法时删除
                        ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                        redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
                        phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask.getJsy());
                        return phoneCallBackYQVO;
                    }
                }
            }
            //如果是文本回调
            //根据问题ID获取该问题的类型
            if (ivrTaskTemplateScriptVO.getScriptType().equals("1")) {
                //用来标记,是否有匹配上的
                Integer flag = 0;
                //是选择题
                for (int j = 0; j < ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size(); j++) {
                    log.error("phoneCallReqYQVO.getAsrtext()的值为:{}", phoneCallReqYQVO.getAsrtext());
@@ -800,6 +859,7 @@
                        serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate));
                        serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
                        saveQuestionAnswerPhone(serviceSubTaskDetailReq);
                        flag = 1;
                        //将当前前的播报状态删除,给下一题让位
                        redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
//                        //获取下一题
@@ -818,7 +878,7 @@
                                Object obj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
                                Double score = (obj == null ? new Double(0.00) : new Double(((Double) obj).doubleValue()));
                                score = BigDecimal.valueOf(score).add(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getScore()).doubleValue();
                                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score,120,TimeUnit.MINUTES);
                                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES);
                            }
                            for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) {
@@ -827,38 +887,47 @@
                                    phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                                    String scriptContent = script.getScriptContent();
                                    log.error("下一题问题:{}", scriptContent);
                                    phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
                                    phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
                                    //将该患者的Redis中的题目ID,进行修改
                                    redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
                                    //删除无响应
                                    redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
                                }
                            }
                        } else if (ivrTaskTemplateScriptVO.getBranchFlag().equals("0")) {
                            if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
                                phoneCallBackYQVO.setType("text");
                                phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                                //更新一下分数
                                double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
                                serviceSubtask.setScore(BigDecimal.valueOf(score));
                                serviceSubtask.setFinishtime(new Date());
                                serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                                //设置结束语
                                phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
                                Long id = serviceSubtask.getId();
                                Map<String, String> map = delRedisValue(null, id.toString());
                                redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
                                redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
                                redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
                                redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
                                redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
                                //在redis中保存一下结束语,在调用挂电话的方法时删除
                                redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
                        } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
                            ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                            phoneCallBackYQVO.setType("text");
                            phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                            //更新一下分数
                            double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
                            serviceSubtask.setScore(BigDecimal.valueOf(score));
                            serviceSubtask.setFinishtime(new Date());
                            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                            //设置结束语
                            phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask1.getJsy());
                            Long id = serviceSubtask.getId();
                            Map<String, String> map = delRedisValue(null, id.toString());
                            redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
                            redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
                            redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
                            redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
                            redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
                            //在redis中保存一下结束语,在调用挂电话的方法时删除
                            ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                            redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
//                                return phoneCallBackYQVO;
                            }
                        }
                    } else {
                        continue;
                        //flag=0,说明没 匹配上,也要把患者说的话记录下来
                        if (j == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1 && flag == 0) {
                            ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
                            List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>();
                            serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate));
                            serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
                            saveQuestionAnswerPhone(serviceSubTaskDetailReq);
                            continue;
                        }
                    }
                }
                //都没有匹配到
@@ -868,11 +937,12 @@
                        //如果count已经大于或等于没有匹配次数
                        if (ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() == 0 || ivrTaskTemplateScriptVO.getBranchFlag().equals("1") && ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getBranchFlag().equals("1") && ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
                            //如果是最后一道题,或者没有下一题了,就直接挂机
                            ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                            phoneCallBackYQVO.setType("text");
                            phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                            if (StringUtils.isNotEmpty(phoneCallBackYQVO.getValue()))
                                phoneCallBackYQVO.setValue(phoneCallBackYQVO.getValue() + ivrTaskTemplate.getRevisitAfter());
                            else phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
                                phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + phoneCallBackYQVO.getValue() + serviceTask1.getJsy());
                            else phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask1.getJsy());
                            //更新一下分数
                            double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
@@ -881,7 +951,8 @@
                            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                            //在redis中保存一下结束语,在调用挂电话的方法时删除
                            redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
                            ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                            redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
                            //去redis中,把该子任务ID删除
                            Long id = serviceSubtask.getId();
                            Map<String, String> map = delRedisValue(null, id.toString());
@@ -896,7 +967,7 @@
                                    phoneCallBackYQVO.setType("text");
                                    phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                                    String scriptContent = script.getScriptContent();
                                    phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
                                    phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
                                    //将该患者的Redis中的题目ID,进行修改
                                    redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
@@ -904,7 +975,7 @@
                                    double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
                                    score = BigDecimal.valueOf(score).add(script.getScore()).doubleValue();
                                    redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score,120, TimeUnit.MINUTES);
                                    redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES);
                                }
                            }
                        }
@@ -926,7 +997,7 @@
                serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate));
                serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
                saveQuestionAnswerPhone(serviceSubTaskDetailReq);
//                String xh = idSort.split("-")[1];
                //    String xh = idSort.split("-")[1];
                //如果选项分支为1的话,则需要根据问题上的nextScriptno进行跳转
                //问答题没有跳转
@@ -936,23 +1007,23 @@
                            phoneCallBackYQVO.setType("text");
                            phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                            String scriptContent = ivrTaskTemplateScript1.getScriptContent();
                            phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
                            phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
                            redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
                            redisCache.setCacheObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone(), ivrTaskTemplateScript1.getId().toString());
                            //更新一下分数
                            double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
                            score = BigDecimal.valueOf(score).add(ivrTaskTemplateScriptVO.getScore()).doubleValue();
                            redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score,120, TimeUnit.MINUTES);
                            redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES);
//                            return phoneCallBackYQVO;
                        }
                    }
                } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
                    //没有下一题了,就结束了
                    ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                    phoneCallBackYQVO.setType("text");
                    phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
                    phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
                    phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask1.getJsy());
                    //更新一下分数
                    double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
@@ -965,42 +1036,13 @@
                    Map<String, String> map = delRedisValue(null, id.toString());
                    redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
                    //在redis中保存一下结束语,在调用挂电话的方法时删除
                    redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
                    redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask1.getJsy(), 120, TimeUnit.MINUTES);
                    redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
                    redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
                }
                //选项匹配完成后,需要再去通过库再进行匹配一次
                String extemplateID = ivrTaskTemplate.getSubmoduleID();
                if (StringUtils.isNotEmpty(extemplateID)) {
                    String[] split = extemplateID.split(",");
                    List<String> list = Arrays.asList(split);
                    List<Long> list1 = new ArrayList<>();
                    for (String str : list) {
                        list1.add(Long.valueOf(str));
                    }
                    List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
                    for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
                        Matcher matcher = null;
                        if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
                            Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
                            matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
                        }
                        Matcher matcher2 = null;
                        if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
                            Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
                            matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
                        }
                        if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
                            //将通用库匹配的,放到返回值中
                            phoneCallBackYQVO.setValue(phoneCallBackYQVO.getValue() + ivrLibaExtemplatescript.getSwitchText());
                        }
                        break;
                    }
                }
            }
        }
        log.error("phoneCallBackYQVO的返回值是:{}", phoneCallBackYQVO);
        return phoneCallBackYQVO;
    }
@@ -1129,7 +1171,9 @@
                String subId = split[i].trim().replace(",", "");
                ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(subId));
                ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
                IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid());
                if (ObjectUtils.isEmpty(ivrTaskTemplate)) continue;
                //通过任务模板中的"第一次问题编号"获取第一个问题;
                IvrTaskTemplateScript ivrTaskTemplateScript = null;
                IvrTaskTemplateScript ivrTaskTemplateScript1 = new IvrTaskTemplateScript();
@@ -1145,9 +1189,9 @@
                //如果ivrTaskTemplateScript为空,也就没有往下执行的必要了
                if (ObjectUtils.isEmpty(ivrTaskTemplateScript)) return null;
                //获取通配符匹配过后的问题
//                String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent());
//                String kcb = ivrTaskTemplate.getRevisitBefore() + "," + scrContent;
                String kcb = ivrTaskTemplate.getRevisitBefore();
                String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent());
                String kcb = serviceTask.getKcb() + "," + scrContent;
//                String kcb = ivrTaskTemplate.getRevisitBefore();
                //封装返回数据
                //taskId = 子任务ID + 问题ID +问题序号
@@ -1159,7 +1203,7 @@
                pullTaskVO.setDisplayNo("85129866");
                pullTaskVOList.add(pullTaskVO);
                redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim(), ivrTaskTemplateScript.getId().toString());
                redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES);
//                redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES);
            } else {
                if (StringUtils.isEmpty(newValue0)) {
                    newValue0 = "," + split[i].trim() + ",";