| | |
| | | import com.ruoyi.common.dx.MessageSend; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.core.service.IConfigService; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | |
| | | import com.smartor.common.MtSubmitSmUtil; |
| | | import com.smartor.common.ScheduleSubtaskBuilder; |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.DTO.MydTrendReqDTO; |
| | | import com.smartor.domain.DTO.MzMydScoreRankDTO; |
| | | import com.smartor.domain.DTO.QuestionCountKsOrBqDTO; |
| | | import com.smartor.domain.DTO.ServiceSubtaskDetailDTO; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.VO.HeLibraryCountVO; |
| | | import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO; |
| | | import com.smartor.domain.VO.TransferDeptVO; |
| | | import com.smartor.domain.VO.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.*; |
| | |
| | | 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.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | @Autowired |
| | | private PatMedOperationMapper patMedOperationMapper; |
| | | @Autowired |
| | | private PatMedOperationItemMapper patMedOperationItemMapper; |
| | | |
| | | @Autowired |
| | | private ServiceOutPathMapper serviceOutPathMapper; |
| | | |
| | | private static final String KEY_SEP = "\u0001"; |
| | | @Autowired |
| | | private PatMedOperationItemMapper patMedOperationItemMapper; |
| | | |
| | | /** |
| | | * 查询单一任务(随访) |
| | |
| | | |
| | | @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) { |
| | | List<ServiceSubtask> serviceSubtasks = null; |
| | | //先查询一下该患者是否已经创建根据serviceType,sendstate,inhospid,patid,orgid |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setServiceType(serviceSubtask.getServiceType()); |
| | | serviceSubtaskVO.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L))); |
| | | serviceSubtaskVO.setPatid(serviceSubtask.getPatid()); |
| | | serviceSubtaskVO.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceSubtaskVO.setCampusid(serviceSubtask.getCampusid()); |
| | | List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | //这样判断主要是为了想让新华医院的外部导入患者创建任务,也能用这个接口 |
| | | 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; |
| | | } else { |
| | | //如果不存在,则新增 |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if (ObjectUtils.isNotEmpty(serviceTask)) { |
| | | serviceSubtask.setTaskDesc(serviceTask.getTaskDesc()); |
| | | serviceSubtask.setTaskName(serviceTask.getTaskName()); |
| | | 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); |
| | | } |
| | | |
| | |
| | | serviceSubtask.setUpdateTime(DateUtils.getNowDate()); |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 6) |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | |
| | | return serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | |
| | |
| | | redisCache.removeElementFromList("cache-3", serviceSubtask.getId().toString()); |
| | | redisCache.removeElementFromList("cache-4", serviceSubtask.getId().toString()); |
| | | //将出入院表的数据,还原成还未处理的状态 |
| | | if (serviceSubtask.getServiceType().equals("2")) { |
| | | if (serviceSubtask.getServiceType().equals("2") || serviceSubtask.getServiceType().equals("13")) { |
| | | ServiceTask st = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | //如果任务是长期任务,需要将该患者的出入院数据还原成还未处理的状态 |
| | | if (st != null && st.getLongTask() == 1) { |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | case "management_doctor_code": |
| | | rawData = rawData.stream() |
| | | .peek(item -> { |
| | | item.setDrname(item.getManagementDoctor()); |
| | | item.setDrcode(item.getManagementDoctorCode()); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | rawData = rawData.stream().peek(item -> { |
| | | item.setDrname(item.getManagementDoctor()); |
| | | item.setDrcode(item.getManagementDoctorCode()); |
| | | }).collect(Collectors.toList()); |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown"))); |
| | | break; |
| | | case "deptcode": |
| | |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | } |
| | | } |
| | | |
| | | //首次随访人工成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualSuccess(serviceSubtaskStatistic.getManualSuccess() + 1L); |
| | | } |
| | | //首次随访语音成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) { |
| | | serviceSubtaskStatistic.setVoiceSuccess(serviceSubtaskStatistic.getVoiceSuccess() + 1L); |
| | | } |
| | | //首次随访短信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsSuccess(serviceSubtaskStatistic.getSmsSuccess() + 1L); |
| | | } |
| | | //首次随访微信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatSuccess(serviceSubtaskStatistic.getWeChatSuccess() + 1L); |
| | | } |
| | | |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp(); |
| | | serviceSubtaskStatistic.setFollowUpRate(percentFormat.format(rate)); |
| | |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | } |
| | | } |
| | | |
| | | //再次随访人工成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualAgainSuccess(serviceSubtaskStatistic.getManualAgainSuccess() + 1L); |
| | | } |
| | | //再次随访语音成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) { |
| | | serviceSubtaskStatistic.setVoiceAgainSuccess(serviceSubtaskStatistic.getVoiceAgainSuccess() + 1L); |
| | | } |
| | | //再次随访短信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgainSuccess(serviceSubtaskStatistic.getSmsAgainSuccess() + 1L); |
| | | } |
| | | //再次随访微信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgainSuccess(serviceSubtaskStatistic.getWeChatAgainSuccess() + 1L); |
| | | } |
| | | |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccessAgain() + serviceSubtaskStatistic.getFollowUpFailAgain()) / serviceSubtaskStatistic.getNeedFollowUpAgain(); |
| | | serviceSubtaskStatistic.setFollowUpRateAgain(percentFormat.format(rate)); |
| | |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | } |
| | | } |
| | | |
| | | //首次随访人工成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualSuccess(serviceSubtaskStatistic.getManualSuccess() + 1L); |
| | | } |
| | | //首次随访语音成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) { |
| | | serviceSubtaskStatistic.setVoiceSuccess(serviceSubtaskStatistic.getVoiceSuccess() + 1L); |
| | | } |
| | | //首次随访短信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsSuccess(serviceSubtaskStatistic.getSmsSuccess() + 1L); |
| | | } |
| | | //首次随访微信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatSuccess(serviceSubtaskStatistic.getWeChatSuccess() + 1L); |
| | | } |
| | | |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp(); |
| | | serviceSubtaskStatistic.setFollowUpRate(percentFormat.format(rate)); |
| | |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | } |
| | | } |
| | | |
| | | //再次随访人工成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualAgainSuccess(serviceSubtaskStatistic.getManualAgainSuccess() + 1L); |
| | | } |
| | | //再次随访语音成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) { |
| | | serviceSubtaskStatistic.setVoiceAgainSuccess(serviceSubtaskStatistic.getVoiceAgainSuccess() + 1L); |
| | | } |
| | | //再次随访短信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgainSuccess(serviceSubtaskStatistic.getSmsAgainSuccess() + 1L); |
| | | } |
| | | //再次随访微信成功 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgainSuccess(serviceSubtaskStatistic.getWeChatAgainSuccess() + 1L); |
| | | } |
| | | |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccessAgain() + serviceSubtaskStatistic.getFollowUpFailAgain()) / serviceSubtaskStatistic.getNeedFollowUpAgain(); |
| | | serviceSubtaskStatistic.setFollowUpRateAgain(percentFormat.format(rate)); |
| | |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | String url = ""; |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | url = localIP + ":" + req_path + "/sf?p=" + format; |
| | | sendMagParam.setUrl(url); |
| | | sendMagParam.setContent("【新华医院】您好,邀请您填写出院随访调查表,请点击" + sendMagParam.getUrl() + "填写。感谢您配合!"); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(url); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setUrl(localIP + ":" + req_path + "/sf?p=" + format); |
| | | sendMagParam.setContent("【新华医院】您好,邀请您填写出院随访调查表,请点击" + sendMagParam.getUrl() + "填写。感谢您配合!"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("phone", serviceSubtask.getPhone()); |
| | | map.put("content", sendMagParam.getContent()); |
| | |
| | | * voiceInfo - visitCount = 1 && currentPreachForm = "3" |
| | | * smsInfo - visitCount = 1 && currentPreachForm = "4" |
| | | * wechatInfo - visitCount = 1 && currentPreachForm = "5" |
| | | * manualSuccessInfo - visitCount = 1 && currentPreachForm = "1" && sendstate = 6 |
| | | * voiceSuccessInfo - visitCount = 1 && currentPreachForm = "3" && sendstate = 6 |
| | | * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6 |
| | | * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6 |
| | | * abnormalInfo - visitCount = 1 && excep = "1" |
| | | * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4 |
| | | * pendingFollowUpAgainInfo - visitCount > 1 && sendstate = 2 |
| | |
| | | * voiceAgainInfo - visitCount > 1 && currentPreachForm = "3" |
| | | * smsAgainInfo - visitCount > 1 && currentPreachForm = "4" |
| | | * wechatAgainInfo - visitCount > 1 && currentPreachForm = "5" |
| | | * manualAgainSuccessInfo - visitCount > 1 && currentPreachForm = "1" && sendstate = 6 |
| | | * voiceAgainSuccessInfo - visitCount > 1 && currentPreachForm = "3" && sendstate = 6 |
| | | * smsAgainSuccessInfo - visitCount > 1 && currentPreachForm = "4" && sendstate = 6 |
| | | * wechatAgainSuccessInfo - visitCount > 1&& currentPreachForm = "5" && sendstate = 6 |
| | | * abnormalAgainInfo- visitCount = 1 && excep = "1" |
| | | * taskSituation1Info - taskSituation = 1 |
| | | * taskSituation2Info - taskSituation = 2 |
| | |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setCurrentPreachform("5"); |
| | | break; |
| | | case "manualSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("1"); |
| | | break; |
| | | case "voiceSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("3"); |
| | | break; |
| | | case "smsSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("4"); |
| | | break; |
| | | case "wechatSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("5"); |
| | | break; |
| | | case "abnormalInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setExcep("1"); |
| | |
| | | break; |
| | | case "wechatAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setCurrentPreachform("5"); |
| | | break; |
| | | case "manualAgainSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("1"); |
| | | break; |
| | | case "voiceAgainSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("3"); |
| | | break; |
| | | case "smsAgainSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("4"); |
| | | break; |
| | | case "wechatAgainSuccessInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L))); |
| | | serviceSubtaskCountReq.setCurrentPreachform("5"); |
| | | break; |
| | | case "abnormalAgainInfo": |
| | |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | |
| | | String url = ""; |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | 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); |
| | | |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(url); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | SysConfig sysConfig = new SysConfig(); |
| | | |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) { |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startFinishTime, Date endFinishTime, 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, startFinishTime, endFinishTime, 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 Map<String, Map<String, List<QuestionCountKsOrBqDTO>>> statQuestionOptionByKsOrBq(QuestionCountKsOrBqVO vo) { |
| | | |
| | | // 1. 查明细 |
| | | List<QuestionCountKsOrBqDTO> sourceList = serviceSubtaskMapper.statQuestionOptionByKsOrBq(vo); |
| | | if (CollectionUtils.isEmpty(sourceList)) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | // 2. 判断按科室还是按病区 |
| | | boolean byDept = vo.getLeaveldeptcodes() != null; |
| | | boolean byDistrict = !byDept && vo.getLeavehospitaldistrictcodes() != null; |
| | | if (!byDept && !byDistrict) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | // 3. key = 科室/病区 + 题目 + 选项 |
| | | Map<String, QuestionCountKsOrBqDTO> map = new LinkedHashMap<>(); |
| | | |
| | | for (QuestionCountKsOrBqDTO dto : sourceList) { |
| | | |
| | | if (StringUtils.isEmpty(dto.getTargetvalue())) { |
| | | continue; |
| | | } |
| | | |
| | | // 分组名:科室 或 病区 |
| | | String groupName = byDept ? dto.getDeptname() : dto.getLeavehospitaldistrictname(); |
| | | if (StringUtils.isEmpty(groupName)) { |
| | | continue; |
| | | } |
| | | |
| | | String asrtext = trimAll(dto.getAsrtext()); // 用户实际选中的选项 |
| | | String questionText = trimAll(dto.getQuestionText()); // 题目 |
| | | if (StringUtils.isEmpty(questionText)) { |
| | | continue; |
| | | } |
| | | |
| | | // 拆分 targetvalue,每个选项都要有一条记录 |
| | | for (String raw : dto.getTargetvalue().split("&")) { |
| | | |
| | | String option = trimAll(raw); |
| | | if (option.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | // key = 科室/病区 + 题目 + 选项 |
| | | String key = buildKey(groupName, questionText, option); |
| | | |
| | | QuestionCountKsOrBqDTO item = map.get(key); |
| | | if (item == null) { |
| | | item = DtoConversionUtils.sourceToTarget(dto, QuestionCountKsOrBqDTO.class); |
| | | item.setTargetvalue(option); |
| | | item.setAsrtext(option); |
| | | item.setQuestionText(dto.getQuestionText()); |
| | | item.setAnswerCount("0"); |
| | | item.setSingleScore("0"); |
| | | map.put(key, item); |
| | | } |
| | | |
| | | // 只有当前选项 == 用户实际选中的选项,才累加 |
| | | if (option.equals(asrtext)) { |
| | | int count = parseCount(item.getAnswerCount()) + 1; |
| | | item.setAnswerCount(String.valueOf(count)); |
| | | |
| | | BigDecimal totalScore = new BigDecimal(item.getSingleScore()) |
| | | .add(new BigDecimal(dto.getSingleScore() == null ? "0" : dto.getSingleScore())); |
| | | item.setSingleScore(totalScore.toPlainString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 4. 计算平均分 |
| | | for (QuestionCountKsOrBqDTO dto : map.values()) { |
| | | String answerCount = dto.getAnswerCount(); |
| | | String singleScore = dto.getSingleScore(); |
| | | |
| | | BigDecimal avg; |
| | | if (StringUtils.isEmpty(answerCount) |
| | | || BigDecimal.ZERO.compareTo(new BigDecimal(answerCount.trim())) == 0) { |
| | | avg = BigDecimal.ZERO; |
| | | } else { |
| | | avg = new BigDecimal(singleScore == null ? "0" : singleScore) |
| | | .divide(new BigDecimal(answerCount.trim()), 2, RoundingMode.HALF_UP); |
| | | } |
| | | dto.setAvgScore(avg.toPlainString()); |
| | | } |
| | | |
| | | // 5. 转成 Map<String, Map<String, List<QuestionCountKsOrBqDTO>>> |
| | | // 第一层 key:科室/病区 |
| | | // 第二层 key:题目 |
| | | // 第二层 value:该题目下的所有选项列表 |
| | | Map<String, Map<String, List<QuestionCountKsOrBqDTO>>> result = new LinkedHashMap<>(); |
| | | |
| | | for (QuestionCountKsOrBqDTO dto : map.values()) { |
| | | |
| | | // 分组名 |
| | | String groupName = byDept ? dto.getDeptname() : dto.getLeavehospitaldistrictname(); |
| | | if (StringUtils.isEmpty(groupName)) { |
| | | continue; |
| | | } |
| | | |
| | | // 题目名 |
| | | String questionText = dto.getQuestionText(); |
| | | if (StringUtils.isEmpty(questionText)) { |
| | | continue; |
| | | } |
| | | |
| | | // 第一层:科室/病区 |
| | | Map<String, List<QuestionCountKsOrBqDTO>> questionMap = |
| | | result.computeIfAbsent(groupName, k -> new LinkedHashMap<>()); |
| | | |
| | | // 第二层:题目 |
| | | List<QuestionCountKsOrBqDTO> optionList = |
| | | questionMap.computeIfAbsent(questionText, k -> new ArrayList<>()); |
| | | |
| | | optionList.add(dto); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime) { |
| | | public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime, Date startFinishTime, Date endFinishTime, String scriptContent, Double scoreStart, Double scoreEnd, String valueType) { |
| | | //先清理一下重复数据 |
| | | List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds(); |
| | | if (!CollectionUtils.isEmpty(repeatIds)) { |
| | | serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds); |
| | | } |
| | | return serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime); |
| | | |
| | | List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime, startFinishTime, endFinishTime, 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 -> { |
| | | if (e == null || export == null) { |
| | | return false; |
| | | } |
| | | String q1 = e.getQuestiontext() != null ? e.getQuestiontext() : ""; |
| | | String q2 = export.getQuestiontext() != null ? export.getQuestiontext() : ""; |
| | | String t1 = value.trim(); |
| | | String t2 = e.getTargetvalue() != null ? e.getTargetvalue() : ""; |
| | | return q1.equals(q2) && t1.equals(t2); |
| | | }).findFirst().orElse(null); |
| | | if (existingExport != null && "0".equals(existingExport.getRatio()) && "0".equals(existingExport.getCount())) { |
| | | //如果存在,则将 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 && !"0".equals(existingExport.getRatio())) { |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /** |
| | | * 满意度趋势查询 |
| | | * |
| | | * @param mydTrendReqVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MydTrendReqDTO> mydTrend(MydTrendReqVO mydTrendReqVO) { |
| | | List<MydTrendReqDTO> list = serviceSubtaskMapper.mydTrend(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType()); |
| | | if (mydTrendReqVO.getType().equals("week")) list = getWeekDate(mydTrendReqVO, list); |
| | | if (mydTrendReqVO.getType().equals("year")) list = getYearDate(mydTrendReqVO, list); |
| | | if (mydTrendReqVO.getType().equals("month")) list = getMonthDate(mydTrendReqVO, list); |
| | | if (mydTrendReqVO.getType().equals("day")) list = getDayDate(mydTrendReqVO, list); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<MydTrendReqDTO> sltdMydTotalByDimension(MydTrendReqVO mydTrendReqVO) { |
| | | List<MydTrendReqDTO> list = null; |
| | | if (mydTrendReqVO.getDimensionType().equals("1")) |
| | | list = serviceSubtaskMapper.sltdMydTotalByDimension(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType()); |
| | | else if (mydTrendReqVO.getDimensionType().equals("2")) |
| | | list = serviceSubtaskMapper.sltdMydTotalByYQ(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType()); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, ServiceTaskdept serviceTaskdept, PatArchive patArchive) { |
| | | ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class); |
| | |
| | | return back; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 问题结果占比 |
| | | * |
| | | * @param sltdMydTotalVO |
| | | * @param serviceSubtaskRes |
| | | * @return |
| | | */ |
| | | public List<ServiceSubtaskDetailRatioExport> getDetailRatio(SltdMydTotalVO sltdMydTotalVO, List<ServiceSubtaskRes> serviceSubtaskRes) { |
| | | List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = null; |
| | | if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("2") && (sltdMydTotalVO.getServiceTypeList().contains("6") || sltdMydTotalVO.getServiceTypeList().contains("14"))) { |
| | | //serviceType,即有随访又有满意度,暂时没法统计 |
| | | return serviceSubtaskDetailRatioExports; |
| | | } else if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("2")) { |
| | | //获取serviceSubtaskList中的所有taskid |
| | | List<Long> taskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getTaskid).filter(ObjectUtils::isNotEmpty).distinct().collect(Collectors.toList()); |
| | | serviceSubtaskDetailRatioExports = statQuestionOption(taskIds, sltdMydTotalVO.getStartFinishTime(), sltdMydTotalVO.getEndFinishTime(), sltdMydTotalVO.getStartOutHospTime(), sltdMydTotalVO.getEndOutHospTime(), sltdMydTotalVO.getQuestionContent(), sltdMydTotalVO.getStartScore(), sltdMydTotalVO.getEndScore(), sltdMydTotalVO.getValueType()); |
| | | } else if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("6") || sltdMydTotalVO.getServiceTypeList().contains("14")) { |
| | | //满意度统计 (通过 subtask 的 id 去统计) |
| | | List<Long> subtaskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getId).collect(Collectors.toList()); |
| | | serviceSubtaskDetailRatioExports = statQuestionOptionBySubtaskIds(subtaskIds, sltdMydTotalVO.getStartOutHospTime(), sltdMydTotalVO.getEndOutHospTime(), sltdMydTotalVO.getStartFinishTime(), sltdMydTotalVO.getEndFinishTime(), sltdMydTotalVO.getQuestionContent(), sltdMydTotalVO.getStartScore(), sltdMydTotalVO.getEndScore(), sltdMydTotalVO.getValueType()); |
| | | } |
| | | return serviceSubtaskDetailRatioExports; |
| | | } |
| | | |
| | | //获取任务组信息 |
| | | private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO) { |
| | | if (StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")) { |
| | |
| | | } |
| | | log.info("ai匹配成功,匹配结果是:" + matchedText); |
| | | } |
| | | |
| | | private static String trimAll(String s) { |
| | | if (s == null) { |
| | | return ""; |
| | | } |
| | | int start = 0; |
| | | int end = s.length(); |
| | | while (start < end && isBlankChar(s.charAt(start))) { |
| | | start++; |
| | | } |
| | | while (end > start && isBlankChar(s.charAt(end - 1))) { |
| | | end--; |
| | | } |
| | | return s.substring(start, end); |
| | | } |
| | | |
| | | private static Boolean isBlankChar(char c) { |
| | | return c == '\u3000' // 全角空格 |
| | | || c == ' ' // 半角空格 |
| | | || c == '\t' || c == '\n' || c == '\r' || c == '\f' || Character.isWhitespace(c); |
| | | } |
| | | |
| | | |
| | | private String buildKey(String groupName, String questionText, String option) { |
| | | return groupName + "\u0001" + questionText + "\u0001" + option; |
| | | } |
| | | |
| | | private static int parseCount(String s) { |
| | | if (StringUtils.isEmpty(s)) { |
| | | return 0; |
| | | } |
| | | try { |
| | | return Integer.parseInt(s.trim()); |
| | | } catch (NumberFormatException e) { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | private List<MydTrendReqDTO> getWeekDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) { |
| | | // 1. 计算总周数(和 SQL 里的公式保持一致) |
| | | long days = (mydTrendReqVO.getEndFinishTime().getTime() - mydTrendReqVO.getStartFinishTime().getTime()) / (1000L * 60 * 60 * 24); |
| | | int totalWeeks = (int) (days / 7) + 1; |
| | | |
| | | // 2. 已有数据:period -> totalScore |
| | | Map<Integer, String> exist = new HashMap<>(); |
| | | for (MydTrendReqDTO row : list) { |
| | | // period 是数字,可能是 Integer / Long / BigDecimal,统一转 int |
| | | int p = Integer.parseInt(StringUtils.isNotEmpty(row.getPeriod()) ? row.getPeriod() : "0"); |
| | | exist.put(p, row.getTotalScore() != null ? row.getTotalScore() : "0"); |
| | | // 下面这行按你的原逻辑保留(虽然看起来有点多余) |
| | | exist.put(p, String.valueOf(row.getTotalScore() != null ? row.getTotalScore() : 0)); |
| | | } |
| | | |
| | | // 3. 补全 1..totalWeeks |
| | | List<MydTrendReqDTO> result = new ArrayList<>(totalWeeks); |
| | | |
| | | // 获取整体的开始时间 |
| | | long startTimeMillis = mydTrendReqVO.getStartFinishTime().getTime(); |
| | | long endTimeMillis = mydTrendReqVO.getEndFinishTime().getTime(); |
| | | long oneWeekMillis = 7L * 24 * 60 * 60 * 1000; // 一周的毫秒数 |
| | | |
| | | for (int i = 1; i <= totalWeeks; i++) { |
| | | MydTrendReqDTO row = new MydTrendReqDTO(); |
| | | row.setPeriod(String.valueOf(i)); |
| | | row.setTotalScore(exist.getOrDefault(i, "0")); |
| | | |
| | | // -------- 新增:设置每周的 startDate 和 endDate -------- |
| | | // 当前周开始时间 = 整体开始时间 + (i - 1) * 7天 |
| | | long currentStartMillis = startTimeMillis + (long) (i - 1) * oneWeekMillis; |
| | | |
| | | // 当前周结束时间 = 当前周开始时间 + 7天 - 1毫秒(保证是这一周的最后一刻) |
| | | long currentEndMillis = currentStartMillis + oneWeekMillis - 1; |
| | | |
| | | // 如果是最后一周,结束时间不能超过整体的 endTime |
| | | if (i == totalWeeks) { |
| | | currentEndMillis = endTimeMillis; |
| | | } |
| | | |
| | | row.setStartDate(new Date(currentStartMillis)); |
| | | row.setEndDate(new Date(currentEndMillis)); |
| | | // ---------------------------------------------------- |
| | | |
| | | result.add(row); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private List<MydTrendReqDTO> getYearDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) { |
| | | // 获取整体开始和结束时间 |
| | | Date startTime = mydTrendReqVO.getStartFinishTime(); |
| | | Date endTime = mydTrendReqVO.getEndFinishTime(); |
| | | |
| | | // 1. 计算年份范围 |
| | | // 使用 Calendar 获取起始年份和结束年份 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(startTime); |
| | | int startYear = cal.get(Calendar.YEAR); |
| | | |
| | | cal.setTime(endTime); |
| | | int endYear = cal.get(Calendar.YEAR); |
| | | |
| | | // 总年数 (包含首尾) |
| | | int totalYears = endYear - startYear + 1; |
| | | |
| | | // 2. 已有数据:period -> totalScore (假设 period 存的是年份字符串,如 "2024") |
| | | Map<String, String> exist = new HashMap<>(); |
| | | for (MydTrendReqDTO row : list) { |
| | | String period = row.getPeriod() != null ? row.getPeriod() : ""; |
| | | exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0"); |
| | | } |
| | | |
| | | // 3. 补全所有年份 |
| | | List<MydTrendReqDTO> result = new ArrayList<>(totalYears); |
| | | |
| | | for (int i = 0; i < totalYears; i++) { |
| | | int currentYear = startYear + i; |
| | | String periodKey = String.valueOf(currentYear); |
| | | |
| | | MydTrendReqDTO row = new MydTrendReqDTO(); |
| | | row.setPeriod(periodKey); |
| | | // 如果没有该年份的数据,默认给 "0" |
| | | row.setTotalScore(exist.getOrDefault(periodKey, "0")); |
| | | |
| | | // -------- 设置该年份的 startDate 和 endDate -------- |
| | | Calendar yearCal = Calendar.getInstance(); |
| | | // 设置为该年的 1月1日 00:00:00 |
| | | yearCal.set(currentYear, Calendar.JANUARY, 1, 0, 0, 0); |
| | | yearCal.set(Calendar.MILLISECOND, 0); |
| | | row.setStartDate(yearCal.getTime()); |
| | | |
| | | // 设置为该年的 12月31日 23:59:59 |
| | | yearCal.set(currentYear, Calendar.DECEMBER, 31, 23, 59, 59); |
| | | yearCal.set(Calendar.MILLISECOND, 999); |
| | | row.setEndDate(yearCal.getTime()); |
| | | // ---------------------------------------------------- |
| | | |
| | | result.add(row); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private List<MydTrendReqDTO> getMonthDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) { |
| | | // 获取整体开始和结束时间 |
| | | Date startTime = mydTrendReqVO.getStartFinishTime(); |
| | | Date endTime = mydTrendReqVO.getEndFinishTime(); |
| | | |
| | | // 1. 计算月份范围 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(startTime); |
| | | int startYear = cal.get(Calendar.YEAR); |
| | | int startMonth = cal.get(Calendar.MONTH); // 注意:Calendar.MONTH 从 0 开始 |
| | | |
| | | cal.setTime(endTime); |
| | | int endYear = cal.get(Calendar.YEAR); |
| | | int endMonth = cal.get(Calendar.MONTH); |
| | | |
| | | // 总月数 = (结束年 - 开始年) * 12 + (结束月 - 开始月) + 1 |
| | | int totalMonths = (endYear - startYear) * 12 + (endMonth - startMonth) + 1; |
| | | |
| | | // 2. 已有数据:period -> totalScore (period 存的是月份字符串,如 "2024-06") |
| | | Map<String, String> exist = new HashMap<>(); |
| | | for (MydTrendReqDTO row : list) { |
| | | String period = row.getPeriod() != null ? row.getPeriod() : ""; |
| | | exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0"); |
| | | } |
| | | |
| | | // 3. 补全所有月份 |
| | | List<MydTrendReqDTO> result = new ArrayList<>(totalMonths); |
| | | |
| | | Calendar monthCal = Calendar.getInstance(); |
| | | monthCal.set(startYear, startMonth, 1, 0, 0, 0); |
| | | monthCal.set(Calendar.MILLISECOND, 0); |
| | | |
| | | for (int i = 0; i < totalMonths; i++) { |
| | | int currentYear = monthCal.get(Calendar.YEAR); |
| | | int currentMonth = monthCal.get(Calendar.MONTH) + 1; // 转成 1-12 月 |
| | | |
| | | // 拼接 period,格式:yyyy-MM,比如 "2024-06" |
| | | // 如果你希望是 "2024-6",可以把 String.format 改成 currentMonth |
| | | String periodKey = String.format("%04d-%02d", currentYear, currentMonth); |
| | | |
| | | MydTrendReqDTO row = new MydTrendReqDTO(); |
| | | row.setPeriod(periodKey); |
| | | row.setTotalScore(exist.getOrDefault(periodKey, "0")); |
| | | |
| | | // -------- 设置该月的 startDate 和 endDate -------- |
| | | // 当月开始时间:1号 00:00:00.000 |
| | | Calendar startCal = (Calendar) monthCal.clone(); |
| | | row.setStartDate(startCal.getTime()); |
| | | |
| | | // 当月结束时间:下个月1号 00:00:00.000 减 1 毫秒 |
| | | Calendar endCal = (Calendar) monthCal.clone(); |
| | | endCal.add(Calendar.MONTH, 1); |
| | | endCal.add(Calendar.MILLISECOND, -1); |
| | | row.setEndDate(endCal.getTime()); |
| | | // ---------------------------------------------------- |
| | | |
| | | result.add(row); |
| | | |
| | | // 进入下一个月 |
| | | monthCal.add(Calendar.MONTH, 1); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private List<MydTrendReqDTO> getDayDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) { |
| | | // 获取整体开始和结束时间 |
| | | Date startTime = mydTrendReqVO.getStartFinishTime(); |
| | | Date endTime = mydTrendReqVO.getEndFinishTime(); |
| | | |
| | | // 1. 计算总天数 |
| | | long oneDayMillis = 24L * 60 * 60 * 1000; |
| | | // 注意:这里只算日期差,不考虑时分秒,否则可能差一天 |
| | | Calendar startCal = Calendar.getInstance(); |
| | | startCal.setTime(startTime); |
| | | startCal.set(Calendar.HOUR_OF_DAY, 0); |
| | | startCal.set(Calendar.MINUTE, 0); |
| | | startCal.set(Calendar.SECOND, 0); |
| | | startCal.set(Calendar.MILLISECOND, 0); |
| | | |
| | | Calendar endCal = Calendar.getInstance(); |
| | | endCal.setTime(endTime); |
| | | endCal.set(Calendar.HOUR_OF_DAY, 0); |
| | | endCal.set(Calendar.MINUTE, 0); |
| | | endCal.set(Calendar.SECOND, 0); |
| | | endCal.set(Calendar.MILLISECOND, 0); |
| | | |
| | | long days = (endCal.getTimeInMillis() - startCal.getTimeInMillis()) / oneDayMillis; |
| | | int totalDays = (int) days + 1; |
| | | |
| | | // 2. 已有数据:period -> totalScore (period 存的是日期字符串,如 "2024-06-01") |
| | | Map<String, String> exist = new HashMap<>(); |
| | | for (MydTrendReqDTO row : list) { |
| | | String period = row.getPeriod() != null ? row.getPeriod() : ""; |
| | | exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0"); |
| | | } |
| | | |
| | | // 3. 补全所有日期 |
| | | List<MydTrendReqDTO> result = new ArrayList<>(totalDays); |
| | | |
| | | Calendar dayCal = (Calendar) startCal.clone(); |
| | | for (int i = 0; i < totalDays; i++) { |
| | | // 拼接 period,格式:yyyy-MM-dd |
| | | String periodKey = String.format("%04d-%02d-%02d", dayCal.get(Calendar.YEAR), dayCal.get(Calendar.MONTH) + 1, dayCal.get(Calendar.DAY_OF_MONTH)); |
| | | |
| | | MydTrendReqDTO row = new MydTrendReqDTO(); |
| | | row.setPeriod(periodKey); |
| | | row.setTotalScore(exist.getOrDefault(periodKey, "0")); |
| | | |
| | | // -------- 设置该天的 startDate 和 endDate -------- |
| | | Calendar startOfDay = (Calendar) dayCal.clone(); |
| | | row.setStartDate(startOfDay.getTime()); |
| | | |
| | | Calendar endOfDay = (Calendar) dayCal.clone(); |
| | | endOfDay.set(Calendar.HOUR_OF_DAY, 23); |
| | | endOfDay.set(Calendar.MINUTE, 59); |
| | | endOfDay.set(Calendar.SECOND, 59); |
| | | endOfDay.set(Calendar.MILLISECOND, 999); |
| | | row.setEndDate(endOfDay.getTime()); |
| | | // ---------------------------------------------------- |
| | | |
| | | result.add(row); |
| | | |
| | | // 进入下一天 |
| | | dayCal.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 门诊满意度综合得分排名(按科室或病区) |
| | | * <p> |
| | | * 综合满意度 = Σ(评分明细权重) / 评分明细条数 × 100%, |
| | | * 权重只取 1、0.8、0.6、0.4、0.2 五档(很满意、满意、一般、不满意、很不满意)。 |
| | | * |
| | | * @param mzMydScoreRankVO 查询条件 |
| | | * @return 排名结果,名次从 1 开始顺序编号 |
| | | */ |
| | | @Override |
| | | public List<MzMydScoreRankDTO> mzMydScoreRank(MzMydScoreRankVO mzMydScoreRankVO) { |
| | | if (StringUtils.isEmpty(mzMydScoreRankVO.getDimensionType())) { |
| | | mzMydScoreRankVO.setDimensionType("1"); |
| | | } |
| | | if (StringUtils.isEmpty(mzMydScoreRankVO.getServiceType())) { |
| | | mzMydScoreRankVO.setServiceType("14"); |
| | | } |
| | | List<MzMydScoreRankDTO> list = serviceSubtaskMapper.selectMzMydScoreRank(mzMydScoreRankVO); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | // 名次:SQL 已按综合得分降序返回,这里顺序编号 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).setRank(i + 1); |
| | | } |
| | | return list; |
| | | } |
| | | } |