| | |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.RSAPublicKeyExample; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.smartor.common.FtpService; |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IIvrTaskTemplateScriptService; |
| | | import com.smartor.service.IIvrTaskTemplateService; |
| | | import com.smartor.service.IServiceSubtaskService; |
| | | import com.smartor.service.IServiceTaskService; |
| | | import com.smartor.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import static cn.hutool.poi.excel.sax.AttributeName.r; |
| | | import static cn.hutool.poi.excel.sax.AttributeName.s; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 单一任务(随访)Service业务层处理 |
| | |
| | | |
| | | @Autowired |
| | | private IIvrTaskTemplateService ivrTaskTemplateService; |
| | | |
| | | @Autowired |
| | | private ISvyTaskTemplateService svyTaskTemplateService; |
| | | |
| | | @Autowired |
| | | private IIvrTaskTemplateScriptService iIvrTaskTemplateScriptService; |
| | | |
| | | @Autowired |
| | | private FtpService ftpService; |
| | | |
| | | @Value("${pri_key}") |
| | | private String pri_key; |
| | | |
| | | @Value("${ASRCallBackPath}") |
| | | private String ASRCallBackPath; |
| | | |
| | | @Value("${hangup}") |
| | | private String hangup; |
| | | |
| | | @Value("${app_key_yq}") |
| | | private String app_key_yq; |
| | | |
| | | @Value("${ruoyi.profile}") |
| | | private String profile; |
| | | |
| | | @Value("${voicePathPrefix}") |
| | | private String voicePathPrefix; |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 查询单一任务(随访)列表 |
| | | * |
| | | * @param ServiceSubtask 单一任务(随访) |
| | | * @param serviceSubtaskVO 单一任务(随访) |
| | | * @return 单一任务(随访) |
| | | */ |
| | | @Override |
| | | public List<ServiceSubtask> selectServiceSubtaskList(ServiceSubtask ServiceSubtask) { |
| | | return serviceSubtaskMapper.selectServiceSubtaskList(ServiceSubtask); |
| | | public List<ServiceSubtask> selectServiceSubtaskList(ServiceSubtaskVO serviceSubtaskVO) { |
| | | return serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | } |
| | | |
| | | @Override |
| | | public ServiceTaskVO queryTaskByCondition(ServiceSubtask ServiceSubtask) { |
| | | public ServiceTaskVO queryTaskByCondition(ServiceSubtask serviceSubtask) { |
| | | //定义患者与单一任务关联表集合 |
| | | List<PatTaskRelevance> patTaskRelevances = new ArrayList<>(); |
| | | List<ServiceSubtask> list = selectServiceSubtaskList(ServiceSubtask); |
| | | ServiceSubtaskVO serviceSubtaskVO = DtoConversionUtils.sourceToTarget(serviceSubtask, ServiceSubtaskVO.class); |
| | | List<ServiceSubtask> list = selectServiceSubtaskList(serviceSubtaskVO); |
| | | |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if (CollectionUtils.isEmpty(list) || list.size() == 0) { |
| | | return new ServiceTaskVO(); |
| | | return DtoConversionUtils.sourceToTarget(serviceTask, ServiceTaskVO.class); |
| | | } |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(ServiceSubtask.getTaskid()); |
| | | |
| | | |
| | | //将查出来的数据倒入ServiceSubtaskVO中 |
| | | ServiceTaskVO serviceTaskVO = DtoConversionUtils.sourceToTarget(serviceTask, ServiceTaskVO.class); |
| | | serviceTaskVO.setShowDate(serviceTask.getShowDate()); |
| | |
| | | //获取到患者信息,并放入到集合中 |
| | | patTaskRelevance.setName(serviceSubtask1.getSendname()); |
| | | patTaskRelevance.setAge(serviceSubtask1.getAge()); |
| | | patTaskRelevance.setFinishtime(serviceSubtask1.getFinishtime()); |
| | | patTaskRelevance.setSfzh(serviceSubtask1.getSfzh()); |
| | | patTaskRelevance.setPhone(serviceSubtask1.getPhone()); |
| | | patTaskRelevance.setTelcode(serviceSubtask1.getPhone()); |
| | | patTaskRelevance.setAddr(serviceSubtask1.getAddr()); |
| | | patTaskRelevance.setDiagname(serviceSubtask1.getDiagname()); |
| | | patTaskRelevance.setPatid(serviceSubtask1.getPatid()); |
| | | patTaskRelevance.setSendStatus(serviceSubtask1.getSendstate()); |
| | | patTaskRelevance.setDeptCode(serviceSubtask1.getDeptcode()); |
| | | patTaskRelevance.setDeptName(serviceSubtask1.getDeptname()); |
| | | patTaskRelevance.setLeavehospitaldistrictcode(serviceSubtask1.getLeavehospitaldistrictcode()); |
| | | patTaskRelevance.setLeavehospitaldistrictname(serviceSubtask1.getLeavehospitaldistrictname()); |
| | | patTaskRelevance.setInhosptime(serviceSubtask1.getInhosptime()); |
| | | patTaskRelevance.setDrname(serviceSubtask1.getDrname()); |
| | | patTaskRelevance.setDrcode(serviceSubtask1.getDrcode()); |
| | | patTaskRelevance.setEndtime(serviceSubtask1.getEndtime()); |
| | | patTaskRelevance.setNurseId(serviceSubtask1.getNurseId()); |
| | | patTaskRelevance.setNurseName(serviceSubtask1.getNurseName()); |
| | | patTaskRelevances.add(patTaskRelevance); |
| | | } |
| | | if (serviceSubtask1.getHospType().equals("2")) { |
| | |
| | | patTaskRelevance.setAge(serviceSubtask1.getAge()); |
| | | patTaskRelevance.setSfzh(serviceSubtask1.getSfzh()); |
| | | patTaskRelevance.setPhone(serviceSubtask1.getPhone()); |
| | | patTaskRelevance.setTelcode(serviceSubtask1.getPhone()); |
| | | patTaskRelevance.setFinishtime(serviceSubtask1.getFinishtime()); |
| | | patTaskRelevance.setAddr(serviceSubtask1.getAddr()); |
| | | patTaskRelevance.setDeptName(serviceSubtask1.getDeptname()); |
| | | patTaskRelevance.setDeptCode(serviceSubtask1.getDeptcode()); |
| | | patTaskRelevance.setBedNo(serviceSubtask1.getBedNo()); |
| | | patTaskRelevance.setDiagname(serviceSubtask1.getDiagname()); |
| | | patTaskRelevance.setPatid(serviceSubtask1.getPatid()); |
| | | patTaskRelevance.setSendStatus(serviceSubtask1.getSendstate()); |
| | | patTaskRelevance.setLeavehospitaldistrictcode(serviceSubtask1.getLeavehospitaldistrictcode()); |
| | | patTaskRelevance.setLeavehospitaldistrictname(serviceSubtask1.getLeavehospitaldistrictname()); |
| | | patTaskRelevance.setInhosptime(serviceSubtask1.getInhosptime()); |
| | | patTaskRelevance.setStarttime(serviceSubtask1.getStarttime()); |
| | | patTaskRelevance.setDrname(serviceSubtask1.getDrname()); |
| | | patTaskRelevance.setDrcode(serviceSubtask1.getDrcode()); |
| | | patTaskRelevance.setEndtime(serviceSubtask1.getEndtime()); |
| | | patTaskRelevance.setStarttime(serviceSubtask1.getStarttime()); |
| | | patTaskRelevance.setNurseId(serviceSubtask1.getNurseId()); |
| | | patTaskRelevance.setNurseName(serviceSubtask1.getNurseName()); |
| | | patTaskRelevances.add(patTaskRelevance); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtask> patItem(ServiceSubtask serviceSubtask) { |
| | | public List<ServiceSubtask> patItem(ServiceSubtaskVO serviceSubtaskVO) { |
| | | List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskVO); |
| | | //根据出院 时间倒序 |
| | | // List<ServiceSubtask> sortedServiceSubtaskList = selectServiceSubtaskList.stream().sorted(Comparator.comparing(ServiceSubtask::getEndtime).reversed()).collect(Collectors.toList()); |
| | | return selectServiceSubtaskList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> patItemCount(ServiceSubtaskVO serviceSubtaskVO) { |
| | | serviceSubtaskVO.setPageSize(99999999); |
| | | serviceSubtaskVO.setPageNum(1); |
| | | List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskVO); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Integer wzx = 0; |
| | | Integer ysf = 0; |
| | | Integer yc = 0; |
| | | Integer fssb = 0; |
| | | Integer yfs = 0; |
| | | Integer blq = 0; |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | if (serviceSubtask.getSendstate() == 4L) wzx = wzx + 1; |
| | | else if (serviceSubtask.getSendstate() != 4L) ysf = ysf + 1; |
| | | if (serviceSubtask.getSendstate() == 5L) fssb = fssb + 1; |
| | | if (serviceSubtask.getSendstate() == 3L) yfs = yfs + 1; |
| | | if (serviceSubtask.getSendstate() == 1L) blq = blq + 1; |
| | | if (serviceSubtask.getExcep().equals("1")) yc = yc + 1; |
| | | } |
| | | map.put("wzx", wzx); |
| | | map.put("ysf", ysf); |
| | | map.put("yc", yc); |
| | | map.put("fssb", fssb); |
| | | map.put("yfs", yfs); |
| | | map.put("blq", blq); |
| | | |
| | | return this.selectServiceSubtaskList(serviceSubtask); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int insertOrUpdateTask(ServiceTaskVO serviceTaskVO) { |
| | | public Map<String, Integer> insertOrUpdateTask(ServiceTaskVO serviceTaskVO) { |
| | | if (ObjectUtils.isEmpty(serviceTaskVO)) { |
| | | log.info("任务入参为空,请检查入参"); |
| | | throw new BaseException("任务入参为空,请检查入参"); |
| | | } |
| | | Integer integer = 1; |
| | | Integer integer = null; |
| | | ServiceTask serviceTask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceTask.class); |
| | | serviceTask.setTextParam(JSON.toJSONString(serviceTaskVO.getTextParam())); |
| | | if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 1) { |
| | | //往任务表中,新增任务 |
| | | if (ObjectUtils.isNotEmpty(serviceTaskVO.getSendTimeslot())) |
| | | serviceTask.setSendTimeSlot(JSON.toJSONString(serviceTaskVO.getSendTimeslot())); |
| | | if (serviceTask.getSendState() == null) serviceTask.setSendState(1); |
| | | serviceTask.setLibtemplateid(serviceTaskVO.getLibtemplateid().toString()); |
| | | if (serviceTask.getSendState() == null) { |
| | | serviceTask.setSendState(1L); |
| | | serviceTaskVO.setSendState(1L); |
| | | } |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getLibtemplateid())) { |
| | | serviceTask.setLibtemplateid(serviceTaskVO.getLibtemplateid()); |
| | | } |
| | | serviceTask.setTemplateid(serviceTaskVO.getTemplateid()); |
| | | |
| | | serviceTask.setLeaveldeptcodes(serviceTaskVO.getLeaveldeptcodes()); |
| | | serviceTask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode()); |
| | | serviceTaskService.insertServiceTask(serviceTask); |
| | | if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1) { |
| | | //这里需要将任务id与任务模板ID,在任务模板中绑定 |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getType()) && serviceTaskVO.getType().equals("1")) { |
| | | IvrTaskTemplate ivrTaskTemplate = new IvrTaskTemplate(); |
| | | ivrTaskTemplate.setTaskid(serviceTask.getTaskid()); |
| | | ivrTaskTemplate.setId(serviceTaskVO.getTemplateid()); |
| | | ivrTaskTemplateService.updateIvrTaskTemplate(ivrTaskTemplate); |
| | | } else if (StringUtils.isNotEmpty(serviceTaskVO.getType()) && serviceTaskVO.getType().equals("2")) { |
| | | SvyTaskTemplate svyTaskTemplate = new SvyTaskTemplate(); |
| | | svyTaskTemplate.setTaskid(serviceTask.getTaskid()); |
| | | svyTaskTemplate.setId(serviceTaskVO.getTemplateid()); |
| | | svyTaskTemplateService.updateSvyTaskTemplate(svyTaskTemplate); |
| | | } |
| | | map.put("subTaskId", null); |
| | | map.put("taskId", serviceTask.getTaskid().intValue()); |
| | | return map; |
| | | } |
| | | |
| | | //将任务信息放到服务表中 |
| | | ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class); |
| | |
| | | //将任务信息新增到随访服务表中 |
| | | serviceSubtask.setSendname(patTaskRelevance.getName()); |
| | | serviceSubtask.setAge(patTaskRelevance.getAge()); |
| | | serviceSubtask.setSfzh(patTaskRelevance.getSfzh()); |
| | | serviceSubtask.setSfzh(patTaskRelevance.getIdcardno()); |
| | | serviceSubtask.setPhone(patTaskRelevance.getTelcode()); |
| | | serviceSubtask.setAddr(patTaskRelevance.getAddr()); |
| | | serviceSubtask.setPatid(patTaskRelevance.getPatid()); |
| | | serviceSubtask.setCreateTime(DateUtils.getNowDate()); |
| | | serviceSubtask.setSendstate(1L); |
| | | if (serviceTaskVO.getLongTask() == 1) serviceSubtask.setSendstate(2L); |
| | | serviceSubtask.setDeptcode(patTaskRelevance.getDeptCode()); |
| | | serviceSubtask.setDeptname(patTaskRelevance.getDeptName()); |
| | | serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode()); |
| | | serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname()); |
| | | serviceSubtask.setType(serviceTaskVO.getHospType()); |
| | | serviceSubtask.setHospType(patTaskRelevance.getHospType()); |
| | | serviceSubtask.setOpenid(patTaskRelevance.getOpenid()); |
| | | serviceSubtask.setDrname(patTaskRelevance.getDrname()); |
| | | serviceSubtask.setDrcode(patTaskRelevance.getDrcode()); |
| | | serviceSubtask.setInhosptime(patTaskRelevance.getInhosptime()); |
| | | serviceSubtask.setEndtime(patTaskRelevance.getEndtime()); |
| | | serviceSubtask.setNurseId(patTaskRelevance.getNurseId()); |
| | | serviceSubtask.setNurseName(patTaskRelevance.getNurseName()); |
| | | if (serviceTaskVO.getLongTask() == 1) |
| | | serviceSubtask.setLongSendTime(patTaskRelevance.getLongSendTime()); |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | integer = serviceSubtask.getId().intValue(); |
| | | } |
| | |
| | | serviceTask.setSendTimeSlot(JSON.toJSONString(serviceTaskVO.getSendTimeslot())); |
| | | //修改操作,需要将stopState状态+1 |
| | | ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceTask.getTaskid()); |
| | | serviceTask.setStopState(serviceTask1.getStopState() + 1); |
| | | serviceTask.setTemplateid(serviceTaskVO.getLibtemplateid()); |
| | | long l = serviceTask1.getStopState() + 1; |
| | | serviceTask.setStopState(l); |
| | | if (serviceTaskVO.getLibtemplateid() != null) |
| | | serviceTask.setLibtemplateid(serviceTaskVO.getLibtemplateid().toString()); |
| | | serviceTask.setTemplateid(serviceTaskVO.getTemplateid()); |
| | | serviceTask.setLongTask(serviceTaskVO.getLongTask()); |
| | | serviceTaskService.updateServiceTask(serviceTask); |
| | | if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1) { |
| | | //这里需要将任务id与任务模板ID,在任务模板中绑定 |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getType()) && serviceTaskVO.getType().equals("1")) { |
| | | IvrTaskTemplate ivrTaskTemplate = new IvrTaskTemplate(); |
| | | ivrTaskTemplate.setTaskid(serviceTask.getTaskid()); |
| | | ivrTaskTemplate.setId(serviceTaskVO.getTemplateid()); |
| | | ivrTaskTemplateService.updateIvrTaskTemplate(ivrTaskTemplate); |
| | | } else if (StringUtils.isNotEmpty(serviceTaskVO.getType()) && serviceTaskVO.getType().equals("2")) { |
| | | SvyTaskTemplate svyTaskTemplate = new SvyTaskTemplate(); |
| | | svyTaskTemplate.setTaskid(serviceTask.getTaskid()); |
| | | svyTaskTemplate.setId(serviceTaskVO.getTemplateid()); |
| | | svyTaskTemplateService.updateSvyTaskTemplate(svyTaskTemplate); |
| | | } |
| | | map.put("subTaskId", null); |
| | | map.put("taskId", serviceTask.getTaskid().intValue()); |
| | | return map; |
| | | } |
| | | if (CollectionUtils.isNotEmpty(serviceTaskVO.getPatTaskRelevances())) { |
| | | for (PatTaskRelevance patTaskRelevance : serviceTaskVO.getPatTaskRelevances()) { |
| | | ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTaskVO, ServiceSubtask.class); |
| | | serviceSubtask.setSendname(patTaskRelevance.getName()); |
| | | serviceSubtask.setAge(patTaskRelevance.getAge()); |
| | | serviceSubtask.setSfzh(patTaskRelevance.getSfzh()); |
| | | serviceSubtask.setPhone(patTaskRelevance.getTelcode()); |
| | | serviceSubtask.setAddr(patTaskRelevance.getAddr()); |
| | | serviceSubtask.setPatid(patTaskRelevance.getPatid()); |
| | | serviceSubtask.setOpenid(patTaskRelevance.getOpenid()); |
| | | serviceSubtask.setDeptcode(patTaskRelevance.getDeptCode()); |
| | | serviceSubtask.setLeavehospitaldistrictname(patTaskRelevance.getLeavehospitaldistrictname()); |
| | | serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode()); |
| | | serviceSubtask.setDeptname(patTaskRelevance.getDeptName()); |
| | | serviceSubtask.setType(serviceTaskVO.getHospType()); |
| | | serviceSubtask.setCreateTime(DateUtils.getNowDate()); |
| | | serviceSubtask.setDrname(patTaskRelevance.getDrname()); |
| | | serviceSubtask.setDrcode(patTaskRelevance.getDrcode()); |
| | | serviceSubtask.setInhosptime(patTaskRelevance.getInhosptime()); |
| | | serviceSubtask.setHospType(patTaskRelevance.getHospType()); |
| | | serviceSubtask.setEndtime(patTaskRelevance.getEndtime()); |
| | | serviceSubtask.setNurseId(patTaskRelevance.getNurseId()); |
| | | serviceSubtask.setNurseName(patTaskRelevance.getNurseName()); |
| | | serviceSubtask.setTextParam(new Gson().toJson(serviceTaskVO.getTextParam())); |
| | | if (patTaskRelevance.getIsoperation() != null) { |
| | | if (patTaskRelevance.getIsoperation() == 2) |
| | |
| | | } |
| | | } |
| | | } |
| | | return integer; |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | map.put("subTaskId", integer); |
| | | map.put("taskId", serviceTask.getTaskid().intValue()); |
| | | return map; |
| | | } |
| | | |
| | | |
| | |
| | | if (noVoice == ivrTaskTemplateVO.getNoVoiceNum().intValue()) { |
| | | //已经问了对应的遍数,就判断是否还有下一题 |
| | | if (nowQuestion.getTargetid() == IvrTaskTemplateScriptVOs.size()) { |
| | | //没有下一题了,就挂断电话,播放结束语 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } else { |
| | | //有下一题 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(IvrTaskTemplateScriptVOs, nowQuestion); |
| | | // 问题, 去调用“tts合成和播放”接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | |
| | | Pattern pattern2 = Pattern.compile(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()); |
| | | matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult()); |
| | | } |
| | | log.error("PCB--getQuestionText问题为:{},UUID:{}", nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | 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.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1); |
| | | serviceTaskScriptTargetoptionMapper.updateIvrTaskTemplateTargetoption(nowQuestion.getIvrTaskScriptTargetoptionList().get(j)); |
| | | |
| | | //将静默置为0 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES); |
| | | |
| | | //将患者的回签写进表里 |
| | | IvrTaskVisitResult serviceTaskVisitResult = DtoConversionUtils.sourceToTarget(serviceSubtask, IvrTaskVisitResult.class); |
| | | serviceTaskVisitResult.setId(null); |
| | | serviceTaskVisitResult.setQuestion(nowQuestion.getScriptContent()); |
| | | serviceTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult()); |
| | | serviceTaskVisitResult.setCreateTime(new Date()); |
| | | serviceTaskVisitResult.setOptionResult(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue()); |
| | | serviceTaskVisitResultMapper.insertIvrTaskVisitResult(serviceTaskVisitResult); |
| | | |
| | | //将匹配到的标识改成true |
| | | isppd = true; |
| | | |
| | | //获取下一题 |
| | | Long nextQuestion = nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getNextQuestion(); |
| | | for (IvrTaskTemplateScriptVO script : IvrTaskTemplateScriptVOs) { |
| | | if (script.getTargetid() == nextQuestion) { |
| | | QuestionMessage questionMessage = new QuestionMessage(); |
| | | questionMessage.setNowQuestion(script); |
| | | questionMessage.setQuestionList(IvrTaskTemplateScriptVOs); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(script.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } 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(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | try { |
| | | Thread.sleep(3000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | phoneUtils.hangup("", "", ivrTaskTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid()); |
| | | return; |
| | | } |
| | | } |
| | | return; |
| | | } else { |
| | | //没有匹配上当前option |
| | | //Targetregex2 为false,表示在Targetregex2中存在 语句中的关键字,这个option就不用再继续匹配了,直接匹配下一个option |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (isppd != true) { |
| | |
| | | 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()); |
| | | phoneUtils.ttsPlayback(nextQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | |
| | | //就可以挂断电话了 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("就可以挂断电话了------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(ivrTaskTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | try { |
| | | Thread.sleep(3000); |
| | |
| | | } |
| | | List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1); |
| | | for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) { |
| | | Matcher matcher = null; |
| | | if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) { |
| | | Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex()); |
| | | pattern.matcher(returnQues.getContent()); |
| | | matcher = pattern.matcher(returnQues.getContent()); |
| | | } |
| | | |
| | | Matcher matcher2 = null; |
| | | if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) { |
| | | Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2()); |
| | | pattern2.matcher(returnQues.getContent()); |
| | | 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(); |
| | | ivrTaskTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText()); |
| | | ivrTaskTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav()); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | if (ivrLibaExtemplatescript.getIsEnd() == 1) { |
| | | //将问题置空 |
| | | IvrTaskTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion(); |
| | | nowQuestion1.setScriptContent(null); |
| | | nowQuestion1.setScriptVoice(null); |
| | | questionMessage.setNowQuestion(nowQuestion1); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES); |
| | | } |
| | | //调用“15、tts合成和播放, tts_playback”将结果传回 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("调用“15、tts合成和播放------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getScriptContent() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid()); |
| | | } |
| | | break; |
| | | } |
| | | String date = simpleDateFormat1.format(new Date()); |
| | |
| | | */ |
| | | @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); |
| | | PhoneCallBackYQVO phoneCallBackYQVO = new PhoneCallBackYQVO(); |
| | | //channel_create 通道创建的时候,可以执行一些其它操作,譬如发个短信之类的; 我们的业务可以不用管 PlayEventCallback 这个是播放语音的,暂时用不到 End_time()= -1或null表示当前的asrtext不是一句完整的话 |
| | | if (phoneCallReqYQVO.getOperate().equals("channel_create") || phoneCallReqYQVO.getOperate().equals("PlayEventCallback") || phoneCallReqYQVO.getEnd_time() == null || phoneCallReqYQVO.getEnd_time() == -1) { |
| | | if (phoneCallReqYQVO.getOperate().equals("channel_create")) { |
| | | return phoneCallBackYQVO; |
| | | } |
| | | //PlayEventCallback 这个是播放语音的 playstart:放音开始(问题播报开始) playstop: 放音结束(问题播报结束) |
| | | if (phoneCallReqYQVO.getOperate().equals("PlayEventCallback")) { |
| | | String cacheJSY = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- jsy"); |
| | | if (phoneCallReqYQVO.getOperate().equals("PlayEventCallback") && phoneCallReqYQVO.getPlaystop() == false) { |
| | | //判断redis中是否有结束语 |
| | | if (StringUtils.isEmpty(cacheJSY)) { |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", false, 120, TimeUnit.MINUTES); |
| | | log.error("PlayEventCallbackPlaystop的值为-------:{}", false); |
| | | } |
| | | } else { |
| | | //如果结束语不为空,则要挂电话了 |
| | | if (StringUtils.isNotEmpty(cacheJSY)) { |
| | | Map<String, String> req = new HashMap<>(); |
| | | req.put("uuid", phoneCallReqYQVO.getUuid()); |
| | | req.put("caller", phoneCallReqYQVO.getPhone()); |
| | | // HttpUtils.sendPost(hangup, new Gson().toJson(req)); |
| | | HttpUtil.postJsonRequest(hangup, new Gson().toJson(req)); |
| | | //删除结束语的患存 |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "- jsy"); |
| | | } else { |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", true, 120, TimeUnit.MINUTES); |
| | | log.error("-------PlayEventCallbackPlaystop的值为:{}", true); |
| | | } |
| | | } |
| | | return phoneCallBackYQVO; |
| | | } |
| | | //获取放音是否结束 |
| | | Object isPlayEventOverObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop"); |
| | | if (ObjectUtils.isNotEmpty(isPlayEventOverObj)) { |
| | | Boolean isPlayEventOver = (Boolean) isPlayEventOverObj; |
| | | if (!isPlayEventOver) { |
| | | return phoneCallBackYQVO; |
| | | } |
| | | } |
| | | |
| | | //通过子任务ID获取到模板信息 |
| | | ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(phoneCallReqYQVO.getTaskid())); |
| | | IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid()); |
| | |
| | | if (!aBoolean) { |
| | | //给静默设置一个默认次数在redis中 |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | //如果不存在,就把当前的UUID做为key,放到对象中去 |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid(), phoneCallReqYQVO, 120, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | if ("SilentCallback".equals(phoneCallReqYQVO.getOperate())) { |
| | |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = ivrTaskTemplateScriptVO.getScriptContent(); |
| | | log.error("SilentCallback的问题内容scriptContent:{}", scriptContent); |
| | | phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent)); |
| | | //将静默次数加1 |
| | | Integer noVoiceNum = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "noVoice"); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "noVoice", noVoiceNum + 1, 120, TimeUnit.MINUTES); |
| | | return phoneCallBackYQVO; |
| | | } else { |
| | | log.error("静默次数达到,挂掉电话:{}", num); |
| | | ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | //大与等于的话,直接挂断 |
| | | phoneCallBackYQVO.setType("hangup"); |
| | | 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<>(); |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | //去redis中,把该子任务ID删除 |
| | | Long id = serviceSubtask.getId(); |
| | | //先更新一下分数 |
| | | double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | Map<String, String> map = delRedisValue(null, id.toString()); |
| | | if (ObjectUtils.isNotEmpty(map)) redisCache.setCacheObject(map.get("cacheName"), map.get("val")); |
| | | redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone()); |
| | | 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 if ("AsrCallback".equals(phoneCallReqYQVO.getOperate())) { |
| | | } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) { |
| | | |
| | | // 先对通话进行通用库匹配一次 |
| | | 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.setType("text"); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + les.getSwitchText()); |
| | | //将结果写进detail表 |
| | | ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>(); |
| | | ivrTaskTemplateScriptVO.setExtemplateText(les.getSwitchText()); |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | 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()); |
| | |
| | | ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>(); |
| | | ivrTaskTemplateScriptVO.setQuestionResult(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getOptiondesc()); |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | ServiceSubtaskDetail serviceSubtaskDetail = getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate); |
| | | //修改一下语音路径(改成前端可以访问的,存到数据库中) |
| | | if (StringUtils.isNotEmpty(serviceSubtaskDetail.getQuestionvoice())) { |
| | | String questionvoice = serviceSubtaskDetail.getQuestionvoice(); |
| | | String[] split = questionvoice.split("\\\\"); |
| | | if (split.length > 0) { |
| | | String lastPart = split[split.length - 1]; |
| | | serviceSubtaskDetail.setQuestionvoice(voicePathPrefix + lastPart); |
| | | } |
| | | } |
| | | serviceSubtaskDetailList.add(serviceSubtaskDetail); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | // |
| | | //判断一下,这个选项结果是不是还有继续问下去的必要,例如选项结果是别人不想继续回答问题,就要结束掉 |
| | | if (ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).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.setType("text"); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask.getJsy()); |
| | | return phoneCallBackYQVO; |
| | | } |
| | | |
| | | flag = 1; |
| | | //将当前前的播报状态删除,给下一题让位 |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop"); |
| | | // //获取下一题 |
| | | if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1") || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | log.error("获取下一题的信息:{}", ivrTaskTemplateScriptVO); |
| | | if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1") || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | Long nextQuestion = null; |
| | | if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1")) { |
| | | nextQuestion = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getNextQuestion(); |
| | | //更新分数 |
| | | double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | score = BigDecimal.valueOf(score).add(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getScore()).doubleValue(); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score); |
| | | } else { |
| | | nextQuestion = ivrTaskTemplateScriptVO.getNextScriptno(); |
| | | //更新分数 |
| | | 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); |
| | | } |
| | | |
| | | |
| | | for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) { |
| | | if (script.getSort() == nextQuestion.intValue()) { |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = script.getScriptContent(); |
| | | phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent)); |
| | | log.error("下一题问题:{}", 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() == 0 || ivrTaskTemplateScriptVO.getNextScriptno() == null) { |
| | | phoneCallBackYQVO.setType("hangup"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | //设置结束语 |
| | | phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter()); |
| | | Long id = serviceSubtask.getId(); |
| | | Map<String, String> map = delRedisValue(null, id.toString()); |
| | | } 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 = 0.0; |
| | | Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | if (ObjectUtils.isNotEmpty(scoreObj)) score = (double) scoreObj; |
| | | 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()); |
| | | log.error("map的值为:{}", map); |
| | | if (ObjectUtils.isNotEmpty(map)) |
| | | redisCache.setCacheObject(map.get("cacheName"), map.get("val")); |
| | | redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone()); |
| | | redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid()); |
| | | 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 { |
| | | //flag=0,说明没 匹配上,也要把患者说的话记录下来 |
| | | if (j == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1 && flag == 0) { |
| | | ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>(); |
| | | ServiceSubtaskDetail serviceSubtaskDetail = getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate); |
| | | //修改一下语音路径(改成前端可以访问的,存到数据库中) |
| | | if (StringUtils.isNotEmpty(serviceSubtaskDetail.getQuestionvoice())) { |
| | | String questionvoice = serviceSubtaskDetail.getQuestionvoice(); |
| | | String[] split = questionvoice.split("\\\\"); |
| | | if (split.length > 0) { |
| | | String lastPart = split[split.length - 1]; |
| | | serviceSubtaskDetail.setQuestionvoice(voicePathPrefix + lastPart); |
| | | } |
| | | } |
| | | serviceSubtaskDetailList.add(serviceSubtaskDetail); |
| | | //如果没有 匹配上,这个必须为null |
| | | serviceSubtaskDetailList.get(0).setMatchedtext(""); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | } |
| | | continue; |
| | | } |
| | | } |
| | | //都没有匹配到 |
| | | if (StringUtils.isEmpty(phoneCallBackYQVO.getValue())) { |
| | | Integer count = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid()); |
| | | Integer count = null; |
| | | Object countObj = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid()); |
| | | if (ObjectUtils.isNotEmpty(countObj)) count = (Integer) countObj; |
| | | if (count != null && count >= ivrTaskTemplate.getMateNum()) { |
| | | //如果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) { |
| | | //如果是最后一道题,或者没有下一题了,就直接挂机 |
| | | phoneCallBackYQVO.setType("hangup"); |
| | | 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 = null; |
| | | Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | if (ObjectUtils.isNotEmpty(scoreObj)) score = (Double) scoreObj; |
| | | serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | |
| | | //在redis中保存一下结束语,在调用挂电话的方法时删除 |
| | | 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()); |
| | | redisCache.setCacheObject(map.get("cacheName"), map.get("val")); |
| | | redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone()); |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | // return phoneCallBackYQVO; |
| | | } else { |
| | | //根据ivrTaskTemplateScriptVO.getNextScriptno()获取下一题进行提问 |
| | |
| | | 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 = null; |
| | | Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | if (ObjectUtils.isNotEmpty(scoreObj)) score = (Double) scoreObj; |
| | | score = BigDecimal.valueOf(score).add(script.getScore()).doubleValue(); |
| | | |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | } |
| | |
| | | //不是选择题,直接记录答案,将结果写到detail中 |
| | | ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>(); |
| | | serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate)); |
| | | ServiceSubtaskDetail serviceSubtaskDetail = getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate); |
| | | //修改一下语音路径(改成前端可以访问的,存到数据库中) |
| | | if (StringUtils.isNotEmpty(serviceSubtaskDetail.getQuestionvoice())) { |
| | | String questionvoice = serviceSubtaskDetail.getQuestionvoice(); |
| | | String[] split = questionvoice.split("\\\\"); |
| | | if (split.length > 0) { |
| | | String lastPart = split[split.length - 1]; |
| | | serviceSubtaskDetail.setQuestionvoice(voicePathPrefix + lastPart); |
| | | } |
| | | } |
| | | serviceSubtaskDetailList.add(serviceSubtaskDetail); |
| | | serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | // String xh = idSort.split("-")[1]; |
| | | |
| | | //如果选项分支为1的话,则需要根据问题上的nextScriptno进行跳转 |
| | | //问答题没有跳转 |
| | | if (ivrTaskTemplateScriptVO.getNextScriptno() != null || ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | if (ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) { |
| | | for (IvrTaskTemplateScript ivrTaskTemplateScript1 : ivrTaskTemplateScripts) { |
| | | if (ivrTaskTemplateScriptVO.getNextScriptno().intValue() == ivrTaskTemplateScript1.getSort()) { |
| | | 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 = null; |
| | | Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | if (ObjectUtils.isNotEmpty(scoreObj)) score = (Double) scoreObj; |
| | | score = BigDecimal.valueOf(score).add(ivrTaskTemplateScriptVO.getScore()).doubleValue(); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES); |
| | | |
| | | } |
| | | } |
| | | } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null) { |
| | | } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) { |
| | | //没有下一题了,就结束了 |
| | | phoneCallBackYQVO.setType("hangup"); |
| | | 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 = null; |
| | | Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | if (ObjectUtils.isNotEmpty(scoreObj)) score = (Double) scoreObj; |
| | | serviceSubtask.setScore(BigDecimal.valueOf(score)); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | |
| | | //去redis中,把该子任务ID删除 |
| | | Long id = serviceSubtask.getId(); |
| | | Map<String, String> map = delRedisValue(null, id.toString()); |
| | | redisCache.setCacheObject(map.get("cacheName"), map.get("val")); |
| | | //在redis中保存一下结束语,在调用挂电话的方法时删除 |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask1.getJsy(), 120, TimeUnit.MINUTES); |
| | | redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone()); |
| | | log.error("电话挂断4"); |
| | | redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE"); |
| | | } |
| | | |
| | | //选项匹配完成后,需要再去通过库再进行匹配一次 |
| | | String extemplateID = ivrTaskTemplate.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(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; |
| | | } |
| | | |
| | | |
| | | private String getObject(ServiceSubtask serviceSubtask, String scriptContent) { |
| | | Map<String, Map<String, String>> param = getParam(serviceSubtask.getTaskid()); |
| | |
| | | scriptContent = scriptContent.replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : ""); |
| | | } |
| | | } |
| | | scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getName()) ? serviceSubtask.getName() : ""); |
| | | scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getPlaceOfResidence()) ? serviceSubtask.getPlaceOfResidence() : ""); |
| | | scriptContent.replace("${phone}", StringUtils.isNotEmpty(serviceSubtask.getTelcode()) ? serviceSubtask.getTelcode() : ""); |
| | | scriptContent = scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : ""); |
| | | scriptContent = scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : ""); |
| | | scriptContent = scriptContent.replace("${phone}", StringUtils.isNotEmpty(serviceSubtask.getTelcode()) ? serviceSubtask.getTelcode() : ""); |
| | | |
| | | return scriptContent; |
| | | } |
| | |
| | | //pullTaskVOList用于数据返回 |
| | | List<PullTaskVO> pullTaskVOList = new ArrayList<>(); |
| | | String value0 = redisCache.getCacheObject("cache-0"); |
| | | log.error("任务拉取value0的值是多少:{}", value0); |
| | | // cache-0为立即发起的,其它的先推迟 |
| | | if (!StringUtils.isEmpty(value0)) { |
| | | pullTaskVOList = getPullTaskList(value0, "cache-0"); |
| | | //将cache-0的数据,转移不对劲cache-00中 |
| | | String cache00 = redisCache.getCacheObject("cache-0"); |
| | | if (!StringUtils.isEmpty(cache00)) redisCache.setCacheObject("cache-0", cache00 + "," + value0); |
| | | else redisCache.setCacheObject("cache-0", value0); |
| | | //将cache-0的数据,转移到cache-00中 |
| | | redisCache.deleteObject("cache-00"); |
| | | String cache00 = redisCache.getCacheObject("cache-00"); |
| | | if (!StringUtils.isEmpty(cache00)) |
| | | redisCache.setCacheObject("cache-00", cache00 + "," + value0, 120, TimeUnit.MINUTES); |
| | | else redisCache.setCacheObject("cache-00", value0, 120, TimeUnit.MINUTES); |
| | | redisCache.deleteObject("cache-0"); |
| | | } else { |
| | | for (int i = 1; i < 6; i++) { |
| | |
| | | if (CollectionUtils.isNotEmpty(pullTaskVOList2) && pullTaskVOList2.size() > 0) { |
| | | pullTaskVOList.addAll(pullTaskVOList2); |
| | | } |
| | | //将cache-i的数据,转移不对劲cache-0i中 |
| | | String cache0i = redisCache.getCacheObject("cache-0" + i); |
| | | if (!StringUtils.isEmpty(cache0i)) redisCache.setCacheObject("cache-0" + i, cache0i + "," + value); |
| | | else redisCache.setCacheObject("cache-0" + i, value); |
| | | redisCache.deleteObject("cache-" + i); |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(pullTaskVOList)) { |
| | | //给回调参数赋值 |
| | | for (PullTaskVO pullTaskVO : pullTaskVOList) { |
| | | pullTaskVO.setAsrcallback(ASRCallBackPath); |
| | | } |
| | | } |
| | | return pullTaskVOList; |
| | | } |
| | | |
| | | |
| | | private List<PullTaskVO> getPullTaskList(String subIds, String cacheName) { |
| | | log.error("任务拉取subIds的值是多少:{}", subIds); |
| | | //pullTaskVOList用于数据返回 |
| | | List<PullTaskVO> pullTaskVOList = new ArrayList<>(); |
| | | //newValue0用于保存没有处理的子 任务 |
| | |
| | | if (cacheName.equals("cache-0") && i < 5 || !cacheName.equals("cache-0") && i < 1) { |
| | | PullTaskVO pullTaskVO = new PullTaskVO(); |
| | | 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(); |
| | |
| | | if (ObjectUtils.isEmpty(ivrTaskTemplateScript)) return null; |
| | | //获取通配符匹配过后的问题 |
| | | String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent()); |
| | | String kcb = ivrTaskTemplate.getRevisitBefore() + "," + scrContent; |
| | | String kcb = serviceTask.getKcb() + "," + scrContent; |
| | | // String kcb = ivrTaskTemplate.getRevisitBefore(); |
| | | |
| | | //封装返回数据 |
| | | //taskId = 子任务ID + 问题ID +问题序号 |
| | | pullTaskVO.setTaskid(subId); |
| | | pullTaskVO.setAppkey("ZurNHpaQLq6P55YS"); |
| | | pullTaskVO.setAppkey(app_key_yq); |
| | | pullTaskVO.setSections(LocalTime.now().format(DateTimeFormatter.ofPattern("hh:mm")) + "-" + LocalTime.now().plusMinutes(1).format(DateTimeFormatter.ofPattern("hh:mm"))); |
| | | pullTaskVO.setPhones(serviceSubtask.getPhone()); |
| | | pullTaskVO.setPrologue(kcb); |
| | | pullTaskVO.setDisplayNo("85129866"); |
| | | if (cacheName.equals("cache-0")) pullTaskVO.setDisplayNo("2"); |
| | | else pullTaskVO.setDisplayNo("2"); |
| | | pullTaskVOList.add(pullTaskVO); |
| | | redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim(), ivrTaskTemplateScript.getId().toString()); |
| | | redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim(), ivrTaskTemplateScript.getId().toString(), 120, TimeUnit.MINUTES); |
| | | // redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES); |
| | | } else { |
| | | if (StringUtils.isEmpty(newValue0)) { |
| | | newValue0 = "," + split[i].trim() + ","; |
| | |
| | | return pullTaskVOList; |
| | | } |
| | | |
| | | |
| | | //下面的代码不能删除,上面的方法只是配合电话端联调用的, |
| | | // @Override |
| | | // public PhoneCallBackVO phoneCallBack(PhoneCallBackVO phoneCallBackVO) { |
| | | // log.error("phoneCallBackVO的入参:{},{},{},{},{},{},{}", phoneCallBackVO.getResultType(), phoneCallBackVO.getUuid(), phoneCallBackVO.getErrResult(), phoneCallBackVO.getTextResult(), phoneCallBackVO.getHangUpResult(), phoneCallBackVO.getEnumState(), phoneCallBackVO.getUint8()); |
| | | // //获取数据 |
| | | // Boolean aBoolean = redisCache.hasKey(phoneCallBackVO.getUuid()); |
| | | // if (!aBoolean) { |
| | | // throw new BaseException("该uuid不存在"); |
| | | // } |
| | | // Integer hangupValue = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "hangup"); |
| | | // if (hangupValue != null && hangupValue == 1) { |
| | | // //hangupValue == 1 随访结束,直接可以挂电话 |
| | | // PhoneUtils phoneUtils = new PhoneUtils(); |
| | | // phoneUtils.hangup(phoneCallBackVO.getUuid(), null, null, null, null, null, null, null); |
| | | // |
| | | // } |
| | | // |
| | | // Map<String, Object> map = redisCache.getCacheObject(phoneCallBackVO.getUuid()); |
| | | //// ObjectMapper objectMapper = new ObjectMapper(); |
| | | //// Map<String, Object> map = null; |
| | | //// try { |
| | | //// map = objectMapper.readValue(cacheObject, Map.class); |
| | | //// } catch (JsonProcessingException e) { |
| | | //// e.printStackTrace(); |
| | | //// } |
| | | // |
| | | // ServiceSubtask ServiceSubtask = (ServiceSubtask) map.get("ServiceSubtask"); |
| | | // List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOs = (List<IvrLibaTemplateScriptVO>) map.get("ivrLibaTemplateScriptVO"); |
| | | // //将uuid更新到数据库中 |
| | | // ServiceSubtask.setSenduuid(phoneCallBackVO.getUuid()); |
| | | // ServiceSubtaskMapper.updateServiceSubtask(ServiceSubtask); |
| | | // |
| | | // //获取模板信息 |
| | | // IvrLibaTemplateVO ivrLibaTemplateVO = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "ivrLibaTemplateVO"); |
| | | // |
| | | // |
| | | // //首先判断resultType |
| | | // if (phoneCallBackVO.getResultType() == 1) { |
| | | // //呼叫结果接口: 1 |
| | | // if (phoneCallBackVO.getUint8() == 1) { |
| | | // //呼叫失败,去redis中记录一下失败次数,进行再次呼叫 |
| | | // Integer integer = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "uint8"); |
| | | // if (integer != null) { |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "uint8", integer + 1, 120, TimeUnit.MINUTES); |
| | | // } else { |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "uint8", 1, 120, TimeUnit.MINUTES); |
| | | // } |
| | | // |
| | | // if (integer != null && integer == ServiceSubtask.getRecallcount().intValue()) { |
| | | // log.info("无人接听:{}, {}", phoneCallBackVO.getErrResult(), phoneCallBackVO.getUuid()); |
| | | // //连续打规定次,如果要没人接,那就结束 |
| | | // ServiceSubtask.setResult(phoneCallBackVO.getErrResult()); |
| | | // ServiceSubtaskMapper.updateServiceSubtask(ServiceSubtask); |
| | | // redisCache.deleteObject(phoneCallBackVO.getUuid() + "uint8"); |
| | | // } else if (integer != null && integer < ServiceSubtask.getRecallcount().intValue()) { |
| | | // //进行重拨 |
| | | // PhoneUtils phoneUtils = new PhoneUtils(); |
| | | // phoneUtils.ob(null, null, null, null, null, null, null, ServiceSubtask.getPhone(), phoneCallBackVO.getUuid(), true); |
| | | // } |
| | | // } |
| | | // |
| | | // } else if (phoneCallBackVO.getResultType() == 2) { |
| | | // //通话状态更新接口: 2 |
| | | // if (phoneCallBackVO.getEnumState() == 0) { |
| | | // // 0-振铃 |
| | | // Integer integer = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "enumState"); |
| | | // |
| | | // if (integer != null && integer < ServiceSubtask.getRecallcount().intValue()) { |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "enumState", integer + 1, 120, TimeUnit.MINUTES); |
| | | // } else if (integer == null) { |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "enumState", 1, 120, TimeUnit.MINUTES); |
| | | // } else if (integer != null && integer == ServiceSubtask.getRecallcount().intValue()) { |
| | | // ServiceSubtask.setResult("无人接听"); |
| | | // ServiceSubtaskMapper.updateServiceSubtask(ServiceSubtask); |
| | | // redisCache.deleteObject(phoneCallBackVO.getUuid() + "enumState"); |
| | | // } |
| | | // } else if (phoneCallBackVO.getEnumState() == 2) { |
| | | // //患者挂断电话 |
| | | // log.info("患者挂断电话:{}", phoneCallBackVO.getUuid()); |
| | | // ServiceSubtask.setResult(phoneCallBackVO.getHangUpResult()); |
| | | // ServiceSubtaskMapper.updateServiceSubtask(ServiceSubtask); |
| | | // redisCache.deleteObject(phoneCallBackVO.getUuid() + "enumState"); |
| | | // } |
| | | // |
| | | // |
| | | // } else if (phoneCallBackVO.getResultType() == 3) { |
| | | // //语音识别结果上报接口: 3 |
| | | // Integer noVoice = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "noVoice"); |
| | | // QuestionMessage returnQues = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues"); |
| | | // IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion(); |
| | | // PhoneUtils phoneUtils = new PhoneUtils(); |
| | | // |
| | | // if (StringUtils.isEmpty(phoneCallBackVO.getTextResult())) { |
| | | // //无回话 |
| | | // //判断noVoice是否已经到了最大值 |
| | | // if (noVoice == ivrLibaTemplateVO.getNoVoiceNum().intValue()) { |
| | | // //已经问了对应的遍数,就判断是否还有下一题 |
| | | // if (nowQuestion.getTargetid() == ivrLibaTemplateScriptVOs.size()) { |
| | | // //没有下一题了,就挂断电话,播放结束语 |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | // phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | // } else { |
| | | // //有下一题 |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | // IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion); |
| | | // // 问题, 去调用“tts合成和播放”接口 |
| | | // phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid()); |
| | | // } |
| | | // } else { |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES); |
| | | // //调用ivrLibaTemplateScriptVO中的slienceText(静默话术) |
| | | // String slienceText = nowQuestion.getSlienceText(); |
| | | // //静默话术 + 问题, 去调用“tts合成和播放”接口 |
| | | // phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid()); |
| | | // return new PhoneCallBackVO(); |
| | | // } |
| | | // |
| | | // } else { |
| | | // //有回话,对回答的问题,进行正则匹配(这里只针对选择题,其它题型不行) |
| | | // for (int j = 0; j < nowQuestion.getIvrLibaScriptTargetoptionList().size(); j++) { |
| | | // //包含 |
| | | // Matcher matcher = null; |
| | | // if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex())) { |
| | | // Pattern pattern = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().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()); |
| | | // matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult()); |
| | | // } |
| | | // log.info("phoneCallBack--Targetregex的值为:{}, phoneCallBack--Targetregex2的值为:{}", nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex(), nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()); |
| | | // if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.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()) { |
| | | // //说明匹配正确了 |
| | | // //这里应该先判断类型,去再修改,设置IsUserOperation是单选题的改法 |
| | | // nowQuestion.getIvrLibaScriptTargetoptionList().get(j).setIsUserOperation(true); |
| | | // ivrLibaScriptTargetoptionMapper.updateIvrLibaTemplateTargetoption(nowQuestion.getIvrLibaScriptTargetoptionList().get(j)); |
| | | // |
| | | // |
| | | // //将静默置为0 |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES); |
| | | // //获取下一题 |
| | | // Integer nextQuestion = nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion(); |
| | | // for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOs) { |
| | | // if (script.getTargetid() == nextQuestion) { |
| | | // QuestionMessage questionMessage = new QuestionMessage(); |
| | | // questionMessage.setNowQuestion(script); |
| | | // questionMessage.setQuestionList(ivrLibaTemplateScriptVOs); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | // break; |
| | | // } |
| | | // } |
| | | // break; |
| | | // } else { |
| | | // //没有匹配到 |
| | | // Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum"); |
| | | // //无匹配次数去判断是否到最大询问次数,并且所有的选项都匹配完了 |
| | | // if (mateNum == ivrLibaTemplateVO.getMateNum().intValue() && j == nowQuestion.getIvrLibaScriptTargetoptionList().size() - 1) { |
| | | // //如果下一题为空.则新的数据返回,并加上感谢语 |
| | | // if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) { |
| | | // QuestionMessage questionMessage = new QuestionMessage(); |
| | | // IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion); |
| | | // questionMessage.setQuestionList(ivrLibaTemplateScriptVOs); |
| | | // questionMessage.setNowQuestion(nextQuestion); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES); |
| | | // } else { |
| | | // //就可以挂断电话了 |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES); |
| | | // phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid()); |
| | | // break; |
| | | // } |
| | | // } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue() && j == nowQuestion.getIvrLibaScriptTargetoptionList().size() - 1) { |
| | | // //没有问到规定次数 |
| | | // mateNum = mateNum + 1; |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // //选项匹配完成后,需要再去通过库再进行匹配一次 |
| | | // String extemplateID = ivrLibaTemplateVO.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(returnQues.getContent()); |
| | | // } |
| | | // |
| | | // Matcher matcher2 = null; |
| | | // if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) { |
| | | // Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2()); |
| | | // matcher2 = pattern2.matcher(returnQues.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 questionMessage = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues"); |
| | | // IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = returnQues.getNowQuestion(); |
| | | // ivrLibaTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText()); |
| | | // ivrLibaTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav()); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | // if (ivrLibaExtemplatescript.getIsEnd() == 1) { |
| | | // //将问题置空 |
| | | // IvrLibaTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion(); |
| | | // nowQuestion1.setQuestionText(null); |
| | | // nowQuestion1.setQuestionVoice(null); |
| | | // questionMessage.setNowQuestion(nowQuestion1); |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | // |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES); |
| | | // } |
| | | // |
| | | // //调用“15、tts合成和播放, tts_playback”将结果传回 |
| | | // |
| | | // |
| | | // } |
| | | // break; |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // return phoneCallBackVO; |
| | | // } |
| | | |
| | | @Override |
| | | public Integer saveQuestionAnswerPhone(ServiceSubTaskDetailReq serviceSubTaskDetailReq) { |
| | | int i = 0; |
| | |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskDetailReq.getParam1(), pri_key)); |
| | | Long pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskDetailReq.getParam2(), pri_key)); |
| | | ServiceSubtask ivrTaskSingle = new ServiceSubtask(); |
| | | ServiceSubtaskVO ivrTaskSingle = new ServiceSubtaskVO(); |
| | | ivrTaskSingle.setTaskid(tid); |
| | | ivrTaskSingle.setPatid(pid); |
| | | List<ServiceSubtask> selectServiceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(ivrTaskSingle); |
| | |
| | | } else { |
| | | for (ServiceSubtaskDetail serviceSubtaskDetail : serviceSubTaskDetailReq.getServiceSubtaskDetailList()) { |
| | | serviceSubtaskDetail.setCreateTime(new Date()); |
| | | i = serviceSubtaskDetailMapper.insertServiceSubtaskDetail(serviceSubtaskDetail); |
| | | //先根据子任务id,任务ID和问题序号查询一下,该问题是否已经有值,如果有值,直接修改,如果为空,直接插入 |
| | | ServiceSubtaskDetail ssd = new ServiceSubtaskDetail(); |
| | | ssd.setSubId(serviceSubtaskDetail.getSubId()); |
| | | ssd.setTaskid(serviceSubtaskDetail.getTaskid()); |
| | | ssd.setTemplatequestionnum(serviceSubtaskDetail.getTemplatequestionnum()); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetails = serviceSubtaskDetailMapper.selectServiceSubtaskDetailList(ssd); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskDetails) && StringUtils.isNotEmpty(serviceSubtaskDetails.get(0).getMatchedtext())) { |
| | | serviceSubtaskDetail.setId(serviceSubtaskDetails.get(0).getId()); |
| | | serviceSubtaskDetailMapper.updateServiceSubtaskDetail(serviceSubtaskDetail); |
| | | } else { |
| | | i = serviceSubtaskDetailMapper.insertServiceSubtaskDetail(serviceSubtaskDetail); |
| | | } |
| | | } |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | @Override |
| | | public Integer recordAccept(PhoneCallRecordVO phoneCallRecordVO) { |
| | | if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) { |
| | | log.error("有人接电话了,并且完了"); |
| | | //说明有人接了 |
| | | int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1; // 加1是跳过/符号 |
| | | int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/"); |
| | | String result = phoneCallRecordVO.getRecord_path().substring(startIndex, endIndex); |
| | | //下载文件 |
| | | ftpService.downloadFolder("/" + LocalDate.now().toString(), profile + "/upload/vadio/voice/" + LocalDate.now().toString()); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskCount> getSfFzInfoEveryMonth(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | if (serviceSubtaskCountReq.getUserId() == null) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | serviceSubtaskCountReq.setUserId(userId); |
| | | } |
| | | if (serviceSubtaskCountReq.getStartTime() == null) { |
| | | LocalDate of = LocalDate.of(LocalDate.now().getYear(), 1, 1); |
| | | serviceSubtaskCountReq.setStartTime(Date.from(of.atStartOfDay(ZoneId.systemDefault()).toInstant())); |
| | | } |
| | | if (serviceSubtaskCountReq.getEndTime() == null) { |
| | | serviceSubtaskCountReq.setEndTime(new Date()); |
| | | } |
| | | List<ServiceSubtaskCount> sfFzInfoEveryMonth = serviceSubtaskMapper.getSfFzInfoEveryMonth(serviceSubtaskCountReq); |
| | | List<ServiceSubtaskCount> result = sfFzInfoEveryMonth.stream().collect(Collectors.groupingBy(ServiceSubtaskCount::getMonth, Collectors.groupingBy(ServiceSubtaskCount::getServiceType, Collectors.summingLong(ServiceSubtaskCount::getCount)))).entrySet().stream().flatMap(monthEntry -> monthEntry.getValue().entrySet().stream().map(typeEntry -> new ServiceSubtaskCount(monthEntry.getKey(), typeEntry.getKey(), typeEntry.getValue()))).collect(Collectors.toList()); |
| | | |
| | | List<ServiceSubtaskCount> result2 = new ArrayList<>(); |
| | | //根据服务类型进行筛选 |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getServiceType())) { |
| | | for (ServiceSubtaskCount serviceSubtaskCount : result) { |
| | | for (Long type : serviceSubtaskCountReq.getServiceType()) { |
| | | if (type == serviceSubtaskCount.getServiceType()) { |
| | | result2.add(serviceSubtaskCount); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | result2 = result; |
| | | } |
| | | return result2; |
| | | } |
| | | |
| | | private IvrTaskTemplateScriptVO getNextQuestion(List<IvrTaskTemplateScriptVO> IvrTaskTemplateScriptVOList, IvrTaskTemplateScriptVO IvrTaskTemplateScriptVO) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private ServiceSubtaskDetail getServiceSubtaskDetail(PhoneCallReqYQVO phoneCallReqYQVO, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate) { |
| | | ServiceSubtaskDetail serviceSubtaskDetail = new ServiceSubtaskDetail(); |
| | | serviceSubtaskDetail.setSubId(Long.valueOf(phoneCallReqYQVO.getTaskid())); |
| | | ServiceSubtask serviceSubtask1 = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(phoneCallReqYQVO.getTaskid())); |
| | | if (serviceSubtask1 != null) { |
| | | serviceSubtaskDetail.setTaskid(serviceSubtask1.getTaskid()); |
| | | serviceSubtaskDetail.setPatid(serviceSubtask1.getPatid()); |
| | | } |
| | | serviceSubtaskDetail.setUuid(phoneCallReqYQVO.getUuid()); |
| | | serviceSubtaskDetail.setPhone(phoneCallReqYQVO.getPhone()); |
| | | serviceSubtaskDetail.setOperate(serviceSubtask.getCreateBy()); |
| | |
| | | serviceSubtaskDetail.setTemplateid(ivrTaskTemplate.getId().toString()); |
| | | serviceSubtaskDetail.setTemplatequestionnum(ivrTaskTemplateScriptVO.getId()); |
| | | serviceSubtaskDetail.setQuestiontext(ivrTaskTemplateScriptVO.getScriptContent()); |
| | | serviceSubtaskDetail.setQuestionvoice(phoneCallReqYQVO.getRecordpath()); |
| | | serviceSubtaskDetail.setCategoryname(ivrTaskTemplateScriptVO.getScriptType()); |
| | | serviceSubtaskDetail.setTargetoptions(ivrTaskTemplateScriptVO.getTargetOptions()); |
| | | serviceSubtaskDetail.setExtemplateText(ivrTaskTemplateScriptVO.getExtemplateText()); |
| | | |
| | | int i = 1; |
| | | for (IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption : ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList()) { |
| | | if (ivrTaskTemplateTargetoption.getIsUserOperation() == 1) { |
| | | serviceSubtaskDetail.setMatchedtext(ivrTaskTemplateTargetoption.getTargetvalue()); |
| | | } |
| | | serviceSubtaskDetail.setTargetvalue(StringUtils.isEmpty(serviceSubtaskDetail.getTargetvalue()) ? i + ivrTaskTemplateTargetoption.getTargetvalue() : serviceSubtaskDetail.getTargetvalue() + " " + (i + 1) + ivrTaskTemplateTargetoption.getTargetvalue()); |
| | | serviceSubtaskDetail.setTargetvalue(StringUtils.isEmpty(serviceSubtaskDetail.getTargetvalue()) ? ivrTaskTemplateTargetoption.getTargetvalue() : serviceSubtaskDetail.getTargetvalue() + "&" + ivrTaskTemplateTargetoption.getTargetvalue()); |
| | | } |
| | | |
| | | serviceSubtaskDetail.setAddtime(new Date()); |