| | |
| | | result.putIfAbsent("wzx", 0); |
| | | result.putIfAbsent("ysf", 0); |
| | | result.putIfAbsent("yc", 0); |
| | | result.putIfAbsent("jg", 0); |
| | | result.putIfAbsent("fssb", 0); |
| | | result.putIfAbsent("yfs", 0); |
| | | result.putIfAbsent("blq", 0); |
| | |
| | | @Override |
| | | public Integer saveQuestionAnswerPhone(ServiceSubTaskDetailReq serviceSubTaskDetailReq) { |
| | | int i = 0; |
| | | log.info("保存电话回调内容 saveQuestionAnswerPhone:{}", serviceSubTaskDetailReq); |
| | | if (StringUtils.isNotEmpty(serviceSubTaskDetailReq.getParam1())) { |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskDetailReq.getParam1(), pri_key)); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | // @Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | @Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.info("getSfStatistics的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | |
| | | String groupKeyType = ""; |
| | | |
| | | String groupKey = "drcode"; |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && !serviceSubtaskCountReq.getLeavehospitaldistrictcodes().isEmpty()) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | groupKeyType = "drCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | groupKey = "drcode"; |
| | | } else { |
| | | groupKeyType = "leaveHospitalDistrictCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown"))); |
| | | groupKey = "leavehospitaldistrictcode"; |
| | | } |
| | | } else if (serviceSubtaskCountReq.getDeptcodes() != null && !serviceSubtaskCountReq.getDeptcodes().isEmpty()) { |
| | | if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { |
| | | groupKeyType = "drCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | groupKey = "drcode"; |
| | | } else { |
| | | groupKeyType = "deptCode"; |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | groupKey = "deptcode"; |
| | | } |
| | | } |
| | | 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) |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | serviceSubtaskCountReq.setGroupKey(groupKey); |
| | | List<String> groupKeyList = serviceSubtaskMapper.getSfStatisticsGroupKey(serviceSubtaskCountReq); |
| | | serviceSubtaskCountReq.setGroupKeyList(groupKeyList); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | switch (groupKey) |
| | | { |
| | | case "deptCode": |
| | | ssRate.setGroupKey("deptcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | case "deptcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | break; |
| | | case "drCode": |
| | | ssRate.setGroupKey("drcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | case "drcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | case "leaveHospitalDistrictCode": |
| | | ssRate.setGroupKey("leavehospitaldistrictcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | case "leavehospitaldistrictcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown"))); |
| | | break; |
| | | default: |
| | | ssRate.setGroupKey("drcode"); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | } |
| | | Map<String, Map<String, Object>> jsRates = new HashMap<>(); |
| | | if(!collect.isEmpty()){ |
| | | jsRates = serviceSubtaskMapper.selectTimelyRateBatch(ssRate); |
| | | } |
| | | |
| | | //获取及时率统计合集 |
| | | Map<String, Map<String, Object>> jsRates = getSsRateForSfStatistics(serviceSubtaskCountReq, collect); |
| | | for (String collectKey : collect.keySet()) { |
| | | List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey); |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList); |
| | | 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()); |
| | | ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList, serviceSubtaskCountReq.getFollowUpCountStyle()); |
| | | if(ObjectUtils.isNotEmpty(jsRates)){ |
| | | 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()); |
| | | } |
| | | Double jsRateDouble = (jsRate.setScale(4, RoundingMode.HALF_UP)).doubleValue(); |
| | | statistic.setRate(jsRateDouble); |
| | | } |
| | | Double jsRateDouble = (jsRate.setScale(4, RoundingMode.HALF_UP)).doubleValue(); |
| | | statistic.setRate(jsRateDouble); |
| | | |
| | | if (ObjectUtils.isNotEmpty(statistic)) { |
| | | serviceSubtaskStatistics.add(statistic); |
| | | } |
| | |
| | | return serviceSubtaskStatistics; |
| | | } |
| | | |
| | | /** |
| | | * 随访统计-及时率统计 |
| | | * @param serviceSubtaskCountReq |
| | | * @param collect |
| | | * @return |
| | | */ |
| | | public Map<String, Map<String, Object>> getSsRateForSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq, Map<String, List<ServiceSubtask>> collect){ |
| | | if(ObjectUtils.isEmpty(serviceSubtaskCountReq)){ |
| | | return null; |
| | | } |
| | | String groupKey = serviceSubtaskCountReq.getGroupKey(); |
| | | if(StringUtils.isEmpty(groupKey)){ |
| | | return null; |
| | | } |
| | | List<String> groupKeyList = new ArrayList<>(collect.keySet()); |
| | | if(ObjectUtils.isEmpty(groupKeyList)){ |
| | | return null; |
| | | } |
| | | //及时率统计 |
| | | 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()); |
| | | } |
| | | ssRate.setGroupKey(groupKey); |
| | | ssRate.setGroupKeyList(groupKeyList); |
| | | Map<String, Map<String, Object>> jsRates = new HashMap<>(); |
| | | if(!collect.isEmpty()){ |
| | | jsRates = serviceSubtaskMapper.selectTimelyRateBatch(ssRate); |
| | | } |
| | | return jsRates; |
| | | } |
| | | @Override |
| | | public List<ServiceSubtaskStatistic> getSfStatisticsExport(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | List<ServiceSubtaskStatistic> sfStatistics = getSfStatistics(serviceSubtaskCountReq); |
| | |
| | | } |
| | | |
| | | |
| | | private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList) { |
| | | private ServiceSubtaskStatistic getStatistic(List<ServiceSubtask> serviceSubtaskList, String followUpCountStyle) { |
| | | ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic(); |
| | | //格式化为两位小数的百分比 |
| | | DecimalFormat percentFormat = new DecimalFormat("##.##%"); |
| | |
| | | serviceSubtaskStatistic.setPendingFollowUp(serviceSubtaskStatistic.getPendingFollowUp() + 1L); |
| | | pendingFollowUpInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 6)) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | followUpSuccessInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访失败 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 5) { |
| | | serviceSubtaskStatistic.setFollowUpFail(serviceSubtaskStatistic.getFollowUpFail() + 1L); |
| | | followUpFailInfo.add(serviceSubtask); |
| | | } |
| | | /** |
| | | * 不同统计方式下不同的随访成功数 参数 followUpCountStyle 控制 |
| | | */ |
| | | if(StringUtils.isNotEmpty(followUpCountStyle) && followUpCountStyle.equals("1")){ |
| | | //首次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 6L)) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | followUpSuccessInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访人工 (不统计不执行) |
| | | 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.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSms(serviceSubtaskStatistic.getSms() + 1L); |
| | | smsInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | wechatInfo.add(serviceSubtask); |
| | | } |
| | | }else { |
| | | //首次随访成功 - 统计时候加上不执行的,已发送的 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate().equals(6L) |
| | | || serviceSubtask.getSendstate().equals(3L) || serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setFollowUpSuccess(serviceSubtaskStatistic.getFollowUpSuccess() + 1L); |
| | | followUpSuccessInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访人工 (统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManual(serviceSubtaskStatistic.getManual() + 1L); |
| | | manualInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访短信(统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSms(serviceSubtaskStatistic.getSms() + 1L); |
| | | smsInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访微信(统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | wechatInfo.add(serviceSubtask); |
| | | } |
| | | } |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp(); |
| | | serviceSubtaskStatistic.setFollowUpRate(percentFormat.format(rate)); |
| | | } else { |
| | | serviceSubtaskStatistic.setFollowUpRate("0.00%"); |
| | | } |
| | | //首次随访人工 (不统计不执行) |
| | | 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.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSms(serviceSubtaskStatistic.getSms() + 1L); |
| | | smsInfo.add(serviceSubtask); |
| | | } |
| | | //首次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L); |
| | | wechatInfo.add(serviceSubtask); |
| | | } |
| | | //结果异常 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getExcep().equals("1")) { |
| | |
| | | serviceSubtaskStatistic.setPendingFollowUpAgain(serviceSubtaskStatistic.getPendingFollowUpAgain() + 1L); |
| | | pendingFollowUpAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 1 || serviceSubtask.getSendstate() == 3 || serviceSubtask.getSendstate() == 6)) { |
| | | serviceSubtaskStatistic.setFollowUpSuccessAgain(serviceSubtaskStatistic.getFollowUpSuccessAgain() + 1L); |
| | | followUpSuccessAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访失败 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 5) { |
| | | serviceSubtaskStatistic.setFollowUpFailAgain(serviceSubtaskStatistic.getFollowUpFailAgain() + 1L); |
| | | followUpFailAgainInfo.add(serviceSubtask); |
| | | } |
| | | /** |
| | | * 不同统计方式下不同的随访成功数 参数 followUpCountStyle 控制 |
| | | */ |
| | | if(StringUtils.isNotEmpty(followUpCountStyle) && followUpCountStyle.equals("1")){ |
| | | //再次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && (serviceSubtask.getSendstate() == 1 || serviceSubtask.getSendstate() == 3 || serviceSubtask.getSendstate() == 6)) { |
| | | serviceSubtaskStatistic.setFollowUpSuccessAgain(serviceSubtaskStatistic.getFollowUpSuccessAgain() + 1L); |
| | | followUpSuccessAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访人工(不统计不执行) |
| | | 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.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgain(serviceSubtaskStatistic.getSmsAgain() + 1L); |
| | | smsAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | wechatAgainInfo.add(serviceSubtask); |
| | | } |
| | | }else { |
| | | //再次随访成功 |
| | | if (serviceSubtask.getSendstate() != null && |
| | | (serviceSubtask.getSendstate().equals(1L) || serviceSubtask.getSendstate().equals(6L) || |
| | | serviceSubtask.getSendstate().equals(3L) || serviceSubtask.getSendstate().equals(4L))) { |
| | | serviceSubtaskStatistic.setFollowUpSuccessAgain(serviceSubtaskStatistic.getFollowUpSuccessAgain() + 1L); |
| | | followUpSuccessAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访人工(统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("1")) { |
| | | serviceSubtaskStatistic.setManualAgain(serviceSubtaskStatistic.getManualAgain() + 1L); |
| | | manualAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访短信(统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgain(serviceSubtaskStatistic.getSmsAgain() + 1L); |
| | | smsAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访微信(统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | wechatAgainInfo.add(serviceSubtask); |
| | | } |
| | | } |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccessAgain() + serviceSubtaskStatistic.getFollowUpFailAgain()) / serviceSubtaskStatistic.getNeedFollowUpAgain(); |
| | | serviceSubtaskStatistic.setFollowUpRateAgain(percentFormat.format(rate)); |
| | | } else { |
| | | serviceSubtaskStatistic.setFollowUpRateAgain("0.00%"); |
| | | } |
| | | //再次随访人工(不统计不执行) |
| | | 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.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("4")) { |
| | | serviceSubtaskStatistic.setSmsAgain(serviceSubtaskStatistic.getSmsAgain() + 1L); |
| | | smsAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次随访微信(不统计不执行) |
| | | if (serviceSubtask.getSendstate() != null |
| | | && !serviceSubtask.getSendstate().equals(4L) |
| | | && serviceSubtask.getPreachform().equals("5")) { |
| | | serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L); |
| | | wechatAgainInfo.add(serviceSubtask); |
| | | } |
| | | //再次异常 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getExcep().equals("1")) { |
| | |
| | | @Override |
| | | @Cacheable(value = "getSfStatisticsScript", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | public List<ServiceSubtaskStatistic> getSfStatisticsScript(ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | log.error("getSfStatisticsScript的入参为:{}", serviceSubtaskCountReq); |
| | | log.info("getSfStatisticsScript的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | | |
| | | // 根据条件进行分组 |
| | | Map<String, List<ServiceSubtask>> collect = new HashMap<>(); |
| | | String orgid = null; |
| | | |
| | | if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) { |
| | | String groupKey = "drcode"; |
| | | 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"))); |
| | | |
| | | groupKey = "drcode"; |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown"))); |
| | | groupKey = "leavehospitaldistrictcode"; |
| | | } |
| | | } 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"))); |
| | | groupKey = "drcode"; |
| | | } else { |
| | | collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown"))); |
| | | groupKey = "deptcode"; |
| | | } |
| | | } |
| | | for (List<ServiceSubtask> serviceSubtaskList : collect.values()) { |
| | | serviceSubtaskCountReq.setGroupKey(groupKey); |
| | | List<String> groupKeyList = serviceSubtaskMapper.getSfStatisticsGroupKey(serviceSubtaskCountReq); |
| | | serviceSubtaskCountReq.setGroupKeyList(groupKeyList); |
| | | List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); |
| | | switch (groupKey) |
| | | { |
| | | case "deptcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown"))); |
| | | break; |
| | | case "drcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | case "leavehospitaldistrictcode": |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown"))); |
| | | break; |
| | | default: |
| | | collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown"))); |
| | | break; |
| | | } |
| | | //获取及时率统计合集 |
| | | Map<String, Map<String, Object>> jsRates = getSsRateForSfStatistics(serviceSubtaskCountReq, collect); |
| | | for (String collectKey : collect.keySet()) { |
| | | List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey); |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatisticCategory(serviceSubtaskList, serviceSubtaskCountReq); |
| | | //及时率 |
| | | ServiceSubtask ss = new ServiceSubtask(); |
| | | orgid = serviceSubtaskList.get(0).getOrgid(); |
| | | ss.setOrgid(orgid); |
| | | |
| | | // 如果有医生编码,设置医生编码用于及时率查询 |
| | | 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()); |
| | | if(ObjectUtils.isNotEmpty(jsRates)){ |
| | | 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()); |
| | | } |
| | | Double jsRateDouble = (jsRate.setScale(4, RoundingMode.HALF_UP)).doubleValue(); |
| | | statistic.setRate(jsRateDouble); |
| | | } |
| | | |
| | | 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); |
| | | if (ObjectUtils.isNotEmpty(statistic)) { |
| | | serviceSubtaskStatistics.add(statistic); |
| | | } |
| | | } |
| | | |
| | | //统计随访题目分类 |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskStatistics)) { |
| | | for (ServiceSubtaskStatistic serviceSubtaskStatistic : serviceSubtaskStatistics) { |
| | | //获取满意度题目总量 |
| | |
| | | * @return |
| | | */ |
| | | public Boolean setFailPreachForm(ServiceSubtask serviceSubtask, String preachform, String remark, String failSendstate) { |
| | | log.info("setFailPreachForm 随访流程处理 serviceSubtask:{}, preachform:{}, remark:{}, failSendstate:{}", |
| | | serviceSubtask, preachform, remark, failSendstate); |
| | | //将状态设置为失败 |
| | | ServiceSubtaskPreachform serviceSubtaskPreachform = new ServiceSubtaskPreachform(); |
| | | serviceSubtaskPreachform.setSubid(serviceSubtask.getId()); |
| | |
| | | if (serviceSubtaskPreachform1.getSort() == spSize.size() && failSendstate.equals("4")) { |
| | | serviceSubtask.setCurrentPreachform(preachform); |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtask.setRemark("setFailPreachForm方法 当前的preachform已经是最后一个了,全失败了"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | return true; |
| | | } |