| | |
| | | private IIvrTaskService ivrTaskService; |
| | | |
| | | @Autowired |
| | | private IvrLibaTemplateTargetoptionMapper ivrLibaScriptTargetoptionMapper; |
| | | private IvrTaskTemplateTargetoptionMapper ivrTaskScriptTargetoptionMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaTemplateScriptMapper ivrLibaTemplateScriptMapper; |
| | | private IvrLibaTemplateScriptMapper ivrTaskTemplateScriptMapper; |
| | | |
| | | @Autowired |
| | | private IvrTaskVisitResultMapper ivrTaskVisitResultMapper; |
| | |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | new BaseException("该任务不存在"); |
| | | } |
| | | //将查出来的数据倒入IvrTaskcallVO中 |
| | | IvrTaskSingleVO ivrTaskcallVO2 = DtoConversionUtils.sourceToTarget(list.get(0), IvrTaskSingleVO.class); |
| | | String sendTimeSlot = list.get(0).getSendTimeSlot(); |
| | | IvrTask ivrTask = ivrTaskService.selectIvrTaskByTaskid(ivrTaskcall.getTaskid()); |
| | | //将查出来的数据倒入ivrTasksingleVO中 |
| | | IvrTaskSingleVO ivrTasksingleVO2 = DtoConversionUtils.sourceToTarget(list.get(0), IvrTaskSingleVO.class); |
| | | String sendTimeSlot = ivrTask.getSendTimeSlot(); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | try { |
| | | //获取到发送时间的集合 |
| | | if (com.ruoyi.common.utils.StringUtils.isNotEmpty(sendTimeSlot)) { |
| | | List<TaskSendTimeVO> taskSendTimeVOList = objectMapper.readValue(sendTimeSlot, List.class); |
| | | ivrTaskcallVO2.setSendTimeslot(taskSendTimeVOList); |
| | | ivrTasksingleVO2.setSendTimeslot(taskSendTimeVOList); |
| | | } |
| | | //文本变量参数 |
| | | if (com.ruoyi.common.utils.StringUtils.isNotEmpty(list.get(0).getTextParam())) { |
| | | Map<String, Map<String, String>> textParam = objectMapper.readValue(list.get(0).getTextParam(), Map.class); |
| | | ivrTaskcallVO2.setTextParam(textParam); |
| | | ivrTasksingleVO2.setTextParam(textParam); |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | ivrTaskcallVO2.setPatTaskRelevances(patTaskRelevances); |
| | | return ivrTaskcallVO2; |
| | | ivrTasksingleVO2.setPatTaskRelevances(patTaskRelevances); |
| | | return ivrTasksingleVO2; |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int insertOrUpdateTask(IvrTaskSingleVO ivrTaskcallVO) { |
| | | if (ObjectUtils.isEmpty(ivrTaskcallVO)) { |
| | | public int insertOrUpdateTask(IvrTaskSingleVO ivrTasksingleVO) { |
| | | if (ObjectUtils.isEmpty(ivrTasksingleVO)) { |
| | | log.info("任务入参为空,请检查入参"); |
| | | throw new BaseException("任务入参为空,请检查入参"); |
| | | } |
| | | Integer integer = 0; |
| | | if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 1) { |
| | | if (ivrTasksingleVO.getIsoperation() != null && ivrTasksingleVO.getIsoperation() == 1) { |
| | | //往任务表中,新增任务 |
| | | IvrTask ivrTask = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTask.class); |
| | | IvrTask ivrTask = DtoConversionUtils.sourceToTarget(ivrTasksingleVO, IvrTask.class); |
| | | if (ObjectUtils.isNotEmpty(ivrTasksingleVO.getSendTimeslot())) |
| | | ivrTask.setSendTimeSlot(JSON.toJSONString(ivrTasksingleVO.getSendTimeslot())); |
| | | ivrTaskService.insertIvrTask(ivrTask); |
| | | |
| | | ivrTaskcallVO.setTaskid(ivrTask.getTaskid().longValue()); |
| | | ivrTasksingleVO.setTaskid(ivrTask.getTaskid().longValue()); |
| | | //新增 |
| | | if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getPatTaskRelevances())) { |
| | | for (PatTaskRelevance patTaskRelevance : ivrTaskcallVO.getPatTaskRelevances()) { |
| | | //将任务信息新增到宣教任务表中 |
| | | IvrTaskSingle ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskSingle.class); |
| | | if (CollectionUtils.isNotEmpty(ivrTasksingleVO.getPatTaskRelevances())) { |
| | | for (PatTaskRelevance patTaskRelevance : ivrTasksingleVO.getPatTaskRelevances()) { |
| | | //将任务信息新增到随访服务表中 |
| | | IvrTaskSingle ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTasksingleVO, IvrTaskSingle.class); |
| | | ivrTaskcall.setSendname(patTaskRelevance.getName()); |
| | | ivrTaskcall.setAge(patTaskRelevance.getAge()); |
| | | ivrTaskcall.setSfzh(patTaskRelevance.getSfzh()); |
| | |
| | | ivrTaskcall.setAddr(patTaskRelevance.getAddr()); |
| | | ivrTaskcall.setCreateTime(DateUtils.getNowDate()); |
| | | ivrTaskcall.setTextParam(new Gson().toJson(patTaskRelevance.getTextParam())); |
| | | if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) { |
| | | ivrTaskcall.setSendTimeSlot(ivrTaskcallVO.getSendTimeslot().toString()); |
| | | } |
| | | ivrTaskSingleMapper.insertIvrTaskcall(ivrTaskcall); |
| | | integer = ivrTaskcall.getId().intValue(); |
| | | } |
| | | } |
| | | |
| | | } else if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 2) { |
| | | } else if (ivrTasksingleVO.getIsoperation() != null && ivrTasksingleVO.getIsoperation() == 2) { |
| | | //任务修改 |
| | | IvrTask ivrTask = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTask.class); |
| | | IvrTask ivrTask = DtoConversionUtils.sourceToTarget(ivrTasksingleVO, IvrTask.class); |
| | | if (ObjectUtils.isNotEmpty(ivrTasksingleVO.getSendTimeslot())) |
| | | ivrTask.setSendTimeSlot(JSON.toJSONString(ivrTasksingleVO.getSendTimeslot())); |
| | | //获取表里的stopState数值 + 1 |
| | | IvrTask ivrTask1 = ivrTaskService.selectIvrTaskByTaskid(ivrTask.getTaskid()); |
| | | ivrTask.setStopState(ivrTask1.getStopState() + 1); |
| | | ivrTaskService.updateIvrTask(ivrTask); |
| | | |
| | | if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getPatTaskRelevances())) { |
| | | for (PatTaskRelevance patTaskRelevance : ivrTaskcallVO.getPatTaskRelevances()) { |
| | | if (CollectionUtils.isNotEmpty(ivrTasksingleVO.getPatTaskRelevances())) { |
| | | for (PatTaskRelevance patTaskRelevance : ivrTasksingleVO.getPatTaskRelevances()) { |
| | | |
| | | IvrTaskSingle ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskSingle.class); |
| | | IvrTaskSingle ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTasksingleVO, IvrTaskSingle.class); |
| | | ivrTaskcall.setSendname(patTaskRelevance.getName()); |
| | | ivrTaskcall.setAge(patTaskRelevance.getAge()); |
| | | ivrTaskcall.setSfzh(patTaskRelevance.getSfzh()); |
| | | ivrTaskcall.setPhone(patTaskRelevance.getPhone()); |
| | | ivrTaskcall.setAddr(patTaskRelevance.getAddr()); |
| | | ivrTaskcall.setCreateTime(DateUtils.getNowDate()); |
| | | if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) { |
| | | ivrTaskcall.setSendTimeSlot(ivrTaskcallVO.getSendTimeslot().toString()); |
| | | } |
| | | ivrTaskcall.setTextParam(new Gson().toJson(ivrTaskcallVO.getTextParam())); |
| | | ivrTaskcall.setTextParam(new Gson().toJson(ivrTasksingleVO.getTextParam())); |
| | | if (patTaskRelevance.getIsoperation() == 2) ivrTaskSingleMapper.updateIvrTaskcall(ivrTaskcall); |
| | | if (patTaskRelevance.getIsoperation() == 1) ivrTaskSingleMapper.insertIvrTaskcall(ivrTaskcall); |
| | | integer = ivrTaskcall.getId().intValue(); |
| | | } |
| | | } |
| | | |
| | | } else if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 3) { |
| | | ivrTaskSingleMapper.deleteIvrTaskcallById(ivrTaskcallVO.getId()); |
| | | } else if (ivrTasksingleVO.getIsoperation() != null && ivrTasksingleVO.getIsoperation() == 3) { |
| | | ivrTaskSingleMapper.deleteIvrTaskcallById(ivrTasksingleVO.getId()); |
| | | |
| | | integer = ivrTaskcallVO.getId().intValue(); |
| | | integer = ivrTasksingleVO.getId().intValue(); |
| | | } |
| | | return integer; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int heTaskSend(IvrTaskSingleVO ivrTaskcallVO) { |
| | | public int heTaskSend(SendTaskVO sendTaskVO) { |
| | | if (sendTaskVO.getTaskId() == null) throw new BaseException("任务ID不能为空,请检查后,再进行执行"); |
| | | IvrTask ivrTask = ivrTaskService.selectIvrTaskByTaskid(sendTaskVO.getTaskId()); |
| | | if (StringUtils.isNotEmpty(sendTaskVO.getSendState()) && sendTaskVO.getSendState().equals("3") || StringUtils.isNotEmpty(sendTaskVO.getSendState()) && sendTaskVO.getSendState().equals("4")) { |
| | | //任务暂停或终止 |
| | | IvrTask ivrTask3 = new IvrTask(); |
| | | ivrTask3.setTaskid(sendTaskVO.getTaskId()); |
| | | ivrTask3.setStopState(ivrTask.getStopState() + 1); |
| | | ivrTask3.setSendState(sendTaskVO.getSendState()); |
| | | ivrTaskService.updateIvrTask(ivrTask3); |
| | | return 0; |
| | | } |
| | | |
| | | //判断发送状态是否为空 |
| | | if (StringUtils.isEmpty(sendTaskVO.getSendType())) { |
| | | sendTaskVO.setSendType(ivrTask.getSendType().toString()); |
| | | } |
| | | |
| | | //判断任务是否是立即发送 |
| | | if (ivrTaskcallVO.getSendType().equals("2")) { |
| | | if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) { |
| | | IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ(); |
| | | ivrTaskcallMQ.setTaskid(ivrTaskcallVO.getTaskid()); |
| | | ivrTaskcallMQ.setSendType("1"); |
| | | ivrTaskcallMQ.setTemplateid(ivrTaskcallVO.getTemplateid()); |
| | | ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId()); |
| | | ivrTaskcallMQ.setSendType(sendTaskVO.getSendType()); |
| | | ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString()); |
| | | ivrTaskcallMQ.setStopState(ivrTask.getStopState()); |
| | | |
| | | String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ); |
| | | ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1); |
| | | //立即发送 |
| | | rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L); |
| | | |
| | | } else if (ivrTaskcallVO.getSendType().equals("1")) { |
| | | //将任务状态修改成执行中 |
| | | IvrTask ivrTask2 = new IvrTask(); |
| | | ivrTask2.setTaskid(ivrTask.getTaskid()); |
| | | ivrTask2.setSendState("2"); |
| | | ivrTask2.setStopState(ivrTask.getStopState() + 1); |
| | | ivrTaskService.updateIvrTask(ivrTask2); |
| | | } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1")) { |
| | | //时间段发送 |
| | | if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) { |
| | | for (TaskSendTimeVO taskSendTimeVO : ivrTaskcallVO.getSendTimeslot()) { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (StringUtils.isNotEmpty(ivrTask.getSendTimeSlot())) { |
| | | List<TaskSendTimeVO> taskSendTimeVOList = null; |
| | | try { |
| | | taskSendTimeVOList = objectMapper.readValue(ivrTask.getSendTimeSlot(), List.class); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JsonProcessingException报错了:{}", e.getMessage()); |
| | | } |
| | | for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) { |
| | | //去SendTimeslot中,获取所有的时间段 |
| | | List<TaskSendTimeVO> list = new ArrayList<>(); |
| | | list.add(taskSendTimeVO); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ(); |
| | | ivrTaskcallMQ.setTaskid(ivrTaskcallVO.getTaskid()); |
| | | ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId()); |
| | | ivrTaskcallMQ.setSendType("1"); |
| | | ivrTaskcallMQ.setTemplateid(ivrTaskcallVO.getTemplateid()); |
| | | ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString()); |
| | | ivrTaskcallMQ.setSendTimeslot(list); |
| | | ivrTaskcallMQ.setStopState(ivrTask.getStopState()); |
| | | |
| | | Long finalMilliseconds = milliseconds; |
| | | String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ); |
| | |
| | | rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L); |
| | | } |
| | | //将任务状态修改成执行中 |
| | | IvrTask ivrTask = new IvrTask(); |
| | | ivrTask.setTaskid(ivrTaskcallVO.getTaskid()); |
| | | ivrTask.setSendState("2"); |
| | | ivrTaskService.updateIvrTask(ivrTask); |
| | | IvrTask ivrTask2 = new IvrTask(); |
| | | ivrTask2.setTaskid(ivrTask.getTaskid()); |
| | | ivrTask2.setSendState("2"); |
| | | ivrTask2.setStopState(ivrTask.getStopState() + 1); |
| | | ivrTaskService.updateIvrTask(ivrTask2); |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | |
| | | |
| | | Map<String, Object> map = redisCache.getCacheObject(phoneCallBackVO.getUuid()); |
| | | IvrTaskSingle ivrTaskcall = (IvrTaskSingle) map.get("ivrTaskSingle"); |
| | | List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOs = (List<IvrLibaTemplateScriptVO>) map.get("ivrLibaTemplateScriptVO"); |
| | | List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVOs = (List<IvrTaskTemplateScriptVO>) map.get("ivrTaskTemplateScriptVO"); |
| | | //将uuid更新到数据库中 |
| | | ivrTaskcall.setSenduuid(phoneCallBackVO.getUuid()); |
| | | ivrTaskSingleMapper.updateIvrTaskcall(ivrTaskcall); |
| | | |
| | | //获取模板信息 |
| | | IvrLibaTemplateVO ivrLibaTemplateVO = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "ivrLibaTemplateVO"); |
| | | IvrTaskTemplateVO ivrTaskTemplateVO = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "ivrTaskTemplateVO"); |
| | | |
| | | //语音识别结果上报接口: 3 |
| | | Integer noVoice = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "noVoice"); |
| | |
| | | //将传回的结果放到回复对象中 |
| | | returnQues.setContent(phoneCallBackVO.getTextResult()); |
| | | |
| | | IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion(); |
| | | IvrTaskTemplateScriptVO nowQuestion = returnQues.getNowQuestion(); |
| | | |
| | | if (StringUtils.isEmpty(returnQues.getContent())) { |
| | | //无回话 |
| | | //判断noVoice是否已经到了最大值 |
| | | if (noVoice == ivrLibaTemplateVO.getNoVoiceNum().intValue()) { |
| | | if (noVoice == ivrTaskTemplateVO.getNoVoiceNum().intValue()) { |
| | | //已经问了对应的遍数,就判断是否还有下一题 |
| | | if (nowQuestion.getTargetid() == ivrLibaTemplateScriptVOs.size()) { |
| | | if (nowQuestion.getTargetid() == ivrTaskTemplateScriptVOs.size()) { |
| | | //没有下一题了,就挂断电话,播放结束语 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } else { |
| | | //有下一题 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion); |
| | | IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(ivrTaskTemplateScriptVOs, nowQuestion); |
| | | // 问题, 去调用“tts合成和播放”接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | |
| | | //isppd用来记录是否匹配到 |
| | | Boolean isppd = false; |
| | | //有回话,对回答的问题,进行正则匹配(这里只针对选择题,其它题型不行) |
| | | for (int j = 0; j < nowQuestion.getIvrLibaScriptTargetoptionList().size(); j++) { |
| | | for (int j = 0; j < nowQuestion.getIvrTaskScriptTargetoptionList().size(); j++) { |
| | | //包含 |
| | | Matcher matcher = null; |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex())) { |
| | | Pattern pattern = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()); |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) { |
| | | Pattern pattern = Pattern.compile(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()); |
| | | matcher = pattern.matcher(phoneCallBackVO.getTextResult()); |
| | | } |
| | | //不包含 |
| | | Matcher matcher2 = null; |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2())) { |
| | | Pattern pattern2 = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()); |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) { |
| | | Pattern pattern2 = Pattern.compile(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()); |
| | | matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult()); |
| | | } |
| | | log.error("PCB--getQuestionText问题为:{},UUID:{}", nowQuestion.getQuestionText(), phoneCallBackVO.getUuid()); |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) { |
| | | if (StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) { |
| | | //说明匹配正确了 |
| | | //这里应该先判断类型,去再修改,设置IsUserOperation是单选题的改法 |
| | | nowQuestion.getIvrLibaScriptTargetoptionList().get(j).setIsUserOperation(true); |
| | | ivrLibaScriptTargetoptionMapper.updateIvrLibaTemplateTargetoption(nowQuestion.getIvrLibaScriptTargetoptionList().get(j)); |
| | | nowQuestion.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(true); |
| | | ivrTaskScriptTargetoptionMapper.updateIvrTaskTemplateTargetoption(nowQuestion.getIvrTaskScriptTargetoptionList().get(j)); |
| | | |
| | | //将静默置为0 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | |
| | | ivrTaskVisitResult.setQuestion(nowQuestion.getQuestionText()); |
| | | ivrTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult()); |
| | | ivrTaskVisitResult.setCreateTime(new Date()); |
| | | ivrTaskVisitResult.setOptionResult(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetvalue()); |
| | | ivrTaskVisitResult.setOptionResult(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue()); |
| | | ivrTaskVisitResultMapper.insertIvrTaskVisitResult(ivrTaskVisitResult); |
| | | |
| | | //将匹配到的标识改成true |
| | | isppd = true; |
| | | |
| | | //获取下一题 |
| | | Integer nextQuestion = nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion(); |
| | | for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOs) { |
| | | Long nextQuestion = nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getNextQuestion(); |
| | | for (IvrTaskTemplateScriptVO script : ivrTaskTemplateScriptVOs) { |
| | | if (script.getTargetid() == nextQuestion) { |
| | | QuestionMessage questionMessage = new QuestionMessage(); |
| | | questionMessage.setNowQuestion(script); |
| | | questionMessage.setQuestionList(ivrLibaTemplateScriptVOs); |
| | | questionMessage.setQuestionList(ivrTaskTemplateScriptVOs); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(script.getQuestionText(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } else if (nextQuestion > ivrLibaTemplateScriptVOs.size()) { |
| | | } else if (nextQuestion > ivrTaskTemplateScriptVOs.size()) { |
| | | //没有下一题了,就结束了 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.error("没有下一题了,就结束了: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | try { |
| | | Thread.sleep(3000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid()); |
| | | phoneUtils.hangup("", "", ivrTaskTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid()); |
| | | return; |
| | | } |
| | | } |
| | |
| | | Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum"); |
| | | if (mateNum == null) mateNum = 0; |
| | | //无匹配次数去判断是否到最大询问次数,并且所有的选项都匹配完了 |
| | | if (mateNum == ivrLibaTemplateVO.getMateNum().intValue()) { |
| | | if (mateNum == ivrTaskTemplateVO.getMateNum().intValue()) { |
| | | //如果下一题为空.则新的数据返回,并加上感谢语 |
| | | if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) { |
| | | if (nowQuestion.getTargetid() < ivrTaskTemplateScriptVOs.size()) { |
| | | QuestionMessage questionMessage = new QuestionMessage(); |
| | | IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion); |
| | | questionMessage.setQuestionList(ivrLibaTemplateScriptVOs); |
| | | IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(ivrTaskTemplateScriptVOs, nowQuestion); |
| | | questionMessage.setQuestionList(ivrTaskTemplateScriptVOs); |
| | | questionMessage.setNowQuestion(nextQuestion); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES); |
| | |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("就可以挂断电话了------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | try { |
| | | Thread.sleep(3000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid()); |
| | | phoneUtils.hangup("", "", ivrTaskTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid()); |
| | | return; |
| | | } |
| | | } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue()) { |
| | | } else if (mateNum < ivrTaskTemplateVO.getMateNum().intValue()) { |
| | | //没有问到规定次数 |
| | | mateNum = mateNum + 1; |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | //选项匹配完成后,需要再去通过库再进行匹配一次 |
| | | String extemplateID = ivrLibaTemplateVO.getSubmoduleID(); |
| | | String extemplateID = ivrTaskTemplateVO.getSubmoduleID(); |
| | | String[] split = extemplateID.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | List<Long> list1 = new ArrayList<>(); |
| | |
| | | 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 questionMessage = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues"); |
| | | IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = returnQues.getNowQuestion(); |
| | | ivrLibaTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText()); |
| | | ivrLibaTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav()); |
| | | IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO = returnQues.getNowQuestion(); |
| | | ivrTaskTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText()); |
| | | ivrTaskTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav()); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | if (ivrLibaExtemplatescript.getIsEnd() == 1) { |
| | | //将问题置空 |
| | | IvrLibaTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion(); |
| | | IvrTaskTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion(); |
| | | nowQuestion1.setQuestionText(null); |
| | | nowQuestion1.setQuestionVoice(null); |
| | | questionMessage.setNowQuestion(nowQuestion1); |
| | |
| | | //调用“15、tts合成和播放, tts_playback”将结果传回 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("调用“15、tts合成和播放------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getQuestionText() + ivrLibaTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getQuestionText() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid()); |
| | | } |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //下面的代码不能删除,上面的方法只是配合电话端联调用的, |
| | | // @Override |
| | |
| | | // return phoneCallBackVO; |
| | | // } |
| | | |
| | | private IvrLibaTemplateScriptVO getNextQuestion(List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOList, IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO) { |
| | | |
| | | for (int j = 0; j < ivrLibaTemplateScriptVOList.size(); j++) { |
| | | if (ivrLibaTemplateScriptVOList.get(j).getTargetid() == ivrLibaTemplateScriptVO.getTargetid() + 1) { |
| | | private IvrTaskTemplateScriptVO getNextQuestion(List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVOList, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO) { |
| | | |
| | | for (int j = 0; j < ivrTaskTemplateScriptVOList.size(); j++) { |
| | | if (ivrTaskTemplateScriptVOList.get(j).getTargetid() == ivrTaskTemplateScriptVO.getTargetid() + 1) { |
| | | // 对该条templateScriptVO进行处理 |
| | | return ivrLibaTemplateScriptVOList.get(j); |
| | | return ivrTaskTemplateScriptVOList.get(j); |
| | | } |
| | | } |
| | | return null; |