|
@ -11,10 +11,7 @@ import com.ruoyi.common.utils.StakeMarkUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
import com.zc.business.domain.*; |
|
|
import com.zc.business.domain.*; |
|
|
import com.zc.business.domain.export.RealTimeTrafficFlow; |
|
|
import com.zc.business.domain.export.*; |
|
|
import com.zc.business.domain.export.SectionTrafficIndexAnalysis; |
|
|
|
|
|
import com.zc.business.domain.export.SectionTrafficRanking; |
|
|
|
|
|
import com.zc.business.domain.export.TrafficPeriodAnalysis; |
|
|
|
|
|
import com.zc.business.enums.StakeMarkRange; |
|
|
import com.zc.business.enums.StakeMarkRange; |
|
|
import com.zc.business.enums.UniversalEnum; |
|
|
import com.zc.business.enums.UniversalEnum; |
|
|
import com.zc.business.request.DcTrafficMetricsDataRequest; |
|
|
import com.zc.business.request.DcTrafficMetricsDataRequest; |
|
@ -32,9 +29,11 @@ import org.springframework.web.bind.annotation.*; |
|
|
import javax.servlet.ServletOutputStream; |
|
|
import javax.servlet.ServletOutputStream; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.function.Function; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -454,7 +453,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
String sectionName = value.getDescription(); |
|
|
String sectionName = value.getDescription(); |
|
|
SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis(); |
|
|
SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis(); |
|
|
sectionTrafficIndexAnalysis.setName(value.getDescription()); |
|
|
sectionTrafficIndexAnalysis.setName(value.getDescription()); |
|
|
if (thisYearData.containsKey(sectionName)){ |
|
|
if (thisYearData != null && thisYearData.containsKey(sectionName)){ |
|
|
Map<String, Object> sectionData = thisYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); |
|
|
Map<String, Object> sectionData = thisYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); |
|
|
sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString()); |
|
@ -465,7 +464,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
sectionTrafficIndexAnalysis.setTrafficCompositionRate(UniversalEnum.ZERO.getValue()); |
|
|
sectionTrafficIndexAnalysis.setTrafficCompositionRate(UniversalEnum.ZERO.getValue()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (lastYearData.containsKey(sectionName)){ |
|
|
if (lastYearData != null && lastYearData.containsKey(sectionName)){ |
|
|
Map<String, Object> sectionData = lastYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); |
|
|
Map<String, Object> sectionData = lastYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); |
|
|
sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); |
|
|
sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); |
|
@ -491,6 +490,73 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
// 将查询结果封装为成功响应并返回
|
|
|
// 将查询结果封装为成功响应并返回
|
|
|
return AjaxResult.success(mapList); |
|
|
return AjaxResult.success(mapList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value="导出交通指标时间分布",tags = {"ECharts导出"}) |
|
|
|
|
|
@GetMapping("/history/exportPassIndicatorTimeDistribution") |
|
|
|
|
|
public void exportPassIndicatorTimeDistribution(HttpServletResponse response,String startDate, String direction,String periodType){ |
|
|
|
|
|
List<PassIndicatorTimeDistribution> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
String endDate = UniversalEnum.EMPTY_STRING.getValue(); |
|
|
|
|
|
if (UniversalEnum.FOUR.getValue().equals(periodType)){ |
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); |
|
|
|
|
|
LocalDate inputDate = LocalDate.parse(startDate, formatter); |
|
|
|
|
|
// 获取一年前的日期
|
|
|
|
|
|
LocalDate end = inputDate.minusYears(1); |
|
|
|
|
|
endDate = end.format(formatter); |
|
|
|
|
|
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ |
|
|
|
|
|
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); |
|
|
|
|
|
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); |
|
|
|
|
|
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); |
|
|
|
|
|
|
|
|
|
|
|
// 计算一年前的年份和月份
|
|
|
|
|
|
year -= UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
// 如果计算后月份为0,则调整为上一年的12月
|
|
|
|
|
|
if (month == UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
year -= UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
month = UniversalEnum.TWELVE.getNumber(); |
|
|
|
|
|
} |
|
|
|
|
|
endDate = String.format("%04d-%02d", year, month); |
|
|
|
|
|
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ |
|
|
|
|
|
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
endDate = String.valueOf(year); |
|
|
|
|
|
} |
|
|
|
|
|
List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); |
|
|
|
|
|
Map<String,List<Map<String, Object>>> thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); |
|
|
|
|
|
List<Map<String, Object>> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate,direction,periodType); |
|
|
|
|
|
Map<String,List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); |
|
|
|
|
|
|
|
|
|
|
|
Set<String> allKey = new HashSet<>(); |
|
|
|
|
|
if (thisYearData != null){ |
|
|
|
|
|
allKey.addAll(thisYearData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
if (lastYearData != null){ |
|
|
|
|
|
allKey.addAll(lastYearData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String key : allKey) { |
|
|
|
|
|
PassIndicatorTimeDistribution passIndicatorTimeDistribution = new PassIndicatorTimeDistribution(); |
|
|
|
|
|
passIndicatorTimeDistribution.setTime(key); |
|
|
|
|
|
if (thisYearData != null && thisYearData.containsKey(key)){ |
|
|
|
|
|
Map<String, Object> sectionData = thisYearData.get(key).get(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
passIndicatorTimeDistribution.setCrowdingRate(sectionData.get("crowdingRate").toString()); |
|
|
|
|
|
passIndicatorTimeDistribution.setSaturationRate(sectionData.get("saturationRate").toString()); |
|
|
|
|
|
passIndicatorTimeDistribution.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (lastYearData != null && lastYearData.containsKey(key)){ |
|
|
|
|
|
Map<String, Object> sectionData = lastYearData.get(key).get(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
passIndicatorTimeDistribution.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); |
|
|
|
|
|
passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); |
|
|
|
|
|
passIndicatorTimeDistribution.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString()); |
|
|
|
|
|
} |
|
|
|
|
|
list.add(passIndicatorTimeDistribution); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ExcelUtil<PassIndicatorTimeDistribution> util = new ExcelUtil<>(PassIndicatorTimeDistribution.class); |
|
|
|
|
|
util.exportExcel(response, list, "交通指标时间分布"); |
|
|
|
|
|
// 将查询结果封装为成功响应并返回
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ApiOperation("交通指标雷达图") |
|
|
@ApiOperation("交通指标雷达图") |
|
|
@GetMapping("/history/radarMapOfTrafficIndicators") |
|
|
@GetMapping("/history/radarMapOfTrafficIndicators") |
|
|
public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction,String periodType ){ |
|
|
public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction,String periodType ){ |
|
@ -498,6 +564,73 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
// 将查询结果封装为成功响应并返回
|
|
|
// 将查询结果封装为成功响应并返回
|
|
|
return AjaxResult.success(map); |
|
|
return AjaxResult.success(map); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value="导出交通指标雷达图",tags = {"ECharts导出"}) |
|
|
|
|
|
@GetMapping("/history/exportRadarMapOfTrafficIndicators") |
|
|
|
|
|
public void exportRadarMapOfTrafficIndicators(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){ |
|
|
|
|
|
List<RadarMapOfTrafficIndicators> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
String endDate = UniversalEnum.EMPTY_STRING.getValue(); |
|
|
|
|
|
if (UniversalEnum.FOUR.getValue().equals(periodType)){ |
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); |
|
|
|
|
|
LocalDate inputDate = LocalDate.parse(startDate, formatter); |
|
|
|
|
|
// 获取一年前的日期
|
|
|
|
|
|
LocalDate end = inputDate.minusYears(1); |
|
|
|
|
|
endDate = end.format(formatter); |
|
|
|
|
|
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ |
|
|
|
|
|
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); |
|
|
|
|
|
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); |
|
|
|
|
|
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); |
|
|
|
|
|
|
|
|
|
|
|
// 计算一年前的年份和月份
|
|
|
|
|
|
year -= UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
// 如果计算后月份为0,则调整为上一年的12月
|
|
|
|
|
|
if (month == UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
year -= UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
month = UniversalEnum.TWELVE.getNumber(); |
|
|
|
|
|
} |
|
|
|
|
|
endDate = String.format("%04d-%02d", year, month); |
|
|
|
|
|
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ |
|
|
|
|
|
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); |
|
|
|
|
|
endDate = String.valueOf(year); |
|
|
|
|
|
} |
|
|
|
|
|
Map<String, Object> map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate,direction,periodType); |
|
|
|
|
|
Map<String, Object> mapLastYear = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(endDate,direction,periodType); |
|
|
|
|
|
|
|
|
|
|
|
RadarMapOfTrafficIndicators radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); |
|
|
|
|
|
radarMapOfTrafficIndicators.setName("拥挤度"); |
|
|
|
|
|
radarMapOfTrafficIndicators.setCurrentData(map.get("crowdingRate").toString()); |
|
|
|
|
|
radarMapOfTrafficIndicators.setContemporaneousData(mapLastYear.get("crowdingRate").toString()); |
|
|
|
|
|
list.add(radarMapOfTrafficIndicators); |
|
|
|
|
|
|
|
|
|
|
|
radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); |
|
|
|
|
|
radarMapOfTrafficIndicators.setName("饱和度"); |
|
|
|
|
|
if (map.get("saturationRate") instanceof Double){ |
|
|
|
|
|
double saturationRate = (Double)map.get("saturationRate"); |
|
|
|
|
|
radarMapOfTrafficIndicators.setCurrentData(String.format("%.4f", saturationRate)); |
|
|
|
|
|
} else { |
|
|
|
|
|
radarMapOfTrafficIndicators.setCurrentData("0"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapLastYear.get("saturationRate") instanceof Double){ |
|
|
|
|
|
double saturationRate = (Double)mapLastYear.get("saturationRate"); |
|
|
|
|
|
radarMapOfTrafficIndicators.setContemporaneousData(String.format("%.4f", saturationRate)); |
|
|
|
|
|
} else { |
|
|
|
|
|
radarMapOfTrafficIndicators.setContemporaneousData("0"); |
|
|
|
|
|
} |
|
|
|
|
|
list.add(radarMapOfTrafficIndicators); |
|
|
|
|
|
|
|
|
|
|
|
radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); |
|
|
|
|
|
radarMapOfTrafficIndicators.setName("交通特征组成指数"); |
|
|
|
|
|
radarMapOfTrafficIndicators.setCurrentData(map.get("trafficCompositionRate").toString()); |
|
|
|
|
|
radarMapOfTrafficIndicators.setContemporaneousData(mapLastYear.get("trafficCompositionRate").toString()); |
|
|
|
|
|
list.add(radarMapOfTrafficIndicators); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExcelUtil<RadarMapOfTrafficIndicators> util = new ExcelUtil<>(RadarMapOfTrafficIndicators.class); |
|
|
|
|
|
util.exportExcel(response, list, "交通指标雷达图"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ApiOperation("综合指标查询") |
|
|
@ApiOperation("综合指标查询") |
|
|
@GetMapping("/history/comprehensiveIndexQuery") |
|
|
@GetMapping("/history/comprehensiveIndexQuery") |
|
|
public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery){ |
|
|
public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery){ |
|
@ -630,6 +763,182 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String |
|
|
return AjaxResult.success(jsonArray); |
|
|
return AjaxResult.success(jsonArray); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 导出收费站出入口实时车流量 |
|
|
|
|
|
*/ |
|
|
|
|
|
@ApiOperation(value = "导出收费站出入口实时车流量",tags = {"ECharts导出"}) |
|
|
|
|
|
@GetMapping("/history/exportTrafficFlowAtTollStationEntranceHour") |
|
|
|
|
|
public void exportTrafficFlowAtTollStationEntranceHour(HttpServletResponse response) throws IOException, HttpException { |
|
|
|
|
|
|
|
|
|
|
|
response.setContentType(UniversalEnum.DERIVE_THE_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_OF_THE_WHOLE_SECTION.getValue()); |
|
|
|
|
|
response.setCharacterEncoding(UniversalEnum.LOWERCASE_UTF_8.getValue()); |
|
|
|
|
|
String fileName = "收费站出入口实时车流量.xlsx"; |
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); |
|
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); |
|
|
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
|
|
String now = currentDate.format(formatter); |
|
|
|
|
|
|
|
|
|
|
|
// 获取一年前的日期
|
|
|
|
|
|
LocalDate oneYearAgo = currentDate.minusYears(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
String lastYear = oneYearAgo.format(formatter); |
|
|
|
|
|
|
|
|
|
|
|
Set<String> stationList = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 本期入口
|
|
|
|
|
|
List<Map<String, String>> thisYearEntrance = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "1"); |
|
|
|
|
|
Map<String,List<Map<String, String>>> thisYearEntranceData = new HashMap<>(); |
|
|
|
|
|
if (thisYearEntrance != null && thisYearEntrance.size() > 0){ |
|
|
|
|
|
thisYearEntranceData = thisYearEntrance.stream().collect(Collectors.groupingBy(item -> item.get("name"))); |
|
|
|
|
|
stationList.addAll(thisYearEntranceData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 本期出口
|
|
|
|
|
|
List<Map<String, String>> thisYearExport = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "2"); |
|
|
|
|
|
Map<String,List<Map<String, String>>> thisYearExportData = new HashMap<>(); |
|
|
|
|
|
if (thisYearExport != null && thisYearExport.size() > 0){ |
|
|
|
|
|
thisYearExportData = thisYearExport.stream().collect(Collectors.groupingBy(item -> item.get("name"))); |
|
|
|
|
|
stationList.addAll(thisYearExportData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 去年入口
|
|
|
|
|
|
List<Map<String, String>> lastYearEntrance = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(lastYear, lastYear, "1"); |
|
|
|
|
|
Map<String, List<Map<String, String>>> lastYearEntranceData = new HashMap<>(); |
|
|
|
|
|
if (lastYearEntrance != null && lastYearEntrance.size() > 0) { |
|
|
|
|
|
lastYearEntranceData = lastYearEntrance.stream().collect(Collectors.groupingBy(item -> item.get("name"))); |
|
|
|
|
|
stationList.addAll(lastYearEntranceData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 去年出口
|
|
|
|
|
|
List<Map<String, String>> lastYearExport = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(lastYear, lastYear, "2"); |
|
|
|
|
|
Map<String, List<Map<String, String>>> lastYearExportData = new HashMap<>(); |
|
|
|
|
|
if (lastYearExport != null && lastYearExport.size() > 0) { |
|
|
|
|
|
lastYearExportData = lastYearExport.stream().collect(Collectors.groupingBy(item -> item.get("name"))); |
|
|
|
|
|
stationList.addAll(lastYearExportData.keySet()); |
|
|
|
|
|
} |
|
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿
|
|
|
|
|
|
Sheet sheet = workbook.createSheet(UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue()); // 创建工作表
|
|
|
|
|
|
|
|
|
|
|
|
// 创建数据行样式
|
|
|
|
|
|
CellStyle dataStyle = workbook.createCellStyle(); |
|
|
|
|
|
dataStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
|
|
dataStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
|
|
dataStyle.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
|
|
|
|
|
dataStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
|
|
dataStyle.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
|
|
|
|
|
dataStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
|
|
dataStyle.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
|
|
|
|
|
dataStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
|
|
dataStyle.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
|
|
|
|
|
Font dataFont = workbook.createFont(); |
|
|
|
|
|
dataFont.setFontName(UniversalEnum.ARIAL.getValue()); |
|
|
|
|
|
dataFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); |
|
|
|
|
|
dataStyle.setFont(dataFont); |
|
|
|
|
|
|
|
|
|
|
|
// 创建表头样式
|
|
|
|
|
|
CellStyle headerStyle = workbook.createCellStyle(); |
|
|
|
|
|
headerStyle.cloneStyleFrom(dataStyle); |
|
|
|
|
|
headerStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
|
|
headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
|
|
|
|
|
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
|
Font headerFont = workbook.createFont(); |
|
|
|
|
|
headerFont.setFontName(UniversalEnum.ARIAL.getValue()); |
|
|
|
|
|
headerFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); |
|
|
|
|
|
headerFont.setBold(true); |
|
|
|
|
|
headerFont.setColor(IndexedColors.WHITE.getIndex()); |
|
|
|
|
|
headerStyle.setFont(headerFont); |
|
|
|
|
|
|
|
|
|
|
|
// 添加第一层级表头
|
|
|
|
|
|
Row row = sheet.createRow(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
Cell cell = row.createCell(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.TOLL_STATION.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
cell = row.createCell(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.ENTRANCE.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
cell = row.createCell(UniversalEnum.TWO.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle);; |
|
|
|
|
|
cell = row.createCell(UniversalEnum.THREE.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.EXIT.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
cell = row.createCell(UniversalEnum.FOUR.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
|
|
|
|
|
|
// 添加第二层级表头(与第一层级对齐)
|
|
|
|
|
|
Row subHeaderRow1 = sheet.createRow(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
cell = subHeaderRow1.createCell(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
cell = subHeaderRow1.createCell(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.CURRENT_TRAFFIC_FLOW.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
|
|
|
|
|
|
cell = subHeaderRow1.createCell(UniversalEnum.TWO.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.THE_SAME_PERIOD_LAST_YEAR.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
cell = subHeaderRow1.createCell(UniversalEnum.THREE.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.CURRENT_TRAFFIC_FLOW.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
|
|
|
|
|
|
cell = subHeaderRow1.createCell(UniversalEnum.FOUR.getNumber()); |
|
|
|
|
|
cell.setCellValue(UniversalEnum.THE_SAME_PERIOD_LAST_YEAR.getValue()); |
|
|
|
|
|
cell.setCellStyle(headerStyle); |
|
|
|
|
|
|
|
|
|
|
|
//合并单元格,参数依次为起始行,结束行,起始列,结束列 (从0开始)
|
|
|
|
|
|
//路段名称
|
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber())); |
|
|
|
|
|
//济南方向
|
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.TWO.getNumber())); |
|
|
|
|
|
//菏泽方向
|
|
|
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.THREE.getNumber(), UniversalEnum.FOUR.getNumber())); |
|
|
|
|
|
|
|
|
|
|
|
int i = 2; |
|
|
|
|
|
for (String station : stationList) { |
|
|
|
|
|
Row subHeaderRow = sheet.createRow(i); |
|
|
|
|
|
cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); |
|
|
|
|
|
cell.setCellValue(station); |
|
|
|
|
|
cell.setCellStyle(dataStyle); |
|
|
|
|
|
|
|
|
|
|
|
if (thisYearEntranceData.containsKey(station)){ |
|
|
|
|
|
cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
cell.setCellValue(thisYearEntranceData.get(station).get(0).get("value")); |
|
|
|
|
|
cell.setCellStyle(dataStyle); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (lastYearEntranceData.containsKey(station)){ |
|
|
|
|
|
cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); |
|
|
|
|
|
cell.setCellValue(lastYearEntranceData.get(station).get(0).get("value")); |
|
|
|
|
|
cell.setCellStyle(dataStyle); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (thisYearExportData.containsKey(station)){ |
|
|
|
|
|
cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); |
|
|
|
|
|
cell.setCellValue(thisYearExportData.get(station).get(0).get("value")); |
|
|
|
|
|
cell.setCellStyle(dataStyle); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (lastYearExportData.containsKey(station)){ |
|
|
|
|
|
cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); |
|
|
|
|
|
cell.setCellValue(lastYearExportData.get(station).get(0).get("value")); |
|
|
|
|
|
cell.setCellStyle(dataStyle); |
|
|
|
|
|
} |
|
|
|
|
|
i++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 写入文件
|
|
|
|
|
|
try (ServletOutputStream outputStream = response.getOutputStream()){ |
|
|
|
|
|
workbook.write(outputStream); |
|
|
|
|
|
} finally { |
|
|
|
|
|
workbook.close(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 各收费站入口分车型小时车流量 |
|
|
* 各收费站入口分车型小时车流量 |
|
|
*/ |
|
|
*/ |
|
@ -685,15 +994,6 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD |
|
|
String fileName = UniversalEnum.REAL_TIME_TRAFFIC_FLOW_IN_BOTH_DIRECTIONS_XLSX.name(); |
|
|
String fileName = UniversalEnum.REAL_TIME_TRAFFIC_FLOW_IN_BOTH_DIRECTIONS_XLSX.name(); |
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); |
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); |
|
|
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
|
|
|
String now = currentDate.format(formatter); |
|
|
|
|
|
|
|
|
|
|
|
// 获取一年前的日期
|
|
|
|
|
|
LocalDate oneYearAgo = currentDate.minusYears(UniversalEnum.ONE.getNumber()); |
|
|
|
|
|
String lastYear = oneYearAgo.format(formatter); |
|
|
|
|
|
|
|
|
|
|
|
Map<String,List<Map<String,Object>>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour(); |
|
|
Map<String,List<Map<String,Object>>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour(); |
|
|
if (map != null){ |
|
|
if (map != null){ |
|
|
List<Map<String,Object>> thisYearHZ = map.get(UniversalEnum.ONE.getValue()); |
|
|
List<Map<String,Object>> thisYearHZ = map.get(UniversalEnum.ONE.getValue()); |
|
|