| | |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.dx.MessageSend; |
| | |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.smartor.common.DeepSeekApi; |
| | | import com.smartor.common.FtpService; |
| | | import com.smartor.common.MtSubmitSmUtil; |
| | | import com.smartor.common.ScheduleSubtaskBuilder; |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.DTO.ServiceSubtaskDetailDTO; |
| | | import com.smartor.domain.*; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.junit.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | @Autowired |
| | | private IServiceSubtaskDetailTraceService traceService; |
| | | |
| | | @Autowired |
| | | private IServiceTaskScheduleService serviceTaskScheduleService; |
| | | |
| | | @Autowired |
| | | private ScheduleSubtaskBuilder scheduleSubtaskBuilder; |
| | | |
| | | @Autowired |
| | | private FtpService ftpService; |
| | |
| | | serviceTaskoperService.insertServiceTaskoper(serviceTaskoper); |
| | | } |
| | | } |
| | | |
| | | } else if (serviceTaskVO.getAppltype().equals("5")) { |
| | | // 任务组:必须为长期任务(否则 findMatchingTaskIds 扫不到,无法自动纳入新出院患者) |
| | | if (serviceTaskVO.getLongTask() == null || serviceTaskVO.getLongTask() != 1) { |
| | | throw new BaseException("appltype=5 任务组必须为长期任务(longTask=1)"); |
| | | } |
| | | // 保存计划 + 明细 |
| | | ServiceTaskScheduleVO scheduleVO = serviceTaskVO.getServiceTaskScheduleVO(); |
| | | if (scheduleVO == null) { |
| | | throw new BaseException("appltype=5 任务组:serviceTaskScheduleVO 不能为空"); |
| | | } |
| | | scheduleVO.setTaskid(serviceTask.getTaskid()); |
| | | scheduleVO.setOrgid(serviceTask.getOrgid()); |
| | | scheduleVO.setCampusid(serviceTask.getCampusid()); |
| | | scheduleVO.setCreateBy(serviceTask.getCreateBy()); |
| | | |
| | | scheduleVO.setDeptCodes(serviceTaskVO.getDeptcode()); |
| | | scheduleVO.setWardCodes(serviceTaskVO.getLeavehospitaldistrictcode()); |
| | | scheduleVO.setIcd10Codes(serviceTaskVO.getIcd10code()); |
| | | scheduleVO.setOplevelCodes(serviceTaskVO.getOplevelcode()); |
| | | |
| | | log.info("----serviceTaskSchedule的值为:{}", scheduleVO); |
| | | serviceTaskScheduleService.saveScheduleWithDetail(scheduleVO); |
| | | } else { |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setTaskId(serviceTask.getTaskid()); |
| | |
| | | serviceSubtask.setLongSendTime(patTaskRelevance.getLongSendTime()); |
| | | serviceSubtask.setVisitTime(patTaskRelevance.getVisittime()); |
| | | } |
| | | |
| | | // ===== appltype=5 任务组:按 schedule 的 detailList 派生多条 subtask ===== |
| | | if ("5".equals(serviceTaskVO.getAppltype())) { |
| | | ServiceTaskSchedule schedule = serviceTaskScheduleService.selectByTaskid(serviceTask.getTaskid()); |
| | | if (schedule == null) { |
| | | throw new BaseException("appltype=5 任务组:未找到 taskid=" + serviceTask.getTaskid() + " 的计划"); |
| | | } |
| | | List<ServiceTaskScheduleDetail> detailList = |
| | | serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId()); |
| | | scheduleSubtaskBuilder.buildSubtasksForPatient( |
| | | serviceTask, serviceTaskVO.getPreachformList(), schedule, detailList, patTaskRelevance, serviceSubtask); |
| | | continue; |
| | | } |
| | | |
| | | serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | serviceSubtask.getId().intValue(); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } else if (serviceTaskVO.getAppltype().equals("5")) { |
| | | // 任务组修改:删旧 schedule + 明细,重建。subtask 上面已批量清理。 |
| | | if (serviceTaskVO.getLongTask() == null || serviceTaskVO.getLongTask() != 1) { |
| | | throw new BaseException("appltype=5 任务组必须为长期任务(longTask=1)"); |
| | | } |
| | | ServiceTaskScheduleVO scheduleVO = serviceTaskVO.getServiceTaskScheduleVO(); |
| | | if (scheduleVO == null) { |
| | | throw new BaseException("appltype=5 任务组:serviceTaskScheduleVO 不能为空"); |
| | | } |
| | | scheduleVO.setTaskid(serviceTask.getTaskid()); |
| | | scheduleVO.setOrgid(serviceTask.getOrgid()); |
| | | scheduleVO.setCampusid(serviceTask.getCampusid()); |
| | | scheduleVO.setDeptCodes(serviceTaskVO.getDeptcode()); |
| | | scheduleVO.setWardCodes(serviceTaskVO.getLeavehospitaldistrictcode()); |
| | | scheduleVO.setIcd10Codes(serviceTaskVO.getIcd10code()); |
| | | scheduleVO.setOplevelCodes(serviceTaskVO.getOplevelcode()); |
| | | scheduleVO.setCreateBy(serviceTask.getUpdateBy()); |
| | | serviceTaskScheduleService.saveScheduleWithDetail(scheduleVO); |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(serviceTaskVO.getIvrTaskTemplateVO())) { |
| | |
| | | serviceSubtask.setVisitTime(patTaskRelevance.getVisittime()); |
| | | serviceSubtask.setTextParam(new Gson().toJson(serviceTaskVO.getTextParam())); |
| | | if (patTaskRelevance.getIsoperation() != null) { |
| | | // appltype=5 任务组:追加患者(isoperation=1)走计划派生;修改(2)/删除(3)仍走原逻辑 |
| | | if ("5".equals(serviceTaskVO.getAppltype()) && patTaskRelevance.getIsoperation() == 1) { |
| | | ServiceTaskSchedule schedule = serviceTaskScheduleService.selectByTaskid(serviceTask.getTaskid()); |
| | | if (schedule == null) { |
| | | throw new BaseException("appltype=5 任务组:未找到 taskid=" + serviceTask.getTaskid() + " 的计划"); |
| | | } |
| | | List<ServiceTaskScheduleDetail> detailList = |
| | | serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId()); |
| | | serviceSubtask.setUpdateBy(serviceTask.getUpdateBy()); |
| | | serviceSubtask.setCreateBy(serviceTask.getUpdateBy()); |
| | | scheduleSubtaskBuilder.buildSubtasksForPatient( |
| | | serviceTask, serviceTaskVO.getPreachformList(), schedule, detailList, patTaskRelevance, serviceSubtask); |
| | | continue; |
| | | } |
| | | if (patTaskRelevance.getIsoperation() == 2) { |
| | | serviceSubtask.setUpdateBy(serviceTask.getUpdateBy()); |
| | | serviceSubtaskMapper.updateServiceSubtaskByCondition(serviceSubtask); |
| | |
| | | map.put("taskId", serviceTask.getTaskid().intValue()); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void phoneCallBack(PhoneCallBackVO phoneCallBackVO) { |
| | |
| | | //用来标记,是否有匹配上的 |
| | | Integer flag = 0; |
| | | //1-AI识别 |
| | | SysConfig configVoiceMatchAi = new SysConfig(); |
| | | configVoiceMatchAi.setOrgid(phoneCallReqYQVO.getOrgid()); |
| | | configVoiceMatchAi.setConfigKey("sys.voice.match.ai"); |
| | | SysConfig matchAi = sysConfigMapper.selectConfig(configVoiceMatchAi); |
| | | String aiUrl = configService.selectConfigByKey("sys.voice.match.ai.url"); |
| | | |
| | | if (ObjectUtils.isNotEmpty(matchAi) && StringUtils.isNotEmpty(matchAi.getConfigValue()) |
| | | && matchAi.getConfigValue().equals("1")) { |
| | | if (ObjectUtils.isNotEmpty(aiUrl)) { |
| | | PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO, |
| | | ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate, |
| | | ivrTaskTemplateScripts, scriptId, flag, phoneCallReqYQVO.getUuid()); |
| | |
| | | @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"))); |
| | |
| | | String jsonString = jsonObject.toJSONString(); |
| | | String result = null; |
| | | |
| | | String url = "http://localhost:8099/matchOptionIndex"; |
| | | // String url = configService.selectConfigByKey("sys.voice.match.ai.url"); |
| | | // String url = "http://localhost:8099/matchOptionIndex"; |
| | | String url = configService.selectConfigByKey("sys.voice.match.ai.url"); |
| | | if(StringUtils.isNotEmpty(url)){ |
| | | try { |
| | | Map<String, String> headers = new HashMap<>(); |