Browse Source

交通流预警,太阳能板数据保留两位小数

develop
王兴琳 6 months ago
parent
commit
4b7ec17866
  1. 13
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 384
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  3. 9
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

13
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -431,6 +431,8 @@ public class DcDeviceController extends BaseController {
Map<String, Double> deviceHourlyAggregates = new TreeMap<>(); Map<String, Double> deviceHourlyAggregates = new TreeMap<>();
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
DecimalFormat decimalFormat = new DecimalFormat("#.##");
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
// 处理每个数据点 // 处理每个数据点
for (Object o : dataArray) { for (Object o : dataArray) {
@ -452,9 +454,10 @@ public class DcDeviceController extends BaseController {
String key = String.format("%d-%02d-%02d %02d:00:00", String key = String.format("%d-%02d-%02d %02d:00:00",
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1,
calendar.get(Calendar.DAY_OF_MONTH), hour); calendar.get(Calendar.DAY_OF_MONTH), hour);
//转换为 double 类型,去除单位 //转换为 double 类型,去除单位
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", "");
double formatValue = Double.parseDouble(valueWithoutUnit); double formatValue = Double.parseDouble(decimalFormat.format(valueWithoutUnit));
// 汇总每个小时的数据 // 汇总每个小时的数据
deviceHourlyAggregates.merge(key, formatValue, Double::sum); deviceHourlyAggregates.merge(key, formatValue, Double::sum);
@ -489,7 +492,8 @@ public class DcDeviceController extends BaseController {
); );
List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameters); List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameters);
Map<String, Double> attributeMap = new HashMap<>(); Map<String, Double> attributeMap = new HashMap<>();
DecimalFormat decimalFormat = new DecimalFormat("#.##");
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
for (DcDevice dcDevice : dcDevices) { for (DcDevice dcDevice : dcDevices) {
String deviceId = dcDevice.getIotDeviceId(); String deviceId = dcDevice.getIotDeviceId();
for (String propertyId : propertyIds) { for (String propertyId : propertyIds) {
@ -501,13 +505,12 @@ public class DcDeviceController extends BaseController {
String property = data.get("property").getAsString(); String property = data.get("property").getAsString();
String formatValueStr = data.get("formatValue").getAsString(); String formatValueStr = data.get("formatValue").getAsString();
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", "");
double value = Double.parseDouble(valueWithoutUnit); double value = Double.parseDouble(decimalFormat.format(valueWithoutUnit));
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal);
} }
} }
} }
DecimalFormat decimalFormat = new DecimalFormat("#.##");
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
// 计算碳减排 碳减排(kg)=光伏发电量(kWh)*0.7119 // 计算碳减排 碳减排(kg)=光伏发电量(kWh)*0.7119
double carbonEmissionReduction = attributeMap.getOrDefault("theAccumulatedChargeOfTheYear", 0.0) * 0.7119; double carbonEmissionReduction = attributeMap.getOrDefault("theAccumulatedChargeOfTheYear", 0.0) * 0.7119;

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

