Browse Source

echasts导出修改

develop
lau572 5 months ago
parent
commit
d42f11ed37
  1. 24
      zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java
  2. 283
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

24
zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java

@ -266,11 +266,11 @@ public class DCPerceivedEventsWarningController extends BaseController {
*/ */
@ApiOperation(value = "导出感知事件多发时段",tags = {"ECharts导出"}) @ApiOperation(value = "导出感知事件多发时段",tags = {"ECharts导出"})
@GetMapping("/exportManyTimesInterval") @GetMapping("/exportManyTimesInterval")
public AjaxResult exportManyTimesInterval(HttpServletResponse response,DcWarning dcWarning){ public void exportManyTimesInterval(HttpServletResponse response,DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) ||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){ ||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误"); return ;
} }
HashMap<String,Object> map = perceivedEventsWarningService.selectManyTimesInterval(dcWarning); HashMap<String,Object> map = perceivedEventsWarningService.selectManyTimesInterval(dcWarning);
List<ManyTimesInterval> list = new ArrayList<>(); List<ManyTimesInterval> list = new ArrayList<>();
@ -289,7 +289,6 @@ public class DCPerceivedEventsWarningController extends BaseController {
ExcelUtil<ManyTimesInterval> util = new ExcelUtil<>(ManyTimesInterval.class); ExcelUtil<ManyTimesInterval> util = new ExcelUtil<>(ManyTimesInterval.class);
util.exportExcel(response, list, "感知事件多发时段"); util.exportExcel(response, list, "感知事件多发时段");
return AjaxResult.success("导出感知事件多发时段成功");
} }
//新-感知事件类型分析 //新-感知事件类型分析
@ -304,11 +303,11 @@ public class DCPerceivedEventsWarningController extends BaseController {
} }
@ApiOperation(value = "导出感知事件类型分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出感知事件类型分析",tags = {"ECharts导出"})
@GetMapping("/exportSelectWarningType") @GetMapping("/exportSelectWarningType")
public AjaxResult exportSelectWarningType(HttpServletResponse response,DcWarning dcWarning){ public void exportSelectWarningType(HttpServletResponse response,DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) ||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){ ||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误"); return;
} }
HashMap<String,Object> map = perceivedEventsWarningService.newSelectWarningType(dcWarning); HashMap<String,Object> map = perceivedEventsWarningService.newSelectWarningType(dcWarning);
List<SelectWarningType> list = new ArrayList<>(); List<SelectWarningType> list = new ArrayList<>();
@ -330,7 +329,6 @@ public class DCPerceivedEventsWarningController extends BaseController {
ExcelUtil<SelectWarningType> util = new ExcelUtil<>(SelectWarningType.class); ExcelUtil<SelectWarningType> util = new ExcelUtil<>(SelectWarningType.class);
util.exportExcel(response, list, "感知事件类型分析"); util.exportExcel(response, list, "感知事件类型分析");
return AjaxResult.success("导出感知事件类型分析成功");
} }
//新-感知事件桩号范围内事件分析 //新-感知事件桩号范围内事件分析
@PostMapping("/selectSection") @PostMapping("/selectSection")
@ -345,11 +343,11 @@ public class DCPerceivedEventsWarningController extends BaseController {
@ApiOperation(value = "导出桩号范围内事件分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出桩号范围内事件分析",tags = {"ECharts导出"})
@GetMapping("/exportSelectSection") @GetMapping("/exportSelectSection")
public AjaxResult exportSelectSection(HttpServletResponse response,DcWarning dcWarning){ public void exportSelectSection(HttpServletResponse response,DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) ||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){ ||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误"); return;
} }
HashMap<String,Object> map = perceivedEventsWarningService.newSelectSection(dcWarning); HashMap<String,Object> map = perceivedEventsWarningService.newSelectSection(dcWarning);
List<SelectSection> list = new ArrayList<>(); List<SelectSection> list = new ArrayList<>();
@ -376,7 +374,6 @@ public class DCPerceivedEventsWarningController extends BaseController {
ExcelUtil<SelectSection> util = new ExcelUtil<>(SelectSection.class); ExcelUtil<SelectSection> util = new ExcelUtil<>(SelectSection.class);
util.exportExcel(response, list, "桩号范围内事件分析"); util.exportExcel(response, list, "桩号范围内事件分析");
return AjaxResult.success("导出桩号范围内事件分析成功");
} }
//新-感知事件路段处置类型分析 //新-感知事件路段处置类型分析
@PostMapping("/selectStateType") @PostMapping("/selectStateType")
@ -388,9 +385,9 @@ public class DCPerceivedEventsWarningController extends BaseController {
} }
@ApiOperation(value = "导出感知事件路段分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出感知事件路段分析",tags = {"ECharts导出"})
@GetMapping("/exportSelectStateType") @GetMapping("/exportSelectStateType")
public AjaxResult exportSelectStateType(HttpServletResponse response, DcWarning dcWarning){ public void exportSelectStateType(HttpServletResponse response, DcWarning dcWarning){
if (dcWarning==null||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null){ if (dcWarning==null||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null){
return AjaxResult.error("参数错误"); return;
} }
List<SelectStateType> list = new ArrayList<>(); List<SelectStateType> list = new ArrayList<>();
@ -443,7 +440,6 @@ public class DCPerceivedEventsWarningController extends BaseController {
ExcelUtil<SelectStateType> util = new ExcelUtil<>(SelectStateType.class); ExcelUtil<SelectStateType> util = new ExcelUtil<>(SelectStateType.class);
util.exportExcel(response, list, "感知事件路段分析"); util.exportExcel(response, list, "感知事件路段分析");
return AjaxResult.success("导出感知事件路段分析成功");
} }
//查询感知数量按照路段数量进行排名 //查询感知数量按照路段数量进行排名
@PostMapping("/sectionPerceivedList") @PostMapping("/sectionPerceivedList")
@ -453,7 +449,7 @@ public class DCPerceivedEventsWarningController extends BaseController {
@ApiOperation(value = "导出感知事件路段排名",tags = {"ECharts导出"}) @ApiOperation(value = "导出感知事件路段排名",tags = {"ECharts导出"})
@GetMapping("/exportSectionPerceivedList") @GetMapping("/exportSectionPerceivedList")
public AjaxResult exportSectionPerceivedList(HttpServletResponse response){ public void exportSectionPerceivedList(HttpServletResponse response){
List<HashMap<String,Object>> dataList = perceivedEventsWarningService.selectSectionPerceivedEventsList(); List<HashMap<String,Object>> dataList = perceivedEventsWarningService.selectSectionPerceivedEventsList();
List<SectionPerceivedList> list = new ArrayList<>(); List<SectionPerceivedList> list = new ArrayList<>();
if (dataList != null && dataList.size() > 0){ if (dataList != null && dataList.size() > 0){
@ -467,7 +463,5 @@ public class DCPerceivedEventsWarningController extends BaseController {
} }
ExcelUtil<SectionPerceivedList> util = new ExcelUtil<>(SectionPerceivedList.class); ExcelUtil<SectionPerceivedList> util = new ExcelUtil<>(SectionPerceivedList.class);
util.exportExcel(response, list, "感知事件路段排名"); util.exportExcel(response, list, "感知事件路段排名");
return AjaxResult.success("导出感知事件路段排名成功");
} }
} }

283
zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

@ -24,6 +24,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -222,9 +223,9 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
*/ */
@ApiOperation(value="导出全路段车流量状况分析",tags = {"ECharts导出"}) @ApiOperation(value="导出全路段车流量状况分析",tags = {"ECharts导出"})
@GetMapping("/history/exportRealTimeTrafficFlow") @GetMapping("/history/exportRealTimeTrafficFlow")
public AjaxResult exportRealTimeTrafficFlow(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportRealTimeTrafficFlow(HttpServletResponse response,String startDate, String direction,String periodType ){
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){
return AjaxResult.error("参数错误"); return;
} }
String endDate = ""; String endDate = "";
if ("4".equals(periodType)){ if ("4".equals(periodType)){
@ -280,7 +281,6 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
ExcelUtil<RealTimeTrafficFlow> util = new ExcelUtil<>(RealTimeTrafficFlow.class); ExcelUtil<RealTimeTrafficFlow> util = new ExcelUtil<>(RealTimeTrafficFlow.class);
util.exportExcel(response, list, "全路段双向实时车流量"); util.exportExcel(response, list, "全路段双向实时车流量");
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success("导出成功");
} }
/** /**
* 车流量时段分析 * 车流量时段分析
@ -304,9 +304,9 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
*/ */
@ApiOperation(value="导出车流量时段分析",tags = {"ECharts导出"}) @ApiOperation(value="导出车流量时段分析",tags = {"ECharts导出"})
@GetMapping("/history/exportTrafficPeriodAnalysis") @GetMapping("/history/exportTrafficPeriodAnalysis")
public AjaxResult exportTrafficPeriodAnalysis(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportTrafficPeriodAnalysis(HttpServletResponse response,String startDate, String direction,String periodType ){
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){
return AjaxResult.error("参数错误"); return;
} }
String endDate = ""; String endDate = "";
if ("4".equals(periodType)){ if ("4".equals(periodType)){
@ -361,8 +361,6 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
ExcelUtil<TrafficPeriodAnalysis> util = new ExcelUtil<>(TrafficPeriodAnalysis.class); ExcelUtil<TrafficPeriodAnalysis> util = new ExcelUtil<>(TrafficPeriodAnalysis.class);
util.exportExcel(response, list, "车流量时段分析"); util.exportExcel(response, list, "车流量时段分析");
// 将查询结果封装为成功响应并返回
return AjaxResult.success("导出成功");
} }
@ApiOperation("断面车流量排名") @ApiOperation("断面车流量排名")
@ -383,7 +381,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
*/ */
@ApiOperation(value="导出断面车流量排名",tags = {"ECharts导出"}) @ApiOperation(value="导出断面车流量排名",tags = {"ECharts导出"})
@GetMapping("/history/exportSectionTrafficRanking") @GetMapping("/history/exportSectionTrafficRanking")
public AjaxResult exportSectionTrafficRanking(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportSectionTrafficRanking(HttpServletResponse response,String startDate, String direction,String periodType ){
List<SectionTrafficRanking> list = new ArrayList<>(); List<SectionTrafficRanking> list = new ArrayList<>();
List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType); List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType);
for (int i = 0; i < dcStatisticsData.size(); i++) { for (int i = 0; i < dcStatisticsData.size(); i++) {
@ -396,8 +394,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
ExcelUtil<SectionTrafficRanking> util = new ExcelUtil<>(SectionTrafficRanking.class); ExcelUtil<SectionTrafficRanking> util = new ExcelUtil<>(SectionTrafficRanking.class);
util.exportExcel(response, list, "断面车流量排名"); util.exportExcel(response, list, "断面车流量排名");
// 将查询结果封装为成功响应并返回
return AjaxResult.success("导出成功");
} }
/** /**
@ -418,7 +415,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
@ApiOperation(value="导出路段交通指标分析",tags = {"ECharts导出"}) @ApiOperation(value="导出路段交通指标分析",tags = {"ECharts导出"})
@GetMapping("/history/exportSectionTrafficIndexAnalysis") @GetMapping("/history/exportSectionTrafficIndexAnalysis")
public AjaxResult exportSectionTrafficIndexAnalysis(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){ public void exportSectionTrafficIndexAnalysis(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){
List<SectionTrafficIndexAnalysis> list = new ArrayList<>(); List<SectionTrafficIndexAnalysis> list = new ArrayList<>();
String endDate = ""; String endDate = "";
@ -482,7 +479,6 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
ExcelUtil<SectionTrafficIndexAnalysis> util = new ExcelUtil<>(SectionTrafficIndexAnalysis.class); ExcelUtil<SectionTrafficIndexAnalysis> util = new ExcelUtil<>(SectionTrafficIndexAnalysis.class);
util.exportExcel(response, list, "路段交通指标分析"); util.exportExcel(response, list, "路段交通指标分析");
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success("导出成功");
} }
@ApiOperation("通指标时间分布") @ApiOperation("通指标时间分布")
@ -670,133 +666,140 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
/** /**
* 导出全路段双向实时车流量 * 导出全路段双向实时车流量
*/ */
// @ApiOperation(value = "导出全路段双向实时车流量",tags = {"ECharts导出"}) @ApiOperation(value = "导出全路段双向实时车流量",tags = {"ECharts导出"})
// @GetMapping("/history/exportRealTimeTrafficFlowHour") @GetMapping("/history/exportRealTimeTrafficFlowHour")
// public AjaxResult exportRealTimeTrafficFlowHour(HttpServletResponse response) throws IOException, HttpException { public void exportRealTimeTrafficFlowHour(HttpServletResponse response) throws IOException, HttpException {
//
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// LocalDate currentDate = LocalDate.now(); response.setCharacterEncoding("utf-8");
// String now = currentDate.format(formatter); String fileName = "全路段双向实时车流量.xlsx";
// response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
// // 获取一年前的日期
// LocalDate oneYearAgo = currentDate.minusYears(1);
// String lastYear = oneYearAgo.format(formatter); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// LocalDate currentDate = LocalDate.now();
// List<Map<String,Object>> thisYearHZ = dcTrafficStatisticsService.realTimeTrafficFlowHour(now,1L); String now = currentDate.format(formatter);
// List<Map<String,Object>> thisYearJN = dcTrafficStatisticsService.realTimeTrafficFlowHour(now,3L);
// List<Map<String,Object>> lastYearHZ = dcTrafficStatisticsService.realTimeTrafficFlowHour(lastYear,1L); // 获取一年前的日期
// List<Map<String,Object>> lastYearJN = dcTrafficStatisticsService.realTimeTrafficFlowHour(lastYear,3L); LocalDate oneYearAgo = currentDate.minusYears(1);
// String lastYear = oneYearAgo.format(formatter);
// Workbook workbook = new XSSFWorkbook(); // 创建工作簿
// Sheet sheet = workbook.createSheet("全路段双向实时车流量"); // 创建工作表 Map<String,List<Map<String,Object>>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour();
// if (map != null){
// // 创建数据行样式 List<Map<String,Object>> thisYearHZ = map.get("1");
// CellStyle dataStyle = workbook.createCellStyle(); List<Map<String,Object>> thisYearJN = map.get("2");
// dataStyle.setAlignment(HorizontalAlignment.CENTER); List<Map<String,Object>> lastYearHZ = map.get("3");
// dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); List<Map<String,Object>> lastYearJN = map.get("4");
// dataStyle.setBorderRight(BorderStyle.THIN);
// dataStyle.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿
// dataStyle.setBorderLeft(BorderStyle.THIN); Sheet sheet = workbook.createSheet("全路段双向实时车流量"); // 创建工作表
// dataStyle.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
// dataStyle.setBorderTop(BorderStyle.THIN); // 创建数据行样式
// dataStyle.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); CellStyle dataStyle = workbook.createCellStyle();
// dataStyle.setBorderBottom(BorderStyle.THIN); dataStyle.setAlignment(HorizontalAlignment.CENTER);
// dataStyle.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// Font dataFont = workbook.createFont(); dataStyle.setBorderRight(BorderStyle.THIN);
// dataFont.setFontName("Arial"); dataStyle.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
// dataFont.setFontHeightInPoints((short) 10); dataStyle.setBorderLeft(BorderStyle.THIN);
// dataStyle.setFont(dataFont); dataStyle.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
// dataStyle.setBorderTop(BorderStyle.THIN);
// // 创建表头样式 dataStyle.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
// CellStyle headerStyle = workbook.createCellStyle(); dataStyle.setBorderBottom(BorderStyle.THIN);
// headerStyle.cloneStyleFrom(dataStyle); dataStyle.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
// headerStyle.setAlignment(HorizontalAlignment.CENTER); Font dataFont = workbook.createFont();
// headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); dataFont.setFontName("Arial");
// headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); dataFont.setFontHeightInPoints((short) 10);
// headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); dataStyle.setFont(dataFont);
// Font headerFont = workbook.createFont();
// headerFont.setFontName("Arial"); // 创建表头样式
// headerFont.setFontHeightInPoints((short) 10); CellStyle headerStyle = workbook.createCellStyle();
// headerFont.setBold(true); headerStyle.cloneStyleFrom(dataStyle);
// headerFont.setColor(IndexedColors.WHITE.getIndex()); headerStyle.setAlignment(HorizontalAlignment.CENTER);
// headerStyle.setFont(headerFont); headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
// // 添加第一层级表头 headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// Row row = sheet.createRow(0); Font headerFont = workbook.createFont();
// Cell cell = row.createCell(0); headerFont.setFontName("Arial");
// cell.setCellValue("路段名称"); headerFont.setFontHeightInPoints((short) 10);
// cell.setCellStyle(headerStyle); headerFont.setBold(true);
// cell = row.createCell(1); headerFont.setColor(IndexedColors.WHITE.getIndex());
// cell.setCellValue("济南方向"); headerStyle.setFont(headerFont);
// cell.setCellStyle(headerStyle);
// cell = row.createCell(2); // 添加第一层级表头
// cell.setCellValue(""); Row row = sheet.createRow(0);
// cell.setCellStyle(headerStyle);; Cell cell = row.createCell(0);
// cell = row.createCell(3); cell.setCellValue("路段名称");
// cell.setCellValue("菏泽方向"); cell.setCellStyle(headerStyle);
// cell.setCellStyle(headerStyle); cell = row.createCell(1);
// cell = row.createCell(4); cell.setCellValue("济南方向");
// cell.setCellValue(""); cell.setCellStyle(headerStyle);
// cell.setCellStyle(headerStyle); cell = row.createCell(2);
// cell.setCellValue("");
// // 添加第二层级表头(与第一层级对齐) cell.setCellStyle(headerStyle);;
// Row subHeaderRow1 = sheet.createRow(1); cell = row.createCell(3);
// cell = subHeaderRow1.createCell(0); cell.setCellValue("菏泽方向");
// cell.setCellValue(""); cell.setCellStyle(headerStyle);
// cell.setCellStyle(headerStyle); cell = row.createCell(4);
// cell = subHeaderRow1.createCell(1); cell.setCellValue("");
// cell.setCellValue("本期车流量"); cell.setCellStyle(headerStyle);
// cell.setCellStyle(headerStyle);
// // 添加第二层级表头(与第一层级对齐)
// cell = subHeaderRow1.createCell(2); Row subHeaderRow1 = sheet.createRow(1);
// cell.setCellValue("去年同期"); cell = subHeaderRow1.createCell(0);
// cell.setCellStyle(headerStyle); cell.setCellValue("");
// cell = subHeaderRow1.createCell(3); cell.setCellStyle(headerStyle);
// cell.setCellValue("本期车流量"); cell = subHeaderRow1.createCell(1);
// cell.setCellStyle(headerStyle); cell.setCellValue("本期车流量");
// cell.setCellStyle(headerStyle);
// cell = subHeaderRow1.createCell(4);
// cell.setCellValue("去年同期"); cell = subHeaderRow1.createCell(2);
// cell.setCellStyle(headerStyle); cell.setCellValue("去年同期");
// cell.setCellStyle(headerStyle);
// //合并单元格,参数依次为起始行,结束行,起始列,结束列 (从0开始) cell = subHeaderRow1.createCell(3);
// //路段名称 cell.setCellValue("本期车流量");
// sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); cell.setCellStyle(headerStyle);
// //济南方向
// sheet.addMergedRegion(new CellRangeAddress(0, 0, 1, 2)); cell = subHeaderRow1.createCell(4);
// //菏泽方向 cell.setCellValue("去年同期");
// sheet.addMergedRegion(new CellRangeAddress(0, 0, 3, 4)); cell.setCellStyle(headerStyle);
//
// for (int i = 0; i < thisYearHZ.size(); i++) { //合并单元格,参数依次为起始行,结束行,起始列,结束列 (从0开始)
// Row subHeaderRow = sheet.createRow(i+2); //路段名称
// cell = subHeaderRow.createCell(0); sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
// cell.setCellValue(thisYearJN.get(i).get("name").toString()); //济南方向
// cell.setCellStyle(dataStyle); sheet.addMergedRegion(new CellRangeAddress(0, 0, 1, 2));
// cell = subHeaderRow.createCell(1); //菏泽方向
// cell.setCellValue(thisYearJN.get(i).get("totalFlow").toString()); sheet.addMergedRegion(new CellRangeAddress(0, 0, 3, 4));
// cell.setCellStyle(dataStyle);
// cell = subHeaderRow.createCell(2); for (int i = 0; i < thisYearHZ.size(); i++) {
// cell.setCellValue(lastYearJN.get(i).get("totalFlow").toString()); Row subHeaderRow = sheet.createRow(i+2);
// cell.setCellStyle(dataStyle); cell = subHeaderRow.createCell(0);
// cell = subHeaderRow.createCell(3); cell.setCellValue(thisYearJN.get(i).get("name").toString());
// cell.setCellValue(thisYearHZ.get(i).get("totalFlow").toString()); cell.setCellStyle(dataStyle);
// cell.setCellStyle(dataStyle); cell = subHeaderRow.createCell(1);
// cell = subHeaderRow.createCell(4); cell.setCellValue(thisYearJN.get(i).get("totalFlow").toString());
// cell.setCellValue(lastYearHZ.get(i).get("totalFlow").toString()); cell.setCellStyle(dataStyle);
// cell.setCellStyle(dataStyle); cell = subHeaderRow.createCell(2);
// } cell.setCellValue(lastYearJN.get(i).get("totalFlow").toString());
// cell.setCellStyle(dataStyle);
// cell = subHeaderRow.createCell(3);
// // 写入文件 cell.setCellValue(thisYearHZ.get(i).get("totalFlow").toString());
// try { cell.setCellStyle(dataStyle);
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); cell = subHeaderRow.createCell(4);
// response.setCharacterEncoding("utf-8"); cell.setCellValue(lastYearHZ.get(i).get("totalFlow").toString());
// workbook.write(response.getOutputStream()); cell.setCellStyle(dataStyle);
// } finally { }
// workbook.close();
// }
// // 写入文件
// return AjaxResult.success("导出感知事件多发时段成功"); try (ServletOutputStream outputStream = response.getOutputStream()){
// } workbook.write(outputStream);
} finally {
workbook.close();
}
}
}
} }
Loading…
Cancel
Save