| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Time; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalTime; |
| | |
| | | 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()); |
| | |
| | | Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2()); |
| | | matcher2 = pattern2.matcher(returnQues.getContent()); |
| | | } |
| | | log.info("++++++++++++++++++++++++++通用库是否为空:selfRegex : {} , selfRegex2 : {}", ivrLibaExtemplatescript.getSelfRegex(), ivrLibaExtemplatescript.getSelfRegex2()); |
| | | log.error("++++++++++++++++++++++++++通用库是否为空: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"); |
| | | IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO = returnQues.getNowQuestion(); |
| | |
| | | */ |
| | | @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); |
| | |
| | | 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 { |
| | |
| | | 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<>(); |
| | |
| | | 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()); |
| | |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | flag = 1; |
| | | //将当前前的播报状态删除,给下一题让位 |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop"); |
| | | // //获取下一题 |
| | |
| | | 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); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) { |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | //都没有匹配到 |
| | |
| | | //如果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"); |
| | |
| | | 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()); |
| | |
| | | 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); |
| | | |
| | |
| | | double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | score = BigDecimal.valueOf(score).add(script.getScore()).doubleValue(); |
| | | |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | } |
| | |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | // String xh = idSort.split("-")[1]; |
| | | // String xh = idSort.split("-")[1]; |
| | | |
| | | //如果选项分支为1的话,则需要根据问题上的nextScriptno进行跳转 |
| | | //问答题没有跳转 |
| | |
| | | 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); |
| | | 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"); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | //如果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 +问题序号 |
| | |
| | | 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() + ","; |