| | |
| | | import com.xiaopeng.common.core.constant.Constants; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | | import com.xiaopeng.common.core.enums.PushMessageTypeEnum; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.operation.config.UidVinBindingConfig; |
| | | import com.xiaopeng.operation.dto.PriorityMatchResult; |
| | |
| | | //非合作商的车辆需要处理巡游单 |
| | | if(null != vehiclePosition.getOfficialPartnerId()){ |
| | | // 关闭巡游单子 |
| | | R stringR = xpCruiseOrderClient.cancelCruiseOrderByVin(vehiclePosition.getVehicleVin()); |
| | | R<XpCruiseOrder> stringR = xpCruiseOrderClient.cancelCruiseOrderByVin(vehiclePosition.getVehicleVin()); |
| | | if (stringR == null || stringR.getCode() != 200) { |
| | | log.info("关闭巡游单子失败 车牌号 {}", vehiclePosition.getPlateNumber()); |
| | | continue; |
| | | } |
| | | log.info("关闭巡游单成功 {} {}", vehiclePosition.getPlateNumber(), orderNo); |
| | | XpCruiseOrder cruiseOrder = stringR.getData(); |
| | | // 下发命令 |
| | | PushOrderDto pushOrderDto = new PushOrderDto(); |
| | | pushOrderDto.setVin(vehiclePosition.getVehicleVin()); |
| | |
| | | pushOrderDto.setEndPoiName(xpOrder.getEndPointName()); |
| | | pushOrderDto.setOrderType(OrderType.USER_ORDER); |
| | | pushOrderDto.setStage(1); |
| | | pushOrderDto.setLastOrderId("XU" + cruiseOrder.getId()); |
| | | pushOrderDto.setLastXpuTaskId(cruiseOrder.getXpuTaskId()); |
| | | pushOrderDto.setTaskActionType(TaskActionType.kTerminateForNewTask); |
| | | // 调用推送服务 orderId + carVin |
| | | orderMissionClient.pushOrder(pushOrderDto); |
| | | log.info("开始推送 {} 订单到XPU。单号 {}", xpOrder.getOrderNumber(), orderNo); |
| | |
| | | |
| | | if(null == vehicleId1.getOfficialPartnerId()){ |
| | | // 关闭巡游单子 |
| | | R<?> stringR = xpCruiseOrderClient.cancelCruiseOrderByVin(vehicleId1.getVehicleVin()); |
| | | R<XpCruiseOrder> stringR = xpCruiseOrderClient.cancelCruiseOrderByVin(vehicleId1.getVehicleVin()); |
| | | if (stringR == null || stringR.getCode() != 200) { |
| | | log.info("关闭巡游单子失败 车牌号 {}", vehicleId1.getPlateNumber()); |
| | | continue; |
| | | } |
| | | log.info("关闭巡游单成功 {} {}", vehicleId1.getPlateNumber(), orderNo); |
| | | XpCruiseOrder cruiseOrder = stringR.getData(); |
| | | PushOrderDto pushOrderDto = new PushOrderDto(); |
| | | pushOrderDto.setVin(vehiclePosition.getVin()); |
| | | pushOrderDto.setOrderId(xpOrder.getId().toString()); |
| | |
| | | pushOrderDto.setEndPoiName(xpOrder.getEndPointName()); |
| | | pushOrderDto.setOrderType(OrderType.USER_ORDER); |
| | | pushOrderDto.setStage(1); |
| | | pushOrderDto.setLastOrderId("XU" + cruiseOrder.getId()); |
| | | pushOrderDto.setLastXpuTaskId(cruiseOrder.getXpuTaskId()); |
| | | pushOrderDto.setTaskActionType(TaskActionType.kTerminateForNewTask); |
| | | // 调用推送服务 orderId + carVin |
| | | orderMissionClient.pushOrder(pushOrderDto); |
| | | }else { |
| | |
| | | redisService.setCacheObject(CacheConstants.navigationStart(xpOrder.getAppUserId().toString()), JSON.toJSONString(route)); |
| | | redisService.removeByPattern(quoteName,xpOrder.getOrderNumber()); |
| | | log.info("将订单 {} 从队列 {} 弹出去", orderNo, quoteName); |
| | | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", xpOrder.getId().toString()); |
| | | content.put("status", 2); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | | params.put("timestamp", System.currentTimeMillis() + ""); |
| | | String message = JSONObject.toJSONString(params); |
| | | SendMessageDTO dto1 = new SendMessageDTO(); |
| | | dto1.setAppUserId(xpOrder.getAppUserId() + ""); |
| | | dto1.setMessage(message); |
| | | R<String> stringR = xpPushMessageClient.sendStatus(dto1); |
| | | |
| | | //推送失败,重试3次 |
| | | if (stringR.getCode() != Constants.SUCCESS) { |
| | | ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()); |
| | | XpOrder finalXpOrder = xpOrder; |
| | | executor.execute(() -> { |
| | | for (int j = 0; j < 3; j++) { |
| | | R<String> stringR1 = xpPushMessageClient.sendStatus(dto1); |
| | | if (stringR1.getCode() == Constants.SUCCESS) { |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("推送订单状态消息失败:{} {} {}", stringR1.getMsg(), JSON.toJSONString(dto1), finalXpOrder.getOrderNumber()); |
| | | } |
| | | }); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | entity.setIsComplete(true); |
| | | // //接单成功 将 修改 订单的状态=1 ( 状态 0=已取消,1=待接单,2=待出发,3=接驾中,4=待客上车,5=乘客已上车,6=服务中,7=待客下车,8=待付款,9=待评价,10=已完成) |
| | | // orderCarStatus = true; |
| | | xpOrderClient.updateOrderStatus(data.getId(), OrderStatusEnum.PENDING_ORDER.getCode(), false); |
| | | xpOrderClient.updateOrderStatus(data.getId(), OrderStatusEnum.PENDING_ORDER.getCode()); |
| | | redisService.setCacheObject("ORDER_STATUS:" + data.getId(), OrderStatusEnum.PENDING_ORDER.getCode(), 24L, TimeUnit.HOURS); |
| | | |
| | | break; |