Browse Source

拥堵路段 桩号(修改)

develop
王兴琳 8 months ago
parent
commit
fd878186d5
  1. 21
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

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

@ -734,6 +734,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return map; return map;
} }
//处理 接口响应数据 //处理 接口响应数据
private List<Map<String, Object>> getMaps(String direction, JSONArray jsonArray) throws IOException { private List<Map<String, Object>> getMaps(String direction, JSONArray jsonArray) throws IOException {
@ -792,6 +793,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
} }
return mapList; return mapList;
} }
// 获取车流量接口 返回 jsonArray // 获取车流量接口 返回 jsonArray
private JSONArray getResponseBody(String startDate, RequestParams requestParams, OkHttp okHttp) throws HttpException, IOException { private JSONArray getResponseBody(String startDate, RequestParams requestParams, OkHttp okHttp) throws HttpException, IOException {
JSONObject parameters = new JSONObject() { JSONObject parameters = new JSONObject() {
@ -902,6 +904,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
/** /**
* 获取路况信息 * 获取路况信息
*
* @return * @return
* @throws HttpException * @throws HttpException
* @throws IOException * @throws IOException
@ -930,6 +933,13 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
for (Object object : jsonArray) { for (Object object : jsonArray) {
JSONObject jsonObject = (JSONObject) object; JSONObject jsonObject = (JSONObject) object;
Integer asOneRoad = jsonObject.getInteger("as_one_road"); Integer asOneRoad = jsonObject.getInteger("as_one_road");
double endPileNo = jsonObject.getDouble("end_pile_no");
double startPileNo = jsonObject.getDouble("start_pile_no");
String stakeMark = formatNumber(startPileNo);
String endMark = formatNumber(endPileNo);
jsonObject.put("stakeMark", stakeMark);//当前拥堵距离
jsonObject.put("endMark", endMark);//当前拥堵距离
//as_one_road //as_one_road
//是否为同一条路,1-是,0-否 //是否为同一条路,1-是,0-否
if (asOneRoad == UniversalEnum.ZERO.getNumber()) { if (asOneRoad == UniversalEnum.ZERO.getNumber()) {
@ -999,6 +1009,17 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return nearestFacility; // 返回最近的桩号信息 return nearestFacility; // 返回最近的桩号信息
} }
//桩号转换
public static String formatNumber(double number) {
//将数字分成整数和四舍五入的小数部分
int integerPart = (int) number;
int decimalPart = (int) Math.round((number - integerPart) * 1000); // 四舍五入到最接近的整数
// 将数字格式化为 "K 000+000"
String formattedString = String.format("K%03d+%03d", integerPart, decimalPart);
return formattedString;
}
//经纬度计算距离 //经纬度计算距离
public static double calculateDistance(double startLat, double startLon, double endLat, double endLon) { public static double calculateDistance(double startLat, double startLon, double endLat, double endLon) {

Loading…
Cancel
Save