@ -1,8 +1,6 @@
package com.zc.business.controller; package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -11,6 +9,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StakeMarkUtils; import com.ruoyi.common.utils.StakeMarkUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.zc.business.domain.*; import com.zc.business.domain.*;
import com.zc.business.domain.export.*; import com.zc.business.domain.export.*;
import com.zc.business.enums.LocationEnum; import com.zc.business.enums.LocationEnum;
@ -19,6 +18,7 @@ import com.zc.business.enums.UniversalEnum;
import com.zc.business.request.DcTrafficMetricsDataRequest; import com.zc.business.request.DcTrafficMetricsDataRequest;
import com.zc.business.request.DcTrafficSectionDataRequest; import com.zc.business.request.DcTrafficSectionDataRequest;
import com.zc.business.service.*; import com.zc.business.service.*;
import com.zc.business.service.impl.DcNoStakeWarningTableServiceImpl;
import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.exception.HttpException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -26,19 +26,19 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -47,7 +47,7 @@ import java.util.stream.Collectors;
* *
* @author xiepufeng * @author xiepufeng
*/ */
@Component
@Api(tags = "交通数据统计") @Api(tags = "交通数据统计")
@RestController @RestController
@RequestMapping("/business/traffic-statistics") @RequestMapping("/business/traffic-statistics")
@ -68,6 +68,63 @@ public class DcTrafficStatisticsController extends BaseController {
@Autowired @Autowired
private IDcGantryMetricsStatisticsDataService dcGantryMetricsStatisticsDataService; private IDcGantryMetricsStatisticsDataService dcGantryMetricsStatisticsDataService;
public void TrafficFlowAnomalies() throws HttpException {
IDcTrafficStatisticsService ben = SpringUtils.getBean(IDcTrafficStatisticsService.class);
DcNoStakeWarningTableServiceImpl dcNoStakeWarningTableService = SpringUtils.getBean(DcNoStakeWarningTableServiceImpl.class);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDate date = LocalDate.now();
// 获取一天的开始时间
LocalDateTime startOfDay = LocalDateTime.of(date, LocalTime.MIN);
// 获取一天的结束时间
LocalDateTime endOfDay = LocalDateTime.of(date, LocalTime.of(23, 59, 59));
// 格式化为字符串
String startOfDayStr = startOfDay.format(formatter);
String endOfDayStr = endOfDay.format(formatter);
JSONArray mapList = ben.exampleQueryTrafficFlowAnomalies(startOfDayStr, endOfDayStr);
mapList.forEach(item -> {
// 设置时区
ZoneId zoneId = ZoneId.of("Asia/Shanghai");
Map<String, Object> map = (Map<String, Object>) item;
long occur_time = (long) map.get("occur_time");
long end_time = (long) map.get("end_time");
// 创建一个SimpleDateFormat对象,定义你想要的日期格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 使用Date对象将时间戳转换为日期
Date date2 = new Date(occur_time);
Date date3 = new Date(end_time);
// 将Date对象格式化为字符串
String occurTime = sdf.format(date2);
String endTime = sdf.format(date3);
String stakeNum = (String) map.get("opma_stake_num");
int direction = (int) map.get("direction");
DcNoStakeWarningTable dcNoStakeWarningTable = new DcNoStakeWarningTable();
String description = direction == 1 ? "菏泽方向" : "济南方向";
dcNoStakeWarningTable.setWarningDescription(occurTime + " " + stakeNum + " " + description + "发生交通流异常事件");
dcNoStakeWarningTable.setWarningType("3");
Date warningTime = getDate(occurTime, formatter);// 获取开始时间
dcNoStakeWarningTable.setWarningTime(warningTime);
List<DcNoStakeWarningTable> dcNoStakeWarningTables = dcNoStakeWarningTableService.listDcNoStakeWarningTable(dcNoStakeWarningTable, getDate(endOfDayStr, formatter), getDate(startOfDayStr, formatter));
if (dcNoStakeWarningTables.isEmpty()) {
dcNoStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable);
}
});
}
private static Date getDate(String occurTime, DateTimeFormatter formatter) {
// 解析字符串为 LocalDateTime
LocalDateTime localDateTime = LocalDateTime.parse(occurTime, formatter);
// 转换为 Date 对象
Date warningTime = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
return warningTime;
}
/** /**
* 获取当前交通截面数据 * 获取当前交通截面数据
* *
@ -76,7 +133,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取当前交通截面数据") @ApiOperation("获取当前交通截面数据")
@GetMapping("/current/sections") @GetMapping("/current/sections")
public AjaxResult currentSections(DcTrafficSectionDataRequest request){ public AjaxResult currentSections(DcTrafficSectionDataRequest request) {
// 调用服务层方法,查询当前交通截面数据 // 调用服务层方法,查询当前交通截面数据
List<DcTrafficSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentSections(request); List<DcTrafficSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentSections(request);
// 将查询结果封装为AjaxResult对象返回 // 将查询结果封装为AjaxResult对象返回
@ -91,7 +148,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取历史交通截面数据") @ApiOperation("获取历史交通截面数据")
@GetMapping("/history/sections") @GetMapping("/history/sections")
public AjaxResult historySections(DcTrafficSectionDataRequest request){ public AjaxResult historySections(DcTrafficSectionDataRequest request) {
// 调用服务层方法,获取历史交通截面的统计数据 // 调用服务层方法,获取历史交通截面的统计数据
List<DcTrafficSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.historySections(request); List<DcTrafficSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.historySections(request);
// 将获取到的历史交通截面数据封装成AjaxResult对象并返回 // 将获取到的历史交通截面数据封装成AjaxResult对象并返回
@ -107,7 +164,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取当前交通特征指数") @ApiOperation("获取当前交通特征指数")
@GetMapping("/current/metrics") @GetMapping("/current/metrics")
public AjaxResult currentTrafficMetrics(DcTrafficMetricsDataRequest request){ public AjaxResult currentTrafficMetrics(DcTrafficMetricsDataRequest request) {
// 调用服务层方法,获取当前交通指标数据 // 调用服务层方法,获取当前交通指标数据
List<DcTrafficMetricsData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentTrafficMetrics(request); List<DcTrafficMetricsData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentTrafficMetrics(request);
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
@ -122,7 +179,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取历史交通特征指数") @ApiOperation("获取历史交通特征指数")
@GetMapping("/history/metrics") @GetMapping("/history/metrics")
public AjaxResult historyTrafficMetrics(DcTrafficMetricsDataRequest request){ public AjaxResult historyTrafficMetrics(DcTrafficMetricsDataRequest request) {
// 调用服务层方法,查询历史交通特征指数数据 // 调用服务层方法,查询历史交通特征指数数据
List<DcTrafficMetricsData> dcTrafficMetricsDataList = dcTrafficSectionStatisticsService.historyTrafficMetrics(request); List<DcTrafficMetricsData> dcTrafficMetricsDataList = dcTrafficSectionStatisticsService.historyTrafficMetrics(request);
// 将查询结果封装成成功响应并返回 // 将查询结果封装成成功响应并返回
@ -137,7 +194,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取当前拥堵路段") @ApiOperation("获取当前拥堵路段")
@GetMapping("/current/congested") @GetMapping("/current/congested")
public AjaxResult currentCongestedSection(Byte direction){ public AjaxResult currentCongestedSection(Byte direction) {
// 调用服务层方法,获取当前交通指标数据 // 调用服务层方法,获取当前交通指标数据
List<DcCongestedSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentCongestedSection(direction); List<DcCongestedSectionData> dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentCongestedSection(direction);
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
@ -153,7 +210,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取收费站统计数据") @ApiOperation("获取收费站统计数据")
@GetMapping("/history/toll-station") @GetMapping("/history/toll-station")
public AjaxResult historyTollStation(DcTollStationStatisticsData request){ public AjaxResult historyTollStation(DcTollStationStatisticsData request) {
// 调用服务层方法,根据请求条件查询历史车收费站数据 // 调用服务层方法,根据请求条件查询历史车收费站数据
List<DcTollStationStatisticsData> dcStatisticsData = dcTollStationStatisticsDataService.tollStationData(request); List<DcTollStationStatisticsData> dcStatisticsData = dcTollStationStatisticsDataService.tollStationData(request);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
@ -168,7 +225,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取累计车流量") @ApiOperation("获取累计车流量")
@GetMapping("/history/accumulated-flow") @GetMapping("/history/accumulated-flow")
public AjaxResult accumulatedFlow(DcTollStationStatisticsData request){ public AjaxResult accumulatedFlow(DcTollStationStatisticsData request) {
// 调用服务层方法,根据请求条件查询历史车收费站数据 // 调用服务层方法,根据请求条件查询历史车收费站数据
List<DcTollStationStatisticsData> dcStatisticsData = dcTollStationStatisticsDataService.accumulatedFlow(request); List<DcTollStationStatisticsData> dcStatisticsData = dcTollStationStatisticsDataService.accumulatedFlow(request);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
@ -183,7 +240,7 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("获取门架统计数据") @ApiOperation("获取门架统计数据")
@GetMapping("/history/gantry") @GetMapping("/history/gantry")
public AjaxResult historyGantryData(DcGantryStatisticsData request){ public AjaxResult historyGantryData(DcGantryStatisticsData request) {
// 调用服务层方法,根据请求条件查询历史车门架数据 // 调用服务层方法,根据请求条件查询历史车门架数据
List<DcGantryStatisticsData> dcStatisticsData = dcGantryStatisticsDataService.gantryData(request); List<DcGantryStatisticsData> dcStatisticsData = dcGantryStatisticsDataService.gantryData(request);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
@ -192,6 +249,7 @@ public class DcTrafficStatisticsController extends BaseController {
/** /**
* 交通流统计 列表 * 交通流统计 列表
*
* @param startDate * @param startDate
* @param endDate * @param endDate
* @param direction * @param direction
@ -200,49 +258,50 @@ public class DcTrafficStatisticsController extends BaseController {
*/ */
@ApiOperation("交通流统计") @ApiOperation("交通流统计")
@GetMapping("/history/trafficFlowStatistics") @GetMapping("/history/trafficFlowStatistics")
public TableDataInfo trafficFlowStatistics(String startDate, String endDate, String direction, String periodType){ public TableDataInfo trafficFlowStatistics(String startDate, String endDate, String direction, String periodType) {
startPage(); startPage();
List<Map<String,String>> mapList = dcGantryStatisticsDataService.trafficFlowStatistics(startDate,endDate,direction,periodType); List<Map<String, String>> mapList = dcGantryStatisticsDataService.trafficFlowStatistics(startDate, endDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return getDataTable(mapList); return getDataTable(mapList);
} }
/**
/**
* 全路段双向实时车流量 * 全路段双向实时车流量
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
*/ */
@ApiOperation("全路段车流量状况分析") @ApiOperation("全路段车流量状况分析")
@GetMapping("/history/realTimeTrafficFlow") @GetMapping("/history/realTimeTrafficFlow")
public AjaxResult realTimeTrafficFlow(String startDate, String direction,String periodType ){ public AjaxResult realTimeTrafficFlow(String startDate, String direction, String periodType) {
List<Map<String,String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate,direction,periodType); List<Map<String, String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
/** /**
* 导出全路段双向实时车流量 * 导出全路段双向实时车流量
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
*/ */
@ApiOperation(value="导出全路段车流量状况分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出全路段车流量状况分析", tags = {"ECharts导出"})
@GetMapping("/history/exportRealTimeTrafficFlow") @GetMapping("/history/exportRealTimeTrafficFlow")
public void exportRealTimeTrafficFlow(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportRealTimeTrafficFlow(HttpServletResponse response, String startDate, String direction, String periodType) {
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)) {
return; return;
} }
String endDate = UniversalEnum.EMPTY_STRING.getValue(); String endDate = UniversalEnum.EMPTY_STRING.getValue();
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate inputDate = LocalDate.parse(startDate, formatter); LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期 // 获取一年前的日期
LocalDate end = inputDate.minusYears(UniversalEnum.ONE.getNumber()); LocalDate end = inputDate.minusYears(UniversalEnum.ONE.getNumber());
endDate = end.format(formatter); endDate = end.format(formatter);
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue());
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]);
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
@ -255,15 +314,15 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
month = UniversalEnum.TWELVE.getNumber(); month = UniversalEnum.TWELVE.getNumber();
} }
endDate = String.format("%04d-%02d", year, month); endDate = String.format("%04d-%02d", year, month);
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber();
endDate = String.valueOf(year); endDate = String.valueOf(year);
} }
List<RealTimeTrafficFlow> list = new ArrayList<>(); List<RealTimeTrafficFlow> list = new ArrayList<>();
List<Map<String,String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate,direction,periodType); List<Map<String, String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate, direction, periodType);
List<Map<String,String>> lastList = dcGantryStatisticsDataService.realTimeTrafficFlow(endDate,direction,periodType); List<Map<String, String>> lastList = dcGantryStatisticsDataService.realTimeTrafficFlow(endDate, direction, periodType);
mapList = mapList.stream().sorted( mapList = mapList.stream().sorted(
Comparator.comparing(map -> { Comparator.comparing(map -> {
String stakeMark = map.get("stake_make"); String stakeMark = map.get("stake_make");
@ -290,61 +349,67 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
util.exportExcel(response, list, UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue()); util.exportExcel(response, list, UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue());
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
} }
/** /**
* 车流量时段分析 * 车流量时段分析
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
*/ */
@ApiOperation("车流量时段分析") @ApiOperation("车流量时段分析")
@GetMapping("/history/trafficPeriodAnalysis") @GetMapping("/history/trafficPeriodAnalysis")
public AjaxResult trafficPeriodAnalysis(String startDate, String direction,String periodType ){ public AjaxResult trafficPeriodAnalysis(String startDate, String direction, String periodType) {
List<Map<String,String>> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate,direction,periodType); List<Map<String, String>> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
/** /**
* 车流量异常事件流量查询 * 车流量异常事件流量查询
*
* @param eventId 事件id * @param eventId 事件id
*/ */
@ApiOperation("车流量异常事件流量查询") @ApiOperation("车流量异常事件流量查询")
@GetMapping("/history/eventtrafficflowcnt") @GetMapping("/history/eventtrafficflowcnt")
public AjaxResult eventtrafficflowcnt(String eventId ) throws HttpException { public AjaxResult eventtrafficflowcnt(String eventId) throws HttpException {
JSONArray mapList = dcTrafficStatisticsService.eventtrafficflowcnt(eventId); JSONArray mapList = dcTrafficStatisticsService.eventtrafficflowcnt(eventId);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
/** /**
* 交通流统计分析重点数据查询交通流异常信息 * 交通流统计分析重点数据查询交通流异常信息
*/ */
@ApiOperation("交通流统计分析重点数据查询交通流异常信息") @ApiOperation("交通流统计分析重点数据查询交通流异常信息")
@GetMapping("/history/exampleQueryTrafficFlowAnomalies") @GetMapping("/history/exampleQueryTrafficFlowAnomalies")
public AjaxResult exampleQueryTrafficFlowAnomalies(String startTime,String endTime ) throws HttpException { public AjaxResult exampleQueryTrafficFlowAnomalies(String startTime, String endTime) throws HttpException {
JSONArray mapList = dcTrafficStatisticsService.exampleQueryTrafficFlowAnomalies(startTime,endTime); JSONArray mapList = dcTrafficStatisticsService.exampleQueryTrafficFlowAnomalies(startTime, endTime);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
/** /**
* 导出车流量时段分析 * 导出车流量时段分析
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
*/ */
@ApiOperation(value="导出车流量时段分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出车流量时段分析", tags = {"ECharts导出"})
@GetMapping("/history/exportTrafficPeriodAnalysis") @GetMapping("/history/exportTrafficPeriodAnalysis")
public void exportTrafficPeriodAnalysis(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportTrafficPeriodAnalysis(HttpServletResponse response, String startDate, String direction, String periodType) {
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)) {
return; return;
} }
String endDate = UniversalEnum.EMPTY_STRING.getValue(); String endDate = UniversalEnum.EMPTY_STRING.getValue();
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate inputDate = LocalDate.parse(startDate, formatter); LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期 // 获取一年前的日期
LocalDate end = inputDate.minusYears(1); LocalDate end = inputDate.minusYears(1);
endDate = end.format(formatter); endDate = end.format(formatter);
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue());
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]);
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
@ -357,31 +422,31 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
month = UniversalEnum.TWELVE.getNumber(); month = UniversalEnum.TWELVE.getNumber();
} }
endDate = String.format("%04d-%02d", year, month); endDate = String.format("%04d-%02d", year, month);
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber();
endDate = String.valueOf(year); endDate = String.valueOf(year);
} }
List<TrafficPeriodAnalysis> list = new ArrayList<>(); List<TrafficPeriodAnalysis> list = new ArrayList<>();
List<Map<String,String>> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate,direction,periodType); List<Map<String, String>> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate, direction, periodType);
Map<String,String> mapData = new HashMap<>(); Map<String, String> mapData = new HashMap<>();
if (mapList != null && mapList.size() > UniversalEnum.ZERO.getNumber()){ if (mapList != null && mapList.size() > UniversalEnum.ZERO.getNumber()) {
for (Map<String, String> item : mapList) { for (Map<String, String> item : mapList) {
mapData.put(item.get("statisticalHour"),item.get("trafficVolume")); mapData.put(item.get("statisticalHour"), item.get("trafficVolume"));
} }
} }
List<Map<String,String>> lastList = dcGantryStatisticsDataService.trafficPeriodAnalysis(endDate,direction,periodType); List<Map<String, String>> lastList = dcGantryStatisticsDataService.trafficPeriodAnalysis(endDate, direction, periodType);
Map<String,String> lastData = new HashMap<>(); Map<String, String> lastData = new HashMap<>();
if (lastList != null && lastList.size() > UniversalEnum.ZERO.getNumber()){ if (lastList != null && lastList.size() > UniversalEnum.ZERO.getNumber()) {
for (Map<String, String> item : lastList) { for (Map<String, String> item : lastList) {
lastData.put(item.get("statisticalHour"),item.get("trafficVolume")); lastData.put(item.get("statisticalHour"), item.get("trafficVolume"));
} }
} }
for (int i = UniversalEnum.ZERO.getNumber(); i < UniversalEnum.TWENTY_FOUR.getNumber(); i++) { for (int i = UniversalEnum.ZERO.getNumber(); i < UniversalEnum.TWENTY_FOUR.getNumber(); i++) {
TrafficPeriodAnalysis trafficPeriodAnalysis = new TrafficPeriodAnalysis(); TrafficPeriodAnalysis trafficPeriodAnalysis = new TrafficPeriodAnalysis();
trafficPeriodAnalysis.setTime(i + "点至" + (i+UniversalEnum.ONE.getNumber()) + "点"); trafficPeriodAnalysis.setTime(i + "点至" + (i + UniversalEnum.ONE.getNumber()) + "点");
trafficPeriodAnalysis.setCurrentData(mapData.getOrDefault(String.valueOf(i), UniversalEnum.ZERO.getValue())); trafficPeriodAnalysis.setCurrentData(mapData.getOrDefault(String.valueOf(i), UniversalEnum.ZERO.getValue()));
trafficPeriodAnalysis.setContemporaneousData(lastData.getOrDefault(String.valueOf(i), UniversalEnum.ZERO.getValue())); trafficPeriodAnalysis.setContemporaneousData(lastData.getOrDefault(String.valueOf(i), UniversalEnum.ZERO.getValue()));
@ -394,25 +459,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
@ApiOperation("断面车流量排名") @ApiOperation("断面车流量排名")
@GetMapping("/history/sectionTrafficRanking") @GetMapping("/history/sectionTrafficRanking")
public AjaxResult sectionTrafficRanking(String startDate, String direction,String periodType ){ public AjaxResult sectionTrafficRanking(String startDate, String direction, String periodType) {
List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType); List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(dcStatisticsData); return AjaxResult.success(dcStatisticsData);
} }
/** /**
* 导出断面车流量排名 * 导出断面车流量排名
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
*/ */
@ApiOperation(value="导出断面车流量排名",tags = {"ECharts导出"}) @ApiOperation(value = "导出断面车流量排名", tags = {"ECharts导出"})
@GetMapping("/history/exportSectionTrafficRanking") @GetMapping("/history/exportSectionTrafficRanking")
public void exportSectionTrafficRanking(HttpServletResponse response,String startDate, String direction,String periodType ){ public void exportSectionTrafficRanking(HttpServletResponse response, String startDate, String direction, String periodType) {
List<SectionTrafficRanking> list = new ArrayList<>(); List<SectionTrafficRanking> list = new ArrayList<>();
List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType); List<Map<String, String>> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate, direction, periodType);
for (int i = UniversalEnum.ZERO.getNumber(); i < dcStatisticsData.size(); i++) { for (int i = UniversalEnum.ZERO.getNumber(); i < dcStatisticsData.size(); i++) {
SectionTrafficRanking sectionTrafficRanking = new SectionTrafficRanking(); SectionTrafficRanking sectionTrafficRanking = new SectionTrafficRanking();
sectionTrafficRanking.setRank(i + UniversalEnum.ONE.getNumber()); sectionTrafficRanking.setRank(i + UniversalEnum.ONE.getNumber());
@ -428,33 +493,33 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
/** /**
* sectionTrafficIndexAnalysis * sectionTrafficIndexAnalysis
*
* @param startDate 时间 * @param startDate 时间
* @param direction 方向 * @param direction 方向
* @param periodType 时间粒子 * @param periodType 时间粒子
* @param ranking 排名 1 饱和度 2拥挤度 3交通特征指数 * @param ranking 排名 1 饱和度 2拥挤度 3交通特征指数
*
*/ */
@ApiOperation("路段交通指标分析") @ApiOperation("路段交通指标分析")
@GetMapping("/history/sectionTrafficIndexAnalysis") @GetMapping("/history/sectionTrafficIndexAnalysis")
public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction,String periodType,Long ranking ){ public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, Long ranking) {
List<Map<String, Object>> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking); List<Map<String, Object>> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate, direction, periodType, ranking);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
@ApiOperation(value="导出路段交通指标分析",tags = {"ECharts导出"}) @ApiOperation(value = "导出路段交通指标分析", tags = {"ECharts导出"})
@GetMapping("/history/exportSectionTrafficIndexAnalysis") @GetMapping("/history/exportSectionTrafficIndexAnalysis")
public void exportSectionTrafficIndexAnalysis(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){ public void exportSectionTrafficIndexAnalysis(HttpServletResponse response, String startDate, String direction, String periodType, Long ranking) {
List<SectionTrafficIndexAnalysis> list = new ArrayList<>(); List<SectionTrafficIndexAnalysis> list = new ArrayList<>();
String endDate = UniversalEnum.EMPTY_STRING.getValue(); String endDate = UniversalEnum.EMPTY_STRING.getValue();
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate inputDate = LocalDate.parse(startDate, formatter); LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期 // 获取一年前的日期
LocalDate end = inputDate.minusYears(1); LocalDate end = inputDate.minusYears(1);
endDate = end.format(formatter); endDate = end.format(formatter);
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue());
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]);
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
@ -467,20 +532,20 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
month = UniversalEnum.TWELVE.getNumber(); month = UniversalEnum.TWELVE.getNumber();
} }
endDate = String.format("%04d-%02d", year, month); endDate = String.format("%04d-%02d", year, month);
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber();
endDate = String.valueOf(year); endDate = String.valueOf(year);
} }
List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking); 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())); 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); 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())); Map<String, List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString()));
for (StakeMarkRange value : StakeMarkRange.values()) { for (StakeMarkRange value : StakeMarkRange.values()) {
String sectionName = value.getDescription(); String sectionName = value.getDescription();
SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis(); SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis();
sectionTrafficIndexAnalysis.setName(value.getDescription()); sectionTrafficIndexAnalysis.setName(value.getDescription());
if (thisYearData != null && thisYearData.containsKey(sectionName)){ if (thisYearData != null && thisYearData.containsKey(sectionName)) {
Map<String, Object> sectionData = thisYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); Map<String, Object> sectionData = thisYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber());
sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString()); sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString());
sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString()); sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString());
@ -491,7 +556,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
sectionTrafficIndexAnalysis.setTrafficCompositionRate(UniversalEnum.ZERO.getValue()); sectionTrafficIndexAnalysis.setTrafficCompositionRate(UniversalEnum.ZERO.getValue());
} }
if (lastYearData != null && lastYearData.containsKey(sectionName)){ if (lastYearData != null && lastYearData.containsKey(sectionName)) {
Map<String, Object> sectionData = lastYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); Map<String, Object> sectionData = lastYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber());
sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString());
sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString());
@ -512,25 +577,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
@ApiOperation("通指标时间分布") @ApiOperation("通指标时间分布")
@GetMapping("/history/passIndicatorTimeDistribution") @GetMapping("/history/passIndicatorTimeDistribution")
public AjaxResult passIndicatorTimeDistribution(String startDate, String direction,String periodType ){ public AjaxResult passIndicatorTimeDistribution(String startDate, String direction, String periodType) {
List<Map<String, Object>> mapList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); List<Map<String, Object>> mapList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
@ApiOperation(value="导出交通指标时间分布",tags = {"ECharts导出"}) @ApiOperation(value = "导出交通指标时间分布", tags = {"ECharts导出"})
@GetMapping("/history/exportPassIndicatorTimeDistribution") @GetMapping("/history/exportPassIndicatorTimeDistribution")
public void exportPassIndicatorTimeDistribution(HttpServletResponse response,String startDate, String direction,String periodType){ public void exportPassIndicatorTimeDistribution(HttpServletResponse response, String startDate, String direction, String periodType) {
List<PassIndicatorTimeDistribution> list = new ArrayList<>(); List<PassIndicatorTimeDistribution> list = new ArrayList<>();
String endDate = UniversalEnum.EMPTY_STRING.getValue(); String endDate = UniversalEnum.EMPTY_STRING.getValue();
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate inputDate = LocalDate.parse(startDate, formatter); LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期 // 获取一年前的日期
LocalDate end = inputDate.minusYears(1); LocalDate end = inputDate.minusYears(1);
endDate = end.format(formatter); endDate = end.format(formatter);
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue());
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]);
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
@ -543,40 +608,40 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
month = UniversalEnum.TWELVE.getNumber(); month = UniversalEnum.TWELVE.getNumber();
} }
endDate = String.format("%04d-%02d", year, month); endDate = String.format("%04d-%02d", year, month);
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber();
endDate = String.valueOf(year); endDate = String.valueOf(year);
} }
List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate, direction, periodType);
Map<String,List<Map<String, Object>>> thisYearData = new HashMap<>(); Map<String, List<Map<String, Object>>> thisYearData = new HashMap<>();
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"); DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> {
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("HH时"); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("HH时");
return outputFormatter.format(dateTime); return outputFormatter.format(dateTime);
})); }));
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> {
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月d日"); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月d日");
return dateTime.format(outputFormatter); return dateTime.format(outputFormatter);
})); }));
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> {
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月"); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月");
return dateTime.format(outputFormatter); return dateTime.format(outputFormatter);
})); }));
} }
List<Map<String, Object>> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate,direction,periodType); List<Map<String, Object>> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate, direction, periodType);
Map<String,List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); Map<String, List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString()));
Set<String> allKey = new HashSet<>(); Set<String> allKey = new HashSet<>();
if (thisYearData != null){ if (thisYearData != null) {
allKey.addAll(thisYearData.keySet()); allKey.addAll(thisYearData.keySet());
} }
if (lastYearData != null){ if (lastYearData != null) {
allKey.addAll(lastYearData.keySet()); allKey.addAll(lastYearData.keySet());
} }
@ -586,12 +651,12 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
for (String key : keyList) { for (String key : keyList) {
PassIndicatorTimeDistribution passIndicatorTimeDistribution = new PassIndicatorTimeDistribution(); PassIndicatorTimeDistribution passIndicatorTimeDistribution = new PassIndicatorTimeDistribution();
passIndicatorTimeDistribution.setTime(key); passIndicatorTimeDistribution.setTime(key);
if (thisYearData != null && thisYearData.containsKey(key)){ if (thisYearData != null && thisYearData.containsKey(key)) {
Map<String, Object> sectionData = thisYearData.get(key).get(UniversalEnum.ZERO.getNumber()); Map<String, Object> sectionData = thisYearData.get(key).get(UniversalEnum.ZERO.getNumber());
passIndicatorTimeDistribution.setCrowdingRate(sectionData.get("crowdingRate").toString()); passIndicatorTimeDistribution.setCrowdingRate(sectionData.get("crowdingRate").toString());
if (sectionData.get("saturationRate") instanceof Double){ if (sectionData.get("saturationRate") instanceof Double) {
double saturationRate = (Double)sectionData.get("saturationRate"); double saturationRate = (Double) sectionData.get("saturationRate");
passIndicatorTimeDistribution.setSaturationRate(String.format("%.4f", saturationRate)); passIndicatorTimeDistribution.setSaturationRate(String.format("%.4f", saturationRate));
} else { } else {
passIndicatorTimeDistribution.setSaturationRate("0"); passIndicatorTimeDistribution.setSaturationRate("0");
@ -600,18 +665,18 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
passIndicatorTimeDistribution.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString()); passIndicatorTimeDistribution.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString());
} }
if (lastYearData != null && lastYearData.containsKey(key)){ if (lastYearData != null && lastYearData.containsKey(key)) {
Map<String, Object> sectionData = lastYearData.get(key).get(UniversalEnum.ZERO.getNumber()); Map<String, Object> sectionData = lastYearData.get(key).get(UniversalEnum.ZERO.getNumber());
passIndicatorTimeDistribution.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); passIndicatorTimeDistribution.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString());
// passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); // passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString());
if (sectionData.get("saturationRate") instanceof Double){ if (sectionData.get("saturationRate") instanceof Double) {
double saturationRate = (Double)sectionData.get("saturationRate"); double saturationRate = (Double) sectionData.get("saturationRate");
passIndicatorTimeDistribution.setSaturationRateLastYear(String.format("%.4f", saturationRate)); passIndicatorTimeDistribution.setSaturationRateLastYear(String.format("%.4f", saturationRate));
} else { } else {
passIndicatorTimeDistribution.setSaturationRateLastYear("0"); passIndicatorTimeDistribution.setSaturationRateLastYear("0");
} }
passIndicatorTimeDistribution.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString()); passIndicatorTimeDistribution.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString());
}else { } else {
// 如果 lastYearData 不存在或者不包含 key,将所有字段设置为 "0" // 如果 lastYearData 不存在或者不包含 key,将所有字段设置为 "0"
passIndicatorTimeDistribution.setCrowdingRateLastYear("0"); passIndicatorTimeDistribution.setCrowdingRateLastYear("0");
passIndicatorTimeDistribution.setSaturationRateLastYear("0"); passIndicatorTimeDistribution.setSaturationRateLastYear("0");
@ -627,25 +692,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
@ApiOperation("交通指标雷达图") @ApiOperation("交通指标雷达图")
@GetMapping("/history/radarMapOfTrafficIndicators") @GetMapping("/history/radarMapOfTrafficIndicators")
public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction,String periodType ){ public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction, String periodType) {
Map<String, Object> map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate,direction,periodType); Map<String, Object> map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate, direction, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(map); return AjaxResult.success(map);
} }
@ApiOperation(value="导出交通指标雷达图",tags = {"ECharts导出"}) @ApiOperation(value = "导出交通指标雷达图", tags = {"ECharts导出"})
@GetMapping("/history/exportRadarMapOfTrafficIndicators") @GetMapping("/history/exportRadarMapOfTrafficIndicators")
public void exportRadarMapOfTrafficIndicators(HttpServletResponse response,String startDate, String direction,String periodType,Long ranking){ public void exportRadarMapOfTrafficIndicators(HttpServletResponse response, String startDate, String direction, String periodType, Long ranking) {
List<RadarMapOfTrafficIndicators> list = new ArrayList<>(); List<RadarMapOfTrafficIndicators> list = new ArrayList<>();
String endDate = UniversalEnum.EMPTY_STRING.getValue(); String endDate = UniversalEnum.EMPTY_STRING.getValue();
if (UniversalEnum.FOUR.getValue().equals(periodType)){ if (UniversalEnum.FOUR.getValue().equals(periodType)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UniversalEnum.TIME_FORMAT_YEARS_MONTH_DAY.getValue());
LocalDate inputDate = LocalDate.parse(startDate, formatter); LocalDate inputDate = LocalDate.parse(startDate, formatter);
// 获取一年前的日期 // 获取一年前的日期
LocalDate end = inputDate.minusYears(1); LocalDate end = inputDate.minusYears(1);
endDate = end.format(formatter); endDate = end.format(formatter);
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ } else if (UniversalEnum.THREE.getValue().equals(periodType)) {
String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue()); String[] parts = startDate.split(UniversalEnum.SHORT_BAR.getValue());
int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]);
int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]);
@ -658,12 +723,12 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
month = UniversalEnum.TWELVE.getNumber(); month = UniversalEnum.TWELVE.getNumber();
} }
endDate = String.format("%04d-%02d", year, month); endDate = String.format("%04d-%02d", year, month);
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ } else if (UniversalEnum.ONE.getValue().equals(periodType)) {
int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber(); int year = Integer.parseInt(startDate) - UniversalEnum.ONE.getNumber();
endDate = String.valueOf(year); endDate = String.valueOf(year);
} }
Map<String, Object> map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate,direction,periodType); Map<String, Object> map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate, direction, periodType);
Map<String, Object> mapLastYear = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(endDate,direction,periodType); Map<String, Object> mapLastYear = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(endDate, direction, periodType);
RadarMapOfTrafficIndicators radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); RadarMapOfTrafficIndicators radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators();
radarMapOfTrafficIndicators.setName("拥挤度"); radarMapOfTrafficIndicators.setName("拥挤度");
@ -673,15 +738,15 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators();
radarMapOfTrafficIndicators.setName("饱和度"); radarMapOfTrafficIndicators.setName("饱和度");
if (map.get("saturationRate") instanceof Double){ if (map.get("saturationRate") instanceof Double) {
double saturationRate = (Double)map.get("saturationRate"); double saturationRate = (Double) map.get("saturationRate");
radarMapOfTrafficIndicators.setCurrentData(String.format("%.4f", saturationRate)); radarMapOfTrafficIndicators.setCurrentData(String.format("%.4f", saturationRate));
} else { } else {
radarMapOfTrafficIndicators.setCurrentData("0"); radarMapOfTrafficIndicators.setCurrentData("0");
} }
if (mapLastYear.get("saturationRate") instanceof Double){ if (mapLastYear.get("saturationRate") instanceof Double) {
double saturationRate = (Double)mapLastYear.get("saturationRate"); double saturationRate = (Double) mapLastYear.get("saturationRate");
radarMapOfTrafficIndicators.setContemporaneousData(String.format("%.4f", saturationRate)); radarMapOfTrafficIndicators.setContemporaneousData(String.format("%.4f", saturationRate));
} else { } else {
radarMapOfTrafficIndicators.setContemporaneousData("0"); radarMapOfTrafficIndicators.setContemporaneousData("0");
@ -701,7 +766,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
@ApiOperation("综合指标查询") @ApiOperation("综合指标查询")
@GetMapping("/history/comprehensiveIndexQuery") @GetMapping("/history/comprehensiveIndexQuery")
public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery){ public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery) {
startPage(); startPage();
List<ComprehensiveIndexQuery> mapList = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); List<ComprehensiveIndexQuery> mapList = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
@ -712,8 +777,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
//@PreAuthorize("@ss.hasPermi('system:event:export')") //@PreAuthorize("@ss.hasPermi('system:event:export')")
@Log(title = "导出综合指标", businessType = BusinessType.EXPORT) @Log(title = "导出综合指标", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody ComprehensiveIndexQuery comprehensiveIndexQuery) public void export(HttpServletResponse response, @RequestBody ComprehensiveIndexQuery comprehensiveIndexQuery) {
{
List<ComprehensiveIndexQuery> list = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); List<ComprehensiveIndexQuery> list = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery);
ExcelUtil<ComprehensiveIndexQuery> util = new ExcelUtil<ComprehensiveIndexQuery>(ComprehensiveIndexQuery.class); ExcelUtil<ComprehensiveIndexQuery> util = new ExcelUtil<ComprehensiveIndexQuery>(ComprehensiveIndexQuery.class);
util.exportExcel(response, list, UniversalEnum.EVENT_INFORMATION_DATA.getValue()); util.exportExcel(response, list, UniversalEnum.EVENT_INFORMATION_DATA.getValue());
@ -727,7 +791,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
*/ */
@ApiOperation("获取门架交通特指数数据") @ApiOperation("获取门架交通特指数数据")
@GetMapping("/history/gantry-metrics") @GetMapping("/history/gantry-metrics")
public AjaxResult historyGantryMetrics(DcGantryMetricsStatisticsData request){ public AjaxResult historyGantryMetrics(DcGantryMetricsStatisticsData request) {
// 调用服务层方法,根据请求条件查询历史车门架数据 // 调用服务层方法,根据请求条件查询历史车门架数据
List<DcGantryMetricsStatisticsData> dcStatisticsData = dcGantryMetricsStatisticsDataService.gantryMetricsData(request); List<DcGantryMetricsStatisticsData> dcStatisticsData = dcGantryMetricsStatisticsDataService.gantryMetricsData(request);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
@ -798,7 +862,6 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
/** /**
* 获取车道占有率信息 * 获取车道占有率信息
*
*/ */
@ApiOperation("获取车道占有率信息") @ApiOperation("获取车道占有率信息")
@GetMapping("/history/lane-occupancy") @GetMapping("/history/lane-occupancy")
@ -808,28 +871,32 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray); return AjaxResult.success(jsonArray);
} }
/**
/**
* 断面小时车流量分车型 * 断面小时车流量分车型
*/ */
@ApiOperation("断面小时车流量分车型") @ApiOperation("断面小时车流量分车型")
@GetMapping("/history/sectionHourlyTrafficFlow") @GetMapping("/history/sectionHourlyTrafficFlow")
public AjaxResult sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException { public AjaxResult sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据 // 调用服务层方法,获取当前交通指标数据
JSONArray jsonArray = dcTrafficStatisticsService.sectionHourlyTrafficFlow(startDate, endDate); JSONArray jsonArray = dcTrafficStatisticsService.sectionHourlyTrafficFlow(startDate, endDate);
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray); return AjaxResult.success(jsonArray);
}/** }
/**
* 各收费站入口分车型车流量 * 各收费站入口分车型车流量
*/ */
@ApiOperation("各收费站入口分车型小时车流量") @ApiOperation("各收费站入口分车型小时车流量")
@GetMapping("/history/trafficFlowAtTollStationEntranceHour") @GetMapping("/history/trafficFlowAtTollStationEntranceHour")
public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String endDate,String stationType) throws HttpException, IOException { public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String endDate, String stationType) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据 // 调用服务层方法,获取当前交通指标数据
List<Map<String, String>> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType); List<Map<String, String>> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType);
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray); return AjaxResult.success(jsonArray);
} }
/** /**
* 各收费站入口分车型车流量 * 各收费站入口分车型车流量
*/ */
@ -854,7 +921,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
/** /**
* 导出收费站出入口实时车流量 * 导出收费站出入口实时车流量
*/ */
@ApiOperation(value = "导出收费站出入口实时车流量",tags = {"ECharts导出"}) @ApiOperation(value = "导出收费站出入口实时车流量", tags = {"ECharts导出"})
@GetMapping("/history/exportTrafficFlowAtTollStationEntranceHour") @GetMapping("/history/exportTrafficFlowAtTollStationEntranceHour")
public void exportTrafficFlowAtTollStationEntranceHour(HttpServletResponse response) throws IOException, HttpException { public void exportTrafficFlowAtTollStationEntranceHour(HttpServletResponse response) throws IOException, HttpException {
@ -875,16 +942,16 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
// 本期入口 // 本期入口
List<Map<String, String>> thisYearEntrance = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "1"); List<Map<String, String>> thisYearEntrance = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "1");
Map<String,List<Map<String, String>>> thisYearEntranceData = new HashMap<>(); Map<String, List<Map<String, String>>> thisYearEntranceData = new HashMap<>();
if (thisYearEntrance != null && thisYearEntrance.size() > 0){ if (thisYearEntrance != null && thisYearEntrance.size() > 0) {
thisYearEntranceData = thisYearEntrance.stream().collect(Collectors.groupingBy(item -> item.get("name"))); thisYearEntranceData = thisYearEntrance.stream().collect(Collectors.groupingBy(item -> item.get("name")));
stationList.addAll(thisYearEntranceData.keySet()); stationList.addAll(thisYearEntranceData.keySet());
} }
// 本期出口 // 本期出口
List<Map<String, String>> thisYearExport = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "2"); List<Map<String, String>> thisYearExport = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "2");
Map<String,List<Map<String, String>>> thisYearExportData = new HashMap<>(); Map<String, List<Map<String, String>>> thisYearExportData = new HashMap<>();
if (thisYearExport != null && thisYearExport.size() > 0){ if (thisYearExport != null && thisYearExport.size() > 0) {
thisYearExportData = thisYearExport.stream().collect(Collectors.groupingBy(item -> item.get("name"))); thisYearExportData = thisYearExport.stream().collect(Collectors.groupingBy(item -> item.get("name")));
stationList.addAll(thisYearExportData.keySet()); stationList.addAll(thisYearExportData.keySet());
} }
@ -948,7 +1015,8 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
cell.setCellStyle(headerStyle); cell.setCellStyle(headerStyle);
cell = row.createCell(UniversalEnum.TWO.getNumber()); cell = row.createCell(UniversalEnum.TWO.getNumber());
cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue());
cell.setCellStyle(headerStyle);; cell.setCellStyle(headerStyle);
;
cell = row.createCell(UniversalEnum.THREE.getNumber()); cell = row.createCell(UniversalEnum.THREE.getNumber());
cell.setCellValue(UniversalEnum.EXIT.getValue()); cell.setCellValue(UniversalEnum.EXIT.getValue());
cell.setCellStyle(headerStyle); cell.setCellStyle(headerStyle);
@ -992,7 +1060,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
cell.setCellValue(station); cell.setCellValue(station);
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
if (thisYearEntranceData.containsKey(station)){ if (thisYearEntranceData.containsKey(station)) {
cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber());
cell.setCellValue(thisYearEntranceData.get(station).get(0).get("value")); cell.setCellValue(thisYearEntranceData.get(station).get(0).get("value"));
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
@ -1002,7 +1070,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
} }
if (lastYearEntranceData.containsKey(station)){ if (lastYearEntranceData.containsKey(station)) {
cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber());
cell.setCellValue(lastYearEntranceData.get(station).get(0).get("value")); cell.setCellValue(lastYearEntranceData.get(station).get(0).get("value"));
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
@ -1012,7 +1080,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
} }
if (thisYearExportData.containsKey(station)){ if (thisYearExportData.containsKey(station)) {
cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber());
cell.setCellValue(thisYearExportData.get(station).get(0).get("value")); cell.setCellValue(thisYearExportData.get(station).get(0).get("value"));
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
@ -1022,7 +1090,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
} }
if (lastYearExportData.containsKey(station)){ if (lastYearExportData.containsKey(station)) {
cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber());
cell.setCellValue(lastYearExportData.get(station).get(0).get("value")); cell.setCellValue(lastYearExportData.get(station).get(0).get("value"));
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
@ -1035,7 +1103,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
} }
// 写入文件 // 写入文件
try (ServletOutputStream outputStream = response.getOutputStream()){ try (ServletOutputStream outputStream = response.getOutputStream()) {
workbook.write(outputStream); workbook.write(outputStream);
} finally { } finally {
workbook.close(); workbook.close();
@ -1044,52 +1112,57 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String
} }
/** /**
* 各收费站入口分车型小时车流量 * 各收费站入口分车型小时车流量
*/ */
@ApiOperation("各收费站入口分车型车流量") @ApiOperation("各收费站入口分车型车流量")
@GetMapping("/history/trafficFlowAtTollStationEntrance") @GetMapping("/history/trafficFlowAtTollStationEntrance")
public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException { public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate, String stationType) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据 // 调用服务层方法,获取当前交通指标数据
JSONArray jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntranceHour(startDate, endDate, stationType); JSONArray jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntranceHour(startDate, endDate, stationType);
// 将获取到的交通指标数据封装为成功的结果并返回 // 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray); return AjaxResult.success(jsonArray);
} }
/** /**
* 全路段双向实时车流量 * 全路段双向实时车流量
*/ */
@ApiOperation("全路段双向实时车流量") @ApiOperation("全路段双向实时车流量")
@GetMapping("/history/realTimeTrafficFlowHour") @GetMapping("/history/realTimeTrafficFlowHour")
public AjaxResult realTimeTrafficFlowHour() throws HttpException, IOException{ public AjaxResult realTimeTrafficFlowHour() throws HttpException, IOException {
Map<String,List<Map<String, Object>>> mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour(); Map<String, List<Map<String, Object>>> mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour();
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
@ApiOperation("按照桩号查询门架数据 ") @ApiOperation("按照桩号查询门架数据 ")
@GetMapping("/history/queryTheGantryDataByPileNumber") @GetMapping("/history/queryTheGantryDataByPileNumber")
public AjaxResult queryTheGantryDataByPileNumber(String startDate,String stakeMark) throws HttpException, IOException{ public AjaxResult queryTheGantryDataByPileNumber(String startDate, String stakeMark) throws HttpException, IOException {
List<Map<String,Object>> mapList = dcTrafficStatisticsService.queryTheGantryDataByPileNumber(startDate,stakeMark); List<Map<String, Object>> mapList = dcTrafficStatisticsService.queryTheGantryDataByPileNumber(startDate, stakeMark);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
/** /**
* 获取据库中 收费站统计数据 * 获取据库中 收费站统计数据
*
* @param startDate 时间 * @param startDate 时间
* @param accessType 出入口 1入 2出 * @param accessType 出入口 1入 2出
* @param periodType 方向 * @param periodType 方向
*/ */
@ApiOperation("获取据库中收费站数数据") @ApiOperation("获取据库中收费站数数据")
@GetMapping("/history/TollBoothStatistics") @GetMapping("/history/TollBoothStatistics")
public AjaxResult TollBoothStatistics(String startDate,String accessType,String periodType) throws HttpException, IOException{ public AjaxResult TollBoothStatistics(String startDate, String accessType, String periodType) throws HttpException, IOException {
List<Map<String, String>> mapList = dcTollStationStatisticsDataService.TollBoothStatistics(startDate,accessType,periodType); List<Map<String, String>> mapList = dcTollStationStatisticsDataService.TollBoothStatistics(startDate, accessType, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
@ApiOperation("获取据库中收费站数数据") @ApiOperation("获取据库中收费站数数据")
@GetMapping("/history/TollBoothStatisticsList") @GetMapping("/history/TollBoothStatisticsList")
public AjaxResult TollBoothStatisticsList(String startDate, String accessType,String periodType) throws HttpException, IOException{ public AjaxResult TollBoothStatisticsList(String startDate, String accessType, String periodType) throws HttpException, IOException {
List<DcTollStationStatisticsDataMap> mapList = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate,accessType,periodType); List<DcTollStationStatisticsDataMap> mapList = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate, accessType, periodType);
// 将查询结果封装为成功响应并返回 // 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
} }
@ -1097,7 +1170,7 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
/** /**
* 导出全路段双向实时车流量 * 导出全路段双向实时车流量
*/ */
@ApiOperation(value = "导出全路段双向实时车流量",tags = {"ECharts导出"}) @ApiOperation(value = "导出全路段双向实时车流量", tags = {"ECharts导出"})
@GetMapping("/history/exportRealTimeTrafficFlowHour") @GetMapping("/history/exportRealTimeTrafficFlowHour")
public void exportRealTimeTrafficFlowHour(HttpServletResponse response) throws IOException, HttpException { public void exportRealTimeTrafficFlowHour(HttpServletResponse response) throws IOException, HttpException {
@ -1106,12 +1179,12 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
String fileName = UniversalEnum.REAL_TIME_TRAFFIC_FLOW_IN_BOTH_DIRECTIONS_XLSX.name(); String fileName = UniversalEnum.REAL_TIME_TRAFFIC_FLOW_IN_BOTH_DIRECTIONS_XLSX.name();
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
Map<String,List<Map<String,Object>>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour(); Map<String, List<Map<String, Object>>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour();
if (map != null){ if (map != null) {
List<Map<String,Object>> thisYearHZ = map.get(UniversalEnum.ONE.getValue()); List<Map<String, Object>> thisYearHZ = map.get(UniversalEnum.ONE.getValue());
List<Map<String,Object>> thisYearJN = map.get(UniversalEnum.TWO.getValue()); List<Map<String, Object>> thisYearJN = map.get(UniversalEnum.TWO.getValue());
List<Map<String,Object>> lastYearHZ = map.get(UniversalEnum.THREE.getValue()); List<Map<String, Object>> lastYearHZ = map.get(UniversalEnum.THREE.getValue());
List<Map<String,Object>> lastYearJN = map.get(UniversalEnum.FOUR.getValue()); List<Map<String, Object>> lastYearJN = map.get(UniversalEnum.FOUR.getValue());
XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿 XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿
Sheet sheet = workbook.createSheet(UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue()); // 创建工作表 Sheet sheet = workbook.createSheet(UniversalEnum.THE_WHOLE_SECTION_TWO_WAY_REAL_TIME_TRAFFIC_FLOW.getValue()); // 创建工作表
@ -1157,7 +1230,8 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
cell.setCellStyle(headerStyle); cell.setCellStyle(headerStyle);
cell = row.createCell(UniversalEnum.TWO.getNumber()); cell = row.createCell(UniversalEnum.TWO.getNumber());
cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue());
cell.setCellStyle(headerStyle);; cell.setCellStyle(headerStyle);
;
cell = row.createCell(UniversalEnum.THREE.getNumber()); cell = row.createCell(UniversalEnum.THREE.getNumber());
cell.setCellValue(UniversalEnum.DIRECTION_OF_HEZE.getValue()); cell.setCellValue(UniversalEnum.DIRECTION_OF_HEZE.getValue());
cell.setCellStyle(headerStyle); cell.setCellStyle(headerStyle);
@ -1194,7 +1268,7 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.THREE.getNumber(), UniversalEnum.FOUR.getNumber())); sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.THREE.getNumber(), UniversalEnum.FOUR.getNumber()));
for (int i = UniversalEnum.ZERO.getNumber(); i < thisYearHZ.size(); i++) { for (int i = UniversalEnum.ZERO.getNumber(); i < thisYearHZ.size(); i++) {
Row subHeaderRow = sheet.createRow(i+UniversalEnum.TWO.getNumber()); Row subHeaderRow = sheet.createRow(i + UniversalEnum.TWO.getNumber());
cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber());
cell.setCellValue(thisYearJN.get(i).get("name").toString()); cell.setCellValue(thisYearJN.get(i).get("name").toString());
cell.setCellStyle(dataStyle); cell.setCellStyle(dataStyle);
@ -1214,7 +1288,7 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
// 写入文件 // 写入文件
try (ServletOutputStream outputStream = response.getOutputStream()){ try (ServletOutputStream outputStream = response.getOutputStream()) {
workbook.write(outputStream); workbook.write(outputStream);
} finally { } finally {
workbook.close(); workbook.close();

9
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -457,8 +457,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION ALL UNION ALL
SELECT 'Weather Warning' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config SELECT 'Weather Warning' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config
FROM dc_no_stake_warning_table FROM dc_no_stake_warning_table
WHERE warning_type = 2 WHERE warning_type = 2 AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 3 DAY)
AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 3 DAY) UNION ALL
SELECT 'TrafficFlow' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config
FROM dc_no_stake_warning_table
WHERE warning_type = 3
AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
ORDER BY warning_time DESC ORDER BY warning_time DESC
</select> </select>

Loading…
Cancel
Save