Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 坐标
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 15:14
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapCoordinates {
|
|
||||||
|
|
||||||
private double latitude;
|
|
||||||
private double longitude;
|
|
||||||
private String address;
|
|
||||||
private String latlng;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/1 21:56
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapLocationDto {
|
|
||||||
private String title;
|
|
||||||
private String address;
|
|
||||||
private String city;
|
|
||||||
private String country;
|
|
||||||
private String postalCode;
|
|
||||||
private double latitude;
|
|
||||||
private double longitude;
|
|
||||||
|
|
||||||
public HereMapLocationDto() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public HereMapLocationDto(String address, String city, String country, String postalCode, double latitude, double longitude) {
|
|
||||||
this.address = address;
|
|
||||||
this.city = city;
|
|
||||||
this.country = country;
|
|
||||||
this.postalCode = postalCode;
|
|
||||||
this.latitude = latitude;
|
|
||||||
this.longitude = longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HereMapLocationDto(String title, String address, double latitude, double longitude) {
|
|
||||||
this.title = title;
|
|
||||||
this.address = address;
|
|
||||||
this.latitude = latitude;
|
|
||||||
this.longitude = longitude;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap;
|
|
||||||
|
|
||||||
import com.vetti.common.entity.hereMap.vehicle.HereMapVehicleTruck;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 16:40
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRouteVo {
|
|
||||||
|
|
||||||
// 基本路线参数
|
|
||||||
private HereMapCoordinates origin; // 起点坐标 (纬度,经度)
|
|
||||||
private HereMapCoordinates destination; // 终点坐标 (纬度,经度)
|
|
||||||
private List<HereMapCoordinates> via; // 途径点坐标列表 (纬度,经度)
|
|
||||||
private String transportMode; // 运输方式
|
|
||||||
private List<String> avoid; // 避开选项
|
|
||||||
|
|
||||||
private String routingMode; // 路线偏好
|
|
||||||
|
|
||||||
private String returnStr = "polyline,actions,instructions,summary,travelSummary,typicalDuration,turnByTurnActions,elevation,routeHandle,passthrough,incidents,routingZones,truckRoadTypes,tolls,routeLabels,potentialTimeDependentViolations,noThroughRestrictions"; // 路线偏好
|
|
||||||
private String lang; // 语言
|
|
||||||
private String units; // 单位("metric" "imperial" 枚举:“公制”“英制”)
|
|
||||||
|
|
||||||
private String departureTime; // 开始时间
|
|
||||||
private String arrivalTime; // 结束时间
|
|
||||||
|
|
||||||
|
|
||||||
private HereMapVehicleTruck vehicle;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 16:40
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapTruckRoute {
|
|
||||||
|
|
||||||
// 基本路线参数
|
|
||||||
private String start; // 起点坐标 (纬度,经度)
|
|
||||||
private String end; // 终点坐标 (纬度,经度)
|
|
||||||
private String routePreference; // 路线偏好: fastest, shortest, balanced
|
|
||||||
|
|
||||||
// 车辆基本参数
|
|
||||||
private Integer height; // 高度(厘米)
|
|
||||||
private Integer width; // 宽度(厘米)
|
|
||||||
private Integer length; // 长度(厘米)
|
|
||||||
private Integer weightTotal; // 总重量(KG)
|
|
||||||
|
|
||||||
// 避开选项
|
|
||||||
private boolean avoidHighways; // 避开高速公路
|
|
||||||
private boolean avoidTolls; // 避开收费道路
|
|
||||||
private boolean avoidFerries; // 避开轮渡
|
|
||||||
private boolean avoidTunnels; // 避开隧道
|
|
||||||
private boolean avoidDifficultTurns; // 避开掉头
|
|
||||||
private boolean avoidDirtRoads; // 避开土路
|
|
||||||
|
|
||||||
// 危化品参数
|
|
||||||
private boolean hazmatExplosive;
|
|
||||||
private boolean hazmatGas;
|
|
||||||
private boolean hazmatFlammable;
|
|
||||||
private boolean hazmatCombustible;
|
|
||||||
private boolean hazmatOrganic;
|
|
||||||
private boolean hazmatPoison;
|
|
||||||
private boolean hazmatRadioactive;
|
|
||||||
private boolean hazmatCorrosive;
|
|
||||||
private boolean hazmatPoisonousInhalation;
|
|
||||||
private boolean hazmatHarmfulToWater;
|
|
||||||
private boolean hazmatOther;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.queryParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/5 23:55
|
|
||||||
*/
|
|
||||||
public abstract class BaseHereMapQueryParamVehicle {
|
|
||||||
|
|
||||||
private Integer height;//高 cm
|
|
||||||
|
|
||||||
private Integer width;//宽 cm
|
|
||||||
|
|
||||||
private Integer length;//长 cm
|
|
||||||
|
|
||||||
private Integer payloadCapacity;//载重 kg
|
|
||||||
|
|
||||||
private String shippedHazardousGoods;//危化品
|
|
||||||
|
|
||||||
protected HereMapQueryParam getHeight(Integer height) {
|
|
||||||
return HereMapQueryParam.build("vehicle[height]", height);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HereMapQueryParam getWidth(Integer width) {
|
|
||||||
return HereMapQueryParam.build("vehicle[width]", width);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HereMapQueryParam getLength(Integer length) {
|
|
||||||
return HereMapQueryParam.build("vehicle[length]", length);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HereMapQueryParam getPayloadCapacity(Integer payloadCapacity) {
|
|
||||||
return HereMapQueryParam.build("vehicle[payloadCapacity]", payloadCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HereMapQueryParam getShippedHazardousGoods(String shippedHazardousGoods) {
|
|
||||||
return HereMapQueryParam.build("vehicle[shippedHazardousGoods]", shippedHazardousGoods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.queryParam;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 22:03
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapQueryParam {
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
private Object value;
|
|
||||||
|
|
||||||
public static HereMapQueryParam build(String key, Object value) {
|
|
||||||
HereMapQueryParam data = new HereMapQueryParam();
|
|
||||||
data.setKey(key);
|
|
||||||
data.setValue(value);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.queryParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/5 23:55
|
|
||||||
*/
|
|
||||||
public class HereMapQueryParamTruck extends BaseHereMapQueryParamVehicle{
|
|
||||||
|
|
||||||
public HereMapQueryParam getHeight(Integer height) {
|
|
||||||
return super.getHeight(height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HereMapQueryParam getWidth(Integer width) {
|
|
||||||
return super.getWidth(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HereMapQueryParam getLength(Integer length) {
|
|
||||||
return super.getLength(length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HereMapQueryParam getPayloadCapacity(Integer payloadCapacity) {
|
|
||||||
return super.getPayloadCapacity(payloadCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HereMapQueryParam getShippedHazardousGoods(String shippedHazardousGoods) {
|
|
||||||
return super.getShippedHazardousGoods(shippedHazardousGoods);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础导航动作(含中文指令)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:44
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapAction {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动作类型(depart/turn/continue/arrive)
|
|
||||||
*/
|
|
||||||
private String action;
|
|
||||||
/**
|
|
||||||
* 动作耗时(秒)
|
|
||||||
*/
|
|
||||||
private Integer duration;
|
|
||||||
/**
|
|
||||||
* 动作距离(米)
|
|
||||||
*/
|
|
||||||
private Integer length;
|
|
||||||
/**
|
|
||||||
* 中文导航指令(如"沿着 Bluegum Pl 朝 Alison St 行驶")
|
|
||||||
*/
|
|
||||||
private String instruction;
|
|
||||||
/**
|
|
||||||
* 偏移量(路线中的位置索引)
|
|
||||||
*/
|
|
||||||
private Integer offset;
|
|
||||||
/**
|
|
||||||
* 转向方向(仅turn动作有值:left/right)
|
|
||||||
*/
|
|
||||||
private String direction;
|
|
||||||
/**
|
|
||||||
* 转向强度(仅turn动作有值:quite)
|
|
||||||
*/
|
|
||||||
private String severity;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 到达信息
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:55
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapArrival {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 到达时间(ISO8601格式,如"2025-09-11T11:44:37+10:00")
|
|
||||||
*/
|
|
||||||
private String time;
|
|
||||||
/**
|
|
||||||
* 到达地点
|
|
||||||
*/
|
|
||||||
private HereMapPlace place;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 出发信息
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:54
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapDeparture {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 出发时间(ISO8601格式,如"2025-09-11T11:27:17+10:00")
|
|
||||||
*/
|
|
||||||
private String time;
|
|
||||||
/**
|
|
||||||
* 出发地点
|
|
||||||
*/
|
|
||||||
private HereMapPlace place;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 坐标信息(经纬度、海拔)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:57
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapLocation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 纬度(如-33.7895301)
|
|
||||||
*/
|
|
||||||
private Double lat;
|
|
||||||
/**
|
|
||||||
* 经度(如151.16786)
|
|
||||||
*/
|
|
||||||
private Double lng;
|
|
||||||
/**
|
|
||||||
* 海拔(米,如70.0)
|
|
||||||
*/
|
|
||||||
private Double elv;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知信息(如计算提示、警告)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 15:02
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapNotice {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知标题(如"Pre-conditions required for mlDuration calculation failed")
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
/**
|
|
||||||
* 通知编码(如"mlDurationUnavailable")
|
|
||||||
*/
|
|
||||||
private String code;
|
|
||||||
/**
|
|
||||||
* 通知级别(info/warn/error,此处为info)
|
|
||||||
*/
|
|
||||||
private String severity;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地点信息(经纬度、海拔)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:56
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapPlace {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地点类型(固定为"place")
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* 校正后坐标(含海拔)
|
|
||||||
*/
|
|
||||||
private HereMapLocation location;
|
|
||||||
/**
|
|
||||||
* 原始坐标(用户输入或初始定位)
|
|
||||||
*/
|
|
||||||
private HereMapLocation originalLocation;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路信息(名称、编号、行驶方向)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:47
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRoadInfo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路名称列表(多语言,此处仅en)
|
|
||||||
*/
|
|
||||||
private List<HereMapRoadName> name;
|
|
||||||
/**
|
|
||||||
* 道路编号列表(如A1、A38,含路线类型)
|
|
||||||
*/
|
|
||||||
private List<HereMapRoadNumber> number;
|
|
||||||
/**
|
|
||||||
* 行驶方向列表(如"Frenchs Forest"、"City")
|
|
||||||
*/
|
|
||||||
private List<HereMapRoadToward> toward;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路名称(多语言支持)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:48
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRoadName {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路名称(如"Bluegum Pl")
|
|
||||||
*/
|
|
||||||
private String value;
|
|
||||||
/**
|
|
||||||
* 语言(固定为"en")
|
|
||||||
*/
|
|
||||||
private String language;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路编号(含路线类型)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:49
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRoadNumber {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路编号(如"A1"、"A38")
|
|
||||||
*/
|
|
||||||
private String value;
|
|
||||||
/**
|
|
||||||
* 语言(固定为"en")
|
|
||||||
*/
|
|
||||||
private String language;
|
|
||||||
/**
|
|
||||||
* 路线类型(固定为6,代表主干道)
|
|
||||||
*/
|
|
||||||
private Integer routeType;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路行驶方向
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:50
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRoadToward {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 方向名称(如"Northbridge"、"Airport")
|
|
||||||
*/
|
|
||||||
private String value;
|
|
||||||
/**
|
|
||||||
* 语言(固定为"en")
|
|
||||||
*/
|
|
||||||
private String language;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个路由信息
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:42
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRoute {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路由ID(如"6e1a8f39-d309-43d0-8b72-ab9b810af8b1")
|
|
||||||
*/
|
|
||||||
private String id;
|
|
||||||
/**
|
|
||||||
* 路由分段列表(仅包含vehicle类型分段)
|
|
||||||
*/
|
|
||||||
private List<HereMapRouteSection> sections;
|
|
||||||
/**
|
|
||||||
* 路由标识(如道路名称、编号)
|
|
||||||
*/
|
|
||||||
private List<HereMapRouteLabel> routeLabels;
|
|
||||||
/**
|
|
||||||
* 路由句柄(编码字符串)
|
|
||||||
*/
|
|
||||||
private String routeHandle;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路由响应顶层实体
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:41
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRouteDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路由列表(JSON中的"routes"数组)
|
|
||||||
*/
|
|
||||||
private List<HereMapRoute> routes;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路由标识(道路名称、编号)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:43
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRouteLabel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标识类型(Name/RouteNumber)
|
|
||||||
*/
|
|
||||||
private String label_type;
|
|
||||||
/**
|
|
||||||
* 名称信息(如道路名称)
|
|
||||||
*/
|
|
||||||
private HereMapRoadName name;
|
|
||||||
/**
|
|
||||||
* 路线编号信息(如A38)
|
|
||||||
*/
|
|
||||||
private HereMapRoadNumber routeNumber;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路由分段(车辆行驶分段)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:42
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapRouteSection {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分段ID(如"7bed8aae-2ad3-4e74-8a11-0a2ae7eedc97")
|
|
||||||
*/
|
|
||||||
private String id;
|
|
||||||
/**
|
|
||||||
* 分段类型(固定为"vehicle")
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* 行驶动作列表(含中文导航指令)
|
|
||||||
*/
|
|
||||||
private List<HereMapAction> actions;
|
|
||||||
/**
|
|
||||||
* 详细转向动作列表(含道路信息、转向角度)
|
|
||||||
*/
|
|
||||||
private List<HereMapTurnByTurnAction> turnByTurnActions;
|
|
||||||
/**
|
|
||||||
* 出发信息(时间、地点)
|
|
||||||
*/
|
|
||||||
private HereMapDeparture departure;
|
|
||||||
/**
|
|
||||||
* 到达信息(时间、地点)
|
|
||||||
*/
|
|
||||||
private HereMapArrival arrival;
|
|
||||||
/**
|
|
||||||
* 分段概要(时长、距离等)
|
|
||||||
*/
|
|
||||||
private HereMapSummary summary;
|
|
||||||
/**
|
|
||||||
* 行程概要(与summary结构一致)
|
|
||||||
*/
|
|
||||||
private HereMapTravelSummary travelSummary;
|
|
||||||
/**
|
|
||||||
* 路线polyline编码(用于地图绘制)
|
|
||||||
*/
|
|
||||||
private String polyline;
|
|
||||||
/**
|
|
||||||
* 通知信息(如计算提示)
|
|
||||||
*/
|
|
||||||
private List<HereMapNotice> notices;
|
|
||||||
/**
|
|
||||||
* 语言(固定为"zh-cn")
|
|
||||||
*/
|
|
||||||
private String language;
|
|
||||||
/**
|
|
||||||
* 交通方式(固定为"car")
|
|
||||||
*/
|
|
||||||
private HereMapTransport transport;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路牌信息(导航标识)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:52
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapSignpost {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路牌标签列表(含道路名称、方向、编号)
|
|
||||||
*/
|
|
||||||
private List<HereMapSignpostLabel> labels;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 路牌标签(单个标识项)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:52
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapSignpostLabel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称标签(如道路名称、方向)
|
|
||||||
*/
|
|
||||||
private HereMapRoadName name;
|
|
||||||
/**
|
|
||||||
* 路线编号标签(如"A38")
|
|
||||||
*/
|
|
||||||
private HereMapRoadNumber routeNumber;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分段概要(时长、距离统计)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:59
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapSummary {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总耗时(秒,含交通延误)
|
|
||||||
*/
|
|
||||||
private Integer duration;
|
|
||||||
/**
|
|
||||||
* 总距离(米)
|
|
||||||
*/
|
|
||||||
private Integer length;
|
|
||||||
/**
|
|
||||||
* 基础耗时(秒,不含交通延误)
|
|
||||||
*/
|
|
||||||
private Integer baseDuration;
|
|
||||||
/**
|
|
||||||
* 典型耗时(秒,历史平均耗时)
|
|
||||||
*/
|
|
||||||
private Integer typicalDuration;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 交通方式
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 15:03
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapTransport {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 交通模式(固定为"car")
|
|
||||||
*/
|
|
||||||
private String mode;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行程概要(与Summary结构完全一致)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 15:00
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapTravelSummary {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总耗时(秒,含交通延误)
|
|
||||||
*/
|
|
||||||
private Integer duration;
|
|
||||||
/**
|
|
||||||
* 总距离(米)
|
|
||||||
*/
|
|
||||||
private Integer length;
|
|
||||||
/**
|
|
||||||
* 基础耗时(秒,不含交通延误)
|
|
||||||
*/
|
|
||||||
private Integer baseDuration;
|
|
||||||
/**
|
|
||||||
* 典型耗时(秒,历史平均耗时)
|
|
||||||
*/
|
|
||||||
private Integer typicalDuration;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.route;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 详细转向动作(含道路信息、转向角度)
|
|
||||||
*
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/11 14:46
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapTurnByTurnAction {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动作类型(同Action的action字段)
|
|
||||||
*/
|
|
||||||
private String action;
|
|
||||||
/**
|
|
||||||
* 动作耗时(秒)
|
|
||||||
*/
|
|
||||||
private Integer duration;
|
|
||||||
/**
|
|
||||||
* 动作距离(米)
|
|
||||||
*/
|
|
||||||
private Integer length;
|
|
||||||
/**
|
|
||||||
* 偏移量(路线中的位置索引)
|
|
||||||
*/
|
|
||||||
private Integer offset;
|
|
||||||
/**
|
|
||||||
* 转向方向(仅turn动作有值:left/right)
|
|
||||||
*/
|
|
||||||
private String direction;
|
|
||||||
/**
|
|
||||||
* 转向强度(仅turn动作有值:quite)
|
|
||||||
*/
|
|
||||||
private String severity;
|
|
||||||
/**
|
|
||||||
* 当前道路信息(仅非depart动作有值)
|
|
||||||
*/
|
|
||||||
private HereMapRoadInfo currentRoad;
|
|
||||||
/**
|
|
||||||
* 下一条道路信息(仅非arrive动作有值)
|
|
||||||
*/
|
|
||||||
private HereMapRoadInfo nextRoad;
|
|
||||||
/**
|
|
||||||
* 转向角度(度,负值为左转,正值为右转)
|
|
||||||
*/
|
|
||||||
private Double turnAngle;
|
|
||||||
/**
|
|
||||||
* 路牌信息(含导航标识)
|
|
||||||
*/
|
|
||||||
private HereMapSignpost signpost;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.vehicle;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/12 9:33
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapVehicle {
|
|
||||||
|
|
||||||
private Integer height;//高 cm
|
|
||||||
|
|
||||||
private Integer width;//宽 cm
|
|
||||||
|
|
||||||
private Integer length;//长 cm
|
|
||||||
|
|
||||||
private Double speedCap;//最大速度 m/s
|
|
||||||
|
|
||||||
private Integer grossWeight;//车辆总重量,包括挂车和满载货物。 kg
|
|
||||||
|
|
||||||
private Integer currentWeight;//当前车辆总重量,包括挂车和满载货物。 kg
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.vetti.common.entity.hereMap.vehicle;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/12 9:33
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class HereMapVehicleTruck extends HereMapVehicle {
|
|
||||||
|
|
||||||
private Integer axleCount;//总轴数 指定车辆具有的轴的总数,即基础车辆上的轴和任何附加的拖车。
|
|
||||||
private Integer trailerAxleCount;//拖车总轴数,不含车头 指定连接到车辆的所有拖车的轴总数。 这个数字包含在 axleCount 中,因此 trailerAxleCount 必须严格小于 axleCount 。 trailerCount 必须非零。
|
|
||||||
private Integer weightPerAxle;//每轴最重车辆重量 kg 每轴最重车辆重量,单位为公斤。
|
|
||||||
private Integer trailerCount;//拖车数量 与车辆相连的拖车的数量。
|
|
||||||
private String type;//类型 StraightTruck:直车(单车架设计,载货区(如货箱)与车架永久固定,不可分离);Tractor:牵引车 / 拖拉机()仅为 “牵引车头”,无独立载货区,需通过牵引装置连接半挂车
|
|
||||||
|
|
||||||
private String cargoType;//货物类型 非here map 属性 normal:普通货物;hazardous:危险品
|
|
||||||
private List<String> hazardousGoods;//危化品
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package com.vetti.common.service.hereMap;
|
|
||||||
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapLocationDto;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface HereMapGeocoderService {
|
|
||||||
|
|
||||||
List<HereMapLocationDto> getCoordinates(String location);
|
|
||||||
|
|
||||||
HereMapLocationDto getLocationFromCoordinates(double latitude, double longitude);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.vetti.common.service.hereMap;
|
|
||||||
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapRouteVo;
|
|
||||||
import com.vetti.common.entity.hereMap.route.HereMapRouteDto;
|
|
||||||
|
|
||||||
public interface HereMapRoutingService {
|
|
||||||
|
|
||||||
HereMapRouteDto findRouting(HereMapRouteVo truckRoute);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
package com.vetti.common.service.hereMap.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.vetti.common.config.HereMapsProperties;
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapCoordinates;
|
|
||||||
import com.vetti.common.entity.hereMap.queryParam.HereMapQueryParam;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 21:42
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
public abstract class BaseHereMapsService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected HereMapsProperties hereMapsProperties;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected HttpClient httpClient;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@Value("${http.client.connect-timeout-seconds:10}")
|
|
||||||
protected Integer connectTimeoutSeconds;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建HTTP请求
|
|
||||||
*/
|
|
||||||
protected HttpRequest buildHttpRequest(URI uri) {
|
|
||||||
return HttpRequest.newBuilder()
|
|
||||||
.uri(uri)
|
|
||||||
.timeout(Duration.ofSeconds(connectTimeoutSeconds))
|
|
||||||
.header("Accept", "application/json")
|
|
||||||
.GET()
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected URI buildUri(String url, List<HereMapQueryParam> queryParams) throws Exception {
|
|
||||||
String uriStr = url + "?" + hereMapQueryParamToStr(queryParams) + apiKey();
|
|
||||||
return new URIBuilder(uriStr).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送HTTP请求并处理响应状态
|
|
||||||
*/
|
|
||||||
protected HttpResponse<String> sendHttpRequest(HttpRequest request) throws Exception {
|
|
||||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
|
||||||
int statusCode = response.statusCode();
|
|
||||||
if (statusCode != 200) {
|
|
||||||
String errorMsg = String.format(
|
|
||||||
"HERE Maps API请求失败:状态码=%d, 响应体=%s",
|
|
||||||
statusCode, response.body()
|
|
||||||
);
|
|
||||||
log.error(errorMsg);
|
|
||||||
throw new Exception(errorMsg);
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全获取JSON节点文本,避免空指针
|
|
||||||
*/
|
|
||||||
protected String getOptionalNodeText(JsonNode parentNode, String fieldName) {
|
|
||||||
JsonNode node = parentNode.get(fieldName);
|
|
||||||
return (node != null && !node.isNull()) ? node.asText() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String apiKey() {
|
|
||||||
return "apiKey=" + hereMapsProperties.getApiKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String hereMapQueryParamToStr(List<HereMapQueryParam> queryParams) {
|
|
||||||
if (CollectionUtils.isNotEmpty(queryParams)) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
queryParams.forEach(e -> {
|
|
||||||
if (e.getValue() instanceof HereMapCoordinates) {
|
|
||||||
sb.append(e.getKey()).append("=").append(((HereMapCoordinates) e.getValue()).getLatlng()).append("&");
|
|
||||||
} else {
|
|
||||||
sb.append(e.getKey()).append("=").append(e.getValue()).append("&");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
package com.vetti.common.service.hereMap.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapLocationDto;
|
|
||||||
import com.vetti.common.entity.hereMap.queryParam.HereMapQueryParam;
|
|
||||||
import com.vetti.common.exception.UtilException;
|
|
||||||
import com.vetti.common.service.hereMap.HereMapGeocoderService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 21:43
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Service
|
|
||||||
public class HereMapGeocoderServiceImpl extends BaseHereMapsService implements HereMapGeocoderService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据地点名称查询坐标
|
|
||||||
*
|
|
||||||
* @param location 地点名称(如"北京天安门")
|
|
||||||
* @return 地点信息+坐标列表
|
|
||||||
* @throws Exception 包含网络异常、API错误等
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<HereMapLocationDto> getCoordinates(String location) {
|
|
||||||
try {
|
|
||||||
// 1. 参数校验
|
|
||||||
if (location == null || location.trim().isEmpty()) {
|
|
||||||
log.error("地点名称不能为空");
|
|
||||||
throw new IllegalArgumentException("地点名称不能为空");
|
|
||||||
}
|
|
||||||
// 2. 构建请求URL
|
|
||||||
List<HereMapQueryParam> queryParams = new ArrayList<>();
|
|
||||||
String encodedLocation = URLEncoder.encode(location, StandardCharsets.UTF_8.name());
|
|
||||||
queryParams.add(HereMapQueryParam.build("q", encodedLocation));
|
|
||||||
// 3. 构建并发送HTTP请求
|
|
||||||
URI requestUri = buildUri(hereMapsProperties.getGeocodingApiUrl(), queryParams);
|
|
||||||
HttpRequest request = buildHttpRequest(requestUri);
|
|
||||||
HttpResponse<String> response = sendHttpRequest(request);
|
|
||||||
// 4. 处理响应并返回结果
|
|
||||||
log.info("HERE Maps API请求成功,响应体长度:{} 字符", response.body().length());
|
|
||||||
return parseGeocodingResponse(response.body());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("根据地点名称查询坐标信息失败", e);
|
|
||||||
throw new UtilException("根据地点名称查询坐标信息失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据经纬度获取地理位置信息
|
|
||||||
*
|
|
||||||
* @param latitude 纬度(-90到90之间)
|
|
||||||
* @param longitude 经度(-180到180之间)
|
|
||||||
* @return 地理位置信息Optional
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public HereMapLocationDto getLocationFromCoordinates(double latitude, double longitude) {
|
|
||||||
try {
|
|
||||||
// 1. 参数校验
|
|
||||||
validateCoordinates(latitude, longitude);
|
|
||||||
List<HereMapQueryParam> queryParams = new ArrayList<>();
|
|
||||||
queryParams.add(HereMapQueryParam.build("at", latitude + "," + longitude));
|
|
||||||
URI requestUri = buildUri(hereMapsProperties.getReverseGeocodingApiUrl(), queryParams);
|
|
||||||
HttpRequest request = buildHttpRequest(requestUri);
|
|
||||||
HttpResponse<String> response = sendHttpRequest(request);
|
|
||||||
// 4. 处理响应并返回结果
|
|
||||||
log.info("HERE Maps API请求成功,响应体长度:{} 字符", response.body().length());
|
|
||||||
return parseLocationResponse(response.body(), latitude, longitude);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取地理位置信息失败", e);
|
|
||||||
throw new UtilException("获取地理位置信息失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析地理编码响应
|
|
||||||
*/
|
|
||||||
private List<HereMapLocationDto> parseGeocodingResponse(String responseBody) {
|
|
||||||
List<HereMapLocationDto> results = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
|
||||||
JsonNode itemsNode = rootNode.get("items");
|
|
||||||
if (itemsNode == null || !itemsNode.isArray() || itemsNode.size() == 0) {
|
|
||||||
log.warn("地理编码无匹配结果");
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
for (JsonNode item : itemsNode) {
|
|
||||||
String title = item.get("title").asText();
|
|
||||||
String address = item.get("address").get("label").asText();
|
|
||||||
JsonNode position = item.get("position");
|
|
||||||
double latitude = position.get("lat").asDouble();
|
|
||||||
double longitude = position.get("lng").asDouble();
|
|
||||||
results.add(new HereMapLocationDto(title, address, latitude, longitude));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析地理编码响应失败", e);
|
|
||||||
throw new RuntimeException("解析地理编码结果失败", e);
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析逆地理编码响应
|
|
||||||
*/
|
|
||||||
private HereMapLocationDto parseLocationResponse(String responseBody, double latitude, double longitude) {
|
|
||||||
try {
|
|
||||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
|
||||||
JsonNode itemsNode = rootNode.get("items");
|
|
||||||
if (itemsNode != null && itemsNode.isArray() && itemsNode.size() > 0) {
|
|
||||||
JsonNode firstItem = itemsNode.get(0);
|
|
||||||
JsonNode addressNode = firstItem.get("address");
|
|
||||||
HereMapLocationDto location = new HereMapLocationDto();
|
|
||||||
location.setTitle(firstItem.get("title").asText());
|
|
||||||
location.setLatitude(latitude);
|
|
||||||
location.setLongitude(longitude);
|
|
||||||
location.setAddress(addressNode.get("label").asText());
|
|
||||||
location.setCity(getOptionalNodeText(addressNode, "city"));
|
|
||||||
location.setCountry(getOptionalNodeText(addressNode, "countryName"));
|
|
||||||
location.setPostalCode(getOptionalNodeText(addressNode, "postalCode"));
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
log.warn("逆地理编码无匹配结果");
|
|
||||||
return null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析逆地理编码响应失败", e);
|
|
||||||
throw new RuntimeException("解析地理位置结果失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验经纬度合法性
|
|
||||||
*/
|
|
||||||
private void validateCoordinates(double latitude, double longitude) {
|
|
||||||
if (latitude < -90 || latitude > 90) {
|
|
||||||
log.error("纬度值不合法: {}", latitude);
|
|
||||||
throw new IllegalArgumentException("纬度必须在-90到90之间");
|
|
||||||
}
|
|
||||||
if (longitude < -180 || longitude > 180) {
|
|
||||||
log.error("经度值不合法: {}", longitude);
|
|
||||||
throw new IllegalArgumentException("经度必须在-180到180之间");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package com.vetti.common.service.hereMap.impl;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapCoordinates;
|
|
||||||
import com.vetti.common.entity.hereMap.HereMapRouteVo;
|
|
||||||
import com.vetti.common.entity.hereMap.queryParam.HereMapQueryParam;
|
|
||||||
import com.vetti.common.entity.hereMap.queryParam.HereMapQueryParamTruck;
|
|
||||||
import com.vetti.common.entity.hereMap.route.HereMapRouteDto;
|
|
||||||
import com.vetti.common.entity.hereMap.vehicle.HereMapVehicleTruck;
|
|
||||||
import com.vetti.common.exception.ServiceException;
|
|
||||||
import com.vetti.common.exception.UtilException;
|
|
||||||
import com.vetti.common.service.hereMap.HereMapRoutingService;
|
|
||||||
import com.vetti.common.utils.StringUtils;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ID
|
|
||||||
* @date 2025/9/4 21:43
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Service
|
|
||||||
public class HereMapRoutingServiceImpl extends BaseHereMapsService implements HereMapRoutingService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HereMapRouteDto findRouting(HereMapRouteVo truckRoute) {
|
|
||||||
try {
|
|
||||||
URI requestUri = buildRoutingUri(truckRoute);
|
|
||||||
HttpRequest request = buildHttpRequest(requestUri);
|
|
||||||
HttpResponse<String> response = sendHttpRequest(request);
|
|
||||||
// 4. 处理响应并返回结果
|
|
||||||
log.info("HERE Maps API请求成功,响应体长度:{} 字符", response.body().length());
|
|
||||||
return parseRoutingResponse(response.body());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取地理位置信息失败", e);
|
|
||||||
log.error("获取地理位置信息失败", e);
|
|
||||||
throw new UtilException("获取地理位置信息失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HereMapRouteDto parseRoutingResponse(String body) {
|
|
||||||
if (StringUtils.isEmpty(body)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JSONObject.parseObject(body, HereMapRouteDto.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建路线规划请求URI
|
|
||||||
*/
|
|
||||||
private URI buildRoutingUri(HereMapRouteVo truckRoute) throws Exception {
|
|
||||||
List<HereMapQueryParam> queryParams = new ArrayList<>();
|
|
||||||
// 添加基本路线参数
|
|
||||||
addBasicRoutingParameters(queryParams, truckRoute);
|
|
||||||
// 添加车辆参数
|
|
||||||
addTruckParameters(queryParams, truckRoute);
|
|
||||||
|
|
||||||
return buildUri(hereMapsProperties.getRouterApiUrl(), queryParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String queryParamsListToStr(List<String> list) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
for (String str : list) {
|
|
||||||
sb.append(str).append(",");
|
|
||||||
}
|
|
||||||
sb.deleteCharAt(sb.length() - 1);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加基本路线参数
|
|
||||||
*/
|
|
||||||
private void addBasicRoutingParameters(List<HereMapQueryParam> queryParams, HereMapRouteVo truckRoute) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("origin", truckRoute.getOrigin()));
|
|
||||||
queryParams.add(HereMapQueryParam.build("destination", truckRoute.getDestination()));
|
|
||||||
if (CollectionUtils.isNotEmpty(truckRoute.getVia())) {
|
|
||||||
for (HereMapCoordinates via : truckRoute.getVia()) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("via", via.getLatlng()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(truckRoute.getVia())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("avoid[features]", queryParamsListToStr(truckRoute.getAvoid())));
|
|
||||||
}
|
|
||||||
|
|
||||||
queryParams.add(HereMapQueryParam.build("transportMode", truckRoute.getTransportMode()));
|
|
||||||
|
|
||||||
queryParams.add(HereMapQueryParam.build("routingMode", truckRoute.getRoutingMode()));
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(truckRoute.getReturnStr())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("return",
|
|
||||||
"polyline,actions,instructions,summary,travelSummary,typicalDuration,turnByTurnActions,elevation,routeHandle,passthrough,incidents,routingZones,truckRoadTypes,tolls,routeLabels,potentialTimeDependentViolations,noThroughRestrictions"
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
queryParams.add(HereMapQueryParam.build("return", truckRoute.getReturnStr()));
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(truckRoute.getLang())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("lang", "zh-CN"));
|
|
||||||
} else {
|
|
||||||
queryParams.add(HereMapQueryParam.build("lang", truckRoute.getLang()));
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(truckRoute.getUnits())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("units", "metric"));
|
|
||||||
} else {
|
|
||||||
queryParams.add(HereMapQueryParam.build("units", truckRoute.getUnits()));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(truckRoute.getDepartureTime())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("departureTime", truckRoute.getDepartureTime()));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(truckRoute.getArrivalTime())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("arrivalTime", truckRoute.getArrivalTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加车辆参数
|
|
||||||
*/
|
|
||||||
private void addTruckParameters(List<HereMapQueryParam> queryParams, HereMapRouteVo truckRoute) {
|
|
||||||
HereMapQueryParamTruck hereMapQueryParamTruck = new HereMapQueryParamTruck();
|
|
||||||
HereMapVehicleTruck vehicle = truckRoute.getVehicle();
|
|
||||||
if (vehicle == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (vehicle.getHeight() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[height]", vehicle.getHeight()));
|
|
||||||
}
|
|
||||||
if (vehicle.getWidth() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[width]", vehicle.getWidth()));
|
|
||||||
}
|
|
||||||
if (vehicle.getLength() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[length]", vehicle.getLength()));
|
|
||||||
}
|
|
||||||
if (vehicle.getSpeedCap() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[speedCap]", vehicle.getSpeedCap()));
|
|
||||||
}
|
|
||||||
if (vehicle.getGrossWeight() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[grossWeight]", vehicle.getGrossWeight()));
|
|
||||||
}
|
|
||||||
if (vehicle.getCurrentWeight() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[currentWeight]", vehicle.getCurrentWeight()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vehicle.getAxleCount() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[axleCount]", vehicle.getAxleCount()));
|
|
||||||
}
|
|
||||||
if (vehicle.getTrailerAxleCount() != null) {
|
|
||||||
if (vehicle.getAxleCount() >= 2 && (vehicle.getTrailerAxleCount() >= 1 && vehicle.getTrailerAxleCount() <= (vehicle.getAxleCount() - 1))) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[trailerAxleCount]", vehicle.getTrailerAxleCount()));
|
|
||||||
} else {
|
|
||||||
throw new ServiceException("区间trailerAxleCount:[1,(axleCount-1)]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vehicle.getWeightPerAxle() != null) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[weightPerAxle]", vehicle.getWeightPerAxle()));
|
|
||||||
}
|
|
||||||
if (vehicle.getTrailerCount() != null && (vehicle.getTrailerAxleCount() >= vehicle.getTrailerCount())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[trailerCount]", vehicle.getTrailerCount()));
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(vehicle.getType())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[type]", vehicle.getType()));
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(vehicle.getCargoType()) && "hazardous".equals(vehicle.getCargoType()) && CollectionUtils.isNotEmpty(vehicle.getHazardousGoods())) {
|
|
||||||
queryParams.add(HereMapQueryParam.build("vehicle[shippedHazardousGoods]", String.join(",", vehicle.getHazardousGoods())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user