| | |
| | | configVoiceMatchAi.setConfigKey("sys.voice.match.ai"); |
| | | SysConfig matchAi = sysConfigMapper.selectConfig(configVoiceMatchAi); |
| | | |
| | | // if (ObjectUtils.isNotEmpty(matchAi) && StringUtils.isNotEmpty(matchAi.getConfigValue()) |
| | | // && matchAi.getConfigValue().equals("1")) { |
| | | // PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO, |
| | | // ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate, |
| | | // ivrTaskTemplateScripts, scriptId, flag); |
| | | // if(aiMatchResult != null){ |
| | | // return aiMatchResult; |
| | | // } |
| | | // } else { |
| | | if (ObjectUtils.isNotEmpty(matchAi) && StringUtils.isNotEmpty(matchAi.getConfigValue()) |
| | | && matchAi.getConfigValue().equals("1")) { |
| | | PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO, |
| | | ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate, |
| | | ivrTaskTemplateScripts, scriptId, flag, phoneCallReqYQVO.getUuid()); |
| | | if(aiMatchResult != null){ |
| | | return aiMatchResult; |
| | | } |
| | | } else { |
| | | //是选择题 |
| | | for (int j = 0; j < ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size(); j++) { |
| | | log.error("phoneCallReqYQVO.getAsrtext()的值为:{}", phoneCallReqYQVO.getAsrtext()); |
| | |
| | | continue; |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | //都没有匹配到 |
| | | if (StringUtils.isEmpty(phoneCallBackYQVO.getValue())) { |
| | | log.info("都没有匹配到-------------------------"); |
| | |
| | | @Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.info("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | String groupKey = "drcode"; |
| | | String drcode = "drcode"; |
| | | //缙云人民 根据经管医生分组 |
| | | if(serviceSubtaskCountReq.getOrgid().equals("47246116333112211A1001")){ |
| | | drcode = "management_doctor_code"; |
| | | } |
| | | String groupKey = drcode; |
| | | if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 1) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | groupKey = "drcode"; |
| | | groupKey = drcode; |
| | | } else { |
| | | groupKey = "leavehospitaldistrictcode"; |
| | | } |
| | | } else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 2) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | groupKey = "drcode"; |
| | | groupKey = drcode; |
| | | } else { |
| | | groupKey = "deptcode"; |
| | | } |
| | |
| | | serviceSubtaskCountReq.setGroupKeyList(groupKeyList); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | switch (groupKey) { |
| | | case "deptcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | break; |
| | | case "drcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | case "management_doctor_code": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown"))); |
| | | break; |
| | | case "deptcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | break; |
| | | case "leavehospitaldistrictcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown"))); |
| | |
| | | * @param options |
| | | * @return |
| | | */ |
| | | public Integer matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options){ |
| | | public Integer matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options, String uuid){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("userQuestion",questionText); |
| | | jsonObject.put("userAnswer",voiceText); |
| | | jsonObject.put("options", options); |
| | | jsonObject.put("uuid", uuid); |
| | | String jsonString = jsonObject.toJSONString(); |
| | | String result = null; |
| | | |
| | |
| | | |
| | | public PhoneCallBackYQVO AiMatch(PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO, |
| | | IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate, |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag){ |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag, String uuid){ |
| | | PhoneCallBackYQVO back = null; |
| | | List<IvrTaskTemplateTargetoption> options = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList(); |
| | | String voiceText = phoneCallReqYQVO.getAsrtext(); |
| | | String questionText = StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrtext()) ? ivrTaskTemplateScriptVO.getIvrtext() : ivrTaskTemplateScriptVO.getScriptContent(); |
| | | Integer matched = -1; |
| | | matched = matchOptionIndex(questionText, voiceText, options); |
| | | matched = matchOptionIndex(questionText, voiceText, options, uuid); |
| | | //说明匹配正确了 |
| | | if(matched != null && matched >= 0){ |
| | | IvrTaskTemplateTargetoption chosenOption = options.get(matched); |
| | |
| | | ivrTaskTemplateTargetoption3.setTargetvalue("其他"); |
| | | options.add(ivrTaskTemplateTargetoption3); |
| | | |
| | | Integer matched = matchOptionIndex(questionText,voiceText,options); |
| | | Integer matched = matchOptionIndex(questionText,voiceText,options,"1"); |
| | | if(ObjectUtils.isNotEmpty(matched)){ |
| | | if(matched >= 0){ |
| | | matchedText = options.get(matched).getTargetvalue(); |