| New file |
| | |
| | | package com.xiaopeng.api.dto.map; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class HistoryPointDto { |
| | | /** |
| | | * 经纬度116.473195,39.993253 |
| | | */ |
| | | private String location; |
| | | /** |
| | | * 定位时间戳 |
| | | */ |
| | | private String locateTime; |
| | | /** |
| | | * 定位精度 |
| | | */ |
| | | private Double accuracy; |
| | | /** |
| | | * 定位方向 |
| | | */ |
| | | private Double direction; |
| | | /** |
| | | * 速度 |
| | | */ |
| | | private Double speed; |
| | | } |
| | |
| | | private Integer routeType; |
| | | @ApiModelProperty(value = "前端不处理") |
| | | private Integer routePlanRule; |
| | | |
| | | @ApiModelProperty("车辆VIN码") |
| | | private String vin; |
| | | } |
| | |
| | | @ApiModelProperty(value = "优惠券id(是否指定使用某个优惠券)") |
| | | private Long userCouponId; |
| | | |
| | | @ApiModelProperty("车辆VIN码") |
| | | private String vin; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "自增id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | @TableId(value = "id", type = IdType.NONE) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "测试计划ID") |
| | |
| | | package com.xiaopeng.map.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.xiaopeng.api.dto.map.HistoryPointDto; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | |
| | | } |
| | | } |
| | | } |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule()); |
| | | |
| | | List<Object> cacheList = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVin()); |
| | | List<HistoryPointDto> history = new ArrayList<>(); |
| | | if(cacheList!=null && !cacheList.isEmpty()){ |
| | | for (Object cache : cacheList) { |
| | | HistoryPointDto historyPointDto = JSON.parseObject(cache.toString(), HistoryPointDto.class); |
| | | history.add(historyPointDto); |
| | | } |
| | | } |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule(), history); |
| | | if(routeVo==null){ |
| | | return R.fail("没有找到路线"); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule()); |
| | | List<Object> cacheList = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVin()); |
| | | List<HistoryPointDto> history = new ArrayList<>(); |
| | | if(cacheList!=null && !cacheList.isEmpty()){ |
| | | for (Object cache : cacheList) { |
| | | HistoryPointDto historyPointDto = JSON.parseObject(cache.toString(), HistoryPointDto.class); |
| | | history.add(historyPointDto); |
| | | } |
| | | } |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule(), history); |
| | | if(routeVo==null){ |
| | | return R.fail("没有找到路线"); |
| | | } |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.map.HistoryPointDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.common.core.utils.HttpUtils; |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public RouteVo getDistanceAndTime(LonLatDto start, LonLatDto end,String avoidRoads,String fenceId,Integer routePlanRule) { |
| | | public RouteVo getDistanceAndTime(LonLatDto start, LonLatDto end,String avoidRoads,String fenceId,Integer routePlanRule, List<HistoryPointDto> history) { |
| | | RouteVo routeVo = new RouteVo(); |
| | | |
| | | String url = "https://tsapi.amap.com/v1/route/price?key=" + key + "&extensions=all&start=" + start.getLongitude() + "," + start.getLatitude(); |
| | |
| | | if(routePlanRule!=null){ |
| | | params.put("strategy", routePlanRule); |
| | | } |
| | | if(null != history && !history.isEmpty()){ |
| | | params.put("history", history); |
| | | } |
| | | log.info("高德地图接口:{}", url); |
| | | log.info("高德地图参数:{}", params); |
| | | String post = HttpUtils.post(url, JSON.toJSONString(params)); |