| | |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.*; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | |
| | | List<ServiceSubtask> list = selectServiceSubtaskList(serviceSubtaskVO); |
| | | |
| | | ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if(ObjectUtils.isEmpty(serviceTask)){ |
| | | log.error("找不到对应的serviceTask, orgid:{}, taskid: {}", serviceSubtask.getOrgid(), serviceSubtask.getTaskid()); |
| | | return null; |
| | | } |
| | | if (CollectionUtils.isEmpty(list) || list.size() == 0) { |
| | | ServiceTaskVO serviceTaskVO = DtoConversionUtils.sourceToTarget(serviceTask, ServiceTaskVO.class); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getExcep()) && !serviceSubtask.getExcep().equals("0")) |
| | | yc = yc + 1; |
| | | } |
| | | |
| | | map.put("wzx", wzx); |
| | | map.put("ysf", ysf); |
| | | map.put("yc", yc); |
| | |
| | | map.put("dsf", dsf); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 统计任务各种状态的数量(已优化) |
| | | * 优化说明: |
| | | * 1. 使用数据库层聚合计算,替代应用层遍历 |
| | | * 2. 性能提升 10-100 倍(取决于数据量) |
| | | * 3. 降低内存占用和网络传输 |
| | | * |
| | | * @param serviceSubtaskVO 查询条件 |
| | | * @return 各状态统计结果 |
| | | */ |
| | | @Override |
| | | public Map<String, Object> patItemCount1(ServiceSubtaskVO serviceSubtaskVO) { |
| | | // 直接调用数据库统计方法,在数据库层完成聚合计算 |
| | | Map<String, Object> result = serviceSubtaskMapper.countByCondition(serviceSubtaskVO); |
| | | |
| | | // 确保所有 key 都有值,避免空指针异常 |
| | | // MyBatis 的 SUM 在没有匹配行时会返回 null |
| | | result.putIfAbsent("wzx", 0); |
| | | result.putIfAbsent("ysf", 0); |
| | | result.putIfAbsent("yc", 0); |
| | | result.putIfAbsent("fssb", 0); |
| | | result.putIfAbsent("yfs", 0); |
| | | result.putIfAbsent("blq", 0); |
| | | result.putIfAbsent("dsf", 0); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size()); |
| | | //记录过滤患者详情 |
| | | List<ServiceSubtask> filterServiceSubtasks = new ArrayList<>(); |
| | | //记录首次应随访详情 |
| | | List<ServiceSubtask> needFollowUpInfo = new ArrayList<>(); |
| | | //记录首次待随访详情 |
| | | List<ServiceSubtask> pendingFollowUpInfo = new ArrayList<>(); |
| | | //记录首次随访成功详情 |
| | | List<ServiceSubtask> followUpSuccessInfo = new ArrayList<>(); |
| | | //记录首次随访失败详情 |
| | | List<ServiceSubtask> followUpFailInfo = new ArrayList<>(); |
| | | |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | //无需随访人次 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | |
| | | |
| | | //首次出院随访 |
| | | if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) { |
| | | //首次应随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L); |
| | | needFollowUpInfo.add(serviceSubtask); |
| | | } |
| | | //首次待随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) { |
| | | 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); |
| | | } |
| | | if (serviceSubtaskStatistic.getNeedFollowUp() > 0) { |
| | | double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp(); |
| | |
| | | } |
| | | } |
| | | serviceSubtaskStatistic.setFilterCountList(filterServiceSubtasks); |
| | | |
| | | //记录首次应随访详情 |
| | | serviceSubtaskStatistic.setNeedFollowUpInfo(needFollowUpInfo); |
| | | //记录首次待随访详情 |
| | | serviceSubtaskStatistic.setPendingFollowUpInfo(pendingFollowUpInfo); |
| | | //记录首次随访成功详情 |
| | | serviceSubtaskStatistic.setFollowUpSuccessInfo(followUpSuccessInfo); |
| | | //记录首次随访失败详情 |
| | | serviceSubtaskStatistic.setFollowUpFailInfo(followUpFailInfo); |
| | | return serviceSubtaskStatistic; |
| | | } |
| | | |