Commit bc8d9c28 authored by duwei's avatar duwei

指标导出接口开发

parent ffb125e1
...@@ -418,22 +418,64 @@ public class TrendController { ...@@ -418,22 +418,64 @@ public class TrendController {
} }
@ApiOperation(value = "周期导出功能", notes = "周期导出功能") /**
* 周期车道数据导出
* @param lanePeriodVO
* @param response
* @throws Exception
*/
@ApiOperation(value = "周期车道数据导出功能", notes = "周期导出功能")
@PostMapping(value = "/periodExcel") @PostMapping(value = "/periodExcel")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class), @ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class),
}) })
public void periodExcel(@RequestBody CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception { public void periodLaneExcel(@RequestBody LanePeriodVO lanePeriodVO, HttpServletResponse response) throws Exception {
trendService.periodExcel(crossIdDateTimeVO, response); trendService.periodLaneExcel(lanePeriodVO, response);
} }
/**
* 周期转向数据导出
* @param periodTurnVO
* @param response
* @throws Exception
*/
@ApiOperation(value = "周期转向数据导出功能", notes = "周期转向数据导出功能") @ApiOperation(value = "周期转向数据导出功能", notes = "周期转向数据导出功能")
@PostMapping(value = "/periodTurnExcel") @PostMapping(value = "/periodTurnExcel")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class), @ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class),
}) })
public void periodTurnExcel(@RequestBody LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception { public void periodTurnExcel(@RequestBody LanePeriodTurnVO periodTurnVO, HttpServletResponse response) throws Exception {
trendService.periodTurnExcel(lanePeriodTurnVO, response); trendService.periodTurnExcel(periodTurnVO, response);
}
/**
* 周期方向数据导出
* @param directionVO
* @param response
* @throws Exception
*/
@ApiOperation(value = "周期方向数据导出功能", notes = "周期转向数据导出功能")
@PostMapping(value = "/periodDirExcel")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class),
})
public void directionExcel(@RequestBody PeriodDirectionVO directionVO, HttpServletResponse response) throws Exception {
trendService.periodDirectionExcel(directionVO, response);
}
/**
* 周期路口数据导出
* @param crossingVO
* @param response
* @throws Exception
*/
@ApiOperation(value = "周期路口数据导出功能", notes = "周期转向数据导出功能")
@PostMapping(value = "/periodCrossExcel")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = HttpServletResponse.class),
})
public void crossExcel(@RequestBody PeriodCrossingVO crossingVO, HttpServletResponse response) throws Exception {
trendService.periodCrossExcel(crossingVO, response);
} }
@ApiOperation(value = "车道快照数据导出功能", notes = "车道快照数据导出功能") @ApiOperation(value = "车道快照数据导出功能", notes = "车道快照数据导出功能")
......
...@@ -89,9 +89,21 @@ public interface TrendService { ...@@ -89,9 +89,21 @@ public interface TrendService {
List<LaneIdAliasNameVO> laneIdList(CommonCrossIdVO commonCrossIdVO) throws Exception; List<LaneIdAliasNameVO> laneIdList(CommonCrossIdVO commonCrossIdVO) throws Exception;
void periodExcel(CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception; // void periodExcel(CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception;
void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception; void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception;
/**
* 周期方向数据导出
* @param turnVO
* @param response
*/
void periodDirectionExcel(PeriodDirectionVO turnVO, HttpServletResponse response);
/**
* 周期路口数据导出
* @param turnVO
* @param response
*/
void periodCrossExcel(PeriodCrossingVO turnVO, HttpServletResponse response);
void laneSnapshotExcel(LaneSnapshotIndexVO laneSnapshotIndexVO, HttpServletResponse response) throws Exception; void laneSnapshotExcel(LaneSnapshotIndexVO laneSnapshotIndexVO, HttpServletResponse response) throws Exception;
} }
...@@ -2921,26 +2921,49 @@ public class TrendServiceImpl implements TrendService { ...@@ -2921,26 +2921,49 @@ public class TrendServiceImpl implements TrendService {
} }
} }
@Override /**
public void periodExcel(CommonCrossIdDateTimeVO crossIdDateTimeVO, HttpServletResponse response) throws Exception { * 周期车道数据导出
String crossId = crossIdDateTimeVO.getCrossId(); * @param lanePeriodVO
Date startDate = crossIdDateTimeVO.getStart(); * @param response
Date endDate = crossIdDateTimeVO.getEnd(); * @throws Exception
String startStr = DateUtil.format(startDate, DateStyle.YYYY_MM_DD_HH_MM.getValue()); */
String endStr = DateUtil.format(endDate, DateStyle.MM_DD_HH_MM.getValue()); public void periodLaneExcel(LanePeriodVO lanePeriodVO, HttpServletResponse response) throws Exception {
int start = (int) (startDate.getTime() / 1000); String crossId = lanePeriodVO.getCrossId();
int end = (int) (endDate.getTime() / 1000); int start = (int) (lanePeriodVO.getStart().getTime() / 1000);
int end = (int) (lanePeriodVO.getEnd().getTime() / 1000);
String startStr = DateUtil.format(lanePeriodVO.getStart(), DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(lanePeriodVO.getEnd(), DateStyle.MM_DD_HH_MM.getValue());
String ids = lanePeriodVO.getIds();
List<String> idsList = null;
if (!StringUtils.isBlank(ids)) {
idsList = Arrays.asList(ids.split(","));
}
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = lanePeriodVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5";
}else {
granularity = granularity.replace("m", "").replace("h", "");
}
// 查询周期数据 // 查询周期数据
List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end); List<CrossLaneDataHistVOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeIds(crossId, start, end, granularity, idsList);
List<TableQueryVO.CycleDataElement> dataList = buildCycleData(crossId, poExtList); List<TableQueryVO.CycleDataElement> dataList = buildLaneCycleData(crossId, poExtList);
String crossName = crossInfoCache.getCrossName(crossId); String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, crossName.concat("车道周期数据"), TableQueryVO.CycleDataElement.class); ExcelExportUtils.exportExcel(response, startStr, endStr, dataList, crossName.concat("车道周期数据"), TableQueryVO.CycleDataElement.class);
} }
/**
* 周期转向数据导出
* @param turnVO
* @param response
* @throws Exception
*/
@Override @Override
public void periodTurnExcel(LanePeriodTurnVO lanePeriodTurnVO, HttpServletResponse response) throws Exception { public void periodTurnExcel(LanePeriodTurnVO turnVO, HttpServletResponse response) throws Exception {
/*
String startStr = null; String startStr = null;
String endStr = null; String endStr = null;
List<TurnDataIndexExcelVO> result = new ArrayList<>(); List<TurnDataIndexExcelVO> result = new ArrayList<>();
...@@ -3036,14 +3059,120 @@ public class TrendServiceImpl implements TrendService { ...@@ -3036,14 +3059,120 @@ public class TrendServiceImpl implements TrendService {
} }
} }
} }
*/
try{
//路口
String crossId = turnVO.getCrossId();
int start = (int) (turnVO.getStart().getTime() / 1000);
int end = (int) (turnVO.getEnd().getTime() / 1000);
String startStr = DateUtil.format(turnVO.getStart(), DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(turnVO.getEnd(), DateStyle.MM_DD_HH_MM.getValue());
//转向 用逗号分隔
String turnType = turnVO.getTurnType();
List<String> turnTypeList = null;
if (!StringUtils.isBlank(turnType)) {
turnTypeList = Arrays.asList(turnType.split(","));
}
//驶入方向 用逗号分隔
String inDir = turnVO.getInDir();
List<Integer> inDirList = null;
if (!StringUtils.isBlank(inDir)) {
inDirList = Arrays.stream(inDir.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = turnVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5";
}else {
granularity = granularity.replace("m", "").replace("h", "");;
}
// 查询周期数据
List<CrossTurnDataHistVO> vo = crossTurnDataHistMapper.selectByCrossIdTurn(crossId, start, end, granularity, turnTypeList, inDirList);
List<CrossingTurnQueryVO.CycleDataElement> result = buildCrossingTurnCycleData(crossId, vo);
String crossName = crossInfoCache.getCrossName(crossId); String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, result, crossName.concat("转向周期数据"), TurnDataIndexExcelVO.class); ExcelExportUtils.exportExcel(response, startStr, endStr, result, crossName.concat("转向周期数据"), CrossingTurnQueryVO.CycleDataElement.class);
} catch (Exception e) { } catch (Exception e) {
log.error("导出转向数据异常:", e); log.error("导出转向数据异常:", e);
throw new OptServiceException(e); throw new OptServiceException(e);
} }
} }
/**
* 周期方向数据导出
* @param directionVO
* @param response
* @throws Exception
*/
@Override
public void periodDirectionExcel(PeriodDirectionVO directionVO, HttpServletResponse response) {
try{
//路口
String crossId = directionVO.getCrossId();
int start = (int) (directionVO.getStart().getTime() / 1000);
int end = (int) (directionVO.getEnd().getTime() / 1000);
String startStr = DateUtil.format(directionVO.getStart(), DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(directionVO.getEnd(), DateStyle.MM_DD_HH_MM.getValue());
//方向
String dirType = directionVO.getDirection();
List<Integer> dirTypeList = null;
if (!StringUtils.isBlank(dirType)) {
dirTypeList = Arrays.stream(dirType.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = directionVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5";
}else {
granularity = granularity.replace("m", "").replace("h", "");;
}
// 查询周期数据
List<CrossDirDataHistVO> vo = crossDirDataHistMapper.selectByCrossIdAndStartEndDir(crossId, start, end, dirTypeList, granularity);
List<CrossingDirectionQueryVO.CycleDataElement> result = buildCrossingDirectionCycleData(crossId, vo);
String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, result, crossName.concat("方向周期数据"), CrossingDirectionQueryVO.CycleDataElement.class);
} catch (Exception e) {
log.error("导出方向数据异常:", e);
throw new OptServiceException(e);
}
}
/**
* 周期路口数据导出
* @param crossingVO
* @param response
* @throws Exception
*/
@Override
public void periodCrossExcel(PeriodCrossingVO crossingVO, HttpServletResponse response) {
try{
String crossId = crossingVO.getCrossId();
int start = (int) (crossingVO.getStart().getTime() / 1000);
int end = (int) (crossingVO.getEnd().getTime() / 1000);
String startStr = DateUtil.format(crossingVO.getStart(), DateStyle.YYYY_MM_DD_HH_MM.getValue());
String endStr = DateUtil.format(crossingVO.getEnd(), DateStyle.MM_DD_HH_MM.getValue());
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = crossingVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5";
}else {
granularity = granularity.replace("m", "").replace("h", "");
}
// 查询周期数据
List<CrossDataHistVO> vo = crossDataHistMapper.selectByCrossIdAndStartEndStat(crossId, start, end, granularity);
List<CrossingQueryVO.CycleDataElement> result = buildCrossingCycleData(crossId, vo);
String crossName = crossInfoCache.getCrossName(crossId);
ExcelExportUtils.exportExcel(response, startStr, endStr, result, crossName.concat("路口周期数据"), CrossingQueryVO.CycleDataElement.class);
} catch (Exception e) {
log.error("导出路口数据异常:", e);
throw new OptServiceException(e);
}
}
@Override @Override
public void laneSnapshotExcel(LaneSnapshotIndexVO laneSnapshotIndexVO, HttpServletResponse response) throws Exception { public void laneSnapshotExcel(LaneSnapshotIndexVO laneSnapshotIndexVO, HttpServletResponse response) throws Exception {
try { try {
......
...@@ -23,6 +23,9 @@ public class CommonCrossIdDateTimeVO { ...@@ -23,6 +23,9 @@ public class CommonCrossIdDateTimeVO {
@ApiModelProperty(value = "路口ID") @ApiModelProperty(value = "路口ID")
@NotBlank(message = "路口编号不能为空") @NotBlank(message = "路口编号不能为空")
private String crossId; private String crossId;
@ApiModelProperty(value = "车道IDs")
@NotBlank(message = "车道ids不能为空")
private String ids;
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
@NotNull(message = "开始日期不能为空") @NotNull(message = "开始日期不能为空")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
......
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