Commit 728f850f authored by duanruiming's avatar duanruiming

[update] 微观大数据平台-Excel导出优化

parent bdf0aae0
......@@ -58,6 +58,15 @@ public class BaseCrossInfoCache implements CommandLineRunner {
return isSignalCrossIdList;
}
public String getCrossName(String crossId) {
for (BaseCrossInfoPO baseCrossInfoPO : crossInfoList) {
if (StringUtils.equals(crossId, baseCrossInfoPO.getId())) {
return baseCrossInfoPO.getName();
}
}
return "";
}
@Override
public void run(String... args) throws Exception {
init();
......
......@@ -22,6 +22,7 @@ import net.wanji.databus.po.*;
import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.GreenwaveListVO;
import net.wanji.opt.bo.*;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.common.ExcelExportUtils;
import net.wanji.opt.common.RedisUtils;
import net.wanji.opt.config.DirectionMappingsConfig;
......@@ -111,6 +112,7 @@ public class TrendServiceImpl implements TrendService {
private final RunningEvaluateServiceImpl runningEvaluateService;
private final AnalysisRidTurnIndicatorsMapper ridTurnIndicatorsMapper;
private final HoloEventMapper holoEventMapper;
private final BaseCrossInfoCache crossInfoCache;
// 用于计算路口状态,key为方向,value为状态
private Map<Integer, Integer> preStatus = new HashMap<Integer, Integer>() {{
......@@ -141,7 +143,8 @@ public class TrendServiceImpl implements TrendService {
RidInfoMapper ridInfoMapper, BaseCrossDirInfoMapper baseCrossDirInfoMapper,
CrossSchemeOptLogMapper crossSchemeOptLogMapper, GreenwaveCrossMapper greenwaveCrossMapper, CrossDirDataRealtimeMapper crossDirDataRealtimeMapper, GreenwaveHistMapper greenwaveHistMapper, GreenwaveRealtimeMapper greenwaveRealtimeMapper, SceneStrategyIdeaMapper strategyIdeaMapper, StrategyMapper strategyMapper, BaseCrossSchedulesMapper baseCrossSchedulesMapper, BaseCrossSchedulesPlanMapper baseCrossSchedulesPlanMapper, BaseCrossSectionMapper baseCrossSectionMapper, BaseCrossSchemeMapper crossSchemeMapper, BaseCrossSchemeMapper baseCrossSchemeMapper, BaseCrossPhaseMapper baseCrossPhaseMapper, BaseCrossPhaseLightsMapper crossPhaseLightsMapper, BaseCrossLaneLightsMapper baseCrossLaneLightsMapper, CrossBaseLaneInfoMapper crossBaseLaneInfoMapper, CrossTurnDataHistMapper crossTurnDataHistMapper, @Qualifier("greenwaveSceneMapper") GreenwaveSceneMapper greenwaveSceneMapper, @Qualifier("sceneStrategyMapper") SceneStrategyMapper sceneStrategyMapper, @Qualifier("sceneMapper") SceneMapper sceneMapper, @Qualifier("baseCrossPlanMapper") BaseCrossPlanMapper baseCrossPlanMapper, MainlineEvaluateServiceImpl mainlineEvaluateServiceImpl, CrossLaneDataHistMapper crossLaneDataHistMapper, LaneSnapshotDataQueryService laneSnapshotDataQueryService, DirectionMappingsConfig directionMappingsConfig,
CrossDataHistMapper crossDataHistMapper, RunningEvaluateServiceImpl runningEvaluateService,
AnalysisRidTurnIndicatorsMapper ridTurnIndicatorsMapper, HoloEventMapper holoEventMapper) {
AnalysisRidTurnIndicatorsMapper ridTurnIndicatorsMapper, HoloEventMapper holoEventMapper,
BaseCrossInfoCache crossInfoCache) {
this.greenwaveInfoMapper = greenwaveInfoMapper;
this.baseCrossInfoMapper = baseCrossInfoMapper;
this.crossDataRealtimeMapper = crossDataRealtimeMapper;
......@@ -177,6 +180,7 @@ public class TrendServiceImpl implements TrendService {
this.runningEvaluateService = runningEvaluateService;
this.ridTurnIndicatorsMapper = ridTurnIndicatorsMapper;
this.holoEventMapper = holoEventMapper;
this.crossInfoCache = crossInfoCache;
}
@Override
......@@ -1252,6 +1256,7 @@ public class TrendServiceImpl implements TrendService {
element.setTime(date);
element.setDir(dto.getDir());
element.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(dto.getDir()));
String laneId = dto.getLaneId();
String laneSort = laneId.substring(laneId.length() - 2);
......@@ -1362,7 +1367,6 @@ public class TrendServiceImpl implements TrendService {
if (po.getId().contains(crossId.concat(Constants.SystemParam.SEPARATOR_MINUS))) {
pedFlow += po.getFlow();
}
String laneId = po.getId();
Integer batchTime = po.getBatchTime();
// 将10位时间戳转换为毫秒
long millis = batchTime * 1000L;
......@@ -1371,6 +1375,7 @@ public class TrendServiceImpl implements TrendService {
vo.setTime(dateFromTimestamp);
vo.setDir(po.getDir());
vo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getDir()));
vo.setFlow(po.getFlow());
Double speed = po.getSpeed();
......@@ -2051,14 +2056,15 @@ public class TrendServiceImpl implements TrendService {
List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end);
List<TableQueryVO.CycleDataElement> dataList = buildCycleData(crossId, poExtList);
ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, "车道周期数据", TableQueryVO.CycleDataElement.class);
String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, crossName.concat("车道周期数据"), TableQueryVO.CycleDataElement.class);
}
@Override
public void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception {
String startStr = null;
String endStr = null;
List<TurnDataIndexExcelVO> result = null;
List<TurnDataIndexExcelVO> result = new ArrayList<>();
try {
String crossId = lanePeriodTurnVO.getCrossId();
Date startDate = lanePeriodTurnVO.getStart();
......@@ -2119,19 +2125,28 @@ public class TrendServiceImpl implements TrendService {
turnDataIndexExcelVO.setDir(BaseEnum.SignalDirectionEnum.getNameByCode(dir));
turnDataIndexExcelVO.setFlow(allFlow);
turnDataIndexExcelVO.setLeftFlow(leftFlow);
BigDecimal leftAverage = leftSpeed.divide(new BigDecimal(left), 2, RoundingMode.HALF_UP);
BigDecimal leftAverage = new BigDecimal(0);
if (left > 0) {
leftAverage = leftSpeed.divide(new BigDecimal(left), 2, RoundingMode.HALF_UP);
}
turnDataIndexExcelVO.setLeftSpeed(leftAverage);
if (leftFlow == 0) {
turnDataIndexExcelVO.setLeftSpeed(new BigDecimal(0));
}
turnDataIndexExcelVO.setStraightFlow(straightFlow);
BigDecimal straightAverage = straightSpeed.divide(new BigDecimal(straight), 2, RoundingMode.HALF_UP);
BigDecimal straightAverage = new BigDecimal(0);
if (straight > 0) {
straightAverage = straightSpeed.divide(new BigDecimal(straight), 2, RoundingMode.HALF_UP);
}
turnDataIndexExcelVO.setStraightSpeed(straightAverage);
if (straightFlow == 0) {
turnDataIndexExcelVO.setStraightSpeed(new BigDecimal(0));
}
turnDataIndexExcelVO.setRightFlow(rightFlow);
BigDecimal rightAverage = rightSpeed.divide(new BigDecimal(right), 2, RoundingMode.HALF_UP);
BigDecimal rightAverage = new BigDecimal(0);
if (right > 0) {
rightAverage = rightSpeed.divide(new BigDecimal(right), 2, RoundingMode.HALF_UP);
}
turnDataIndexExcelVO.setRightSpeed(rightAverage);
if (rightFlow == 0) {
turnDataIndexExcelVO.setRightSpeed(new BigDecimal(0));
......@@ -2142,16 +2157,17 @@ public class TrendServiceImpl implements TrendService {
}
}
}
String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, result, crossName.concat("转向周期数据"), TurnDataIndexExcelVO.class);
} catch (Exception e) {
log.error("导出转向数据异常:", e);
throw new RuntimeException(e);
}
ExcelExportUtils.exportExcel(response, startStr, endStr, result, "周期转向数据", TurnDataIndexExcelVO.class);
}
@Override
public void laneSnapshotExcel(LaneSnapshotIndexVO laneSnapshotIndexVO, HttpServletResponse response) throws Exception {
try {
String crossId = laneSnapshotIndexVO.getCrossId();
Date startDate = laneSnapshotIndexVO.getStart();
Date endDate = laneSnapshotIndexVO.getEnd();
......@@ -2169,7 +2185,12 @@ public class TrendServiceImpl implements TrendService {
if (!CollectionUtils.isEmpty(result)) {
dataList = result.stream().sorted(Comparator.comparing(TableQueryVO.RealTimeDataElement::getTime).reversed()).collect(Collectors.toList());
}
String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, crossName.concat("车道快照数据"), TableQueryVO.RealTimeDataElement.class);
} catch (Exception e) {
log.error("快照数据导出失败:", e);
throw new RuntimeException(e);
}
ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, "车道快照数据", TableQueryVO.RealTimeDataElement.class);
}
}
package net.wanji.opt.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
......@@ -34,14 +35,17 @@ public class TableQueryVO {
private Date time;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@ExcelProperty("方向")
@ExcelIgnore
private Integer dir;
@ExcelProperty("方向")
private String dirName;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
@ExcelProperty("车道号")
private String laneSort;
@ApiModelProperty(value = "车道编号")
@ExcelIgnore
private String laneId;
@ApiModelProperty(value = "排队长度")
......@@ -65,6 +69,7 @@ public class TableQueryVO {
private int carNums;
@ApiModelProperty(value = "空间密度车辆负荷比")
@ExcelIgnore
private double vehicleNumsRatio;
@ApiModelProperty(value = "空间密度(长度占比)")
......@@ -79,8 +84,8 @@ public class TableQueryVO {
@ExcelProperty("头车速度")
private double headSpeed;
@ApiModelProperty(value = "车速度")
@ExcelProperty("车速度")
@ApiModelProperty(value = "车速度")
@ExcelProperty("车速度")
private double mailSpeed;
@ApiModelProperty(value = "队首距离(米)")
......@@ -105,10 +110,14 @@ public class TableQueryVO {
private Date time;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@ExcelProperty("方向")
@ExcelIgnore
private Integer dir;
@ExcelProperty("方向")
private String dirName;
@ApiModelProperty(value = "车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n")
@ExcelIgnore
private Integer turn;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
......@@ -116,13 +125,9 @@ public class TableQueryVO {
private String laneSort;
@ApiModelProperty(value = "流量")
@ExcelProperty("流量")
@ExcelIgnore
private Integer flow;
@ApiModelProperty(value = "速度")
@ExcelProperty("速度")
private Integer speed;
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private Integer queueLength;
......@@ -144,31 +149,35 @@ public class TableQueryVO {
private Double vehheadDist;
@ApiModelProperty(value = "时间占有率")
@ExcelProperty("平均时间占有率")
private Integer timeOccupancy;
@ApiModelProperty(value = "空间占有率")
// 空间占有率即车辆负荷比
@ExcelProperty("空间占有率")
@ExcelProperty("平均空间占有率")
private Integer vehicleNumsRatioMean;
@ExcelProperty("85位速度")
private double v85;
@ApiModelProperty(value = "速度")
@ExcelProperty("平均速度")
private Integer speed;
@ExcelProperty("大车流量")
private Integer trafficFlowA;
@ExcelProperty("中车流量")
private Integer trafficFlowB;
@ExcelProperty("小车流量")
private Integer trafficFlowC;
@ExcelProperty("85速度")
private double v85;
@ApiModelProperty(value = "非机动车流量")
@ExcelProperty("非机动车流量")
private int nonMotorFlow;
@ApiModelProperty(value = "行人流量")
@ExcelProperty("行人流量")
private int pedFlow;
@ApiModelProperty(value = "总流量")
@ExcelProperty("总流量")
private int allFlow;
@ApiModelProperty(value = "车辆总和")
@ExcelProperty("车辆总和")
private int allVehiceleFlow;
@ApiModelProperty(value = "总流量")
@ExcelProperty("总流量")
private int allFlow;
}
}
......@@ -51,12 +51,12 @@ public class TurnDataIndexExcelVO {
@ExcelProperty("直行平均速度")
private BigDecimal straightSpeed;
@ApiModelProperty(value = "右转平均流量")
@ExcelProperty("右转平均流量")
@ApiModelProperty(value = "右转流量")
@ExcelProperty("右转流量")
private Integer rightFlow;
@ApiModelProperty(value = "右转速度")
@ExcelProperty("右转速度")
@ExcelProperty("右转平均速度")
private BigDecimal rightSpeed;
}
......@@ -104,7 +104,7 @@
<select id="selectByCrossIdAndTimeSpan" resultType="net.wanji.databus.po.CrossLaneDataHistPOExt">
SELECT t1.id, t2.dir,t2.turn, t2.sort, t1.flow, t1.speed, t1.queue_length, t1.delay_time, t1.stop_times,
t1.vehhead_time, t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean, t1.start_time,
t1.vehhead_time,t1.vehhead_dist, t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean, t1.start_time,
t1.traffic_flow_A, t1.traffic_flow_B, t1.traffic_flow_C,t1.v_85, t1.non_motor_flow, t1.time_occupancy
FROM t_lane_data_hist t1 JOIN t_base_lane_info t2 ON t1.id = t2.id
where t1.cross_id = #{crossId}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment