From 4b7ec1786616088398afff9b2338bebc18f968d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Mon, 4 Nov 2024 11:38:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=B5=81=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=EF=BC=8C=E5=A4=AA=E9=98=B3=E8=83=BD=E6=9D=BF=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=A4=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcDeviceController.java | 13 +- .../DcTrafficStatisticsController.java | 490 ++++++++++-------- .../mapper/business/DcWarningMapper.xml | 9 +- 3 files changed, 297 insertions(+), 215 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index dd848952..81eb058c 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -431,6 +431,8 @@ public class DcDeviceController extends BaseController { Map deviceHourlyAggregates = new TreeMap<>(); List> list = new ArrayList<>(); + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 处理每个数据点 for (Object o : dataArray) { @@ -452,9 +454,10 @@ public class DcDeviceController extends BaseController { String key = String.format("%d-%02d-%02d %02d:00:00", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), hour); + //转换为 double 类型,去除单位 String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); - double formatValue = Double.parseDouble(valueWithoutUnit); + double formatValue = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); // 汇总每个小时的数据 deviceHourlyAggregates.merge(key, formatValue, Double::sum); @@ -489,7 +492,8 @@ public class DcDeviceController extends BaseController { ); List dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameters); Map attributeMap = new HashMap<>(); - + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); for (DcDevice dcDevice : dcDevices) { String deviceId = dcDevice.getIotDeviceId(); for (String propertyId : propertyIds) { @@ -501,13 +505,12 @@ public class DcDeviceController extends BaseController { String property = data.get("property").getAsString(); String formatValueStr = data.get("formatValue").getAsString(); 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); } } } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - decimalFormat.setRoundingMode(RoundingMode.HALF_UP); + // 计算碳减排 碳减排(kg)=光伏发电量(kWh)*0.7119 double carbonEmissionReduction = attributeMap.getOrDefault("theAccumulatedChargeOfTheYear", 0.0) * 0.7119; diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java index 3e28caec..907a5618 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java @@ -1,8 +1,6 @@ package com.zc.business.controller; 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.core.controller.BaseController; 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.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.utils.spring.SpringUtils; import com.zc.business.domain.*; import com.zc.business.domain.export.*; 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.DcTrafficSectionDataRequest; import com.zc.business.service.*; +import com.zc.business.service.impl.DcNoStakeWarningTableServiceImpl; import com.zc.common.core.httpclient.exception.HttpException; import io.swagger.annotations.Api; 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.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.text.DecimalFormat; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; @@ -47,11 +47,11 @@ import java.util.stream.Collectors; * * @author xiepufeng */ - +@Component @Api(tags = "交通数据统计") @RestController @RequestMapping("/business/traffic-statistics") -public class DcTrafficStatisticsController extends BaseController { +public class DcTrafficStatisticsController extends BaseController { @Autowired private IDcTrafficSectionStatisticsService dcTrafficSectionStatisticsService; @@ -68,6 +68,63 @@ public class DcTrafficStatisticsController extends BaseController { @Autowired 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 map = (Map) 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 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("获取当前交通截面数据") @GetMapping("/current/sections") - public AjaxResult currentSections(DcTrafficSectionDataRequest request){ + public AjaxResult currentSections(DcTrafficSectionDataRequest request) { // 调用服务层方法,查询当前交通截面数据 List dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentSections(request); // 将查询结果封装为AjaxResult对象返回 @@ -91,7 +148,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取历史交通截面数据") @GetMapping("/history/sections") - public AjaxResult historySections(DcTrafficSectionDataRequest request){ + public AjaxResult historySections(DcTrafficSectionDataRequest request) { // 调用服务层方法,获取历史交通截面的统计数据 List dcTrafficMetricsData = dcTrafficSectionStatisticsService.historySections(request); // 将获取到的历史交通截面数据封装成AjaxResult对象并返回 @@ -107,7 +164,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取当前交通特征指数") @GetMapping("/current/metrics") - public AjaxResult currentTrafficMetrics(DcTrafficMetricsDataRequest request){ + public AjaxResult currentTrafficMetrics(DcTrafficMetricsDataRequest request) { // 调用服务层方法,获取当前交通指标数据 List dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentTrafficMetrics(request); // 将获取到的交通指标数据封装为成功的结果并返回 @@ -122,7 +179,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取历史交通特征指数") @GetMapping("/history/metrics") - public AjaxResult historyTrafficMetrics(DcTrafficMetricsDataRequest request){ + public AjaxResult historyTrafficMetrics(DcTrafficMetricsDataRequest request) { // 调用服务层方法,查询历史交通特征指数数据 List dcTrafficMetricsDataList = dcTrafficSectionStatisticsService.historyTrafficMetrics(request); // 将查询结果封装成成功响应并返回 @@ -137,7 +194,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取当前拥堵路段") @GetMapping("/current/congested") - public AjaxResult currentCongestedSection(Byte direction){ + public AjaxResult currentCongestedSection(Byte direction) { // 调用服务层方法,获取当前交通指标数据 List dcTrafficMetricsData = dcTrafficSectionStatisticsService.currentCongestedSection(direction); // 将获取到的交通指标数据封装为成功的结果并返回 @@ -151,9 +208,9 @@ public class DcTrafficStatisticsController extends BaseController { * @param request 包含查询条件的请求对象,用于筛选历史收费站统计数据 * @return 返回一个AjaxResult对象,其中包含了查询到的收费站统计数据列表 */ - @ApiOperation("获取收费站统计数据") + @ApiOperation("获取收费站统计数据") @GetMapping("/history/toll-station") - public AjaxResult historyTollStation(DcTollStationStatisticsData request){ + public AjaxResult historyTollStation(DcTollStationStatisticsData request) { // 调用服务层方法,根据请求条件查询历史车收费站数据 List dcStatisticsData = dcTollStationStatisticsDataService.tollStationData(request); // 将查询结果封装为成功响应并返回 @@ -168,7 +225,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取累计车流量") @GetMapping("/history/accumulated-flow") - public AjaxResult accumulatedFlow(DcTollStationStatisticsData request){ + public AjaxResult accumulatedFlow(DcTollStationStatisticsData request) { // 调用服务层方法,根据请求条件查询历史车收费站数据 List dcStatisticsData = dcTollStationStatisticsDataService.accumulatedFlow(request); // 将查询结果封装为成功响应并返回 @@ -183,7 +240,7 @@ public class DcTrafficStatisticsController extends BaseController { */ @ApiOperation("获取门架统计数据") @GetMapping("/history/gantry") - public AjaxResult historyGantryData(DcGantryStatisticsData request){ + public AjaxResult historyGantryData(DcGantryStatisticsData request) { // 调用服务层方法,根据请求条件查询历史车门架数据 List dcStatisticsData = dcGantryStatisticsDataService.gantryData(request); // 将查询结果封装为成功响应并返回 @@ -192,57 +249,59 @@ public class DcTrafficStatisticsController extends BaseController { /** * 交通流统计 列表 + * * @param startDate * @param endDate * @param direction * @param periodType * @return */ - @ApiOperation("交通流统计") + @ApiOperation("交通流统计") @GetMapping("/history/trafficFlowStatistics") - public TableDataInfo trafficFlowStatistics(String startDate, String endDate, String direction, String periodType){ - startPage(); - List> mapList = dcGantryStatisticsDataService.trafficFlowStatistics(startDate,endDate,direction,periodType); + public TableDataInfo trafficFlowStatistics(String startDate, String endDate, String direction, String periodType) { + startPage(); + List> mapList = dcGantryStatisticsDataService.trafficFlowStatistics(startDate, endDate, direction, periodType); // 将查询结果封装为成功响应并返回 return getDataTable(mapList); } - -/** - * 全路段双向实时车流量 - * @param startDate 时间 - * @param direction 方向 - * @param periodType 时间粒子 - */ -@ApiOperation("全路段车流量状况分析") -@GetMapping("/history/realTimeTrafficFlow") -public AjaxResult realTimeTrafficFlow(String startDate, String direction,String periodType ){ - List> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate,direction,periodType); - // 将查询结果封装为成功响应并返回 - return AjaxResult.success(mapList); -} + /** + * 全路段双向实时车流量 + * + * @param startDate 时间 + * @param direction 方向 + * @param periodType 时间粒子 + */ + @ApiOperation("全路段车流量状况分析") + @GetMapping("/history/realTimeTrafficFlow") + public AjaxResult realTimeTrafficFlow(String startDate, String direction, String periodType) { + List> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate, direction, periodType); + // 将查询结果封装为成功响应并返回 + return AjaxResult.success(mapList); + } /** * 导出全路段双向实时车流量 - * @param startDate 时间 - * @param direction 方向 + * + * @param startDate 时间 + * @param direction 方向 * @param periodType 时间粒子 */ - @ApiOperation(value="导出全路段车流量状况分析",tags = {"ECharts导出"}) + @ApiOperation(value = "导出全路段车流量状况分析", tags = {"ECharts导出"}) @GetMapping("/history/exportRealTimeTrafficFlow") - public void exportRealTimeTrafficFlow(HttpServletResponse response,String startDate, String direction,String periodType ){ - if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ + public void exportRealTimeTrafficFlow(HttpServletResponse response, String startDate, String direction, String periodType) { + if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)) { return; } 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()); LocalDate inputDate = LocalDate.parse(startDate, formatter); // 获取一年前的日期 LocalDate end = inputDate.minusYears(UniversalEnum.ONE.getNumber()); 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()); int year = Integer.parseInt(parts[UniversalEnum.ZERO.getNumber()]); int month = Integer.parseInt(parts[UniversalEnum.ONE.getNumber()]); @@ -255,26 +314,26 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String month = UniversalEnum.TWELVE.getNumber(); } 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(); endDate = String.valueOf(year); } List list = new ArrayList<>(); - List> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate,direction,periodType); - List> lastList = dcGantryStatisticsDataService.realTimeTrafficFlow(endDate,direction,periodType); + List> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow(startDate, direction, periodType); + List> lastList = dcGantryStatisticsDataService.realTimeTrafficFlow(endDate, direction, periodType); mapList = mapList.stream().sorted( - Comparator.comparing(map -> { - String stakeMark = map.get("stake_make"); - return StakeMarkUtils.formatMetre(stakeMark); - })) + Comparator.comparing(map -> { + String stakeMark = map.get("stake_make"); + return StakeMarkUtils.formatMetre(stakeMark); + })) .collect(Collectors.toList()); lastList = lastList.stream().sorted( - Comparator.comparing(map -> { - String stakeMark = map.get("stake_make"); - return StakeMarkUtils.formatMetre(stakeMark); - })) + Comparator.comparing(map -> { + String stakeMark = map.get("stake_make"); + return StakeMarkUtils.formatMetre(stakeMark); + })) .collect(Collectors.toList()); for (int i = 0; i < mapList.size(); i++) { RealTimeTrafficFlow realTimeTrafficFlow = new RealTimeTrafficFlow(); @@ -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()); // 将查询结果封装为成功响应并返回 } + /** * 车流量时段分析 - * @param startDate 时间 - * @param direction 方向 + * + * @param startDate 时间 + * @param direction 方向 * @param periodType 时间粒子 */ @ApiOperation("车流量时段分析") @GetMapping("/history/trafficPeriodAnalysis") - public AjaxResult trafficPeriodAnalysis(String startDate, String direction,String periodType ){ - List> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate,direction,periodType); + public AjaxResult trafficPeriodAnalysis(String startDate, String direction, String periodType) { + List> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate, direction, periodType); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + /** * 车流量异常事件流量查询 + * * @param eventId 事件id */ @ApiOperation("车流量异常事件流量查询") @GetMapping("/history/eventtrafficflowcnt") - public AjaxResult eventtrafficflowcnt(String eventId ) throws HttpException { + public AjaxResult eventtrafficflowcnt(String eventId) throws HttpException { JSONArray mapList = dcTrafficStatisticsService.eventtrafficflowcnt(eventId); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + /** * 交通流统计分析重点数据查询交通流异常信息 */ @ApiOperation("交通流统计分析重点数据查询交通流异常信息") @GetMapping("/history/exampleQueryTrafficFlowAnomalies") - public AjaxResult exampleQueryTrafficFlowAnomalies(String startTime,String endTime ) throws HttpException { - JSONArray mapList = dcTrafficStatisticsService.exampleQueryTrafficFlowAnomalies(startTime,endTime); + public AjaxResult exampleQueryTrafficFlowAnomalies(String startTime, String endTime) throws HttpException { + JSONArray mapList = dcTrafficStatisticsService.exampleQueryTrafficFlowAnomalies(startTime, endTime); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } /** * 导出车流量时段分析 - * @param startDate 时间 - * @param direction 方向 + * + * @param startDate 时间 + * @param direction 方向 * @param periodType 时间粒子 */ - @ApiOperation(value="导出车流量时段分析",tags = {"ECharts导出"}) + @ApiOperation(value = "导出车流量时段分析", tags = {"ECharts导出"}) @GetMapping("/history/exportTrafficPeriodAnalysis") - public void exportTrafficPeriodAnalysis(HttpServletResponse response,String startDate, String direction,String periodType ){ - if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)){ + public void exportTrafficPeriodAnalysis(HttpServletResponse response, String startDate, String direction, String periodType) { + if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(direction) || StringUtils.isEmpty(periodType)) { return; } 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()); LocalDate inputDate = LocalDate.parse(startDate, formatter); // 获取一年前的日期 LocalDate end = inputDate.minusYears(1); 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()); int year = Integer.parseInt(parts[UniversalEnum.ZERO.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(); } 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(); endDate = String.valueOf(year); } List list = new ArrayList<>(); - List> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate,direction,periodType); - Map mapData = new HashMap<>(); - if (mapList != null && mapList.size() > UniversalEnum.ZERO.getNumber()){ + List> mapList = dcGantryStatisticsDataService.trafficPeriodAnalysis(startDate, direction, periodType); + Map mapData = new HashMap<>(); + if (mapList != null && mapList.size() > UniversalEnum.ZERO.getNumber()) { for (Map item : mapList) { - mapData.put(item.get("statisticalHour"),item.get("trafficVolume")); + mapData.put(item.get("statisticalHour"), item.get("trafficVolume")); } } - List> lastList = dcGantryStatisticsDataService.trafficPeriodAnalysis(endDate,direction,periodType); - Map lastData = new HashMap<>(); - if (lastList != null && lastList.size() > UniversalEnum.ZERO.getNumber()){ + List> lastList = dcGantryStatisticsDataService.trafficPeriodAnalysis(endDate, direction, periodType); + Map lastData = new HashMap<>(); + if (lastList != null && lastList.size() > UniversalEnum.ZERO.getNumber()) { for (Map 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++) { 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.setContemporaneousData(lastData.getOrDefault(String.valueOf(i), UniversalEnum.ZERO.getValue())); @@ -394,25 +459,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String @ApiOperation("断面车流量排名") @GetMapping("/history/sectionTrafficRanking") - public AjaxResult sectionTrafficRanking(String startDate, String direction,String periodType ){ - List> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType); + public AjaxResult sectionTrafficRanking(String startDate, String direction, String periodType) { + List> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate, direction, periodType); // 将查询结果封装为成功响应并返回 return AjaxResult.success(dcStatisticsData); } - /** * 导出断面车流量排名 - * @param startDate 时间 - * @param direction 方向 + * + * @param startDate 时间 + * @param direction 方向 * @param periodType 时间粒子 */ - @ApiOperation(value="导出断面车流量排名",tags = {"ECharts导出"}) + @ApiOperation(value = "导出断面车流量排名", tags = {"ECharts导出"}) @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 list = new ArrayList<>(); - List> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate,direction,periodType); + List> dcStatisticsData = dcGantryStatisticsDataService.sectionTrafficRanking(startDate, direction, periodType); for (int i = UniversalEnum.ZERO.getNumber(); i < dcStatisticsData.size(); i++) { SectionTrafficRanking sectionTrafficRanking = new SectionTrafficRanking(); sectionTrafficRanking.setRank(i + UniversalEnum.ONE.getNumber()); @@ -428,33 +493,33 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String /** * sectionTrafficIndexAnalysis - * @param startDate 时间 - * @param direction 方向 - * @param periodType 时间粒子 - * @param ranking 排名 1 饱和度 2拥挤度 3交通特征指数 * + * @param startDate 时间 + * @param direction 方向 + * @param periodType 时间粒子 + * @param ranking 排名 1 饱和度 2拥挤度 3交通特征指数 */ @ApiOperation("路段交通指标分析") @GetMapping("/history/sectionTrafficIndexAnalysis") - public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction,String periodType,Long ranking ){ - List> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking); + public AjaxResult sectionTrafficIndexAnalysis(String startDate, String direction, String periodType, Long ranking) { + List> mapList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate, direction, periodType, ranking); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } - @ApiOperation(value="导出路段交通指标分析",tags = {"ECharts导出"}) + @ApiOperation(value = "导出路段交通指标分析", tags = {"ECharts导出"}) @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 list = new ArrayList<>(); 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()); LocalDate inputDate = LocalDate.parse(startDate, formatter); // 获取一年前的日期 LocalDate end = inputDate.minusYears(1); 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()); int year = Integer.parseInt(parts[UniversalEnum.ZERO.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(); } 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(); endDate = String.valueOf(year); } - List> thisYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate,direction,periodType,ranking); - Map>> thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString())); - List> lastYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(endDate,direction,periodType,ranking); - Map>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString())); + List> thisYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(startDate, direction, periodType, ranking); + Map>> thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString())); + List> lastYearList = dcGantryMetricsStatisticsDataService.sectionTrafficIndexAnalysis(endDate, direction, periodType, ranking); + Map>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupName").toString())); for (StakeMarkRange value : StakeMarkRange.values()) { String sectionName = value.getDescription(); SectionTrafficIndexAnalysis sectionTrafficIndexAnalysis = new SectionTrafficIndexAnalysis(); sectionTrafficIndexAnalysis.setName(value.getDescription()); - if (thisYearData != null && thisYearData.containsKey(sectionName)){ + if (thisYearData != null && thisYearData.containsKey(sectionName)) { Map sectionData = thisYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); sectionTrafficIndexAnalysis.setCrowdingRate(sectionData.get("crowdingRate").toString()); sectionTrafficIndexAnalysis.setSaturationRate(sectionData.get("saturationRate").toString()); @@ -491,7 +556,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String sectionTrafficIndexAnalysis.setTrafficCompositionRate(UniversalEnum.ZERO.getValue()); } - if (lastYearData != null && lastYearData.containsKey(sectionName)){ + if (lastYearData != null && lastYearData.containsKey(sectionName)) { Map sectionData = lastYearData.get(sectionName).get(UniversalEnum.ZERO.getNumber()); sectionTrafficIndexAnalysis.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); sectionTrafficIndexAnalysis.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); @@ -512,25 +577,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String @ApiOperation("通指标时间分布") @GetMapping("/history/passIndicatorTimeDistribution") - public AjaxResult passIndicatorTimeDistribution(String startDate, String direction,String periodType ){ - List> mapList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); + public AjaxResult passIndicatorTimeDistribution(String startDate, String direction, String periodType) { + List> mapList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate, direction, periodType); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } - @ApiOperation(value="导出交通指标时间分布",tags = {"ECharts导出"}) + @ApiOperation(value = "导出交通指标时间分布", tags = {"ECharts导出"}) @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 list = new ArrayList<>(); 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()); LocalDate inputDate = LocalDate.parse(startDate, formatter); // 获取一年前的日期 LocalDate end = inputDate.minusYears(1); 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()); int year = Integer.parseInt(parts[UniversalEnum.ZERO.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(); } 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(); endDate = String.valueOf(year); } - List> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); - Map>> thisYearData = new HashMap<>(); + List> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate, direction, periodType); + Map>> thisYearData = new HashMap<>(); 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 -> { LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("HH时"); 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 -> { LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月d日"); 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 -> { LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月"); return dateTime.format(outputFormatter); })); } - List> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate,direction,periodType); - Map>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); + List> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate, direction, periodType); + Map>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); Set allKey = new HashSet<>(); - if (thisYearData != null){ + if (thisYearData != null) { allKey.addAll(thisYearData.keySet()); } - if (lastYearData != null){ + if (lastYearData != null) { allKey.addAll(lastYearData.keySet()); } @@ -586,12 +651,12 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String for (String key : keyList) { PassIndicatorTimeDistribution passIndicatorTimeDistribution = new PassIndicatorTimeDistribution(); passIndicatorTimeDistribution.setTime(key); - if (thisYearData != null && thisYearData.containsKey(key)){ + if (thisYearData != null && thisYearData.containsKey(key)) { Map sectionData = thisYearData.get(key).get(UniversalEnum.ZERO.getNumber()); passIndicatorTimeDistribution.setCrowdingRate(sectionData.get("crowdingRate").toString()); - if (sectionData.get("saturationRate") instanceof Double){ - double saturationRate = (Double)sectionData.get("saturationRate"); + if (sectionData.get("saturationRate") instanceof Double) { + double saturationRate = (Double) sectionData.get("saturationRate"); passIndicatorTimeDistribution.setSaturationRate(String.format("%.4f", saturationRate)); } else { passIndicatorTimeDistribution.setSaturationRate("0"); @@ -600,18 +665,18 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String passIndicatorTimeDistribution.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString()); } - if (lastYearData != null && lastYearData.containsKey(key)){ + if (lastYearData != null && lastYearData.containsKey(key)) { Map sectionData = lastYearData.get(key).get(UniversalEnum.ZERO.getNumber()); passIndicatorTimeDistribution.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); // passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); - if (sectionData.get("saturationRate") instanceof Double){ - double saturationRate = (Double)sectionData.get("saturationRate"); + if (sectionData.get("saturationRate") instanceof Double) { + double saturationRate = (Double) sectionData.get("saturationRate"); passIndicatorTimeDistribution.setSaturationRateLastYear(String.format("%.4f", saturationRate)); } else { passIndicatorTimeDistribution.setSaturationRateLastYear("0"); } passIndicatorTimeDistribution.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString()); - }else { + } else { // 如果 lastYearData 不存在或者不包含 key,将所有字段设置为 "0" passIndicatorTimeDistribution.setCrowdingRateLastYear("0"); passIndicatorTimeDistribution.setSaturationRateLastYear("0"); @@ -627,25 +692,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String @ApiOperation("交通指标雷达图") @GetMapping("/history/radarMapOfTrafficIndicators") - public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction,String periodType ){ - Map map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate,direction,periodType); + public AjaxResult radarMapOfTrafficIndicators(String startDate, String direction, String periodType) { + Map map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate, direction, periodType); // 将查询结果封装为成功响应并返回 return AjaxResult.success(map); } - @ApiOperation(value="导出交通指标雷达图",tags = {"ECharts导出"}) + @ApiOperation(value = "导出交通指标雷达图", tags = {"ECharts导出"}) @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 list = new ArrayList<>(); 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()); LocalDate inputDate = LocalDate.parse(startDate, formatter); // 获取一年前的日期 LocalDate end = inputDate.minusYears(1); 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()); int year = Integer.parseInt(parts[UniversalEnum.ZERO.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(); } 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(); endDate = String.valueOf(year); } - Map map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate,direction,periodType); - Map mapLastYear = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(endDate,direction,periodType); + Map map = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(startDate, direction, periodType); + Map mapLastYear = dcGantryMetricsStatisticsDataService.radarMapOfTrafficIndicators(endDate, direction, periodType); RadarMapOfTrafficIndicators radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); radarMapOfTrafficIndicators.setName("拥挤度"); @@ -673,15 +738,15 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String radarMapOfTrafficIndicators = new RadarMapOfTrafficIndicators(); radarMapOfTrafficIndicators.setName("饱和度"); - if (map.get("saturationRate") instanceof Double){ - double saturationRate = (Double)map.get("saturationRate"); + if (map.get("saturationRate") instanceof Double) { + double saturationRate = (Double) map.get("saturationRate"); radarMapOfTrafficIndicators.setCurrentData(String.format("%.4f", saturationRate)); } else { radarMapOfTrafficIndicators.setCurrentData("0"); } - if (mapLastYear.get("saturationRate") instanceof Double){ - double saturationRate = (Double)mapLastYear.get("saturationRate"); + if (mapLastYear.get("saturationRate") instanceof Double) { + double saturationRate = (Double) mapLastYear.get("saturationRate"); radarMapOfTrafficIndicators.setContemporaneousData(String.format("%.4f", saturationRate)); } else { radarMapOfTrafficIndicators.setContemporaneousData("0"); @@ -701,9 +766,9 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String @ApiOperation("综合指标查询") @GetMapping("/history/comprehensiveIndexQuery") - public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery){ + public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery) { startPage(); - List mapList = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); + List mapList = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); // 将查询结果封装为成功响应并返回 return getDataTable(mapList); } @@ -712,9 +777,8 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String //@PreAuthorize("@ss.hasPermi('system:event:export')") @Log(title = "导出综合指标", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, @RequestBody ComprehensiveIndexQuery comprehensiveIndexQuery) - { - List list = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); + public void export(HttpServletResponse response, @RequestBody ComprehensiveIndexQuery comprehensiveIndexQuery) { + List list = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery); ExcelUtil util = new ExcelUtil(ComprehensiveIndexQuery.class); util.exportExcel(response, list, UniversalEnum.EVENT_INFORMATION_DATA.getValue()); } @@ -727,7 +791,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String */ @ApiOperation("获取门架交通特指数数据") @GetMapping("/history/gantry-metrics") - public AjaxResult historyGantryMetrics(DcGantryMetricsStatisticsData request){ + public AjaxResult historyGantryMetrics(DcGantryMetricsStatisticsData request) { // 调用服务层方法,根据请求条件查询历史车门架数据 List dcStatisticsData = dcGantryMetricsStatisticsDataService.gantryMetricsData(request); // 将查询结果封装为成功响应并返回 @@ -798,7 +862,6 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String /** * 获取车道占有率信息 - * */ @ApiOperation("获取车道占有率信息") @GetMapping("/history/lane-occupancy") @@ -808,28 +871,32 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String // 将获取到的交通指标数据封装为成功的结果并返回 return AjaxResult.success(jsonArray); } -/** - * 断面小时车流量分车型 - */ -@ApiOperation("断面小时车流量分车型") -@GetMapping("/history/sectionHourlyTrafficFlow") -public AjaxResult sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException { - // 调用服务层方法,获取当前交通指标数据 - JSONArray jsonArray = dcTrafficStatisticsService.sectionHourlyTrafficFlow(startDate, endDate); - // 将获取到的交通指标数据封装为成功的结果并返回 - return AjaxResult.success(jsonArray); - -}/** - * 各收费站入口分车型车流量 - */ -@ApiOperation("各收费站入口分车型小时车流量") -@GetMapping("/history/trafficFlowAtTollStationEntranceHour") -public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String endDate,String stationType) throws HttpException, IOException { - // 调用服务层方法,获取当前交通指标数据 - List> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType); - // 将获取到的交通指标数据封装为成功的结果并返回 - return AjaxResult.success(jsonArray); -} + + /** + * 断面小时车流量分车型 + */ + @ApiOperation("断面小时车流量分车型") + @GetMapping("/history/sectionHourlyTrafficFlow") + public AjaxResult sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException { + // 调用服务层方法,获取当前交通指标数据 + JSONArray jsonArray = dcTrafficStatisticsService.sectionHourlyTrafficFlow(startDate, endDate); + // 将获取到的交通指标数据封装为成功的结果并返回 + return AjaxResult.success(jsonArray); + + } + + /** + * 各收费站入口分车型车流量 + */ + @ApiOperation("各收费站入口分车型小时车流量") + @GetMapping("/history/trafficFlowAtTollStationEntranceHour") + public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String endDate, String stationType) throws HttpException, IOException { + // 调用服务层方法,获取当前交通指标数据 + List> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType); + // 将获取到的交通指标数据封装为成功的结果并返回 + return AjaxResult.success(jsonArray); + } + /** * 各收费站入口分车型车流量 */ @@ -842,7 +909,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String return AjaxResult.success(a); } - @ApiOperation("收费站昨日累计车流辆") + @ApiOperation("收费站昨日累计车流辆") @GetMapping("/history/yesterdayTrafficFlowAtToll") public AjaxResult yesterdayTrafficFlowAtToll(String startDate) throws HttpException, IOException { // 调用服务层方法,获取当前交通指标数据 @@ -854,7 +921,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String /** * 导出收费站出入口实时车流量 */ - @ApiOperation(value = "导出收费站出入口实时车流量",tags = {"ECharts导出"}) + @ApiOperation(value = "导出收费站出入口实时车流量", tags = {"ECharts导出"}) @GetMapping("/history/exportTrafficFlowAtTollStationEntranceHour") public void exportTrafficFlowAtTollStationEntranceHour(HttpServletResponse response) throws IOException, HttpException { @@ -875,16 +942,16 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String // 本期入口 List> thisYearEntrance = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "1"); - Map>> thisYearEntranceData = new HashMap<>(); - if (thisYearEntrance != null && thisYearEntrance.size() > 0){ + Map>> thisYearEntranceData = new HashMap<>(); + if (thisYearEntrance != null && thisYearEntrance.size() > 0) { thisYearEntranceData = thisYearEntrance.stream().collect(Collectors.groupingBy(item -> item.get("name"))); stationList.addAll(thisYearEntranceData.keySet()); } // 本期出口 List> thisYearExport = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(now, now, "2"); - Map>> thisYearExportData = new HashMap<>(); - if (thisYearExport != null && thisYearExport.size() > 0){ + Map>> thisYearExportData = new HashMap<>(); + if (thisYearExport != null && thisYearExport.size() > 0) { thisYearExportData = thisYearExport.stream().collect(Collectors.groupingBy(item -> item.get("name"))); stationList.addAll(thisYearExportData.keySet()); } @@ -948,7 +1015,8 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String cell.setCellStyle(headerStyle); cell = row.createCell(UniversalEnum.TWO.getNumber()); cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); - cell.setCellStyle(headerStyle);; + cell.setCellStyle(headerStyle); + ; cell = row.createCell(UniversalEnum.THREE.getNumber()); cell.setCellValue(UniversalEnum.EXIT.getValue()); cell.setCellStyle(headerStyle); @@ -992,7 +1060,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String cell.setCellValue(station); cell.setCellStyle(dataStyle); - if (thisYearEntranceData.containsKey(station)){ + if (thisYearEntranceData.containsKey(station)) { cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); cell.setCellValue(thisYearEntranceData.get(station).get(0).get("value")); cell.setCellStyle(dataStyle); @@ -1002,7 +1070,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String cell.setCellStyle(dataStyle); } - if (lastYearEntranceData.containsKey(station)){ + if (lastYearEntranceData.containsKey(station)) { cell = subHeaderRow.createCell(UniversalEnum.TWO.getNumber()); cell.setCellValue(lastYearEntranceData.get(station).get(0).get("value")); cell.setCellStyle(dataStyle); @@ -1012,7 +1080,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String cell.setCellStyle(dataStyle); } - if (thisYearExportData.containsKey(station)){ + if (thisYearExportData.containsKey(station)) { cell = subHeaderRow.createCell(UniversalEnum.THREE.getNumber()); cell.setCellValue(thisYearExportData.get(station).get(0).get("value")); cell.setCellStyle(dataStyle); @@ -1022,7 +1090,7 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String cell.setCellStyle(dataStyle); } - if (lastYearExportData.containsKey(station)){ + if (lastYearExportData.containsKey(station)) { cell = subHeaderRow.createCell(UniversalEnum.FOUR.getNumber()); cell.setCellValue(lastYearExportData.get(station).get(0).get("value")); 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); } finally { workbook.close(); @@ -1044,52 +1112,57 @@ public AjaxResult trafficFlowAtTollStationEntranceHour(String startDate, String } -/** - * 各收费站入口分车型小时车流量 - */ -@ApiOperation("各收费站入口分车型车流量") -@GetMapping("/history/trafficFlowAtTollStationEntrance") -public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException { - // 调用服务层方法,获取当前交通指标数据 - JSONArray jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntranceHour(startDate, endDate, stationType); - // 将获取到的交通指标数据封装为成功的结果并返回 - return AjaxResult.success(jsonArray); + /** + * 各收费站入口分车型小时车流量 + */ + @ApiOperation("各收费站入口分车型车流量") + @GetMapping("/history/trafficFlowAtTollStationEntrance") + public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate, String stationType) throws HttpException, IOException { + // 调用服务层方法,获取当前交通指标数据 + JSONArray jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntranceHour(startDate, endDate, stationType); + // 将获取到的交通指标数据封装为成功的结果并返回 + return AjaxResult.success(jsonArray); + + } -} /** * 全路段双向实时车流量 */ @ApiOperation("全路段双向实时车流量") @GetMapping("/history/realTimeTrafficFlowHour") - public AjaxResult realTimeTrafficFlowHour() throws HttpException, IOException{ - Map>> mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour(); + public AjaxResult realTimeTrafficFlowHour() throws HttpException, IOException { + Map>> mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour(); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + @ApiOperation("按照桩号查询门架数据 ") @GetMapping("/history/queryTheGantryDataByPileNumber") - public AjaxResult queryTheGantryDataByPileNumber(String startDate,String stakeMark) throws HttpException, IOException{ - List> mapList = dcTrafficStatisticsService.queryTheGantryDataByPileNumber(startDate,stakeMark); + public AjaxResult queryTheGantryDataByPileNumber(String startDate, String stakeMark) throws HttpException, IOException { + List> mapList = dcTrafficStatisticsService.queryTheGantryDataByPileNumber(startDate, stakeMark); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + /** * 获取据库中 收费站统计数据 - * @param startDate 时间 + * + * @param startDate 时间 * @param accessType 出入口 1入 2出 * @param periodType 方向 */ @ApiOperation("获取据库中收费站数数据") @GetMapping("/history/TollBoothStatistics") - public AjaxResult TollBoothStatistics(String startDate,String accessType,String periodType) throws HttpException, IOException{ - List> mapList = dcTollStationStatisticsDataService.TollBoothStatistics(startDate,accessType,periodType); + public AjaxResult TollBoothStatistics(String startDate, String accessType, String periodType) throws HttpException, IOException { + List> mapList = dcTollStationStatisticsDataService.TollBoothStatistics(startDate, accessType, periodType); // 将查询结果封装为成功响应并返回 return AjaxResult.success(mapList); } + @ApiOperation("获取据库中收费站数数据") @GetMapping("/history/TollBoothStatisticsList") - public AjaxResult TollBoothStatisticsList(String startDate, String accessType,String periodType) throws HttpException, IOException{ - List mapList = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate,accessType,periodType); + public AjaxResult TollBoothStatisticsList(String startDate, String accessType, String periodType) throws HttpException, IOException { + List mapList = dcTollStationStatisticsDataService.TollBoothStatisticsList(startDate, accessType, periodType); // 将查询结果封装为成功响应并返回 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") 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(); response.setHeader("Content-Disposition", "attachment; filename=" + fileName); - Map>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour(); - if (map != null){ - List> thisYearHZ = map.get(UniversalEnum.ONE.getValue()); - List> thisYearJN = map.get(UniversalEnum.TWO.getValue()); - List> lastYearHZ = map.get(UniversalEnum.THREE.getValue()); - List> lastYearJN = map.get(UniversalEnum.FOUR.getValue()); + Map>> map = dcTrafficStatisticsService.realTimeTrafficFlowHour(); + if (map != null) { + List> thisYearHZ = map.get(UniversalEnum.ONE.getValue()); + List> thisYearJN = map.get(UniversalEnum.TWO.getValue()); + List> lastYearHZ = map.get(UniversalEnum.THREE.getValue()); + List> lastYearJN = map.get(UniversalEnum.FOUR.getValue()); XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿 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 = row.createCell(UniversalEnum.TWO.getNumber()); cell.setCellValue(UniversalEnum.EMPTY_STRING.getValue()); - cell.setCellStyle(headerStyle);; + cell.setCellStyle(headerStyle); + ; cell = row.createCell(UniversalEnum.THREE.getNumber()); cell.setCellValue(UniversalEnum.DIRECTION_OF_HEZE.getValue()); 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())); 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.setCellValue(thisYearJN.get(i).get("name").toString()); 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); } finally { workbook.close(); diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 86dbc0fc..30cfa1f5 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -457,8 +457,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UNION ALL SELECT 'Weather Warning' AS WarningTypeSource, id, warning_description, warning_type, warning_time, create_time, other_config FROM dc_no_stake_warning_table - WHERE warning_type = 2 - AND warning_time >= DATE_SUB(CURDATE(), INTERVAL 3 DAY) + WHERE warning_type = 2 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