Commit bdf0aae0 authored by duanruiming's avatar duanruiming

[update] 微观大数据平台-优化转向数据导出逻辑

parent 430c9b7f
package net.wanji.opt.po.trend; package net.wanji.opt.po.trend;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
...@@ -23,86 +22,66 @@ public class AnalysisRidTurnIndicators implements Serializable { ...@@ -23,86 +22,66 @@ public class AnalysisRidTurnIndicators implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键", hidden = true) @ApiModelProperty(value = "主键", hidden = true)
@ExcelProperty("唯一ID")
private Integer oid; private Integer oid;
@ApiModelProperty(value = "路口id") @ApiModelProperty(value = "路口id")
@ExcelProperty("路口编号")
private String crossId; private String crossId;
@ApiModelProperty(name = "fRid", value = "进口rid") @ApiModelProperty(name = "fRid", value = "进口rid")
@JsonProperty("fRid") @JsonProperty("fRid")
@ExcelProperty("进口编号")
private String fRid; private String fRid;
@ApiModelProperty(name = "fRidDir", value = "进口道方向 1北;2东北;3东;4东南;5南;6西南;7西;8西北") @ApiModelProperty(name = "fRidDir", value = "进口道方向 1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@JsonProperty("fRidDir") @JsonProperty("fRidDir")
@ExcelProperty("进口方向")
private Integer fRidDir; private Integer fRidDir;
@ApiModelProperty(value = "出口rid", hidden = true) @ApiModelProperty(value = "出口rid", hidden = true)
@JsonProperty("tRid") @JsonProperty("tRid")
@ExcelProperty("出口编号")
private String tRid; private String tRid;
@ApiModelProperty(value = "转向类型 根据进入、出口路段转向计算 1 左转 2 直行3右转 4 掉头") @ApiModelProperty(value = "转向类型 根据进入、出口路段转向计算 1 左转 2 直行3右转 4 掉头")
@ExcelProperty("转向类型")
private Integer turnDirNo; private Integer turnDirNo;
@ApiModelProperty(value = "交通流量") @ApiModelProperty(value = "交通流量")
@ExcelProperty("交通流量")
private Integer flow; private Integer flow;
@ApiModelProperty(value = "平均速度") @ApiModelProperty(value = "平均速度")
@ExcelProperty("平均速度")
private BigDecimal speed; private BigDecimal speed;
@ApiModelProperty(value = "排队长度") @ApiModelProperty(value = "排队长度")
@ExcelProperty("排队长度")
private Integer queueLength; private Integer queueLength;
@ApiModelProperty(value = "绿灯有效利用率") @ApiModelProperty(value = "绿灯有效利用率")
//@ExcelProperty("绿灯有效利用率%")
private BigDecimal greenUsageRate; private BigDecimal greenUsageRate;
@ApiModelProperty(value = "平均停车次数") @ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
private BigDecimal stopNum; private BigDecimal stopNum;
@ApiModelProperty(value = "一次停车率") @ApiModelProperty(value = "一次停车率")
@ExcelProperty("一次停车率%")
@JsonFormat() @JsonFormat()
private BigDecimal onceStopRate; private BigDecimal onceStopRate;
@ApiModelProperty(value = "二次停车率") @ApiModelProperty(value = "二次停车率")
@ExcelProperty("二次停车率%")
private BigDecimal secondStopRate; private BigDecimal secondStopRate;
@ApiModelProperty(value = "三次停车率") @ApiModelProperty(value = "三次停车率")
@ExcelProperty("三次停车率%")
private BigDecimal threeStopRate; private BigDecimal threeStopRate;
@ApiModelProperty(value = "不停车通过率") @ApiModelProperty(value = "不停车通过率")
@ExcelProperty("不停车通过率%")
private BigDecimal noStopRate; private BigDecimal noStopRate;
@ApiModelProperty(value = "交通状态") @ApiModelProperty(value = "交通状态")
@ExcelProperty("交通状态")
private String trafficState; private String trafficState;
@ApiModelProperty(value = "分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】", hidden = true) @ApiModelProperty(value = "分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】", hidden = true)
@ExcelProperty("时间粒度")
private String granularity; private String granularity;
@JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS") @JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS")
@ExcelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
private Date windowStartTime; private Date windowStartTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS") @JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
@ExcelProperty("结束时间")
private Date windowEndTime; private Date windowEndTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
@ExcelProperty("结束时间")
private Date ruksj; private Date ruksj;
} }
\ No newline at end of file
...@@ -2056,31 +2056,98 @@ public class TrendServiceImpl implements TrendService { ...@@ -2056,31 +2056,98 @@ public class TrendServiceImpl implements TrendService {
@Override @Override
public void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception { public void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception {
String startStr = null;
String endStr = null;
List<TurnDataIndexExcelVO> result = null;
try {
String crossId = lanePeriodTurnVO.getCrossId(); String crossId = lanePeriodTurnVO.getCrossId();
Date startDate = lanePeriodTurnVO.getStart(); Date startDate = lanePeriodTurnVO.getStart();
Date endDate = lanePeriodTurnVO.getEnd(); Date endDate = lanePeriodTurnVO.getEnd();
String startStr = DateUtil.format(startDate, DateStyle.YYYY_MM_DD_HH_MM.getValue()); startStr = DateUtil.format(startDate, DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(endDate, DateStyle.MM_DD_HH_MM.getValue()); endStr = DateUtil.format(endDate, DateStyle.MM_DD_HH_MM.getValue());
LambdaQueryWrapper<AnalysisRidTurnIndicators> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AnalysisRidTurnIndicators> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AnalysisRidTurnIndicators::getCrossId, crossId); queryWrapper.eq(AnalysisRidTurnIndicators::getCrossId, crossId);
queryWrapper.between(AnalysisRidTurnIndicators::getWindowStartTime, startDate, endDate); queryWrapper.between(AnalysisRidTurnIndicators::getWindowStartTime, startDate, endDate);
queryWrapper.orderByDesc(AnalysisRidTurnIndicators::getWindowStartTime); queryWrapper.orderByDesc(AnalysisRidTurnIndicators::getWindowStartTime);
List<AnalysisRidTurnIndicators> dataList = ridTurnIndicatorsMapper.selectList(queryWrapper); List<AnalysisRidTurnIndicators> dataList = ridTurnIndicatorsMapper.selectList(queryWrapper);
// 部分数据*100
BigDecimal offset = new BigDecimal("100"); result = new ArrayList<>();
List<AnalysisRidTurnIndicators> result = dataList.stream() Map<Date, List<AnalysisRidTurnIndicators>> timeMap = dataList.stream().collect(Collectors.groupingBy(AnalysisRidTurnIndicators::getWindowStartTime));
.map(item -> { for (Map.Entry<Date, List<AnalysisRidTurnIndicators>> dateListEntry : timeMap.entrySet()) {
// 假设有一个名为value的字段需要乘以100 Date time = dateListEntry.getKey();
item.setGreenUsageRate(item.getGreenUsageRate().multiply(offset)); List<AnalysisRidTurnIndicators> dateValueList = dateListEntry.getValue();
item.setOnceStopRate(item.getOnceStopRate().multiply(offset)); Map<Integer, List<AnalysisRidTurnIndicators>> dirList = dateValueList.stream().collect(Collectors.groupingBy(AnalysisRidTurnIndicators::getFRidDir));
item.setSecondStopRate(item.getSecondStopRate().multiply(offset)); for (Map.Entry<Integer, List<AnalysisRidTurnIndicators>> entry : dirList.entrySet()) {
item.setThreeStopRate(item.getThreeStopRate().multiply(offset)); Integer dir = entry.getKey();
item.setNoStopRate(item.getNoStopRate().multiply(offset)); List<AnalysisRidTurnIndicators> turnList = entry.getValue();
return item; if (!CollectionUtils.isEmpty(turnList)) {
}).collect(Collectors.toList()); int allFlow = 0;
int leftFlow = 0;
ExcelExportUtils.exportExcel(response, startStr, endStr, result, "周期转向数据", AnalysisRidTurnIndicators.class); int straightFlow = 0;
int rightFlow = 0;
int left = 0;
int straight = 0;
int right = 0;
BigDecimal leftSpeed = new BigDecimal(0);
BigDecimal straightSpeed = new BigDecimal(0);
BigDecimal rightSpeed = new BigDecimal(0);
TurnDataIndexExcelVO turnDataIndexExcelVO = new TurnDataIndexExcelVO();
for (AnalysisRidTurnIndicators analysisRidTurnIndicators : turnList) {
Integer turnDirNo = analysisRidTurnIndicators.getTurnDirNo();
time = analysisRidTurnIndicators.getWindowStartTime();
if (turnDirNo == 1) {
leftFlow += analysisRidTurnIndicators.getFlow();
leftSpeed = leftSpeed.add(analysisRidTurnIndicators.getSpeed());
++left;
}
if (turnDirNo == 2) {
straightFlow += analysisRidTurnIndicators.getFlow();
straightSpeed = straightSpeed.add(analysisRidTurnIndicators.getSpeed());
++straight;
}
if (turnDirNo == 3) {
rightFlow += analysisRidTurnIndicators.getFlow();
rightSpeed = straightSpeed.add(analysisRidTurnIndicators.getSpeed());
++right;
}
}
allFlow = leftFlow + straightFlow + rightFlow;
turnDataIndexExcelVO.setTime(time);
turnDataIndexExcelVO.setDir(BaseEnum.SignalDirectionEnum.getNameByCode(dir));
turnDataIndexExcelVO.setFlow(allFlow);
turnDataIndexExcelVO.setLeftFlow(leftFlow);
BigDecimal 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);
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);
turnDataIndexExcelVO.setRightSpeed(rightAverage);
if (rightFlow == 0) {
turnDataIndexExcelVO.setRightSpeed(new BigDecimal(0));
}
turnDataIndexExcelVO.setSpeed(leftAverage.add(straightAverage).add(rightAverage).divide(BigDecimal.valueOf(3), 2, RoundingMode.HALF_UP));
result.add(turnDataIndexExcelVO);
}
}
}
} catch (Exception e) {
log.error("导出转向数据异常:", e);
throw new RuntimeException(e);
}
ExcelExportUtils.exportExcel(response, startStr, endStr, result, "周期转向数据", TurnDataIndexExcelVO.class);
} }
@Override @Override
......
...@@ -42,7 +42,6 @@ public class TableQueryVO { ...@@ -42,7 +42,6 @@ public class TableQueryVO {
private String laneSort; private String laneSort;
@ApiModelProperty(value = "车道编号") @ApiModelProperty(value = "车道编号")
@ExcelProperty("车道编号")
private String laneId; private String laneId;
@ApiModelProperty(value = "排队长度") @ApiModelProperty(value = "排队长度")
...@@ -66,11 +65,10 @@ public class TableQueryVO { ...@@ -66,11 +65,10 @@ public class TableQueryVO {
private int carNums; private int carNums;
@ApiModelProperty(value = "空间密度车辆负荷比") @ApiModelProperty(value = "空间密度车辆负荷比")
@ExcelProperty("空间密度负荷比")
private double vehicleNumsRatio; private double vehicleNumsRatio;
@ApiModelProperty(value = "空间密度(长度占比)") @ApiModelProperty(value = "空间密度(长度占比)")
@ExcelProperty("空间密度长度占比") @ExcelProperty("车辆分布情况")
private double vehicleLengthRatio; private double vehicleLengthRatio;
@ApiModelProperty(value = "平均速度") @ApiModelProperty(value = "平均速度")
...@@ -94,7 +92,7 @@ public class TableQueryVO { ...@@ -94,7 +92,7 @@ public class TableQueryVO {
private double teamTailDistance; private double teamTailDistance;
@ApiModelProperty(value = "车头间距方差>车道内空间占有率") @ApiModelProperty(value = "车头间距方差>车道内空间占有率")
@ExcelProperty("车道内空间占有率") @ExcelProperty("空间占有率")
private double stdSpaceHeadway; private double stdSpaceHeadway;
} }
...@@ -111,7 +109,6 @@ public class TableQueryVO { ...@@ -111,7 +109,6 @@ public class TableQueryVO {
private Integer dir; private Integer dir;
@ApiModelProperty(value = "车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n") @ApiModelProperty(value = "车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n")
@ExcelProperty("转向")
private Integer turn; private Integer turn;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...") @ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
...@@ -143,11 +140,10 @@ public class TableQueryVO { ...@@ -143,11 +140,10 @@ public class TableQueryVO {
private Integer vehheadTime; private Integer vehheadTime;
@ApiModelProperty(value = "平均车头间距") @ApiModelProperty(value = "平均车头间距")
@ExcelProperty("平均车间距") @ExcelProperty("平均车间距")
private Double vehheadDist; private Double vehheadDist;
@ApiModelProperty(value = "时间占有率") @ApiModelProperty(value = "时间占有率")
@ExcelProperty("时间占有率")
private Integer timeOccupancy; private Integer timeOccupancy;
@ApiModelProperty(value = "空间占有率") @ApiModelProperty(value = "空间占有率")
......
package net.wanji.opt.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author duanruiming
* @date 2024/06/19 15:52
*/
@Data
@NoArgsConstructor
@ApiModel(value = "TurnDataIndexExcelVO", description = "转向数据导出实体")
public class TurnDataIndexExcelVO {
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("时间")
private Date time;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@ExcelProperty("方向")
private String dir;
@ApiModelProperty(value = "总流量")
@ExcelProperty("总流量")
private Integer flow;
@ApiModelProperty(value = "平均速度")
@ExcelProperty("平均速度")
private BigDecimal speed;
@ApiModelProperty(value = "左转流量")
@ExcelProperty("左转流量")
private Integer leftFlow;
@ApiModelProperty(value = "左转平均速度")
@ExcelProperty("左转平均速度")
private BigDecimal leftSpeed;
@ApiModelProperty(value = "直行流量")
@ExcelProperty("直行流量")
private Integer straightFlow;
@ApiModelProperty(value = "直行平均速度")
@ExcelProperty("直行平均速度")
private BigDecimal straightSpeed;
@ApiModelProperty(value = "右转平均流量")
@ExcelProperty("右转平均流量")
private Integer rightFlow;
@ApiModelProperty(value = "右转速度")
@ExcelProperty("右转速度")
private BigDecimal rightSpeed;
}
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