Commit ecf74e26 authored by duanruiming's avatar duanruiming

[update] 微观大数据平台-周期excel导出

parent 23f93720
......@@ -19,6 +19,12 @@
</properties>
<dependencies>
<!-- easyexcel导出 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
......
......@@ -18,6 +18,7 @@ import net.wanji.opt.service.impl.TrendServiceImpl;
import net.wanji.opt.vo.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MediaType;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -339,4 +340,18 @@ public class TrendController {
List<LaneIdAliasNameVO> result = trendService.laneIdList(commonCrossIdVO);
return JsonViewObject.newInstance().success(result);
}
@ApiOperation(value = "周期导出功能", notes = "周期导出功能", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/periodExcel",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
})
public JsonViewObject periodExcel(@RequestBody CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception {
trendService.periodExcel(crossIdDateTimeVO, response);
return JsonViewObject.newInstance().success(null);
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ import net.wanji.opt.po.trend.AnalysisRidTurnIndicators;
import net.wanji.opt.po.trend.HoloEventInfoPO;
import net.wanji.opt.vo.*;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
......@@ -69,4 +70,6 @@ public interface TrendService {
List<HoloEventInfoPO> holoEvenList(HoloEventVO holoEventVO) throws Exception;
List<LaneIdAliasNameVO> laneIdList(CommonCrossIdVO commonCrossIdVO) throws Exception;
void periodExcel(CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception;
}
......@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -52,6 +53,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
......@@ -2031,4 +2033,27 @@ public class TrendServiceImpl implements TrendService {
throw new Exception(e);
}
}
@Override
public void periodExcel(CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception {
try {
String crossId = crossIdDateTimeVO.getCrossId();
Date startDate = crossIdDateTimeVO.getStart();
Date endDate = crossIdDateTimeVO.getEnd();
String startStr = DateUtil.format(startDate, DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(startDate, DateStyle.MM_DD_HH_MM.getValue());
int start = (int) (startDate.getTime() / 1000);
int end = (int) (endDate.getTime() / 1000);
String filePath = "/车道周期数据".concat(startStr).concat("-").concat(endStr);
// 查询周期数据
List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end);
List<TableQueryVO.CycleDataElement> cycleDataElements = buildCycleData(crossId, poExtList);
EasyExcel.write(response.getOutputStream(), TableQueryVO.CycleDataElement.class)
.sheet("车道周期数据")
.doWrite(cycleDataElements);
} catch (Exception e) {
log.error("车道数据查询异常:", e);
throw new RuntimeException(e);
}
}
}
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;
......@@ -85,55 +86,76 @@ public class TableQueryVO {
public static class CycleDataElement {
@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 Integer dir;
@ApiModelProperty(value = "车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n")
@ExcelProperty("转向")
private Integer turn;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
@ExcelProperty("车道号")
private String laneSort;
@ApiModelProperty(value = "流量")
@ExcelProperty("流量")
private Integer flow;
@ApiModelProperty(value = "速度")
@ExcelProperty("速度")
private Integer speed;
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private Integer queueLength;
@ApiModelProperty(value = "平均延误")
@ExcelProperty("平均延误")
private Integer delayTime ;
@ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
private Integer stopTimes;
@ApiModelProperty(value = "平均车头时距")
@ExcelProperty("平均车头时距")
private Integer vehheadTime;
@ApiModelProperty(value = "平均车头间距")
@ExcelProperty("平均车头间距")
private Double vehheadDist;
@ApiModelProperty(value = "时间占有率")
@ExcelProperty("时间占有率")
private Integer timeOccupancy;
@ApiModelProperty(value = "空间占有率")
// 空间占有率即车辆负荷比
@ExcelProperty("空间占有率")
private Integer vehicleNumsRatioMean;
@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;
}
}
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