| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.smartor.common.FtpService; |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | private IIvrTaskTemplateScriptService iIvrTaskTemplateScriptService; |
| | | |
| | | @Autowired |
| | | private IServiceOutPathService iServiceOutPathService; |
| | | |
| | | @Autowired |
| | | private FtpService ftpService; |
| | | |
| | | @Value("${pri_key}") |
| | | private String pri_key; |
| | | |
| | | @Value("${pub_key}") |
| | | private String pub_key; |
| | | |
| | | @Value("${ASRCallBackPath}") |
| | | private String ASRCallBackPath; |
| | | |
| | | @Autowired |
| | | private SendService sendService; |
| | | |
| | | @Value("${hangup}") |
| | | private String hangup; |
| | |
| | | @Value("${voicePathPrefix}") |
| | | private String voicePathPrefix; |
| | | |
| | | @Value("${localIP}") |
| | | private String localIP; |
| | | |
| | | @Value("${req_path}") |
| | | private String req_path; |
| | | |
| | | @Value("${xhsmsPath}") |
| | | private String xhsmsPath; |
| | | |
| | | /** |
| | | * 查询单一任务(随访) |
| | |
| | | Integer yc = 0; |
| | | Integer fssb = 0; |
| | | Integer yfs = 0; |
| | | Integer blq = 0; |
| | | Integer xj = 0; |
| | | Integer dfs = 0; |
| | | Integer ywc = 0; |
| | | Integer ywc2 = 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.getSendstate() == 1L) xj = xj + 1; |
| | | if (serviceSubtask.getSendstate() == 2L) dfs = dfs + 1; |
| | | if (serviceSubtask.getSendstate() == 6L) ywc = ywc + 1; |
| | | if (serviceSubtask.getExcep().equals("1")) yc = yc + 1; |
| | | } |
| | | map.put("wzx", wzx); |
| | |
| | | map.put("yc", yc); |
| | | map.put("fssb", fssb); |
| | | map.put("yfs", yfs); |
| | | map.put("blq", blq); |
| | | |
| | | map.put("xj", xj); |
| | | map.put("dfs", dfs); |
| | | map.put("ywc", ywc); |
| | | map.put("yfs2", yfs + ywc); |
| | | return map; |
| | | } |
| | | |
| | |
| | | //将任务信息新增到随访服务表中 |
| | | serviceSubtask.setSendname(patTaskRelevance.getName()); |
| | | serviceSubtask.setAge(patTaskRelevance.getAge()); |
| | | serviceSubtask.setLibtemplateid(Long.valueOf(serviceTask.getLibtemplateid())); |
| | | 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); |
| | | if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1) |
| | | serviceSubtask.setSendstate(2L); |
| | | serviceSubtask.setDeptcode(patTaskRelevance.getDeptCode()); |
| | | serviceSubtask.setDeptname(patTaskRelevance.getDeptName()); |
| | | serviceSubtask.setLeavehospitaldistrictcode(patTaskRelevance.getLeavehospitaldistrictcode()); |
| | |
| | | serviceSubtask.setEndtime(patTaskRelevance.getEndtime()); |
| | | serviceSubtask.setNurseId(patTaskRelevance.getNurseId()); |
| | | serviceSubtask.setNurseName(patTaskRelevance.getNurseName()); |
| | | if (serviceTaskVO.getLongTask() == 1) |
| | | if (serviceTaskVO.getLongTask() != null && serviceTaskVO.getLongTask() == 1) |
| | | serviceSubtask.setLongSendTime(patTaskRelevance.getLongSendTime()); |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | integer = serviceSubtask.getId().intValue(); |
| | |
| | | // 问题, 去调用“tts合成和播放”接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | | } |
| | | } else { |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES); |
| | |
| | | //静默话术 + 问题, 去调用“tts合成和播放”接口 |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("静默话术 + 问题,去调用tts合成和播放接口: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(slienceText + nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(slienceText + nowQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } |
| | | |
| | |
| | | Pattern pattern2 = Pattern.compile(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()); |
| | | matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult()); |
| | | } |
| | | log.error("PCB--getQuestionText问题为:{},UUID:{}", nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | log.error("PCB--getQuestionText问题为:{},UUID:{}", nowQuestion.getIvrtext(), 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是单选题的改法 |
| | |
| | | //将患者的回签写进表里 |
| | | IvrTaskVisitResult serviceTaskVisitResult = DtoConversionUtils.sourceToTarget(serviceSubtask, IvrTaskVisitResult.class); |
| | | serviceTaskVisitResult.setId(null); |
| | | serviceTaskVisitResult.setQuestion(nowQuestion.getScriptContent()); |
| | | serviceTaskVisitResult.setQuestion(nowQuestion.getIvrtext()); |
| | | serviceTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult()); |
| | | serviceTaskVisitResult.setCreateTime(new Date()); |
| | | serviceTaskVisitResult.setOptionResult(nowQuestion.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue()); |
| | |
| | | questionMessage.setNowQuestion(script); |
| | | questionMessage.setQuestionList(IvrTaskTemplateScriptVOs); |
| | | redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES); |
| | | phoneUtils.ttsPlayback(script.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(script.getIvrtext(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } else if (nextQuestion > IvrTaskTemplateScriptVOs.size()) { |
| | | //没有下一题了,就结束了 |
| | |
| | | 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()); |
| | | phoneUtils.ttsPlayback(nextQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | | return; |
| | | } else { |
| | | //就可以挂断电话了 |
| | |
| | | //调用“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()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getIvrtext() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid()); |
| | | } |
| | | break; |
| | | } |
| | | String date = simpleDateFormat1.format(new Date()); |
| | | log.info("最后的信息回复-: {},uuid为:{}", date, phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getScriptContent(), phoneCallBackVO.getUuid()); |
| | | phoneUtils.ttsPlayback(nowQuestion.getIvrtext(), phoneCallBackVO.getUuid()); |
| | | } |
| | | } |
| | | } |
| | |
| | | public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) { |
| | | //判断是否挂机 |
| | | String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup"); |
| | | if (StringUtils.isNotEmpty(hangupState) && hangup.equals("1")) { |
| | | Object cacheObject1 = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); |
| | | if (StringUtils.isNotEmpty(hangupState) && hangup.equals("1") || ObjectUtils.isNotEmpty(cacheObject1) && String.valueOf(cacheObject1).equals("1")) { |
| | | return new PhoneCallBackYQVO(); |
| | | } |
| | | if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) { |
| | | //处理挂断 |
| | | if (phoneCallReqYQVO.getAsrtext().contains("拨叫的用户正忙")) { |
| | | //判断 recordAccept-hungup 是否有值,如果有,则说明不用处理了,之前已经处理过了(recordAccept-hungup这个主要是给“通话记录用的,”) |
| | | Object cacheObject = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); |
| | | if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) { |
| | | return new PhoneCallBackYQVO(); |
| | | } |
| | | ServiceSubtask serviceSubtask2 = new ServiceSubtask(); |
| | | serviceSubtask2.setRemark("电话发送成功(患者挂断)"); |
| | | serviceSubtask2.setSenduuid(phoneCallReqYQVO.getUuid()); |
| | |
| | | req.put("caller", phoneCallReqYQVO.getPhone()); |
| | | HttpUtil.postJsonRequest(hangup, new Gson().toJson(req)); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- hangup", "1", 2, TimeUnit.MINUTES); |
| | | //先把默认的recordAccept-hungup删除,再更新 |
| | | redisCache.deleteObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES); |
| | | //这个时候就需要走补偿机制了,先暂定走短信 |
| | | getSmsCompensate(Long.valueOf(phoneCallReqYQVO.getTaskid())); |
| | | return new PhoneCallBackYQVO(); |
| | | } |
| | | } |
| | |
| | | //小与的话,就继续问患者 |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = ivrTaskTemplateScriptVO.getScriptContent(); |
| | | String scriptContent = ivrTaskTemplateScriptVO.getIvrtext(); |
| | | log.error("SilentCallback的问题内容scriptContent:{}", scriptContent); |
| | | phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent)); |
| | | //将静默次数加1 |
| | |
| | | } |
| | | return phoneCallBackYQVO; |
| | | } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) { |
| | | |
| | | //做一个标识,用来在通话详情接口里,判断是否有人接电话(value=2,表示有人接) |
| | | redisCache.deleteObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "2", 10, TimeUnit.MINUTES); |
| | | // 先对通话进行通用库匹配一次 |
| | | String extemplateID = ivrTaskTemplate.getSubmoduleID(); |
| | | if (StringUtils.isNotEmpty(extemplateID)) { |
| | |
| | | if (script.getSort() == nextQuestion.intValue()) { |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = script.getScriptContent(); |
| | | String scriptContent = script.getIvrtext(); |
| | | log.error("下一题问题:{}", scriptContent); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent)); |
| | | //将该患者的Redis中的题目ID,进行修改 |
| | |
| | | if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) { |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = script.getScriptContent(); |
| | | String scriptContent = script.getIvrtext(); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent)); |
| | | //将该患者的Redis中的题目ID,进行修改 |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES); |
| | |
| | | redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid(), count + 1, 120, TimeUnit.MINUTES); |
| | | |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setValue(ivrTaskTemplateScriptVO.getNoMatchText() + getObject(serviceSubtask, ivrTaskTemplateScriptVO.getScriptContent())); |
| | | phoneCallBackYQVO.setValue(ivrTaskTemplateScriptVO.getNoMatchText() + getObject(serviceSubtask, ivrTaskTemplateScriptVO.getIvrtext())); |
| | | } |
| | | } |
| | | |
| | |
| | | if (ivrTaskTemplateScriptVO.getNextScriptno().intValue() == ivrTaskTemplateScript1.getSort()) { |
| | | phoneCallBackYQVO.setType("text"); |
| | | phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue()); |
| | | String scriptContent = ivrTaskTemplateScript1.getScriptContent(); |
| | | String scriptContent = ivrTaskTemplateScript1.getIvrtext(); |
| | | phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent)); |
| | | redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid()); |
| | | redisCache.setCacheObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone(), ivrTaskTemplateScript1.getId().toString()); |
| | |
| | | //根据,获取子任务的ID |
| | | String[] split = subIds.split(",,"); |
| | | for (int i = 0; i < split.length; i++) { |
| | | if (cacheName.equals("cache-0") && i < 5 || !cacheName.equals("cache-0") && i < 1) { |
| | | if (cacheName.equals("cache-0") && i < split.length || !cacheName.equals("cache-0") && i < 1) { |
| | | PullTaskVO pullTaskVO = new PullTaskVO(); |
| | | String subId = split[i].trim().replace(",", ""); |
| | | ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(subId)); |
| | |
| | | //如果ivrTaskTemplateScript为空,也就没有往下执行的必要了 |
| | | if (ObjectUtils.isEmpty(ivrTaskTemplateScript)) return null; |
| | | //获取通配符匹配过后的问题 |
| | | String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent()); |
| | | String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getIvrtext()); |
| | | String kcb = serviceTask.getKcb() + "," + scrContent; |
| | | // String kcb = ivrTaskTemplate.getRevisitBefore(); |
| | | |
| | |
| | | |
| | | @Override |
| | | public Integer recordAccept(PhoneCallRecordVO phoneCallRecordVO) { |
| | | if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) { |
| | | Object cacheObject = redisCache.getCacheObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup"); |
| | | if (phoneCallRecordVO.getHangup_cause().equals("NO_USER_RESPONSE") || ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) { |
| | | //无人接听 |
| | | getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | | redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup"); |
| | | } else if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) { |
| | | // 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); |
| | | ServiceSubtask serviceSubtask = new ServiceSubtask(); |
| | | serviceSubtask.setRemark("电话拨打已完成"); |
| | | serviceSubtask.setSendstate(6L); |
| | | serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | //下载文件 |
| | | ftpService.downloadFolder("/" + LocalDate.now().toString(), profile + "/upload/vadio/voice/" + LocalDate.now().toString()); |
| | | redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup"); |
| | | } else { |
| | | //患者拒绝随访 |
| | | ServiceSubtask serviceSubtask = new ServiceSubtask(); |
| | | serviceSubtask.setRemark("电话接通成功,患者拒绝随访"); |
| | | serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | 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()); |
| | | redisCache.deleteObject(phoneCallRecordVO.getTaskid() + "recordAccept-hungup"); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | |
| | | result2 = result; |
| | | } |
| | | return result2; |
| | | } |
| | | |
| | | /** |
| | | * 获取随访统计比例 |
| | | * |
| | | * @param serviceSubtaskCountReq |
| | | * @return |
| | | */ |
| | | @Override |
| | | 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(ServiceSubtask::getLeavehospitaldistrictname)); |
| | | for (List<ServiceSubtask> serviceSubtaskList : collect.values()) { |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList); |
| | | if (ObjectUtils.isNotEmpty(statistic)) { |
| | | serviceSubtaskStatistics.add(statistic); |
| | | } |
| | | } |
| | | return serviceSubtaskStatistics; |
| | | } |
| | | |
| | | private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList) { |
| | | ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic(); |
| | | serviceSubtaskStatistic.setLeavehospitaldistrictname(serviceSubtaskList.get(0).getLeavehospitaldistrictname()); |
| | | serviceSubtaskStatistic.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode()); |
| | | serviceSubtaskStatistic.setServiceCount(serviceSubtaskList.size()); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | //不随访数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setBzxCount(serviceSubtaskStatistic.getBzxCount() + 1L); |
| | | } |
| | | //应随访数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setYsfCount(serviceSubtaskStatistic.getYsfCount() + 1L); |
| | | } |
| | | //发送失败数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 5) { |
| | | serviceSubtaskStatistic.setFssbCount(serviceSubtaskStatistic.getFssbCount() + 1L); |
| | | } |
| | | //待发送数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | | serviceSubtaskStatistic.setDfsCount(serviceSubtaskStatistic.getDfsCount() + 1L); |
| | | } |
| | | //已发送数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 3) { |
| | | serviceSubtaskStatistic.setYfsCount(serviceSubtaskStatistic.getYfsCount() + 1L); |
| | | } |
| | | //已完成数量 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 6) { |
| | | //已发送,包含已完成 |
| | | serviceSubtaskStatistic.setYfsCount(serviceSubtaskStatistic.getYfsCount() + 1L); |
| | | serviceSubtaskStatistic.setYwcCount(serviceSubtaskStatistic.getYwcCount() + 1L); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getExcep()) && serviceSubtask.getExcep().equals("1")) { |
| | | //异常标识 |
| | | serviceSubtaskStatistic.setYczs(serviceSubtaskStatistic.getYczs() + 1L); |
| | | |
| | | } |
| | | |
| | | } |
| | | //随访完成率=已发送/随访数 |
| | | if (serviceSubtaskStatistic.getYfsCount() == 0 || CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | serviceSubtaskStatistic.setSfwcl("0"); |
| | | } else { |
| | | BigDecimal multiply = BigDecimal.valueOf(serviceSubtaskStatistic.getYfsCount()).divide(BigDecimal.valueOf(serviceSubtaskList.size()), 2, BigDecimal.ROUND_HALF_UP); |
| | | serviceSubtaskStatistic.setSfwcl(multiply.toString()); |
| | | } |
| | | |
| | | return serviceSubtaskStatistic; |
| | | } |
| | | |
| | | private IvrTaskTemplateScriptVO getNextQuestion(List<IvrTaskTemplateScriptVO> IvrTaskTemplateScriptVOList, IvrTaskTemplateScriptVO IvrTaskTemplateScriptVO) { |
| | |
| | | serviceSubtaskDetail.setSentEnd(1L); |
| | | serviceSubtaskDetail.setTemplateid(ivrTaskTemplate.getId().toString()); |
| | | serviceSubtaskDetail.setTemplatequestionnum(ivrTaskTemplateScriptVO.getId()); |
| | | serviceSubtaskDetail.setQuestiontext(ivrTaskTemplateScriptVO.getScriptContent()); |
| | | serviceSubtaskDetail.setQuestiontext(ivrTaskTemplateScriptVO.getIvrtext()); |
| | | serviceSubtaskDetail.setQuestionvoice(phoneCallReqYQVO.getRecordpath()); |
| | | serviceSubtaskDetail.setCategoryname(ivrTaskTemplateScriptVO.getScriptType()); |
| | | serviceSubtaskDetail.setTargetoptions(ivrTaskTemplateScriptVO.getTargetOptions()); |
| | |
| | | return serviceSubtaskDetail; |
| | | } |
| | | |
| | | private void getSmsCompensate(Long subTaskId) { |
| | | ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(subTaskId); |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key); |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setUrl(localIP + ":" + req_path + "/sf?p=" + format); |
| | | sendMagParam.setContent("【新华医院】您好,邀请您填写出院随访调查表,请点击" + sendMagParam.getUrl() + "填写。感谢您配合!"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("phone", serviceSubtask.getPhone()); |
| | | map.put("content", sendMagParam.getContent()); |
| | | String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map)); |
| | | redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功"); |
| | | else serviceSubtask.setRemark("短信补偿发送成功"); |
| | | //记录一下补偿方式 |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getPreachform())) { |
| | | serviceSubtask.setPreachform(serviceSubtask.getPreachform() + ",1"); |
| | | } |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | } |