From e6f270ac639f13866b0b03d79d6392d10bef9087 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 4 Jun 2024 15:41:12 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=8C=BA?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E8=BF=94=E5=9B=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zc-business/src/main/java/com/zc/business/domain/DcRegion.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcRegion.java b/zc-business/src/main/java/com/zc/business/domain/DcRegion.java index f15246e6..5cc48e2b 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcRegion.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcRegion.java @@ -18,4 +18,6 @@ public class DcRegion { private String longitude; @ApiModelProperty("纬度") private String latitude; + @ApiModelProperty("桩号") + private String stakeNum; } From 460cc5ee7089e0ed88cf7bd44eb687b90cd41c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Tue, 4 Jun 2024 15:43:17 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=90=84=E6=94=B6=E8=B4=B9=E7=AB=99?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E5=88=86=E8=BD=A6=E5=9E=8B=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E8=BD=A6=E6=B5=81=E9=87=8F=EF=BC=8C=E5=85=A8=E8=B7=AF=E6=AE=B5?= =?UTF-8?q?=E5=8F=8C=E5=90=91=E5=AE=9E=E6=97=B6=E8=BD=A6=E6=B5=81=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTrafficStatisticsController.java | 36 +++++- .../mapper/DcGantryStatisticsDataMapper.java | 7 ++ .../IDcGantryStatisticsDataService.java | 5 + .../service/IDcTrafficStatisticsService.java | 8 ++ .../impl/DcGantryStatisticsDataImpl.java | 11 +- .../impl/DcTrafficStatisticsServiceImpl.java | 104 +++++++++++++++++- .../business/DcGantryStatisticsDataMapper.xml | 43 +++++++- 7 files changed, 207 insertions(+), 7 deletions(-) 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 cb2eb3a4..ae1e0d1a 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 @@ -179,6 +179,20 @@ public class DcTrafficStatisticsController { // 将查询结果封装为成功响应并返回 return AjaxResult.success(dcStatisticsData); } +/** + * 全路段双向实时车流量 + * @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); +} + /********************************************* 智慧高速平接口 **************************************************/ @@ -246,6 +260,26 @@ public class DcTrafficStatisticsController { // 将获取到的交通指标数据封装为成功的结果并返回 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/trafficFlowAtTollStationEntrance") +public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException { + // 调用服务层方法,获取当前交通指标数据 + List> jsonArray = dcTrafficStatisticsService.trafficFlowAtTollStationEntrance(startDate, endDate, stationType); + // 将获取到的交通指标数据封装为成功的结果并返回 + return AjaxResult.success(jsonArray); +} } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java index b7eb758a..7dc79413 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcGantryStatisticsDataMapper.java @@ -3,8 +3,11 @@ package com.zc.business.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcGantryStatisticsData; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.Date; +import java.util.List; +import java.util.Map; /** * 这是一个接口的注释,用于描述门架数据统计的Mapper。 @@ -29,5 +32,9 @@ public interface DcGantryStatisticsDataMapper extends BaseMapper> realTimeTrafficFlow(@Param("startDate") String startDate, @Param("direction")String direction, @Param("periodType")String periodType ); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java index e6b95a43..850eac05 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcGantryStatisticsDataService.java @@ -6,6 +6,7 @@ import com.zc.business.domain.DcStatisticsData; import com.zc.business.domain.DcTollStationStatisticsData; import java.util.List; +import java.util.Map; /** * 门架数据统计接口。该接口扩展了IService接口,用于对DcGantryStatisticsData类型的实体进行数据库操作。 @@ -34,4 +35,8 @@ public interface IDcGantryStatisticsDataService extends IService gantryData(DcGantryStatisticsData dcGantryStatisticsData); + /** + * 全路段双向实时车流量 + */ + List> realTimeTrafficFlow(String startDate, String direction,String periodType ); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java index cb272e49..9835ede1 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java @@ -43,4 +43,12 @@ public interface IDcTrafficStatisticsService { * 获取车道占有率信息 */ JSONArray laneOccupancy(String startDate, String endDate) throws HttpException, IOException; + /** + * 断面小时车流量分车型 + */ + JSONArray sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException; + /** + * 各收费站入口分车型小时车流量 + */ + List>trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java index ed8d6d38..f38a8ae2 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java @@ -21,6 +21,7 @@ import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.Date; import java.util.List; +import java.util.Map; /** * 门架数据统计服务实现类 @@ -37,7 +38,8 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl> realTimeTrafficFlow(String startDate, String direction,String periodType ) { + return dcGantryStatisticsDataMapper.realTimeTrafficFlow(startDate,direction,periodType); + } /** * 恢复日缓存数据的方法 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index af3b68d7..162560dc 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -23,10 +23,7 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsService { @@ -509,5 +506,104 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi return new JSONArray(); } + /** + * 断面小时车流量分车型 + */ + @Override + public JSONArray sectionHourlyTrafficFlow(String startDate, String endDate) throws HttpException, IOException { + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + + requestParams.put("sysid", sysid); + + JSONObject parameters = new JSONObject() { + { + put("start_date", startDate); + put("end_date", endDate); + } + }; + + requestParams.put("parameters", parameters.toJSONString()); + + Map headers = new HashMap<>(); + headers.put("Authorization", getAccessToken()); + + Response response // 请求响应 + = okHttp + .headers(headers) + .url(baseUrl + "/api/dc/query/rd_jihe_d_vehtypeflowbydatesection") // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + + ResponseBody body = response.body(); + if (body != null) { + return JSON.parseArray(body.string()); + } + + return new JSONArray(); + } +/** + * 各收费站入口分车型小时车流量 + */ + @Override + public List> trafficFlowAtTollStationEntrance(String startDate, String endDate,String stationType) throws HttpException, IOException { + OkHttp okHttp = new OkHttp(); + + RequestParams requestParams = new RequestParams(); + + requestParams.put("sysid", sysid); + + JSONObject parameters = new JSONObject() { + { + put("start_date", startDate); + put("end_date", endDate); + put("station_type", stationType); + } + }; + + requestParams.put("parameters", parameters.toJSONString()); + + Map headers = new HashMap<>(); + headers.put("Authorization", getAccessToken()); + + Response response // 请求响应 + = okHttp + .headers(headers) + .url(baseUrl + "/api/dc/query/ts_jihe_d_vehtypeflowbyhourstation") // 请求地址 + .data(requestParams) // 请求参数 + .post(); // 请求方法 + + ResponseBody body = response.body(); + if (body != null) { + JSONArray jsonArray = JSON.parseArray(body.string()); + +// 使用HashMap来分组并求和 + Map sumByName = new HashMap<>(); + List> list = new ArrayList(); + + for (Object item : jsonArray) { // 这里做了微调,直接遍历jsonArray的Object + JSONObject jsonObject = (JSONObject) item; + String name = jsonObject.getString("ts_name"); // 更安全的取值方式 + int totalFlow = jsonObject.getInteger("total_flow"); // 专门针对Integer类型 + sumByName.put(name, sumByName.getOrDefault(name, 0) + totalFlow); + + } + +// 输出结果 +// 输出结果 + // 正确创建新的映射对象并添加到list中 + for (Map.Entry entry : sumByName.entrySet()) { + Map singleResult = new HashMap<>(); // 每次循环都创建一个新的映射 + singleResult.put("name", entry.getKey()); + singleResult.put("value", entry.getValue().toString()); + list.add(singleResult); + System.out.println(entry.getKey() + " 的 total_flow 总和为: " + entry.getValue()); + } + return list; + } + + return new ArrayList(); + } } diff --git a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml index 851f7fe9..e8b420dd 100644 --- a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml @@ -3,7 +3,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + + + INSERT INTO @@ -87,5 +90,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM dc_gantry_statistics_data + From 463db731c6100d13a146b287be77d580560a0422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Wed, 5 Jun 2024 09:34:28 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=98=AF=E5=90=A6dc?= =?UTF-8?q?=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/system/menu/index.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index c30be850..6f249b5e 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -65,6 +65,7 @@ +