| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.automaticPilot.MqttPublishDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.PushOrderDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.VehicleEventDTO; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.order.PopOrderDto; |
| | | import com.xiaopeng.api.dto.pushMessage.PushOrderRouteDTO; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.UpdateVehicleStateDto; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.VehicleBuriedPointClient; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.order.XpOrder;import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.OrderType; |
| | | import com.xiaopeng.api.vo.SystemEventType; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.automaticPilot.protobuf.*; |
| | |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | @Resource |
| | | private VehicleBuriedPointClient vehicleBuriedPointClient; |
| | | @Resource(name = "hutoolSnowflake") |
| | | private Snowflake snowflake; |
| | | |
| | | @PostMapping("/inner/pushOrder") |
| | |
| | | pointBuilderEnd.setActionType(ActionType.DRIVE_THROUGH); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(1); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_CRUISE); |
| | | taskListBuilder.addTasks(taskBuilder.build()); |
| | | }else{ |
| | | }else if(dto.getOrderType().equals(com.xiaopeng.api.vo.OrderType.USER_ORDER)){ |
| | | for (int i = 1; i < 3; i++) { |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | taskBuilder.setOrderId(dto.getOrderId().toString()); |
| | |
| | | pointBuilderEnd.setSequence(2); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(i); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_DESTINATION); |
| | | } |
| | | taskListBuilder.addTasks(taskBuilder.build()); |
| | | } |
| | | }else if(dto.getOrderType().equals(com.xiaopeng.api.vo.OrderType.TEST_ORDER)){ |
| | | for (int i = 1; i < 3; i++) { |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | taskBuilder.setOrderId(dto.getOrderId().toString()); |
| | | taskBuilder.setTaskId(snowflake.nextId() + ""); |
| | | taskBuilder.setTaskType(OrderType.ORDER_TYPE_ROBOTAXI); |
| | | if(i == 1){ |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getVin())), VehiclePosition.class); |
| | | //构建车辆当前位置数据 |
| | | pointBuilderStart.setWaypointId(dto.getOrderId() + "-JJ-001"); |
| | | pointBuilderStart.setPointType(PointType.START_POINT); |
| | | pointBuilderStart.setActionType(ActionType.ACTION_UNSPECIFIED); |
| | | pointBuilderStart.setSequence(1); |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(vehiclePosition.getPoint().getY()); |
| | | geoPointBuilder.setLongitude(vehiclePosition.getPoint().getX()); |
| | | pointBuilderStart.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderStart); |
| | | |
| | | //构建上车点位置信息 |
| | | pointBuilderEnd.setWaypointId(dto.getOrderId() + "-JJ-002"); |
| | | pointBuilderEnd.setPointType(PointType.PICK_UP_POINT); |
| | | pointBuilderEnd.setActionType(ActionType.PICK_UP); |
| | | pointBuilderEnd.setSequence(2); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getStartLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getStartLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(i); |
| | | taskBuilder.addOrderPhase(OrderPhase.ROUTE_TO_PICKUP); |
| | | }else{ |
| | | //构建上车点位置信息 |
| | | pointBuilderStart.setWaypointId(dto.getOrderId() + "-SD-001"); |
| | | pointBuilderStart.setPointType(PointType.PICK_UP_POINT); |
| | | pointBuilderStart.setActionType(ActionType.PICK_UP); |
| | | pointBuilderStart.setSequence(1); |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getStartLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getStartLongitude()); |
| | | pointBuilderStart.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderStart); |
| | | |
| | | //构建下车点位置信息 |
| | | pointBuilderEnd.setWaypointId(dto.getOrderId() + "-SD-002"); |
| | | pointBuilderEnd.setPointType(PointType.END_POINT); |
| | | pointBuilderEnd.setActionType(ActionType.DROP_OFF); |
| | | pointBuilderEnd.setSequence(2); |
| | | geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(dto.getEndLatitude()); |
| | | geoPointBuilder.setLongitude(dto.getEndLongitude()); |
| | | pointBuilderEnd.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilderEnd); |
| | | taskBuilder.setSequence(i); |
| | |
| | | // 修改车子为接单状态 |
| | | xpVehicleClient.updateVehicleStatus(new UpdateVehicleStateDto(dto.getVin(), 1)); |
| | | } |
| | | |
| | | if(null != mqttPublishDto && mqttPublishDto.getCode() == 200){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("event", SystemEventType.CREATE_ORDER); |
| | | jsonObject.put("orderType", dto.getOrderId().contains("XU") ? com.xiaopeng.api.vo.OrderType.CRUISE_ORDER : com.xiaopeng.api.vo.OrderType.USER_ORDER); |
| | | if(dto.getOrderId().contains("XU")){ |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.CRUISE_ORDER); |
| | | }else if(dto.getOrderId().contains("TEST")){ |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.TEST_ORDER); |
| | | }else { |
| | | jsonObject.put("orderType", com.xiaopeng.api.vo.OrderType.USER_ORDER); |
| | | } |
| | | jsonObject.put("orderId", dto.getOrderId()); |
| | | jsonObject.put("vin", dto.getVin()); |
| | | redisService.setCacheObject("CREATE_ORDER:" + dto.getOrderId().toString(), jsonObject.toJSONString(),30L, TimeUnit.MINUTES); |
| | |
| | | Long appUserId = xpOrder.getAppUserId(); |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId()); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | log.info("开始实施推送车辆位置和剩余导航线路 {} {}", xpOrder.getOrderNumber(), JSON.toJSONString(routeVo)); |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1000)); |
| | | Long finalOrderId = orderId; |
| | |
| | | |
| | | //5秒钟循环一次 |
| | | try { |
| | | Thread.sleep(500); |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |