From 3f4749ee0c3f10c37f2aafb36e468c69d3799485 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Mon, 3 Aug 2026 17:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/GardsSampleStatAnalysisMapper.xml | 1 + .../service/impl/ExcelExportService.java | 12 +++++-- .../impl/SampleStatAnalysisService.java | 32 ++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/jeecg-module-data-analyze/src/main/java/org/jeecg/mapper/xml/GardsSampleStatAnalysisMapper.xml b/jeecg-module-data-analyze/src/main/java/org/jeecg/mapper/xml/GardsSampleStatAnalysisMapper.xml index 4982908..9f7cf42 100644 --- a/jeecg-module-data-analyze/src/main/java/org/jeecg/mapper/xml/GardsSampleStatAnalysisMapper.xml +++ b/jeecg-module-data-analyze/src/main/java/org/jeecg/mapper/xml/GardsSampleStatAnalysisMapper.xml @@ -1068,6 +1068,7 @@ LEFT JOIN CONFIGURATION.GARDS_STATIONS c1 ON t1.STATION_ID = c1.STATION_ID WHERE t1.SAMPLE_TYPE = #{sampleType} + AND t1.SPECTRAL_QUALIFIE='FULL' AND t1.COLLECT_STOP BETWEEN #{startTime} AND #{endTime} ORDER BY t1.COLLECT_STOP ASC diff --git a/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/ExcelExportService.java b/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/ExcelExportService.java index 9ed4b1d..5e6429e 100644 --- a/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/ExcelExportService.java +++ b/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/ExcelExportService.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.io.IOException; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.List; @Slf4j @@ -37,11 +38,16 @@ public class ExcelExportService { if (CollectionUtils.isEmpty(data)) { throw new IOException("暂无导出数据"); } + if (data == null) { + data = new ArrayList<>(); + } else { + data = new ArrayList<>(data); // ← 转为可变 List + } ExportParams params = new ExportParams(handler.getSheetName(), handler.getSheetName(), ExcelType.XSSF); - Workbook workbook = ExcelExportUtil.exportExcel(params,handler.getExcelClass(), data); - - download(workbook, handler.getSheetName(), response); + try (Workbook workbook = ExcelExportUtil.exportExcel(params, handler.getExcelClass(), data)) { + download(workbook, handler.getSheetName(), response); + } } private void download(Workbook workbook, diff --git a/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/SampleStatAnalysisService.java b/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/SampleStatAnalysisService.java index ddcd664..9face55 100644 --- a/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/SampleStatAnalysisService.java +++ b/jeecg-module-data-analyze/src/main/java/org/jeecg/service/impl/SampleStatAnalysisService.java @@ -84,6 +84,35 @@ public class SampleStatAnalysisService .toLocalDate() )) .toList(); + //查询每个台站在时间范围内的各个等级的数量 + List> stationLevelCount = sortedList.stream() + .filter(station -> station.getStationCode() != null) + .filter(station -> station.getCategory() != null) + .collect(Collectors.groupingBy( + StationInfoData::getStationCode, + Collectors.mapping( + StationInfoData::getCategory, + Collectors.toList() + ) + )) + .entrySet().stream() + .map(entry -> { + Map map = new HashMap<>(); + map.put("stationCode", entry.getKey()); + Map levelCount = new HashMap<>(); + entry.getValue().stream() + .filter(Objects::nonNull) + .collect(Collectors.groupingBy( + category -> category, + Collectors.counting() + )) + .forEach((category, count) -> + levelCount.put("level" + category, count) + ); + map.put("categoryCount", levelCount); + return map; + }) + .collect(Collectors.toList()); //时间段内有多少台站 Map>> groupedByMonth = sortedList.stream() @@ -144,6 +173,7 @@ public class SampleStatAnalysisService ) )); resultMap.put("stationInfo", stationInfoSet); + resultMap.put("stationLevelCount", stationLevelCount); resultMap.put("sampleMonitorResultList", groupedByMonth); return resultMap; } catch (Exception e) { @@ -233,7 +263,7 @@ public class SampleStatAnalysisService vo.setCount(e.getValue()); return vo; }) - .toList(); + .collect(Collectors.toList()); return sampleStatList; } catch (Exception e) {