| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.ListOperations; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Duration; |
| | |
| | | //有下一题 |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(IvrTaskTemplateScriptVOs, nowQuestion); |
| | | // 问题, 去调用“tts合成和播放”接口 |
| | | // 问题, 去调用"tts合成和播放"接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES); |
| | | //调用ivrLibaTemplateScriptVO中的slienceText(静默话术) |
| | | String slienceText = nowQuestion.getSlienceText(); |
| | | //静默话术 + 问题, 去调用“tts合成和播放”接口 |
| | | //静默话术 + 问题, 去调用"tts合成和播放"接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("静默话术 + 问题,去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(slienceText + nowQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES); |
| | | } |
| | | //调用“15、tts合成和播放, tts_playback”将结果传回 |
| | | //调用"15、tts合成和播放, tts_playback"将结果传回 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("调用“15、tts合成和播放------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | log.info("调用tts合成和播放------: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getIvrtext() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid()); |
| | | } |
| | | break; |
| | |
| | | if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) { |
| | | //处理挂断 |
| | | if (phoneCallReqYQVO.getAsrtext().contains("拨叫的用户正忙")) { |
| | | //判断 recordAccept-hungup 是否有值,如果有,则说明不用处理了,之前已经处理过了(recordAccept-hungup这个主要是给“通话记录用的,”) |
| | | //判断 recordAccept-hungup 是否有值,如果有,则说明不用处理了,之前已经处理过了(recordAccept-hungup这个主要是给"通话记录用的,") |
| | | Object cacheObject = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); |
| | | if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) { |
| | | return new PhoneCallBackYQVO(); |
| | |
| | | // //有下一题 |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES); |
| | | // IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion); |
| | | // // 问题, 去调用“tts合成和播放”接口 |
| | | // // 问题, 去调用"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合成和播放”接口 |
| | | // //静默话术 + 问题, 去调用"tts合成和播放"接口 |
| | | // phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid()); |
| | | // return new PhoneCallBackVO(); |
| | | // } |
| | |
| | | // redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES); |
| | | // } |
| | | // |
| | | // //调用“15、tts合成和播放, tts_playback”将结果传回 |
| | | // //调用"15、tts合成和播放, tts_playback"将结果传回 |
| | | // |
| | | // |
| | | // } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 服务统计查询 - 按时间维度统计出院/门诊随访数据 |
| | | * |
| | | * @param request 统计请求参数 |
| | | * @return 统计结果列表 |
| | | */ |
| | | @Override |
| | | public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request) { |
| | | log.info("getServiceStatistics的入参为:{}", request); |
| | | |
| | | // 参数校验 |
| | | if (request.getStartDate() == null || request.getEndDate() == null) { |
| | | throw new IllegalArgumentException("开始日期和结束日期不能为空"); |
| | | } |
| | | |
| | | if (request.getStartDate().after(request.getEndDate())) { |
| | | throw new IllegalArgumentException("开始日期不能晚于结束日期"); |
| | | } |
| | | |
| | | // 如果timeType为空,默认按天统计 |
| | | if (StringUtils.isEmpty(request.getTimeType())) { |
| | | request.setTimeType("day"); |
| | | } |
| | | |
| | | List<ServiceStatisticsResponse> result = serviceSubtaskMapper.getServiceStatistics(request); |
| | | |
| | | |
| | | log.info("getServiceStatistics返回结果数量:{}", result.size()); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取随访统计比例 |
| | | * |
| | | * @param serviceSubtaskCountReq |
| | |
| | | public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.error("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | //Map<String, List<ServiceSubtask>> collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown"))); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown"))); |
| | | |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown"))); |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown"))); |
| | | } |
| | | } else if (serviceSubtaskCountReq.getDeptcodes() != null && serviceSubtaskCountReq.getDeptcodes().size() > 0) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown"))); |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown"))); |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown"))); |
| | | } |
| | | } |
| | | |
| | | for (List<ServiceSubtask> serviceSubtaskList : collect.values()) { |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | |
| | | //及时率 |
| | | ServiceSubtask ss = new ServiceSubtask(); |
| | | ss.setOrgid(serviceSubtaskList.get(0).getOrgid()); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) { |
| | | ss.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode()); |
| | | } else { |
| | | ss.setDeptcode(serviceSubtaskList.get(0).getDeptcode()); |
| | | |
| | | // 如果有医生编码,设置医生编码用于及时率查询 |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | ss.setDrcode(serviceSubtaskList.get(0).getDrcode()); |
| | | }else { |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) { |
| | | ss.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode()); |
| | | } else if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getDeptcodes())) { |
| | | ss.setDeptcode(serviceSubtaskList.get(0).getDeptcode()); |
| | | } |
| | | } |
| | | |
| | | ss.setStarttime(serviceSubtaskCountReq.getStartTime()); |
| | | ss.setEndtime(serviceSubtaskCountReq.getEndTime()); |
| | | if (serviceSubtaskCountReq.getEndTime() != null && new Date().before(serviceSubtaskCountReq.getEndTime())) { |
| | |
| | | serviceSubtaskStatistic.setDeptcode(serviceSubtaskList.get(0).getDeptcode()); |
| | | serviceSubtaskStatistic.setLeavehospitaldistrictname(serviceSubtaskList.get(0).getLeavehospitaldistrictname()); |
| | | serviceSubtaskStatistic.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode()); |
| | | serviceSubtaskStatistic.setDrcode(serviceSubtaskList.get(0).getDrcode()); |
| | | serviceSubtaskStatistic.setDrname(serviceSubtaskList.get(0).getDrname()); |
| | | //出院人次 |
| | | serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size()); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |