diff --git a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java index 3f4ed79be..1f7526d50 100644 --- a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java +++ b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java @@ -156,35 +156,36 @@ public class EcganalysisparasController { @Operation(summary = "导出医生工作量统计Excel") @PreAuthorize("@ss.hasPermission('tblist:ecganalysisparas:export')") @ApiAccessLog(operateType = EXPORT) - public void exportWorkloadExcel(@RequestParam("startTime") String startTime, - @RequestParam("endTime") String endTime, - HttpServletResponse response) throws IOException { - // 设置响应头 - // response.setContentType("application/vnd.ms-excel"); - // response.setCharacterEncoding("utf-8"); - // String fileName = URLEncoder.encode("医生工作量统计", "UTF-8").replaceAll("\\+", "%20"); - // response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xls"); - + public void exportWorkloadExcel( + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime, + @RequestParam(value = "doctorName", required = false) String doctorName, + HttpServletResponse response) throws IOException { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.select("doctorId, doctorName, doctorDiagTime, COUNT(*) as count") + queryWrapper.select("doctorName, DATE(doctorDiagTime) as diagDate, COUNT(*) as count") .ge("doctorDiagTime", startTime) - .le("doctorDiagTime", endTime) - .groupBy("doctorId, doctorName, doctorDiagTime") - .orderByDesc("doctorDiagTime"); + .le("doctorDiagTime", endTime); + + if (doctorName != null && !doctorName.isEmpty()) { + queryWrapper.eq("doctorName", doctorName); + } + + queryWrapper.groupBy("doctorName, DATE(doctorDiagTime)") + .orderByAsc("doctorName") + .orderByDesc("diagDate"); List> resultList = ecganalysisparasMapper.selectMaps(queryWrapper); List workloadList = new ArrayList<>(); for (Map result : resultList) { EcgWorkloadVO workload = new EcgWorkloadVO(); - //workload.setDoctorId((Integer) result.get("doctorId")); workload.setDoctorName(result.get("doctorName").toString()); - workload.setDoctorDiagTime(result.get("doctorDiagTime").toString().replace('T',' ')); + workload.setDoctorDiagTime(result.get("diagDate").toString()); workload.setCount((Long) result.get("count")); workloadList.add(workload); } // 导出Excel - ExcelUtils.write(response, "医生工作量统计.xls", "数据", EcgWorkloadVO.class, BeanUtils.toBean(workloadList, EcgWorkloadVO.class)); + ExcelUtils.write(response, "医生工作量统计.xls", "数据", EcgWorkloadVO.class, workloadList); } } \ No newline at end of file