| | |
| | | import com.ruoyi.task.domain.ServiceSubtask; |
| | | import com.ruoyi.task.domain.ServiceSubtaskRecord; |
| | | import com.ruoyi.task.domain.ServiceTask; |
| | | import com.ruoyi.task.domain.ServiceTaskSchedule; |
| | | import com.ruoyi.task.domain.ServiceTaskScheduleDetail; |
| | | import com.ruoyi.task.mapper.ServiceSubtaskMapper; |
| | | import com.ruoyi.task.mapper.ServiceTaskMapper; |
| | | import com.ruoyi.task.mapper.ServiceTaskScheduleMapper; |
| | | import com.ruoyi.task.mapper.ServiceTaskScheduleDetailMapper; |
| | | import com.ruoyi.task.domain.ServiceOutPath; |
| | | import com.ruoyi.task.service.IServiceOutPathService; |
| | | import com.ruoyi.task.domain.ServiceSubtaskPreachform; |
| | | import com.ruoyi.task.domain.SendMagParam; |
| | | import com.ruoyi.task.service.IServiceSubtaskRecordService; |
| | | import com.ruoyi.task.mapper.ServiceSubtaskPreachformMapper; |
| | | import com.ruoyi.task.event.FollowupCompletedEventPublisher; |
| | | import com.ruoyi.patarchive.mapper.PatArchiveMapper; |
| | | @Slf4j |
| | | @Component//监听此队列 |
| | |
| | | |
| | | @Value("${req_path}") |
| | | private String req_path; |
| | | |
| | | @Autowired |
| | | private FollowupCompletedEventPublisher followupCompletedEventPublisher; |
| | | |
| | | @Autowired |
| | | private IServiceOutPathService iServiceOutPathService; |
| | |
| | | |
| | | @Autowired |
| | | private ServiceSubtaskPreachformMapper serviceSubtaskPreachformMapper; |
| | | |
| | | @Autowired |
| | | private ServiceTaskScheduleMapper serviceTaskScheduleMapper; |
| | | |
| | | @Autowired |
| | | private ServiceTaskScheduleDetailMapper serviceTaskScheduleDetailMapper; |
| | | |
| | | @Autowired |
| | | private IServiceSubtaskRecordService serviceSubtaskRecordService; |
| | |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(ip + ":" + req_path + "/sf?p=" + format); |
| | |
| | | serviceOutPath.setDeptName(serviceSubtask.getLeaveldeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format); |
| | |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String url = ""; |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | //需要通过模板ID去判断要发的内容是宣教还是通知 |
| | | // ⚠️ 与 RyTask 同口径:**刻意不**为 TemplateModuleDisabledException 降级 —— |
| | | // 模板模块关闭时宣教内容取不到、短信确实发不出去,外层 try-catch 如实记失败 |
| | |
| | | serviceOutPath.setDeptName(serviceSubtask.getLeaveldeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | url = ip + ":" + req_path + "/sf?p=" + format; |
| | |
| | | serviceOutPath.setDeptName(serviceSubtask.getLeaveldeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | |
| | | url = StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format; |
| | | //如果type是语音随访的话(说明补偿发送方式中有电话随访的方式,这里的外链就地址只能用/sf) |
| | |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String format = ShortCode.encode(serviceOutPath.getId()); |
| | | |
| | | //需要通过模板ID去判断要发的内容是宣教还是通知 |
| | | // HeLibrary heLibrary = templateFacade.findHeLibraryById(serviceSubtask.getLibtemplateid()); |
| | |
| | | serviceSubtask.setSendstate(6L); |
| | | } |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | if (Long.valueOf(6L).equals(serviceSubtask.getSendstate())) { |
| | | followupCompletedEventPublisher.publish(serviceSubtask.getId()); |
| | | } |
| | | |
| | | // 更新当前发送方式明细;发送成功时允许当前行已经是 sendstate=2。 |
| | | currentPreachformRow.setSendstate(failSendstate); |
| | |
| | | if (Objects.isNull(serviceSubtask) || CollectionUtils.isEmpty(serviceSubtaskPreachforms)) { |
| | | return false; |
| | | } |
| | | // 基准时刻:出院时间 + 发送日(sendDay 缺省按 1),并兜底避免 NPE/脏数据 |
| | | if (serviceSubtask.getEndtime() == null) { |
| | | log.warn("【isSubtaskDeadline】subid:{} endtime为空,无法计算超时,按未超时处理", serviceSubtask.getId()); |
| | | return false; |
| | | } |
| | | ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | int sendDay = serviceTask != null && serviceTask.getSendDay() != null ? serviceTask.getSendDay().intValue() : 1; |
| | | Date deadline = DateUtils.addDays(serviceSubtask.getEndtime(), sendDay); |
| | | int sumCompensateTime = CollectionUtils.isEmpty(serviceSubtaskPreachforms) ? 0 : serviceSubtaskPreachforms.stream() |
| | | Date deadline; |
| | | if (serviceTask != null && "5".equals(serviceTask.getAppltype())) { |
| | | // 任务组:基准 = schedule_benchmark 解析出的时间 + day_offset,不叠加 send_day |
| | | deadline = resolveTaskGroupDeadlineBase(serviceSubtask); |
| | | if (deadline == null) { |
| | | log.warn("【isSubtaskDeadline】subid:{} 任务组基准时间为空,无法计算超时,按未超时处理", serviceSubtask.getId()); |
| | | return false; |
| | | } |
| | | } else { |
| | | // 非任务组:基准 = 出院时间 + 发送日(sendDay 缺省按 1) |
| | | if (serviceSubtask.getEndtime() == null) { |
| | | log.warn("【isSubtaskDeadline】subid:{} endtime为空,无法计算超时,按未超时处理", serviceSubtask.getId()); |
| | | return false; |
| | | } |
| | | int sendDay = serviceTask != null && serviceTask.getSendDay() != null ? serviceTask.getSendDay().intValue() : 1; |
| | | deadline = DateUtils.addDays(serviceSubtask.getEndtime(), sendDay); |
| | | } |
| | | int sumCompensateTime = serviceSubtaskPreachforms.stream() |
| | | .mapToInt(x -> NumberUtils.toInt(x.getCompensateTime(), 0)) |
| | | .sum(); |
| | | sumCompensateTime = sumCompensateTime + 1; |
| | | // 只补偿最后一步自身的补偿时间(天),脏值一律按 0 兜底 |
| | | // 补偿时间脏值一律按 0 兜底,最后再加 1 天宽限 |
| | | deadline = DateUtils.addDays(deadline, sumCompensateTime); |
| | | // 出院(发送)时间 + 本步补偿时间 小于当前时间 -> 超时 |
| | | return deadline.getTime() < new Date().getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 任务组基准时间:按 schedule_benchmark 解析后加 day_offset。 |
| | | * 0/其它-自定义时间 1-入院 2-出院 3-就诊 4-入组 |
| | | */ |
| | | private Date resolveTaskGroupDeadlineBase(ServiceSubtask serviceSubtask) { |
| | | if (serviceSubtask.getScheduleId() == null || serviceSubtask.getScheduleDetailId() == null) { |
| | | return null; |
| | | } |
| | | ServiceTaskSchedule schedule = serviceTaskScheduleMapper.selectServiceTaskScheduleById(serviceSubtask.getScheduleId()); |
| | | ServiceTaskScheduleDetail detail = serviceTaskScheduleDetailMapper.selectServiceTaskScheduleDetailById(serviceSubtask.getScheduleDetailId()); |
| | | if (schedule == null || detail == null || detail.getDayOffset() == null) { |
| | | return null; |
| | | } |
| | | Date base; |
| | | Integer benchmark = schedule.getScheduleBenchmark() == null ? 0 : schedule.getScheduleBenchmark(); |
| | | switch (benchmark) { |
| | | case 1: |
| | | base = serviceSubtask.getStarttime(); |
| | | break; |
| | | case 2: |
| | | base = serviceSubtask.getEndtime(); |
| | | break; |
| | | case 3: |
| | | base = serviceSubtask.getAdmindate(); |
| | | break; |
| | | case 4: |
| | | base = serviceSubtask.getCreateTime(); |
| | | break; |
| | | default: |
| | | base = schedule.getScheduleBenchmarkCustomTime(); |
| | | break; |
| | | } |
| | | return base == null ? null : DateUtils.addDays(base, detail.getDayOffset()); |
| | | } |
| | | } |