| | |
| | | import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudCreateOrder.TaskType; |
| | | import com.xiaopeng.api.vo.automaticPilot.protobuf.*; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.api.vo.order.OrderTrajectoryVo; |
| | | import com.xiaopeng.automaticPilot.util.XPUUtil; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Date;import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | |
| | | PopOrderDto dto1 = new PopOrderDto(); |
| | | dto1.setOrderId(Long.valueOf(orderId)); |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 3); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.PICK_UP.getCode()); |
| | | |
| | | // PushOrderRouteDTO dto3 = new PushOrderRouteDTO(); |
| | | // dto3.setOrderId(orderId); |
| | | // dto3.setRouteType(1); |
| | | // dto3.setLongitude(startLon); |
| | | // dto3.setLatitude(startLat); |
| | | // dto3.setDuration(10); |
| | | // dto3.setDistance(2); |
| | | // dto3.setDirection(60); |
| | | // xpPushMessageClient.pushOrderRoute(dto3); |
| | | |
| | | return r; |
| | | } |
| | | |
| | |
| | | Double longitude = lonLatDto.getLongitude(); |
| | | |
| | | //保存车辆实时位置到redis |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin); |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new Point(longitude, latitude), vin); |
| | | |
| | | //保存车辆实时信息到mongodb |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | |
| | | dto.setLatitude(latitude); |
| | | dto.setDuration(10); |
| | | dto.setDistance(2); |
| | | dto.setDirection(60); |
| | | xpPushMessageClient.pushOrderRoute(dto); |
| | | } |
| | | |
| | | //5秒钟循环一次 |
| | | //2秒钟循环一次 |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 4); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", status); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, status); |
| | | if(5 == status){ |
| | | //主动推一次全程轨迹 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId()); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(); |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content1 = new com.alibaba.fastjson2.JSONObject(); |
| | | content1.put("orderId", orderId.toString()); |
| | | content1.put("routeType", 1); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | | route.put("duration", routeVo.getDuration()); |
| | | route.put("routeID", routeVo.getRouteID()); |
| | | |
| | | List<com.alibaba.fastjson2.JSONObject> collect = routeVo.getPolyline().stream().map(item -> { |
| | | com.alibaba.fastjson2.JSONObject point = new com.alibaba.fastjson2.JSONObject(); |
| | | point.put("latitude", item.getLatitude()); |
| | | point.put("longitude", item.getLongitude()); |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content1.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content1.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | | messageDTO.setAppUserId(xpOrder.getAppUserId().toString()); |
| | | messageDTO.setMessage(jsonObject.toJSONString()); |
| | | xpPushMessageClient.sendRoute(messageDTO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | Double longitude = lonLatDto.getLongitude(); |
| | | |
| | | //保存车辆实时位置到redis |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin); |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new Point(longitude, latitude), vin); |
| | | |
| | | //保存车辆实时信息到mongodb |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | |
| | | if (null != orderId) { |
| | | PushOrderRouteDTO dto = new PushOrderRouteDTO(); |
| | | dto.setOrderId(orderId); |
| | | dto.setRouteType(2); |
| | | dto.setRouteType(1); |
| | | dto.setLongitude(longitude); |
| | | dto.setLatitude(latitude); |
| | | dto.setDuration(20); |
| | | dto.setDistance(10); |
| | | dto.setDirection(60); |
| | | xpPushMessageClient.pushOrderRoute(dto); |
| | | |
| | | //存储历史轨迹 |
| | | OrderTrajectoryVo orderTrajectory = new OrderTrajectoryVo(); |
| | | orderTrajectory.setOrderId(orderId); |
| | | orderTrajectory.setLocation(longitude + "," + latitude); |
| | | orderTrajectory.setDirection(dto.getDirection()); |
| | | orderTrajectory.setSpeed(0D); |
| | | orderTrajectory.setLocatetime(System.currentTimeMillis()); |
| | | orderTrajectory.setCreateTime(new Date()); |
| | | xpOrderClient.saveVehicleLocation(orderTrajectory); |
| | | } |
| | | |
| | | //5秒钟循环一次 |
| | | try { |
| | | Thread.sleep(2000); |
| | | Thread.sleep(500); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("status", 4); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 7); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | | params.put("timestamp", System.currentTimeMillis() + ""); |
| | |
| | | if (R.isError(stringR)) { |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.PICK_UP_GUESTS.getCode()); |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | }); |
| | | } |
| | | |