添加导出数据服务
This commit is contained in:
parent
ce2817d168
commit
3f4749ee0c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,35 @@ public class SampleStatAnalysisService
|
|||
.toLocalDate()
|
||||
))
|
||||
.toList();
|
||||
//查询每个台站在时间范围内的各个等级的数量
|
||||
List<Map<String, Object>> 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<String, Object> map = new HashMap<>();
|
||||
map.put("stationCode", entry.getKey());
|
||||
Map<String, Long> 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<String, List<Map<String, Object>>> 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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user