From b22f118eabab8f2f27dbd73e7c6cb1090cd82c82 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期四, 27 三月 2025 14:46:00 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/boymi/YiFeiNN --- medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java | 54 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 28 insertions(+), 26 deletions(-) diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java index 9a71886..ec4b822 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java @@ -12,6 +12,7 @@ import com.sinata.common.utils.DateUtils; import com.sinata.common.utils.SecurityUtils; import com.sinata.common.utils.StringUtils; +import com.sinata.system.config.AutoColumnWidthStrategy; import com.sinata.system.domain.MwCollectRecord; import com.sinata.system.domain.MwMicroEquipment; import com.sinata.system.domain.MwMicroEquipmentRecord; @@ -118,7 +119,9 @@ // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 String fileName = URLEncoder.encode("微波设备使用记录", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - FastExcel.write(response.getOutputStream(), MwCollectRecordVO.class).sheet("微波设备使用记录").doWrite(list); + FastExcel.write(response.getOutputStream(), MwCollectRecordVO.class) + .registerWriteHandler(new AutoColumnWidthStrategy()) + .sheet("微波设备使用记录").doWrite(list); } /** @@ -214,7 +217,7 @@ vo.setLegend(wasteTypeList.stream().map(SysDictDataVO::getDictLabel).collect(Collectors.toList())); vo.getLegend().add("小计"); String treeCode = sysDepartmentService.getTreeCodeByDepartmentId(query.getDepartmentId()); - List<SysDictData> medicalWasteTypeList = sysDictDataService.lambdaQuery().eq(SysDictData::getDictType, "medical_waste_type").list(); + List<SysDictData> medicalWasteTypeList = sysDictDataService.lambdaQuery().eq(SysDictData::getDictType, "medical_waste_type").orderByDesc(SysDictData::getDictCode).list(); List<MwMicroEquipmentStaticsVO> staticsData = baseMapper.getStaticsData(query, treeCode); SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYY_MM_DD_HH_MM_SS); @@ -230,32 +233,30 @@ break; } List<String> dateList = DateUtils.getDayBetween(query.getStartTime(), query.getEndTime(), query.getDateType()); - if (CollUtils.isNotEmpty(staticsData)) { - List<DepartmentReportItemVO> result = new ArrayList<>(); - for (String date : dateList) { - DepartmentReportItemVO departmentReportItemVO = new DepartmentReportItemVO(); - departmentReportItemVO.setName(date); - departmentReportItemVO.setData(new ArrayList<>()); - SimpleDateFormat finalSdf = sdf; - BigDecimal totalWeight = BigDecimal.ZERO; - BigDecimal totalCount = BigDecimal.ZERO; - for (SysDictData sysDictData : medicalWasteTypeList) { - BigDecimal weight = staticsData.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) - && finalSdf.format(e.getUseTime()).equals(date) - ).map(MwMicroEquipmentStaticsVO::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); - long count = staticsData.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) - && finalSdf.format(e.getUseTime()).equals(date)).count(); - departmentReportItemVO.getData().add(weight); - departmentReportItemVO.getData().add(BigDecimal.valueOf(count)); - totalWeight = totalWeight.add(weight); - totalCount = totalCount.add(BigDecimal.valueOf(count)); - } - departmentReportItemVO.getData().add(totalWeight); - departmentReportItemVO.getData().add(totalCount); - result.add(departmentReportItemVO); + List<DepartmentReportItemVO> result = new ArrayList<>(); + for (String date : dateList) { + DepartmentReportItemVO departmentReportItemVO = new DepartmentReportItemVO(); + departmentReportItemVO.setName(date); + departmentReportItemVO.setData(new ArrayList<>()); + SimpleDateFormat finalSdf = sdf; + BigDecimal totalWeight = BigDecimal.ZERO; + BigDecimal totalCount = BigDecimal.ZERO; + for (SysDictData sysDictData : medicalWasteTypeList) { + BigDecimal weight = staticsData.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) + && finalSdf.format(e.getUseTime()).equals(date) + ).map(MwMicroEquipmentStaticsVO::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); + long count = staticsData.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) + && finalSdf.format(e.getUseTime()).equals(date)).count(); + departmentReportItemVO.getData().add(weight); + departmentReportItemVO.getData().add(BigDecimal.valueOf(count)); + totalWeight = totalWeight.add(weight); + totalCount = totalCount.add(BigDecimal.valueOf(count)); } - vo.setList(result); + departmentReportItemVO.getData().add(totalWeight); + departmentReportItemVO.getData().add(totalCount); + result.add(departmentReportItemVO); } + vo.setList(result); return vo; } @@ -274,6 +275,7 @@ FastExcel.write(response.getOutputStream()) .head(head) .autoCloseStream(Boolean.TRUE) + .registerWriteHandler(new AutoColumnWidthStrategy()) .sheet("处置分析报表") .doWrite(getStaticsReportData(query)); } -- Gitblit v1.7.1