| | |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.vo.map.PointByIpVo; |
| | | import com.xiaopeng.api.vo.map.XpDistanceAndDurationVo; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | |
| | | private final GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | private final XpGeoFencingPolygonService xpGeoFencingPolygonService; |
| | | private final RedisService redisService; |
| | | private final XpOrderClient xpOrderClient; |
| | | |
| | | public XpMapController(GDMapGeocodingUtil gdMapGeocodingUtil, XpGeoFencingPolygonService xpGeoFencingPolygonService, RedisService redisService) { |
| | | public XpMapController(GDMapGeocodingUtil gdMapGeocodingUtil, XpGeoFencingPolygonService xpGeoFencingPolygonService, RedisService redisService, XpOrderClient xpOrderClient) { |
| | | this.gdMapGeocodingUtil = gdMapGeocodingUtil; |
| | | this.xpGeoFencingPolygonService = xpGeoFencingPolygonService; |
| | | this.redisService = redisService; |
| | | this.xpOrderClient = xpOrderClient; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 避让区域 |
| | | ArrayList<String> pointStrParam = new ArrayList<>(); |
| | | for (Document document : pointsInFence) { |
| | | List<GeoPoint> points = document.getList("points", GeoPoint.class); |
| | | // 一个区域的点位 |
| | | ArrayList<String> pointStr = new ArrayList<>(); |
| | | for (GeoPoint point : points) { |
| | | pointStr.add( point.getLongitude()+","+point.getLatitude()); |
| | | try { |
| | | for (Document document : pointsInFence) { |
| | | List<GeoPoint> points = document.getList("points", GeoPoint.class); |
| | | // 一个区域的点位 |
| | | ArrayList<String> pointStr = new ArrayList<>(); |
| | | for (GeoPoint point : points) { |
| | | pointStr.add( point.getLongitude()+","+point.getLatitude()); |
| | | } |
| | | if(!pointStr.isEmpty()){ |
| | | pointStrParam.add(String.join(";", pointStr)); |
| | | } |
| | | |
| | | } |
| | | if(!pointStr.isEmpty()){ |
| | | pointStrParam.add(String.join(";", pointStr)); |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule()); |
| | | if(routeVo==null){ |
| | | return R.fail("没有找到路线"); |
| | | } |
| | | |
| | | return R.ok(routeVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), String.join("|", pointStrParam), fenceId,dto.getRoutePlanRule()); |
| | | if(routeVo==null){ |
| | | return R.fail("没有找到路线"); |
| | | } |
| | | |
| | | return R.ok(routeVo); |
| | | return R.fail("没有找到路线"); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | // 存储redis |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo); |
| | | |
| | | // 查询订单信息 |
| | | XpOrder xpOrder = xpOrderClient.queryOrderById(dto.getOrderId()).getData(); |
| | | // 封装消息内容 |
| | | Integer routeType = dto.getRouteType(); |
| | | if(routeType == 2){ |
| | | routeType = 3; |
| | | }else { |
| | | routeType = xpOrder.getStatus() == 4 ? 1 : 2; |
| | | } |
| | | // 存储路线偏离缓存,后续进行轨迹截取 |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo); |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo); |
| | | |
| | | return R.ok(routeVo); |
| | | } |