Browse Source

导出路段交通指标分析

develop
lau572 5 months ago
parent
commit
6df7aea122
  1. 76
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  2. 111
      zc-business/src/main/java/com/zc/business/domain/export/SectionTrafficIndexAnalysis.java

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

@ -10,10 +10,8 @@ import com.ruoyi.common.utils.StakeMarkUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.*;
import com.zc.business.domain.export.ManyTimesInterval;
import com.zc.business.domain.export.RealTimeTrafficFlow;
import com.zc.business.domain.export.SectionTrafficRanking;
import com.zc.business.domain.export.TrafficPeriodAnalysis;
import com.zc.business.domain.export.*;
import com.zc.business.enums.StakeMarkRange;
import com.zc.business.request.DcTrafficMetricsDataRequest;
import com.zc.business.request.DcTrafficSectionDataRequest;
import com.zc.business.service.*;
@ -417,6 +415,76 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
// 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList);
}
@ApiOperation(value="导出路段交通指标分析",tags = {"ECharts导出"})
@GetMapping("/history/exportSectionTrafficIndexAnalysis")
public AjaxResult exportSectionTrafficIndexAnalysis(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){
List<SectionTrafficIndexAnalysis> list = new ArrayList<>();
String endDate = "";
if ("4".equals(periodType)){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期
LocalDate end = inputDate.minusYears(1);
endDate = end.format(formatter);
} else if ("3".equals(periodType)){
String[] parts = startDate.split("-");
int year = Integer.parseInt(parts[0]);
int month = Integer.parseInt(parts[1]);
// 计算一年前的年份和月份
year -= 1;
// 如果计算后月份为0,则调整为上一年的12月
if (month == 0) {
year -= 1;
month = 12;
}
endDate = String.format("%04d-%02d", year, month);
} else if ("1".equals(periodType)){
int year = Integer.parseInt(startDate) - 1;
endDate = String.valueOf(year);
}
List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking);
Map<String,List<Map<String, Object>>> thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString()));
List<Map<String, Object>> lastYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(endDate,direction,periodType,ranking);
Map<String,List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString()));
for (StakeMarkRange value : StakeMarkRange.values()) {
String sectionName = value.getDescription();
SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis();
sectionTrafficIndexAnalysis.setName(value.getDescription());
if (thisYearData.containsKey(sectionName)){
Map<String, Object> sectionData = thisYearData.get(sectionName).get(0);
sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString());
sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString());
sectionTrafficIndexAnalysis.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString());
} else {
sectionTrafficIndexAnalysis.setCrowdingRate("0");
sectionTrafficIndexAnalysis.setSaturationRate("0");
sectionTrafficIndexAnalysis.setTrafficCompositionRate("0");
}
if (lastYearData.containsKey(sectionName)){
Map<String, Object> sectionData = lastYearData.get(sectionName).get(0);
sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString());
sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString());
sectionTrafficIndexAnalysis.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString());
} else {
sectionTrafficIndexAnalysis.setCrowdingRateLastYear("0");
sectionTrafficIndexAnalysis.setSaturationRateLastYear("0");
sectionTrafficIndexAnalysis.setTrafficCompositionRateLastYear("0");
}
list.add(sectionTrafficIndexAnalysis);
}
ExcelUtil<SectionTrafficIndexAnalysis> util = new ExcelUtil<>(SectionTrafficIndexAnalysis.class);
util.exportExcel(response, list, "路段交通指标分析");
// 将查询结果封装为成功响应并返回
return AjaxResult.success("导出成功");
}
@ApiOperation("通指标时间分布")
@GetMapping("/history/passIndicatorTimeDistribution")
public AjaxResult passIndicatorTimeDistribution(String startDate, String direction,String periodType ){

111
zc-business/src/main/java/com/zc/business/domain/export/SectionTrafficIndexAnalysis.java

@ -0,0 +1,111 @@
package com.zc.business.domain.export;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 导出路段交通指标分析对象
*
* @author ruoyi
* @date 2024-01-13
*/
public class SectionTrafficIndexAnalysis extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 路段 */
@Excel(name = "路段")
private String name;
/** 饱和度 */
@Excel(name = "饱和度")
private String saturationRate;
/** 拥挤度 */
@Excel(name = "拥挤度")
private String crowdingRate;
/** 交通组成特征指数 */
@Excel(name = "交通组成特征指数")
private String trafficCompositionRate;
/** 饱和度去年同期 */
@Excel(name = "饱和度去年同期")
private String saturationRateLastYear;
/** 拥挤度去年同期 */
@Excel(name = "拥挤度去年同期")
private String crowdingRateLastYear;
/** 交通组成特征指数去年同期 */
@Excel(name = "交通组成特征指数去年同期")
private String trafficCompositionRateLastYear;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSaturationRate() {
return saturationRate;
}
public void setSaturationRate(String saturationRate) {
this.saturationRate = saturationRate;
}
public String getCrowdingRate() {
return crowdingRate;
}
public void setCrowdingRate(String crowdingRate) {
this.crowdingRate = crowdingRate;
}
public String getTrafficCompositionRate() {
return trafficCompositionRate;
}
public void setTrafficCompositionRate(String trafficCompositionRate) {
this.trafficCompositionRate = trafficCompositionRate;
}
public String getSaturationRateLastYear() {
return saturationRateLastYear;
}
public void setSaturationRateLastYear(String saturationRateLastYear) {
this.saturationRateLastYear = saturationRateLastYear;
}
public String getCrowdingRateLastYear() {
return crowdingRateLastYear;
}
public void setCrowdingRateLastYear(String crowdingRateLastYear) {
this.crowdingRateLastYear = crowdingRateLastYear;
}
public String getTrafficCompositionRateLastYear() {
return trafficCompositionRateLastYear;
}
public void setTrafficCompositionRateLastYear(String trafficCompositionRateLastYear) {
this.trafficCompositionRateLastYear = trafficCompositionRateLastYear;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("name", getName())
.append("saturationRate", getSaturationRate())
.append("crowdingRate", getCrowdingRate())
.append("trafficCompositionRate", getTrafficCompositionRate())
.append("saturationRateLastYear", getSaturationRateLastYear())
.append("crowdingRateLastYear", getCrowdingRateLastYear())
.append("trafficCompositionRateLastYear", getTrafficCompositionRateLastYear())
.toString();
}
}
Loading…
Cancel
Save