| | |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId.contains("XU") ? orderId.substring(2) : orderId), OrderStatusEnum.APPROVAL_REJECTION.getCode()); |
| | | |
| | | // 下发巡游任务 |
| | | if(!orderId.contains("XU")){ |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); |
| | | if(xpOrderR.getCode()==200){ |
| | | XpOrder orderData = xpOrderR.getData(); |
| | | Long vehicleId =orderData.getVehicleId(); |
| | | R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(vehicleId); |
| | | if(xpVehicleR.getData()!=null){ |
| | | XpVehicle xpVehicle = xpVehicleR.getData(); |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); |
| | | if(xpOrderR.getCode()==200){ |
| | | XpOrder orderData = xpOrderR.getData(); |
| | | Long vehicleId =orderData.getVehicleId(); |
| | | R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(vehicleId); |
| | | if(xpVehicleR.getData()!=null){ |
| | | XpVehicle xpVehicle = xpVehicleR.getData(); |
| | | |
| | | AddCruiseMissionDto addCruiseMissionDto = new AddCruiseMissionDto(); |
| | | addCruiseMissionDto.setOrder(orderData); |
| | | addCruiseMissionDto.setVehicle(xpVehicle); |
| | | xpCruiseOrderClient.addCruiseMission(addCruiseMissionDto); |
| | | } |
| | | AddCruiseMissionDto addCruiseMissionDto = new AddCruiseMissionDto(); |
| | | addCruiseMissionDto.setOrder(orderData); |
| | | addCruiseMissionDto.setVehicle(xpVehicle); |
| | | xpCruiseOrderClient.addCruiseMission(addCruiseMissionDto); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | break; |
| | | case ORDER_COMPLETED: |
| | | //已完成 |
| | |
| | | if(xpCruiseOrder.getOrderType()==2){ |
| | | R<XpCruiseOrder> lastOrder = xpCruiseOrderClient.getCruiseOrder(xpCruiseOrder.getLastOrderId()); |
| | | XpCruiseOrder lastXpCruiseOrder = lastOrder.getData(); |
| | | |
| | | // 修改一下id 加一个一样的巡游单子 |
| | | lastXpCruiseOrder.setId(null); |
| | | lastXpCruiseOrder.setStatus(1); |
| | | xpCruiseOrderClient.addCruiseOrder(lastXpCruiseOrder); |
| | | //构建下发XPU订单报文数据 |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | taskBuilder.setOrderId("XU" + lastXpCruiseOrder.getId()); |
| | | taskBuilder.setTaskId(snowflake.nextId() + ""); |
| | | taskBuilder.setTaskType(com.xiaopeng.api.vo.automaticPilot.protobuf.OrderType.ORDER_TYPE_CRUISE); |
| | | //构建点位信息 |
| | | Waypoint.Builder pointBuilder = Waypoint.newBuilder(); |
| | | pointBuilder.setPointType(PointType.CRUISE_END_POINT); |
| | | pointBuilder.setSequence(1); |
| | | //构建终点坐标 |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(lastXpCruiseOrder.getEndLat()); |
| | | geoPointBuilder.setLongitude(lastXpCruiseOrder.getEndLat()); |
| | | // geoPointBuilder.setPoiName("Start Point"); // GeoPoint might not have poi_name |
| | | pointBuilder.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilder); |
| | | |
| | | RtTask task = taskBuilder.build(); |
| | | RtTaskList taskList = RtTaskList.newBuilder().addTasks(task).build(); |
| | | |
| | | long sequence1 = snowflake.nextId(); |
| | | xpuUtil.cloudCreateOrder(taskList, xpVehicle.getVehicleVin(),sequence1); |
| | | }else if(xpCruiseOrder.getOrderType()==1){ |
| | | // 正常巡游 找到下一个点位 若到达最后点位 则反向找点位 |
| | | // 起点 |
| | |
| | | newXpCruiseOrder.setStatus(1); |
| | | newXpCruiseOrder.setLastOrderId(xpCruiseOrder.getId()); |
| | | |
| | | |
| | | // 通过车找终点id |
| | | CruisePointDto cruisePointDto = new CruisePointDto(); |
| | | cruisePointDto.setNewXpCruiseOrder(newXpCruiseOrder); |
| | |
| | | R<XpCruiseOrder> cruisePoint = xpCruisePlanClient.getCruisePoint(cruisePointDto); |
| | | if(cruisePoint!=null){ |
| | | xpCruiseOrderClient.addCruiseOrder(cruisePoint.getData()); |
| | | RtTask.Builder taskBuilder = RtTask.newBuilder(); |
| | | |
| | | taskBuilder.setOrderId("XU" + newXpCruiseOrder.getId()); |
| | | taskBuilder.setTaskId(snowflake.nextId() + ""); |
| | | taskBuilder.setTaskType(com.xiaopeng.api.vo.automaticPilot.protobuf.OrderType.ORDER_TYPE_CRUISE); |
| | | |
| | | //构建点位信息 |
| | | Waypoint.Builder pointBuilder = Waypoint.newBuilder(); |
| | | pointBuilder.setPointType(PointType.CRUISE_END_POINT); |
| | | pointBuilder.setSequence(1); |
| | | //构建终点坐标 |
| | | GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder(); |
| | | geoPointBuilder.setLatitude(cruisePoint.getData().getEndLat()); |
| | | geoPointBuilder.setLongitude(cruisePoint.getData().getEndLat()); |
| | | // geoPointBuilder.setPoiName("Start Point"); // GeoPoint might not have poi_name |
| | | pointBuilder.setPoint(geoPointBuilder.build()); |
| | | taskBuilder.addPoints(pointBuilder); |
| | | |
| | | RtTaskList.Builder taskListBuilder = RtTaskList.newBuilder(); |
| | | taskListBuilder.addTasks(taskBuilder.build()); |
| | | |
| | | long sequence1 = snowflake.nextId(); |
| | | xpuUtil.cloudCreateOrder(taskListBuilder.build(), xpVehicle.getVehicleVin(),sequence1); |
| | | } |
| | | } |
| | | } |