From 8b5bbf10f55bd70221c336a3dc79b726865df688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Tue, 27 Aug 2024 09:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=97=B6=E9=97=B4=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcSdhsEventServiceImpl.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java index 18177e59..bad631f7 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java @@ -957,10 +957,12 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { } else if (dcSdhsEventQuery.getType().equals("1")) { // 将查询开始时间和结束时间转换为 LocalDateTime LocalDateTime queryStart = dcSdhsEventQuery.getStartTime().toInstant().atZone(zoneId).toLocalDateTime(); - // 获取该月的最后一天 + LocalDateTime endOfMonth = dcSdhsEventQuery.getEndTime().toInstant().atZone(zoneId).toLocalDateTime(); + /* // 获取该月的最后一天 LocalDate lastDayOfMonth = queryStart.toLocalDate().with(TemporalAdjusters.lastDayOfMonth()); // 构建该月的最后一刻(23:59:59) - LocalDateTime endOfMonth = LocalDateTime.of(lastDayOfMonth, LocalTime.MAX); + LocalDateTime endOfMonth = LocalDateTime.of(lastDayOfMonth, LocalTime.MAX);*/ + List filteredEvents = getDcSdhsEvents(dcSdhsEventQuery, cacheList, zoneId, queryStart, endOfMonth); // 定义日期格式 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd"); @@ -990,7 +992,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { // 获取该年的最后一天 LocalDate lastDayOfYear = queryStart.toLocalDate().with(TemporalAdjusters.lastDayOfYear()); // 构建该年的最后一刻(23:59:59) - LocalDateTime endOfYear = LocalDateTime.of(lastDayOfYear, LocalTime.MAX); + // LocalDateTime endOfYear = LocalDateTime.of(lastDayOfYear, LocalTime.MAX); + LocalDateTime endOfYear = dcSdhsEventQuery.getEndTime().toInstant().atZone(zoneId).toLocalDateTime(); List filteredEvents = getDcSdhsEvents(dcSdhsEventQuery, cacheList, zoneId, queryStart, endOfYear); // 定义日期格式 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM"); @@ -1004,7 +1007,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { ); // 确保所有月份都出现在结果中 - LocalDate queryEnd = endOfYear.toLocalDate().plusMonths(1); // 确保包含结束月份 + // 目标年的年末之后的一个月 + LocalDate queryEnd = endOfYear.toLocalDate().plusMonths(0); // 确保包含结束月份 LocalDate currentMonth = queryStart.toLocalDate(); while (currentMonth.isBefore(queryEnd)) { String monthString = currentMonth.format(formatter); @@ -1073,20 +1077,17 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { Map lastYearData = accidentTimeAnalysis(dcSdhsEventQuery1); String type = dcSdhsEventQuery.getType(); - int rows = 0; + int rows = currentYearData.size()+1; String stingType = ""; String name = ""; if (type.equals("2")) { - rows = 25; stingType = "点"; name = "wordTemplate/accidentTimeAnalysis.docx"; } else if (type.equals("1")) { - rows = 32; stingType = "日"; name = "wordTemplate/accidentTimeDayAnalysis.docx"; } else { - rows = 13; stingType = "月"; name = "wordTemplate/accidentTimeMonthAnalysis.docx";