Browse Source

拥堵路段

develop
王兴琳 8 months ago
parent
commit
fa630ed55d
  1. 10
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  2. 2
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  3. 3
      zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java
  4. 48
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

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

@ -1,6 +1,7 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -571,6 +572,15 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
return AjaxResult.success(jsonArray);
}
@ApiOperation("获取当前拥堵路段")
@GetMapping("/current/getTheCurrentCongestedSection")
public AjaxResult getTheCurrentCongestedSection() throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据
JSONObject jsonArray = dcTrafficStatisticsService.getTheCurrentCongestedSection();
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(jsonArray);
}
/**
* 获取当前拥堵路段信息
*

2
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -587,7 +587,7 @@ public class DeviceMessageHandler {
//设备名称
meteorologicalDetectorData.setDeviceName(deviceName);
meteorologicalDetectorData.setDeviceName(deviceName+"("+stakeMark+")");
//位置
meteorologicalDetectorData.setStakeMark(stakeMark);
//方向

3
zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java

@ -1,6 +1,7 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zc.business.domain.DcRoadSectionCongestion;
import com.zc.common.core.httpclient.exception.HttpException;
@ -55,4 +56,6 @@ public interface IDcTrafficStatisticsService {
Map<String,List<Map<String, Object>>> realTimeTrafficFlowHour() throws HttpException, IOException;
List<Map<String,Object>> queryTheGantryDataByPileNumber(String startDate,String stakeMark) throws HttpException, IOException;
JSONObject getTheCurrentCongestedSection()throws HttpException, IOException;
}

48
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -269,7 +269,6 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
if (body != null) {
return JSON.parseArray(body.string());
}
return new JSONArray();
}
@ -813,7 +812,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return jsonArray;
}
//格式化桩号
private static String extract(String input) {
Pattern pattern = Pattern.compile("K(\\d{3})\\+(\\d{3})");
Matcher matcher = pattern.matcher(input);
@ -897,6 +896,51 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return null;
}
/**
* 获取路况信息
* @return
* @throws HttpException
* @throws IOException
*/
@Override
public JSONObject getTheCurrentCongestedSection() throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams();
requestParams.put("sysid", sysid);
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", getAccessToken());
Response response // 请求响应
= okHttp
.headers(headers)
.url(baseUrl + "/api/dc/query/rd_tr_congestion_jh") // 请求地址
.data(requestParams) // 请求参数
.post(); // 请求方法
ResponseBody body = response.body();
if (body != null) {
JSONArray jsonArray = JSON.parseArray(body.string());
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
Integer asOneRoad = jsonObject.getInteger("as_one_road");
if (asOneRoad == UniversalEnum.ONE.getNumber()){
String string = jsonObject.getString("road_name");
System.out.println(string);
return jsonObject;
}else {
}
}
return new JSONObject();
}
public DcFacility findNearestFacility(List<DcFacility> dcFacilityList, String stakeMarkCode) {
// 将目标桩号转换为整数,以便比较
int targetCodeAsInt = Integer.parseInt(extract(stakeMarkCode));

Loading…
Cancel
Save