| | |
| | | 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.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.core.service.IDingTalkService; |
| | | import com.ruoyi.common.dx.MessageSend; |
| | | import com.ruoyi.common.enums.MsgLSEnum; |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.smartor.common.LSHospTokenUtil; |
| | | import com.smartor.common.MtSubmitSmUtil; |
| | | import com.smartor.common.QwenLLMUtil; |
| | |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private IDingTalkService dingTalkService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | |
| | | @Value("${localIP}") |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时发送异常信息-景宁 |
| | | */ |
| | | public void sendExceptInfo() throws Exception { |
| | | //1.获取发送人工号 |
| | | ServiceSubtaskDetailTraceVO subtaskDetailTraceVO = new ServiceSubtaskDetailTraceVO(); |
| | | subtaskDetailTraceVO.setHandleFlag("0"); |
| | | List<ServiceSubtaskDetailTrace> serviceSubtaskDetailTraces = |
| | | serviceSubtaskDetailTraceService.selectServiceSubtaskDetailTtraceList(subtaskDetailTraceVO); |
| | | // 获取“异常内容提醒" |
| | | SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("send.except.content"); |
| | | String exceptContent = sysConfig.getConfigValue(); |
| | | |
| | | // 获取“内容提醒测试人工号” |
| | | SysConfig testPersonConfig = sysConfigMapper.checkConfigKeyUnique("send.test.person"); |
| | | String testPerson = ObjectUtils.isNotEmpty(testPersonConfig) ? testPersonConfig.getConfigValue() : ""; |
| | | if(CollectionUtils.isNotEmpty(serviceSubtaskDetailTraces)){ |
| | | for (ServiceSubtaskDetailTrace serviceSubtaskDetailTrace : serviceSubtaskDetailTraces) { |
| | | List<String> dutyDeptPersonCodeList = new ArrayList<>(); |
| | | // 把 dutyDeptPersonCode 整理到 list 中(如果多个人用逗号分割,则展开并去重) |
| | | String dutyDeptPersonCodeStr = serviceSubtaskDetailTrace.getDutyDeptPersonCode(); |
| | | if(StringUtils.isNotEmpty(dutyDeptPersonCodeStr)){ |
| | | String[] dutyDeptPersonCodeSplit = dutyDeptPersonCodeStr.split(","); |
| | | if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) { |
| | | dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(dutyDeptPersonCodeSplit)); |
| | | } else { |
| | | dutyDeptPersonCodeList.addAll(Arrays.asList(dutyDeptPersonCodeSplit)); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(testPerson)) { |
| | | String[] split = testPerson.split(","); |
| | | if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) { |
| | | dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(split)); |
| | | } else { |
| | | dutyDeptPersonCodeList.addAll(Arrays.asList(split)); |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(dutyDeptPersonCodeList)) { |
| | | for (String dutyDeptPersonCode : dutyDeptPersonCodeList) { |
| | | log.info("【sendExceptInfo】发送人工号:{}", dutyDeptPersonCode); |
| | | SysUser sysUser = new SysUser(); |
| | | SysUser sysUserVo = new SysUser(); |
| | | sysUserVo.setUserName(dutyDeptPersonCode); |
| | | sysUserVo.setOrgid(serviceSubtaskDetailTrace.getOrgid()); |
| | | List<SysUser> users = userService.getUserList(sysUserVo); |
| | | String phoneNumber = ""; |
| | | if(ObjectUtils.isNotEmpty(users)){ |
| | | sysUser = users.get(0); |
| | | phoneNumber = sysUser.getPhonenumber(); |
| | | }else { |
| | | continue; |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(phoneNumber)){ |
| | | continue; |
| | | } |
| | | String dutyDeptPerson = dingTalkService.getDingTalkUserByMobile(phoneNumber); |
| | | if(StringUtils.isNotBlank(dutyDeptPerson)){ |
| | | String context = TemplateUtils.render(exceptContent, serviceSubtaskDetailTrace); |
| | | dingTalkService.sendDingTalkText(context, dutyDeptPerson); |
| | | //更新状态 |
| | | serviceSubtaskDetailTrace.setHandleFlag("1"); |
| | | serviceSubtaskDetailTrace.setUpdateTime(new Date()); |
| | | serviceSubtaskDetailTraceService.updateServiceSubtaskDetailTtrace(serviceSubtaskDetailTrace); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时处理外链的数据 |
| | |
| | | iIcd10Service.queryAddIcd10(); |
| | | } |
| | | |
| | | // nhfy/sltd回溯30天分段采集判断(每段最多7天) |
| | | // nhfy/sltd回溯30天分段采集判断(每段最多4天) |
| | | boolean isBackfill = (active.trim().equals("nhfy") || active.trim().equals("sltd")) && StringUtils.isNotBlank(todayZeroStr); |
| | | if (isBackfill) { |
| | | DateTimeFormatter dateFmt = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | |
| | | LocalDate segEndDate = todayZero.toLocalDate(); |
| | | int segCount = 0; |
| | | while (!segStart.isAfter(segEndDate)) { |
| | | LocalDate segEnd = segStart.plusDays(6); |
| | | LocalDate segEnd = segStart.plusDays(3); |
| | | if (segEnd.isAfter(segEndDate)) { |
| | | segEnd = segEndDate; |
| | | } |
| | |
| | | serviceSubtaskList.addAll(compensateServiceSubtaskList); |
| | | } |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | //currentPreachform为空,说明该子任务还没有执行过任何一种发送方式(sendstate=1,属于首次补偿), |
| | | //这里直接交给sfHandlle处理,它会按sort=1的第一种发送方式发送,与getSendPreachform中的处理保持一致 |
| | | if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) { |
| | | log.warn("【compensateTask】subid:{},currentPreachform为空,按第一种发送方式补偿处理", serviceSubtask.getId()); |
| | | sfHandlle(serviceSubtask); |
| | | continue; |
| | | } |
| | | //根据当前的执行方式,获取下一种执行方式 |
| | | ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform(); |
| | | serviceSubtaskPreachform.setTaskid(serviceSubtask.getTaskid()); |
| | |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String url = ""; |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | //先判断一下发的是不是宣教 |
| | | if (!"3".equals(serviceSubtask.getType())) { |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | |
| | | sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format); |
| | | url = StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format; |
| | | sendMagParam.setUrl(url); |
| | | //如果type是语音随访的话(说明补偿发送方式中有电话随访的方式,这里的外链就地址只能用/sf) |
| | | if (serviceSubtask.getType().equals("1")) |
| | | sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/sf?p=" + format : localIP + "/sf?p=" + format); |
| | | url = StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/sf?p=" + format : localIP + "/sf?p=" + format; |
| | | sendMagParam.setUrl(url); |
| | | |
| | | // SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template"); |
| | | SysConfig sysConfig = new SysConfig(); |
| | |
| | | } else { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template"); |
| | | } |
| | | if (!Objects.isNull(sysConfig)) { |
| | | if (!Objects.isNull(sysConfig) && StringUtils.isNotEmpty(sysConfig.getConfigValue())) { |
| | | String smsContemt = sysConfig.getConfigValue(); |
| | | // sendMagParam.setContent("您好,邀请您填写出院调查表,请点击" + sendMagParam.getUrl() + "填写。感谢您配合!"); |
| | | sendMagParam.setContent(smsContemt.replace("${wjurl}", sendMagParam.getUrl())); |
| | |
| | | HeLibrary heLibrary = heLibraryMapper.selectHeLibraryById(serviceSubtask.getLibtemplateid()); |
| | | if (heLibrary.getHetype().equals("1")) { |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/xj?p=" + format : localIP + "/xj?p=" + format); |
| | | url = StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/xj?p=" + format : localIP + "/xj?p=" + format; |
| | | |
| | | sendMagParam.setUrl(url); |
| | | |
| | | SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("xj.sms.template"); |
| | | if (!Objects.isNull(sysConfig)) { |
| | | if (!Objects.isNull(sysConfig) && StringUtils.isNotEmpty(sysConfig.getConfigValue())) { |
| | | String smsContemt = sysConfig.getConfigValue(); |
| | | // sendMagParam.setContent("您好,邀请您填写出院宣教调查表,请点击" + sendMagParam.getUrl() + "查看。感谢您配合!"); |
| | | sendMagParam.setContent(smsContemt.replace("${xjurl}", sendMagParam.getUrl())); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //内容为空说明短信模板未配置或宣教/通知内容为空,直接按发送失败处理,避免后续发送时出现空指针 |
| | | if (StringUtils.isEmpty(sendMagParam.getContent())) { |
| | | log.error("【sfHandlle】长期任务短信内容为空,无法发送,subid:{},taskid:{},type:{},机构ID:{}", serviceSubtask.getId(), serviceSubtask.getTaskid(), serviceSubtask.getType(), serviceSubtask.getOrgid()); |
| | | setSuccessPreachForm(serviceSubtask, sendPreachform, "长期任务短信发送失败:短信内容为空(短信模板未配置或内容为空), 时间: " + now, "5"); |
| | | return; |
| | | } |
| | | |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(url); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | String isSuccess = null; |
| | | log.info("active的值为:{}", active); |
| | | if (active.equals("xh")) { |
| | |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(url); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | |
| | | //获取微信公众号请求信息根据机构ID |
| | |
| | | * @return |
| | | */ |
| | | private String getObject(ServiceSubtask serviceSubtask, String scriptContent) { |
| | | //内容为空时直接返回,避免下面的replace出现空指针 |
| | | if (StringUtils.isEmpty(scriptContent)) { |
| | | return scriptContent; |
| | | } |
| | | Map<String, Map<String, String>> param = getParam(serviceSubtask.getTaskid()); |
| | | for (Map<String, String> map : param.values()) { |
| | | for (String key : map.keySet()) { |
| | | scriptContent = scriptContent.replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : ""); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(scriptContent)) { |
| | | return scriptContent; |
| | | } |
| | | scriptContent = scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : ""); |
| | | scriptContent = scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : ""); |
| | |
| | | * @return |
| | | */ |
| | | public void dealSubtaskDeadline(String orgid, Integer deadlineDay){ |
| | | //获取任务信息 |
| | | ServiceTask st = new ServiceTask(); |
| | | st.setDelFlag("0"); |
| | | st.setLongTask(1); |
| | | st.setNexttaskflag("1"); |
| | | st.setOrgid(orgid); |
| | | List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st); |
| | | |
| | | Date deadline = DateUtils.addDays(new Date(), deadlineDay); |
| | | //通过任务ID拿到患者信息,并且随访时间得是今天之前的 |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setOrgid(orgid); |
| | | serviceSubtaskVO.setSendstate(7L); |
| | | //只扫描首次随访的 |
| | | serviceSubtaskVO.setVisitCount(1); |
| | | serviceSubtaskVO.setEndOutHospTime(deadline); |
| | | List<ServiceSubtask> serviceSubtaskList |
| | | = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | log.info("【dealSubtaskDeadline】获取到{}个超时任务", serviceSubtaskList.size()); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospid(serviceSubtask.getInhospid()); |
| | | List<PatMedInhosp> patMedInhospList = iPatMedInhospService.selectPatMedInhospList(patMedInhosp); |
| | | |
| | | if (patMedInhospList.size() > 0) { |
| | | serviceSubtask.setIsVisitAgain(2); |
| | | serviceSubtask.setRemark(StringUtils.isNotEmpty(serviceSubtask.getRemark()) ? serviceSubtask.getRemark() + ";患者再入院了" : "患者再入院了"); |
| | | serviceSubtask.setSendstate(4L); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | //return "无需再次随访,患者再入院了"; |
| | | }else { |
| | | continue; |
| | | // 随访中心科室 |
| | | String centerDept = configService.selectConfigByKey("sys.smartor.center.dept", orgid); |
| | | SysDept sysDeptVo = new SysDept(); |
| | | SysDept centerSysDept = null; |
| | | if(StringUtils.isNotEmpty(centerDept)){ |
| | | sysDeptVo.setDeptType("1"); |
| | | sysDeptVo.setOrgid(orgid); |
| | | sysDeptVo.setDeptCode(centerDept); |
| | | List<SysDept> sysDepts = sysDeptService.selectDeptList(sysDeptVo); |
| | | if (CollectionUtils.isNotEmpty(sysDepts)) { |
| | | centerSysDept = sysDepts.get(0); |
| | | } |
| | | //新增再次随访任务 |
| | | ServiceSubtask serviceSubtaskAgain = DtoConversionUtils.sourceToTarget(serviceSubtask, ServiceSubtask.class); |
| | | serviceSubtaskAgain.setId(null); |
| | | serviceSubtaskAgain.setUpid(serviceSubtask.getId().intValue()); |
| | | serviceSubtaskAgain.setVisitCount(serviceSubtask.getVisitCount() + 1); |
| | | serviceSubtaskAgain.setSendstate(2L); |
| | | serviceSubtaskAgain.setCreateTime(new Date()); |
| | | serviceSubtaskAgain.setUpdateTime(new Date()); |
| | | serviceSubtaskAgain.setVisitType(serviceSubtask.getVisitType()); |
| | | serviceSubtaskAgain.setVisitDeptCode(serviceSubtask.getVisitDeptCode()); |
| | | serviceSubtaskAgain.setVisitDeptName(serviceSubtask.getVisitDeptName()); |
| | | int i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtaskAgain); |
| | | if (i == 1) { |
| | | //再次随访任务创建成功后,原任务改为失败状态 |
| | | serviceSubtask.setIsVisitAgain(2); |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | |
| | | for (ServiceTask serviceTask : serviceTasks) { |
| | | deadlineDay = -deadlineDay; |
| | | Date deadline = DateUtils.addDays(new Date(), deadlineDay); |
| | | //通过任务ID拿到患者信息,并且随访时间得是今天之前的 |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setOrgid(orgid); |
| | | serviceSubtaskVO.setSendstate(7L); |
| | | //只扫描首次随访的 |
| | | serviceSubtaskVO.setVisitCount(1); |
| | | serviceSubtaskVO.setTaskid(serviceTask.getTaskid()); |
| | | serviceSubtaskVO.setEndOutHospTime(deadline); |
| | | |
| | | List<ServiceSubtask> serviceSubtaskList |
| | | = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | log.info("【dealSubtaskDeadline】获取到{}个超时任务, taskid={}", serviceSubtaskList.size(), serviceTask.getTaskid()); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | PatMedInhosp patMedInhospVo = new PatMedInhosp(); |
| | | patMedInhospVo.setOrgid(serviceSubtask.getOrgid()); |
| | | patMedInhospVo.setInhospid(serviceSubtask.getInhospid()); |
| | | patMedInhospVo.setCry(1); |
| | | List<PatMedInhosp> patMedInhospList = iPatMedInhospService.selectPatMedInhospList(patMedInhospVo); |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | if (!patMedInhospList.isEmpty()) { |
| | | patMedInhosp = patMedInhospList.get(0); |
| | | }else { |
| | | continue; |
| | | } |
| | | if(ObjectUtils.isEmpty(serviceTask.getNexttaskid())){ |
| | | continue; |
| | | } |
| | | ServiceTask nextServiceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceTask.getNexttaskid()); |
| | | PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtask.getPatid()); |
| | | String config = configService.selectConfigByKey("visit.early.day"); |
| | | Integer type = 1; |
| | | |
| | | //新增再次随访任务 |
| | | ServiceSubtask serviceSubtaskAgain = iPatMedInhospService.boxedServiceSubtask(nextServiceTask, |
| | | patMedInhosp, patArchive, config, type); |
| | | serviceSubtaskAgain.setId(null); |
| | | serviceSubtaskAgain.setUpid(serviceSubtask.getId().intValue()); |
| | | serviceSubtaskAgain.setVisitCount(serviceSubtask.getVisitCount() + 1); |
| | | serviceSubtaskAgain.setSendstate(2L); |
| | | serviceSubtaskAgain.setCreateTime(new Date()); |
| | | serviceSubtaskAgain.setUpdateTime(new Date()); |
| | | serviceSubtaskAgain.setVisitType(serviceSubtask.getVisitType()); |
| | | if(ObjectUtils.isNotEmpty(centerSysDept)){ |
| | | serviceSubtaskAgain.setVisitDeptCode(centerSysDept.getDeptCode()); |
| | | serviceSubtaskAgain.setVisitDeptName(centerSysDept.getDeptName()); |
| | | }else { |
| | | serviceSubtaskAgain.setVisitDeptCode(serviceSubtask.getVisitDeptCode()); |
| | | serviceSubtaskAgain.setVisitDeptName(serviceSubtask.getVisitDeptName()); |
| | | } |
| | | int i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtaskAgain); |
| | | if (i == 1) { |
| | | //再次随访任务创建成功后,原任务改为失败状态 |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | } |
| | | } |
| | | } |