| | |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.core.service.IConfigService; |
| | | import com.ruoyi.common.dx.MessageSend; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | |
| | | import com.smartor.common.MtSubmitSmUtil; |
| | | import com.smartor.common.ScheduleSubtaskBuilder; |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.DTO.QuestionResultDTO; |
| | | import com.smartor.domain.DTO.ServiceSubtaskDetailDTO; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.VO.HeLibraryCountVO; |
| | | import com.smartor.domain.VO.QuestionResultVO; |
| | | import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO; |
| | | import com.smartor.domain.VO.TransferDeptVO; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.checkerframework.checker.nullness.qual.NonNull; |
| | | import org.junit.Test; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | private PatMedOperationMapper patMedOperationMapper; |
| | | @Autowired |
| | | private PatMedOperationItemMapper patMedOperationItemMapper; |
| | | @Autowired |
| | | private ServiceOutPathMapper serviceOutPathMapper; |
| | | |
| | | /** |
| | | * 查询单一任务(随访) |
| | |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskRes> patItem(ServiceSubtaskEntity serviceSubtaskEntity) { |
| | | if (serviceSubtaskEntity.getSendstateView() != null) { |
| | | // 1:待随访(1 被领取、2 待发送、3 已发送、5 发送失败、7、超时);2:已完成( 6 已完成)、3:无需随访(4 不执行) |
| | | if (serviceSubtaskEntity.getSendstateView() == 1) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 2) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 3) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(4L))); |
| | | } |
| | | //患者获取随访任务-需要查询同个患者(身份证)所有的任务 景宁 |
| | | if (StringUtils.isNotEmpty(serviceSubtaskEntity.getOrgid()) && serviceSubtaskEntity.getOrgid().equals("47255004333112711A1001")) { |
| | | if (ObjectUtils.isNotEmpty(serviceSubtaskEntity.getPatid())) { |
| | | PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtaskEntity.getPatid()); |
| | | if (ObjectUtils.isNotEmpty(patArchive) && StringUtils.isNotEmpty(patArchive.getIdcardno())) { |
| | | serviceSubtaskEntity.setPatid(null); |
| | | serviceSubtaskEntity.setSfzh(patArchive.getIdcardno()); |
| | | } |
| | | } |
| | | } |
| | | List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskEntity); |
| | | List<ServiceSubtask> selectServiceSubtaskList = getServiceSubtasks(serviceSubtaskEntity); |
| | | |
| | | List<ServiceSubtaskRes> serviceSubtaskResList = new ArrayList<>(); |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | |
| | | serviceSubtaskResList.add(serviceSubtaskRes); |
| | | } |
| | | return serviceSubtaskResList; |
| | | } |
| | | |
| | | public List<ServiceSubtask> getServiceSubtasks(ServiceSubtaskEntity serviceSubtaskEntity) { |
| | | if (serviceSubtaskEntity.getSendstateView() != null) { |
| | | // 1:待随访(1 被领取、2 待发送、3 已发送、5 发送失败、7、超时);2:已完成( 6 已完成)、3:无需随访(4 不执行) |
| | | if (serviceSubtaskEntity.getSendstateView() == 1) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 2) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 3) |
| | | serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(4L))); |
| | | } |
| | | //患者获取随访任务-需要查询同个患者(身份证)所有的任务 景宁 |
| | | if (StringUtils.isNotEmpty(serviceSubtaskEntity.getOrgid()) && serviceSubtaskEntity.getOrgid().equals("47255004333112711A1001")) { |
| | | if (ObjectUtils.isNotEmpty(serviceSubtaskEntity.getPatid())) { |
| | | PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtaskEntity.getPatid()); |
| | | if (ObjectUtils.isNotEmpty(patArchive) && StringUtils.isNotEmpty(patArchive.getIdcardno())) { |
| | | serviceSubtaskEntity.setPatid(null); |
| | | serviceSubtaskEntity.setSfzh(patArchive.getIdcardno()); |
| | | } |
| | | } |
| | | } |
| | | List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskEntity); |
| | | return selectServiceSubtaskList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | @Override |
| | | public Map<String, Object> insertServiceSubtask(ServiceSubtask serviceSubtask) { |
| | | serviceSubtask.setCreateTime(DateUtils.getNowDate()); |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | List<ServiceSubtask> serviceSubtasks = null; |
| | | //先查询一下该患者是否已经创建根据serviceType,sendstate,inhospid,patid,orgid |
| | | //这样判断主要是为了想让新华医院的外部导入患者创建任务,也能用这个接口 |
| | | if (StringUtils.isEmpty(serviceSubtask.getPatfrom()) || !serviceSubtask.getPatfrom().equals("2")) { |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setServiceType(serviceSubtask.getServiceType()); |
| | | serviceSubtaskVO.setInhospid(serviceSubtask.getInhospid()); |
| | | serviceSubtaskVO.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L))); |
| | | serviceSubtaskVO.setPatid(serviceSubtask.getPatid()); |
| | | serviceSubtaskVO.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceSubtaskVO.setCampusid(serviceSubtask.getCampusid()); |
| | | serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | } |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String format = null; |
| | | if (CollectionUtils.isNotEmpty(serviceSubtasks)) { |
| | | ServiceSubtask serviceSubtask1 = serviceSubtasks.get(0); |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setSubId(serviceSubtask1.getId()); |
| | | List<ServiceOutPath> serviceOutPaths = serviceOutPathMapper.selectServiceOutPathList(serviceOutPath); |
| | | if (CollectionUtils.isNotEmpty(serviceOutPaths)) |
| | | format = String.format("%03X", serviceOutPaths.get(0).getId()); |
| | | else format = getOutPath(serviceSubtask1, rsaPublicKeyExample); |
| | | serviceSubtask = serviceSubtask1; |
| | | } else { |
| | | //如果不存在,则新增 |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if (ObjectUtils.isNotEmpty(serviceTask)) { |
| | | serviceSubtask.setDeptcode(serviceTask.getDeptcode()); |
| | | serviceSubtask.setTaskDesc(serviceTask.getTaskDesc()); |
| | | serviceSubtask.setTaskName(serviceTask.getTaskName()); |
| | | serviceSubtask.setDeptname(serviceTask.getDeptname()); |
| | | serviceSubtask.setTemplatename(serviceTask.getTemplatename()); |
| | | } |
| | | |
| | | serviceSubtask.setCreateTime(DateUtils.getNowDate()); |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | //修改住院满意度状态(避免重复查询) |
| | | if (serviceSubtask.getServiceType() != null && "6".equals(serviceSubtask.getServiceType())) { |
| | | Long inhospid = serviceSubtask.getInhospid(); |
| | | if (inhospid != null) { |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospMydFlag("1"); |
| | | patMedInhosp.setInhospid(inhospid); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | } |
| | | } |
| | | format = getOutPath(serviceSubtask, rsaPublicKeyExample); |
| | | } |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(format)) |
| | | result.put("url", StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format); |
| | | else result.put("url", null); |
| | | result.put("subId", serviceSubtask.getId()); |
| | | return result; |
| | | } |
| | | |
| | | private String getOutPath(ServiceSubtask serviceSubtask, RSAPublicKeyExample rsaPublicKeyExample) { |
| | | String format; |
| | | String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key); |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key); |
| | |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setTaskId(serviceSubtask.getTaskid()); |
| | | serviceOutPath.setSubId(serviceSubtask.getId()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("url", StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format); |
| | | result.put("subId", serviceSubtask.getId()); |
| | | return result; |
| | | return format; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) { |
| | | } else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) { |
| | | //任务修改 |
| | | if (ObjectUtils.isNotEmpty(serviceTaskVO.getSendTimeslot())) |
| | | serviceTask.setSendTimeSlot(JSON.toJSONString(serviceTaskVO.getSendTimeslot())); |
| | |
| | | patMedOuthosp.setServerState("0"); |
| | | patMedOuthospService.updatePatMedOuthosp(patMedOuthosp); |
| | | } |
| | | } |
| | | } else if (serviceSubtask.getServiceType().equals("19")) { |
| | | ServiceTask st = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | //如果任务是长期任务,需要将该患者的手术详情数据 |
| | | if (st != null && st.getLongTask() == 1 && ObjectUtils.isNotEmpty(serviceSubtask.getOperationItemId())) { |
| | | PatMedOperationItem patMedOperationItem = new PatMedOperationItem(); |
| | | patMedOperationItem.setOpercheckFlag("0"); |
| | | patMedOperationItem.setId(serviceSubtask.getOperationItemId()); |
| | | patMedOperationItemMapper.updatePatMedOperationItem(patMedOperationItem); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) { |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime, String scriptContent, Double scoreStart, Double scoreEnd,String valueType) { |
| | | //先清理一下重复数据 |
| | | List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds(); |
| | | if (!CollectionUtils.isEmpty(repeatIds)) { |
| | | serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds); |
| | | } |
| | | return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime); |
| | | List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime, scoreStart, scoreEnd, scriptContent, valueType); |
| | | |
| | | // 处理 targetvalue:按 & 分割成多条记录 |
| | | List<ServiceSubtaskDetailRatioExport> result = new ArrayList<>(); |
| | | for (ServiceSubtaskDetailRatioExport export : serviceSubtaskDetailRatioExports) { |
| | | if (StringUtils.isNotEmpty(export.getTargetvalue()) && export.getTargetvalue().contains("&")) { |
| | | String[] values = export.getTargetvalue().split("&"); |
| | | // 如果有多条目标值,拆分成多行 |
| | | for (String value : values) { |
| | | //先去 result 中查一下,有没有这个 questiontext 和对应的 targetvalue |
| | | ServiceSubtaskDetailRatioExport existingExport = result.stream() |
| | | .filter(e -> e.getQuestiontext().equals(export.getQuestiontext()) |
| | | && value.trim().equals(e.getTargetvalue())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (existingExport != null && existingExport.getRatio().equals("0") && existingExport.getCount().equals("0")) { |
| | | //如果存在,则将 result 里的这个问题所对应的 Targetvalue=value 这条数据更新成当前这条数据 |
| | | if(value.equals(export.getOptionresult())) { |
| | | existingExport.setRatio(export.getRatio()); |
| | | existingExport.setScore(export.getScore()); |
| | | existingExport.setCount(export.getCount()); |
| | | existingExport.setOptionresult(export.getOptionresult()); |
| | | } |
| | | } else if (existingExport != null && !existingExport.getRatio().equals("0")) { |
| | | continue; |
| | | } else { |
| | | ServiceSubtaskDetailRatioExport newExport = DtoConversionUtils.sourceToTarget(export, ServiceSubtaskDetailRatioExport.class); |
| | | newExport.setTargetvalue(value.trim()); // targetvalue 显示单个选项 |
| | | if (!value.equals(export.getOptionresult())) { |
| | | newExport.setOptionresult(null); |
| | | newExport.setCount("0"); |
| | | newExport.setRatio("0"); |
| | | } |
| | | result.add(newExport); |
| | | } |
| | | } |
| | | } else { |
| | | // targetvalue 不包含 &,直接添加到结果 |
| | | result.add(export); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime, String scriptContent, Double scoreStart, Double scoreEnd,String valueType) { |
| | | //先清理一下重复数据 |
| | | List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds(); |
| | | if (!CollectionUtils.isEmpty(repeatIds)) { |
| | | serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds); |
| | | } |
| | | |
| | | List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime, scoreStart, scoreEnd, scriptContent,valueType); |
| | | // 处理 targetvalue:按 & 分割成多条记录 |
| | | List<ServiceSubtaskDetailRatioExport> result = new ArrayList<>(); |
| | | for (ServiceSubtaskDetailRatioExport export : serviceSubtaskDetailRatioExports) { |
| | | if (StringUtils.isNotEmpty(export.getTargetvalue()) && export.getTargetvalue().contains("&")) { |
| | | String[] values = export.getTargetvalue().split("&"); |
| | | // 如果有多条目标值,拆分成多行 |
| | | for (String value : values) { |
| | | //先去 result 中查一下,有没有这个 questiontext 和对应的 targetvalue |
| | | ServiceSubtaskDetailRatioExport existingExport = result.stream() |
| | | .filter(e -> e.getQuestiontext().equals(export.getQuestiontext()) |
| | | && value.trim().equals(e.getTargetvalue())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (existingExport != null && existingExport.getRatio().equals("0") && existingExport.getCount().equals("0")) { |
| | | //如果存在,则将 result 里的这个问题所对应的 Targetvalue=value 这条数据更新成当前这条数据 |
| | | if(value.equals(export.getOptionresult())) { |
| | | existingExport.setRatio(export.getRatio()); |
| | | existingExport.setScore(export.getScore()); |
| | | existingExport.setCount(export.getCount()); |
| | | existingExport.setOptionresult(export.getOptionresult()); |
| | | } |
| | | } else if (existingExport != null && !existingExport.getRatio().equals("0")) { |
| | | continue; |
| | | } else { |
| | | ServiceSubtaskDetailRatioExport newExport = DtoConversionUtils.sourceToTarget(export, ServiceSubtaskDetailRatioExport.class); |
| | | newExport.setTargetvalue(value.trim()); // targetvalue 显示单个选项 |
| | | if (!value.equals(export.getOptionresult())) { |
| | | newExport.setOptionresult(null); |
| | | newExport.setCount("0"); |
| | | newExport.setRatio("0"); |
| | | } |
| | | result.add(newExport); |
| | | } |
| | | } |
| | | } else { |
| | | // targetvalue 不包含 &,直接添加到结果 |
| | | result.add(export); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public PhoneCallBackSHVO getFirstQues(PhoneCallReqYQVO phoneCallReqYQVO) { |
| | | //用于返回 |
| | | PhoneCallBackSHVO phoneCallBackSHVO = new PhoneCallBackSHVO(); |
| | | |
| | | //根据手机号获取用户的的子任务信息 |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setPhone(phoneCallReqYQVO.getPhone()); |
| | | serviceSubtaskVO.setType("1"); |
| | | serviceSubtaskVO.setSendstate(2L); |
| | | List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | if (CollectionUtils.isNotEmpty(serviceSubtasks)) { |
| | | ServiceSubtask serviceSubtask = serviceSubtasks.get(0); |
| | | IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid()); |
| | | |
| | | //通过任务模板中的"第一次问题编号"获取第一个问题; |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = null; |
| | | IvrTaskTemplateScript ivrTaskTemplateScript1 = new IvrTaskTemplateScript(); |
| | | ivrTaskTemplateScript1.setTemplateID(ivrTaskTemplate.getId()); |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript1); |
| | | |
| | | for (IvrTaskTemplateScript ivrTaskTemplateScript2 : ivrTaskTemplateScripts) { |
| | | if (ivrTaskTemplate.getFirstQuestionNum() == Long.valueOf(ivrTaskTemplateScript2.getSort())) { |
| | | ivrTaskTemplateScript = ivrTaskTemplateScript2; |
| | | break; |
| | | } |
| | | } |
| | | //获取开场白 |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | |
| | | phoneCallBackSHVO.setSubId(serviceSubtask.getId()); |
| | | phoneCallBackSHVO.setScriptId(ivrTaskTemplateScript.getId()); |
| | | phoneCallBackSHVO.setSort(ivrTaskTemplateScript.getSort()); |
| | | phoneCallBackSHVO.setTaskTemplateid(ivrTaskTemplateScript.getTemplateID()); |
| | | phoneCallBackSHVO.setScriptContent(serviceTask.getKcb() + "," + ivrTaskTemplateScript.getScriptContent()); |
| | | } |
| | | return phoneCallBackSHVO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 三汇ASR结果处理 |
| | | * |
| | | * @param phoneCallResultYQVO |
| | | * @return |
| | | */ |
| | | public PhoneCallBackSHVO processResust(PhoneCallResultYQVO phoneCallResultYQVO) { |
| | | PhoneCallBackSHVO phoneCallBackSHVO = new PhoneCallBackSHVO(); |
| | | //通过scriptid,获取所有的结果 |
| | | String url = configService.selectConfigByKey("sys.voice.match.ai.url", phoneCallResultYQVO.getOrgid()); |
| | | ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(phoneCallResultYQVO.getSubId()); |
| | | IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid()); |
| | | IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO = iIvrTaskTemplateScriptService.getTaskTempScriptInfoByid(Long.valueOf(phoneCallResultYQVO.getScriptId())); |
| | | Integer i = matchOptionIndex(url, phoneCallResultYQVO.getScriptContent(), phoneCallResultYQVO.getAsrResult(), ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList(), phoneCallResultYQVO.getUuid()); |
| | | if (i >= 0) { |
| | | String optiondesc = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(i).getOptiondesc(); |
| | | //将患者的回答写进service_subtask_detail中 |
| | | ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq(); |
| | | List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>(); |
| | | ivrTaskTemplateScriptVO.setQuestionResult(optiondesc); |
| | | |
| | | PhoneCallReqYQVO phoneCallReqYQVO = new PhoneCallReqYQVO(); |
| | | phoneCallReqYQVO.setTaskid("" + serviceSubtask.getId()); |
| | | phoneCallReqYQVO.setPhone(phoneCallResultYQVO.getPhone()); |
| | | phoneCallReqYQVO.setAsrtext(phoneCallResultYQVO.getAsrResult()); |
| | | 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); |
| | | serviceSubTaskDetailReq.setGuid(phoneCallResultYQVO.getGuid()); |
| | | serviceSubTaskDetailReq.setOrgid(phoneCallResultYQVO.getOrgid()); |
| | | saveQuestionAnswerPhone(serviceSubTaskDetailReq); |
| | | |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript(); |
| | | ivrTaskTemplateScript.setTemplateID(ivrTaskTemplateScriptVO.getTemplateID()); |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript); |
| | | |
| | | //获取下一题 |
| | | for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) { |
| | | if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) { |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | phoneCallBackSHVO.setScriptContent(serviceTask.getJsy()); |
| | | phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID()); |
| | | phoneCallBackSHVO.setSort(script.getSort()); |
| | | phoneCallBackSHVO.setScriptId(script.getId()); |
| | | phoneCallBackSHVO.setSubId(serviceSubtask.getId()); |
| | | phoneCallBackSHVO.setStatus("0"); |
| | | } else if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) { |
| | | phoneCallBackSHVO.setScriptContent(script.getScriptContent()); |
| | | phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID()); |
| | | phoneCallBackSHVO.setSort(script.getSort()); |
| | | phoneCallBackSHVO.setScriptId(script.getId()); |
| | | phoneCallBackSHVO.setSubId(serviceSubtask.getId()); |
| | | break; |
| | | } |
| | | } |
| | | //把缓存清除 |
| | | redisCache.deleteObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId()); |
| | | } else { |
| | | //再将重复询问 |
| | | //记录一下这个问题被问题的次数 |
| | | Object cacheObject = redisCache.getCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId()); |
| | | if (cacheObject == null || (Integer) cacheObject < ivrTaskTemplate.getMateNum()) { |
| | | |
| | | |
| | | // 获取选项集合中的 optiondesc 用于引导患者 |
| | | List<IvrTaskTemplateTargetoption> optionList = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList(); |
| | | String optionDescStr = ""; |
| | | if (optionList != null && !optionList.isEmpty()) { |
| | | optionDescStr = optionList.stream().map(IvrTaskTemplateTargetoption::getTargetvalue).filter(StringUtils::isNotEmpty).collect(Collectors.joining("或")); |
| | | } |
| | | |
| | | String scriptContent = "请问" + phoneCallResultYQVO.getScriptContent(); |
| | | if (StringUtils.isNotEmpty(optionDescStr)) { |
| | | scriptContent += ",你可以回答:" + optionDescStr; |
| | | } |
| | | phoneCallBackSHVO.setScriptContent(scriptContent); |
| | | phoneCallBackSHVO.setTaskTemplateid(phoneCallResultYQVO.getTaskTemplateid()); |
| | | phoneCallBackSHVO.setSort(phoneCallResultYQVO.getSort()); |
| | | phoneCallBackSHVO.setScriptId(phoneCallResultYQVO.getScriptId()); |
| | | phoneCallBackSHVO.setSubId(phoneCallResultYQVO.getSubId()); |
| | | if (cacheObject == null) |
| | | redisCache.setCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId(), 1, 120, TimeUnit.MINUTES); |
| | | else |
| | | redisCache.setCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId(), (Integer) cacheObject + 1, 120, TimeUnit.MINUTES); |
| | | } else if ((Integer) cacheObject >= ivrTaskTemplate.getMateNum()) { |
| | | //如果已经问了规定次数,就不问了,继续问下一题(这个要商量一下,是继续问下一题,还是停了,是不是要做个开关) |
| | | IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript(); |
| | | ivrTaskTemplateScript.setTemplateID(ivrTaskTemplateScriptVO.getTemplateID()); |
| | | List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript); |
| | | //获取下一题 |
| | | for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) { |
| | | if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) { |
| | | phoneCallBackSHVO.setScriptContent(script.getScriptContent()); |
| | | phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID()); |
| | | phoneCallBackSHVO.setSort(script.getSort()); |
| | | phoneCallBackSHVO.setScriptId(script.getId()); |
| | | phoneCallBackSHVO.setSubId(serviceSubtask.getId()); |
| | | break; |
| | | } |
| | | } |
| | | //把缓存清除 |
| | | redisCache.deleteObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId()); |
| | | } |
| | | } |
| | | return phoneCallBackSHVO; |
| | | } |
| | | |
| | | |
| | | public PhoneCallBackYQVO AiMatch(String url, PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate, List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag, String uuid) { |
| | | PhoneCallBackYQVO back = null; |
| | | List<IvrTaskTemplateTargetoption> options = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList(); |
| | |
| | | return back; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 问题结果占比 |
| | | * |
| | | * @param serviceSubtaskEntity |
| | | * @param serviceSubtaskRes |
| | | * @return |
| | | */ |
| | | public List<ServiceSubtaskDetailRatioExport> getDetailRatio(QuestionResultVO questionResultVO, List<ServiceSubtaskRes> serviceSubtaskRes) { |
| | | List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = null; |
| | | if (StringUtils.isNotEmpty(questionResultVO.getServiceType()) && questionResultVO.getServiceType().equals("2")) { |
| | | //获取serviceSubtaskList中的所有taskid |
| | | List<Long> taskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getTaskid).filter(ObjectUtils::isNotEmpty).distinct().collect(Collectors.toList()); |
| | | serviceSubtaskDetailRatioExports = statQuestionOption(taskIds, questionResultVO.getStartOutHospTime(), questionResultVO.getEndOutHospTime(), questionResultVO.getQuestionContent(), questionResultVO.getStartScore(), questionResultVO.getEndScore(),questionResultVO.getValueType()); |
| | | } else if (StringUtils.isNotEmpty(questionResultVO.getServiceType()) && questionResultVO.getServiceType().equals("6")) { |
| | | //满意度统计 (通过 subtask 的 id 去统计) |
| | | List<Long> subtaskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getId).collect(Collectors.toList()); |
| | | serviceSubtaskDetailRatioExports = statQuestionOptionBySubtaskIds(subtaskIds, questionResultVO.getStartOutHospTime(), questionResultVO.getEndOutHospTime(), questionResultVO.getQuestionContent(), questionResultVO.getStartScore(), questionResultVO.getEndScore(),questionResultVO.getValueType()); |
| | | } |
| | | return serviceSubtaskDetailRatioExports; |
| | | } |
| | | |
| | | //获取任务组信息 |
| | | private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO){ |
| | | if(StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")){ |
| | | private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO) { |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")) { |
| | | //任务组信息 |
| | | ServiceTaskSchedule schedule = serviceTaskScheduleService.selectByTaskid(serviceTaskVO.getTaskid()); |
| | | if (ObjectUtils.isNotEmpty(schedule)) { |
| | | ServiceTaskScheduleVO serviceTaskScheduleVO = DtoConversionUtils.sourceToTarget(schedule, ServiceTaskScheduleVO.class); |
| | | List<ServiceTaskScheduleDetail> scheduleDetailList = |
| | | serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId()); |
| | | List<ServiceTaskScheduleDetail> scheduleDetailList = serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId()); |
| | | serviceTaskScheduleVO.setDetailList(scheduleDetailList); |
| | | serviceTaskVO.setServiceTaskScheduleVO(serviceTaskScheduleVO); |
| | | } |