From ea865b9f3d447b3baf77c8381e4d1be4cec9ffb6 Mon Sep 17 00:00:00 2001 From: Euni4U <958079825@qq.com> Date: Tue, 10 Dec 2024 17:06:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C=E9=87=8F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EcganalysisparasController.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) 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