| | |
| | | package com.xiaopeng.pushMessage.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.pushMessage.PushOrderRouteDTO; |
| | |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.pushMessage.utils.MapMatchingUtil; |
| | | import io.swagger.annotations.Api; |
| | | import org.powermock.core.ListMap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Api(tags = "订单推送轨迹接口") |
| | | @RestController |
| | |
| | | routeType = xpOrder.getStatus() == 3 ? 1 : 2; |
| | | } |
| | | // 获取路线规划 |
| | | RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType); |
| | | String key = ""; |
| | | //接驾情况,获取车辆位置到起点的导航 |
| | | if(1 == routeType){ |
| | | key = "ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(); |
| | | }else{ |
| | | key = "ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | Object cacheObject = redisService.getCacheObject(key); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | |
| | | if(Objects.nonNull(routeVo)){ |
| | | |
| | |
| | | routeVo.setPolyline(lonLatDtos); |
| | | |
| | | // 存储最新路线偏离缓存,后续进行轨迹截取 |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo); |
| | | // redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo); |
| | | |
| | | redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | |
| | | // 封装轨迹点位集合 |
| | | Map<String, Object> polyline = new HashMap<>(); |
| | | List<Map<String, Object>> polyline = new ArrayList<>(); |
| | | for (LonLatDto lonLatDto : lonLatDtos) { |
| | | polyline.put("longitude",lonLatDto.getLongitude()); |
| | | polyline.put("latitude",lonLatDto.getLatitude()); |
| | | Map<String, Object> polylineMap = new HashMap<>(); |
| | | polylineMap.put("longitude",lonLatDto.getLongitude()); |
| | | polylineMap.put("latitude",lonLatDto.getLatitude()); |
| | | polyline.add(polylineMap); |
| | | } |
| | | // 封装路由详情 |
| | | Map<String, Object> route = new HashMap<>(); |
| | |
| | | route.put("polyline",JSONObject.toJSONString(polyline)); |
| | | |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId",dto.getOrderId()); |
| | | content.put("orderId",dto.getOrderId().toString()); |
| | | content.put("routeType",routeType); |
| | | content.put("direction",dto.getDirection()); |
| | | content.put("route",JSONObject.toJSONString(route)); |
| | | |
| | | // 封装轨迹信息 |