| | |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<ServiceSubtaskPreachform> serviceSubtaskPreachformLists = |
| | | serviceSubtaskPreachformMapper.selectBySubtask(serviceSubtask); |
| | | for (ServiceSubtask serviceSubtask1 : list) { |
| | | PatTaskRelevance patTaskRelevance = new PatTaskRelevance(); |
| | | if (!serviceSubtask1.getHospType().equals("2")) { |
| | |
| | | } |
| | | |
| | | //获取该患者所有的执行状态 |
| | | ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform(); |
| | | serviceSubtaskPreachform.setTaskid(serviceTask.getTaskid()); |
| | | serviceSubtaskPreachform.setSubid(serviceSubtask1.getId()); |
| | | List<ServiceSubtaskPreachform> serviceSubtaskPreachformList = serviceSubtaskPreachformMapper.selectServiceSubtaskPreachformList(serviceSubtaskPreachform); |
| | | List<ServiceSubtaskPreachform> serviceSubtaskPreachformList = |
| | | serviceSubtaskPreachformLists.stream().filter((item -> item.getSubid().equals(serviceSubtask1.getId()) |
| | | && item.getTaskid().equals(serviceTask.getTaskid()))).collect(Collectors.toList()); |
| | | List<Map<String, Object>> resultList = serviceSubtaskPreachformList.stream().map(item -> { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("sort", item.getSort()); |
| | |
| | | public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.info("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | // List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) { |
| | | String groupKeyType = ""; |
| | | |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && !serviceSubtaskCountReq.getLeavehospitaldistrictcodes().isEmpty()) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown"))); |
| | | groupKeyType = "drCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown"))); |
| | | groupKeyType = "leaveHospitalDistrictCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown"))); |
| | | } |
| | | } else if (serviceSubtaskCountReq.getDeptcodes() != null && serviceSubtaskCountReq.getDeptcodes().size() > 0) { |
| | | } else if (serviceSubtaskCountReq.getDeptcodes() != null && !serviceSubtaskCountReq.getDeptcodes().isEmpty()) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown"))); |
| | | groupKeyType = "drCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown"))); |
| | | groupKeyType = "deptCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | } |
| | | } |
| | | List<String> groupKeyList = new ArrayList<>(collect.keySet()); |
| | | //及时率统计 |
| | | ServiceSubtaskVO ssRate = new ServiceSubtaskVO(); |
| | | ssRate.setOrgid(serviceSubtaskCountReq.getOrgid()); |
| | | ssRate.setStarttime(serviceSubtaskCountReq.getStartTime()); |
| | | ssRate.setEndtime(serviceSubtaskCountReq.getEndTime()); |
| | | if (serviceSubtaskCountReq.getEndTime() != null && new Date().before(serviceSubtaskCountReq.getEndTime())) { |
| | | ssRate.setEndtime(new Date()); |
| | | } |
| | | switch (groupKeyType) |
| | | { |
| | | case "deptCode": |
| | | ssRate.setGroupKey("deptcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | break; |
| | | case "drCode": |
| | | ssRate.setGroupKey("drcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | break; |
| | | case "leaveHospitalDistrictCode": |
| | | ssRate.setGroupKey("leavehospitaldistrictcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | break; |
| | | default: |
| | | ssRate.setGroupKey("drcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | break; |
| | | } |
| | | Map<String, Map<String, Object>> jsRates = new HashMap<>(); |
| | | if(!collect.isEmpty()){ |
| | | jsRates = serviceSubtaskMapper.selectTimelyRateBatch(ssRate); |
| | | } |
| | | |
| | | for (List<ServiceSubtask> serviceSubtaskList : collect.values()) { |
| | | for (String collectKey : collect.keySet()) { |
| | | List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey); |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList); |
| | | |
| | | //及时率 |
| | | ServiceSubtask ss = new ServiceSubtask(); |
| | | ss.setOrgid(serviceSubtaskList.get(0).getOrgid()); |
| | | |
| | | // 如果有医生编码,设置医生编码用于及时率查询 |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | ss.setDrcode(serviceSubtaskList.get(0).getDrcode()); |
| | | } else { |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) { |
| | | ss.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode()); |
| | | } else if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getDeptcodes())) { |
| | | ss.setDeptcode(serviceSubtaskList.get(0).getDeptcode()); |
| | | } |
| | | Map<String, Object> jsRateMap = jsRates.get(collectKey); |
| | | BigDecimal jsRate = new BigDecimal("0"); |
| | | if(ObjectUtils.isNotEmpty(jsRateMap) && ObjectUtils.isNotEmpty(jsRateMap.get("rate"))){ |
| | | jsRate = new BigDecimal(jsRateMap.get("rate").toString()); |
| | | } |
| | | |
| | | ss.setStarttime(serviceSubtaskCountReq.getStartTime()); |
| | | ss.setEndtime(serviceSubtaskCountReq.getEndTime()); |
| | | if (serviceSubtaskCountReq.getEndTime() != null && new Date().before(serviceSubtaskCountReq.getEndTime())) { |
| | | ss.setEndtime(new Date()); |
| | | } |
| | | Double jsRate = serviceSubtaskMapper.selectTimelyRate(ss); |
| | | statistic.setRate(jsRate); |
| | | |
| | | Double jsRateDouble = (jsRate.setScale(4, RoundingMode.HALF_UP)).doubleValue(); |
| | | statistic.setRate(jsRateDouble); |
| | | if (ObjectUtils.isNotEmpty(statistic)) { |
| | | serviceSubtaskStatistics.add(statistic); |
| | | } |
| | |
| | | } else { |
| | | serviceSubtaskStatistic.setFollowUpRate("0.00%"); |
| | | } |
| | | //首次随访人工 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("1")) { |
| | | //首次随访人工 (不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManual(serviceSubtaskStatistic.getManual() + 1L); |
| | | manualInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访短信 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("4")) { |
| | | //首次随访短信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSms(serviceSubtaskStatistic.getSms() + 1L); |
| | | smsInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访微信 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("5")) { |
| | | //首次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | wechatInfo.add(serviceSubtask); |
| | | } |
| | |
| | | } else { |
| | | serviceSubtaskStatistic.setFollowUpRateAgain("0.00%"); |
| | | } |
| | | //再次随访人工 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("1")) { |
| | | //再次随访人工(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualAgain(serviceSubtaskStatistic.getManualAgain() + 1L); |
| | | manualAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访短信 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("4")) { |
| | | //再次随访短信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgain(serviceSubtaskStatistic.getSmsAgain() + 1L); |
| | | smsAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访微信 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getPreachform().equals("5")) { |
| | | //再次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | wechatAgainInfo.add(serviceSubtask); |
| | | } |
| | |
| | | BigDecimal finishedSum = new BigDecimal(0); |
| | | //完成比例 |
| | | Double finishedPercentage = null; |
| | | if(ObjectUtils.isNotEmpty(serviceSubtaskStatistic.getJoyAllCount())){ |
| | | finishedSum = new BigDecimal(serviceSubtaskStatistic.getJoyAllCount()); |
| | | if(ObjectUtils.isNotEmpty(serviceSubtaskStatistic.getJoyCount())){ |
| | | finishedSum = new BigDecimal(serviceSubtaskStatistic.getJoyCount()); |
| | | } |
| | | |
| | | if(ObjectUtils.isNotEmpty(serviceSubtaskStatistic.getJoyCount())){ |
| | | sum = new BigDecimal(serviceSubtaskStatistic.getJoyCount()); |
| | | if(ObjectUtils.isNotEmpty(serviceSubtaskStatistic.getJoyAllCount())){ |
| | | sum = new BigDecimal(serviceSubtaskStatistic.getJoyAllCount()); |
| | | } |
| | | if(sum.intValue() != 0){ |
| | | finishedPercentage = finishedSum.divide(sum, 2, RoundingMode.HALF_UP).doubleValue(); |