Merge remote-tracking branch 'origin/master'
| 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") |
| | |
| | | // 1. 基础数据查询 |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(routeAndFareDto.getOrigin().getLongitude().toString(), routeAndFareDto.getOrigin().getLatitude().toString()); |
| | | if(null == geocode){ |
| | | throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND); |
| | | throw new ServiceException("城市暂未开通服务", I18nKeyConstant.CITY_NOT_FOUND); |
| | | } |
| | | Long cityCode = routeAndFareDto.getOpenCityId(); |
| | | XpOpenCity openCities = xpOpenCityMapper.selectById(cityCode); |
| | | if (openCities == null ) { |
| | | throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND); |
| | | throw new ServiceException("城市暂未开通服务", I18nKeyConstant.CITY_NOT_FOUND); |
| | | } |
| | | XpOpenCity xpOpenCity = openCities; |
| | | routeAndFareDto.setOpenCityId(xpOpenCity.getId()); |
| | |
| | | |
| | | XpOpenCity openCities = xpOpenCityMapper.selectById(dto.getOpenCityId()); |
| | | if (openCities == null) { |
| | | throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND); |
| | | throw new ServiceException("城市暂未开通服务", I18nKeyConstant.CITY_NOT_FOUND); |
| | | } |
| | | XpOpenCity xpOpenCity = openCities; |
| | | dto.setOpenCityId(xpOpenCity.getId()); |
| | |
| | | # 中文 |
| | | city.not.found=获取城市信息失败 |
| | | city.not.found=城市暂未开通服务 |
| | | coupon.not.satisfy=券不满足条件 |
| | | no.current.point=该站点已停止运营 |
| | | no.current.region=当前区域未开通服务 |
| | |
| | | # 中文 |
| | | city.not.found=获取城市信息失败 |
| | | city.not.found=城市暂未开通服务 |
| | | coupon.not.satisfy=券不满足条件 |
| | | no.current.point=该站点已停止运营 |
| | | no.current.region=当前区域未开通服务 |
| | |
| | | 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)); |