| | |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.dx.MessageSend; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | private IServiceSubtaskDetailTraceService traceService; |
| | | |
| | | @Autowired |
| | | private IServiceTaskScheduleService serviceTaskScheduleService; |
| | | |
| | | @Autowired |
| | | private ScheduleSubtaskBuilder scheduleSubtaskBuilder; |
| | | |
| | | @Autowired |
| | | private FtpService ftpService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | @Autowired |
| | | private SysDept2Mapper sysDept2Mapper; |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | |
| | | serviceSubtaskRes.setSendstateView(1L); |
| | | if (serviceSubtaskRes.getSendstate() == 6) serviceSubtaskRes.setSendstateView(2L); |
| | | if (serviceSubtaskRes.getSendstate() == 4) serviceSubtaskRes.setSendstateView(3L); |
| | | // 填充当前补偿 |
| | | if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) { |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getPreachform())) { |
| | | //默认取第一个 |
| | | serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0]); |
| | | } |
| | | } |
| | | serviceSubtaskResList.add(serviceSubtaskRes); |
| | | } |
| | | return serviceSubtaskResList; |
| | |
| | | serviceTask.setTemplatename(tempName); |
| | | } |
| | | serviceTask.setLeaveldeptcodes(serviceTaskVO.getLeaveldeptcodes()); |
| | | serviceTask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode()); |
| | | if (StringUtils.isEmpty(serviceTask.getLeavehospitaldistrictname()) && StringUtils.isNotEmpty(serviceTask.getLeavehospitaldistrictcode())) { |
| | | SysDept sysDept = sysDept2Mapper.selectDeptByCode(serviceTask.getLeavehospitaldistrictcode(), null); |
| | | serviceTask.setLeavehospitaldistrictname(sysDept.getDeptName()); |
| | | } |
| | | if (serviceTaskVO.getLongTask() == 1) serviceTask.setSendState(2L); |
| | | serviceTask.setCreateTime(new Date()); |
| | | serviceTask.setUpdateTime(new Date()); |
| | |
| | | //南华附一的icd10code是有重复的,所以不能用南华附一的icd10code去查询 |
| | | log.info("----serviceTaskdiag的值为:{}", serviceTaskdiag); |
| | | if (!StringUtils.isEmpty(serviceTaskVO.getIcd10name())) { |
| | | String[] Icd10Names = serviceTaskVO.getIcd10name().split("$"); |
| | | String[] Icd10codes = serviceTaskVO.getIcd10code().split("$"); |
| | | String[] Icd10Names = serviceTaskVO.getIcd10name().split(","); |
| | | String[] Icd10codes = serviceTaskVO.getIcd10code().split(","); |
| | | for (int i = 0; i < Icd10Names.length; i++) { |
| | | serviceTaskdiag.setIcd10code(Icd10codes[i]); |
| | | serviceTaskdiag.setIcd10name(Icd10Names[i]); |
| | |
| | | serviceTaskoper.setGuid(serviceTask.getGuid()); |
| | | serviceTaskoper.setOrgid(serviceTask.getOrgid()); |
| | | serviceTaskoper.setCreateTime(new Date()); |
| | | //配置科室病区 |
| | | //配置科室、病区 |
| | | serviceTaskoper.setDeptCode(serviceTaskVO.getDeptcode()); |
| | | serviceTaskoper.setDeptName(serviceTaskVO.getDeptname()); |
| | | serviceTaskoper.setWardCode(serviceTaskVO.getLeavehospitaldistrictcode()); |
| | | serviceTaskoper.setWardName(serviceTaskVO.getLeavehospitaldistrictname()); |
| | | |
| | | //多选手术等级 |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getOplevelcode())) { |
| | | String[] opLevelcodes = serviceTaskVO.getOplevelcode().split(","); |
| | |
| | | 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) { |
| | |
| | | serviceSubtask.setRemark("电话接通成功,患者拒绝随访"); |
| | | serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid())); |
| | | serviceSubtask.setSendstate(6L); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | // int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1; // 加1是跳过/符号 |
| | | // int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/"); |
| | |
| | | //首次出院随访 |
| | | if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) { |
| | | //首次应随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) { |
| | | serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L); |
| | | } |
| | | //首次待随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | | serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L); |
| | | //首次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(4L)) { |
| | | serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L); |
| | | } |
| | | //首次随访失败(包括随访失败+人工超时) |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 5 || serviceSubtask.getSendstate() == 7)) { |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(5L) || serviceSubtask.getSendstate().equals(7L))) { |
| | | serviceSubtaskStatistic.setFollowUpFail(serviceSubtaskStatistic.getFollowUpFail() + 1L); |
| | | } |
| | | /** |
| | |
| | | //首次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | } |
| | | //首次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L); |
| | | } |
| | | //首次随访人工 (不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L))) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | } |
| | | //首次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L); |
| | | } |
| | | //首次随访人工 (只统计已完成) |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManual(serviceSubtaskStatistic.getManual() + 1L); |
| | |
| | | //首次随访成功 - 统计时候加上不执行的,已发送的 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L) || serviceSubtask.getSendstate().equals(3L) || serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | } |
| | | //首次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L); |
| | | } |
| | | //首次随访人工 (统计不执行) |
| | | if (serviceSubtask.getSendstate() != null && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | |
| | | //再次应随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L); |
| | | } |
| | | //再次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L); |
| | | } |
| | | //再次待随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L); |
| | | } |
| | | //首次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setNonFollowUpFirst(serviceSubtaskStatistic.getNonFollowUpFirst() + 1L); |
| | | } |
| | | //首次待随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | | serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L); |
| | |
| | | //再次应随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L); |
| | | } |
| | | //再次无需随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setNonFollowUpAgain(serviceSubtaskStatistic.getNonFollowUpAgain() + 1L); |
| | | } |
| | | //再次待随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | |
| | | 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)); |
| | | HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map)); |
| | | redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) |
| | | serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtask> gethelibraryCountHyperlink(HeLibraryCountVO heLibraryCountVO){ |
| | | String hyperLinkInfoType = heLibraryCountVO.getHyperLinkInfoType(); |
| | | if(StringUtils.isNotEmpty(hyperLinkInfoType)){ |
| | | heLibraryCountVO.setSendstate(null); |
| | | heLibraryCountVO.setIsFinished(null); |
| | | switch (hyperLinkInfoType) { |
| | | case "totalCountInfo": |
| | | break; |
| | | case "sendSuccessCountInfo": |
| | | heLibraryCountVO.setSendstate(6L); |
| | | break; |
| | | case "readCountInfo": |
| | | heLibraryCountVO.setIsFinished("1"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.gethelibraryCountHyperlink(heLibraryCountVO); |
| | | return serviceSubtasks; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> smsSubTask(Long subid) { |
| | | log.info("smsSubTask的入参为:{}", subid); |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | |
| | | return resultMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) { |
| | | return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime); |
| | | } |
| | | |
| | | private Boolean saveServiceSubtaskDetail(ServiceSubtask serviceSubtask) { |
| | | Boolean result = true; |
| | | //3.4 如果3.1或3.2为true的话,根据type判断什么类型 |