| | |
| | | |
| | | @Override |
| | | public List<ServiceSubtaskRes> patItem(ServiceSubtaskEntity serviceSubtaskEntity) { |
| | | // 1:待随访(2 待发送);2:随访中(3 已发送、1 被领取)、3:未完成(5 发送失败、7、超时)、4:已完成( 6 已完成)、5:无需随访(4 不执行) |
| | | if (serviceSubtaskEntity.getSendstateView() == 1) serviceSubtaskEntity.setSendstates(Arrays.asList(2L)); |
| | | if (serviceSubtaskEntity.getSendstateView() == 2) serviceSubtaskEntity.setSendstates(Arrays.asList(1L, 3L)); |
| | | if (serviceSubtaskEntity.getSendstateView() == 3) serviceSubtaskEntity.setSendstates(Arrays.asList(5L, 7L)); |
| | | if (serviceSubtaskEntity.getSendstateView() == 4) serviceSubtaskEntity.setSendstates(Arrays.asList(6L)); |
| | | if (serviceSubtaskEntity.getSendstateView() == 5) serviceSubtaskEntity.setSendstates(Arrays.asList(4L)); |
| | | |
| | | if (serviceSubtaskEntity.getSendstateView() != null) { |
| | | // 1:待随访(2 待发送);2:随访中(3 已发送、1 被领取)、3:未完成(5 发送失败、7、超时)、4:已完成( 6 已完成)、5:无需随访(4 不执行) |
| | | if (serviceSubtaskEntity.getSendstateView() == 1) serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(2L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 2) serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(1L, 3L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 3) serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 4) serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L))); |
| | | if (serviceSubtaskEntity.getSendstateView() == 5) serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(4L))); |
| | | } |
| | | |
| | | List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskEntity); |
| | | |
| | |
| | | return serviceSubtaskStatistic; |
| | | } |
| | | |
| | | private ServiceSubtaskStatistic getStatisticCategory(List<ServiceSubtask> serviceSubtaskList, ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | private ServiceSubtaskStatistic getStatisticCategory(List<ServiceSubtask> serviceSubtaskList, ServiceSubtaskCountReq serviceSubtaskCountReq, List<ServiceSubtaskCount> subCounts) { |
| | | ServiceSubtaskStatistic serviceSubtaskStatistic = new ServiceSubtaskStatistic(); |
| | | //格式化为两位小数的百分比 |
| | | DecimalFormat percentFormat = new DecimalFormat("##.##%"); |
| | |
| | | serviceSubtaskStatistic.setJoyAllCount(0); |
| | | |
| | | //获取随访统计 |
| | | List<Long> subTaskIds = new ArrayList<>(); |
| | | if (ObjectUtils.isNotEmpty(serviceSubtaskList)) { |
| | | subTaskIds = serviceSubtaskList.stream().map(ServiceSubtask::getId) // 提取字段 |
| | | .filter(Objects::nonNull) // 过滤 null 值 |
| | | .filter(id -> ObjectUtils.isNotEmpty(id)) // 过滤空字符串(可选) |
| | | .distinct() // 去重 |
| | | .collect(Collectors.toList()); // 收集到 List |
| | | serviceSubtaskCountReq.setSubTaskIds(subTaskIds); |
| | | if (subCounts == null) { |
| | | subCounts = new ArrayList<>(); |
| | | } |
| | | List<ServiceSubtaskCount> subCounts = new ArrayList<>(); |
| | | subCounts = serviceSubtaskMapper.getSfStatisticsCategory(serviceSubtaskCountReq); |
| | | |
| | | //无需随访详情 |
| | | List<ServiceSubtask> nonFollowUpInfo = new ArrayList<>(); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | // @Cacheable(value = "getSfStatisticsScript", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()") |
| | | @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.info("getSfStatisticsScript的入参为:{}", serviceSubtaskCountReq); |
| | | List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>(); |
| | |
| | | } |
| | | //获取及时率统计合集 |
| | | Map<String, Map<String, Object>> jsRates = getSsRateForSfStatistics(serviceSubtaskCountReq, collect); |
| | | //一次性查询所有分组的题目统计,避免每个分组一次SQL(N+1) |
| | | List<Long> allSubTaskIds = rawData.stream().map(ServiceSubtask::getId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | List<ServiceSubtaskCount> subCounts = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(allSubTaskIds)) { |
| | | serviceSubtaskCountReq.setSubTaskIds(allSubTaskIds); |
| | | subCounts = serviceSubtaskMapper.getSfStatisticsCategory(serviceSubtaskCountReq); |
| | | } |
| | | for (String collectKey : collect.keySet()) { |
| | | List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey); |
| | | if (CollectionUtils.isEmpty(serviceSubtaskList)) { |
| | | continue; |
| | | } |
| | | ServiceSubtaskStatistic statistic = getStatisticCategory(serviceSubtaskList, serviceSubtaskCountReq); |
| | | ServiceSubtaskStatistic statistic = getStatisticCategory(serviceSubtaskList, serviceSubtaskCountReq, subCounts); |
| | | if (ObjectUtils.isNotEmpty(jsRates)) { |
| | | Map<String, Object> jsRateMap = jsRates.get(collectKey); |
| | | BigDecimal jsRate = new BigDecimal("0"); |