puzhibing
2026-05-17 993a6e6ea8ae047b9e5fffd249ae7adfcd650d3a
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/TaskOrderUtil.java
@@ -1228,6 +1228,13 @@
                continue;
            }
            log.info("连环派单查询车辆结果 {} {}", orderNo, JSON.toJSONString(servingVehicles.getData()));
            if(!isTargetedService){
                servingVehicles.getData().removeAll(vehicleVinByTargetedService);
                log.info("剔除定向服务车辆后的结果 {} 单号 {}", JSON.toJSONString(servingVehicles), orderNo);
            }else{
                servingVehicles.setData(vehicleVinByTargetedService);
                log.info("查找定向服务车辆后的结果 {} 单号 {}", JSON.toJSONString(servingVehicles), orderNo);
            }
            XpTradingStrategyDetailVO strategyDetailVO = tradingStrategyClient.queryById().getData();
            log.info("连环排查推单逻辑 {} {}", orderNo, JSON.toJSONString(strategyDetailVO));
@@ -1247,7 +1254,8 @@
                XpOrder xpOrder1 = xpOrderClient.queryOrderById(vehiclePosition.getOrderId()).getData();
                Object cacheObject = redisService.getCacheObject(CacheConstants.navigationEnd(xpOrder1.getAppUserId().toString()));
                RouteVo routeRemain = JSON.parseObject(cacheObject.toString(), RouteVo.class);
                if (routeRemain.getDuration() / 60 > timeRegardAsEnding && routeRemain.getDistance() / 1000 > distanceRegardAsEnding) {
                //距离和时间只要有一个满足条件就达到候选对象
                if (routeRemain.getDuration() > timeRegardAsEnding * 60 && routeRemain.getDistance() > distanceRegardAsEnding * 1000) {
                    log.info("连环派单 {} 车辆订单结束时间不满足条件 {} 秒 {} 米 {}", vin, routeRemain.getDuration(), routeRemain.getDistance(), orderNo);
                    continue;
                }
@@ -1260,21 +1268,22 @@
                RouteVo route = xpMapClient.getDistanceAndDuration(next).getData();
                Object new_cacheObject = redisService.getCacheObject(CacheConstants.navigationEnd(xpOrder.getAppUserId().toString()));
                RouteVo new_routeRemain = JSON.parseObject(new_cacheObject.toString(), RouteVo.class);
                long xh = (new_routeRemain.getDistance() + route.getDistance()) / 1000 + backupPower;
                if(vehiclePosition.getMileageRange() < xh){
                    log.info("连环派单 {} 车辆剩余续航不满足派车条件 {} KM {}", vin, xh, orderNo);
                //总续航里程 米
                long xh = new_routeRemain.getDistance() + route.getDistance() + backupPower * 1000;
                if(vehiclePosition.getMileageRange() * 1000 < xh){
                    log.info("连环派单 {} 车辆剩余续航不满足派车条件 {} 米 {}", vin, xh, orderNo);
                    continue;
                }
                //下一单的起点距离本单终点小于X公里,或者下一单的用车时间与本单的预计结束时间偏差小于X分钟
                next = new RouteAndFareDto();
                next.setOrigin(new LonLatDto(xpOrder1.getEndLon(),xpOrder1.getEndLat()));
                next.setDestination(new LonLatDto(xpOrder.getStartLon(),xpOrder.getStartLat()));
                route = xpMapClient.getDistanceAndDuration(next).getData();
                //相差秒时间
                long time = routeRemain.getDuration() - xpOrder.getCreateTime().toEpochSecond(ZoneOffset.of("+8"));
                if(route.getDistance() / 1000 <= destToPassenger || time / 60 <= endingTimeToUseTime){
                    log.info("连环派单 {} 找到满足条件的车辆 {}", vin, orderNo);
                //上一单的预估结束时间
                LocalDateTime localDateTime = LocalDateTime.now().plusSeconds(routeRemain.getDuration());
                //上一单预估结束时间与本单用车时间差 秒
                long time = localDateTime.toEpochSecond(ZoneOffset.of("+8")) - xpOrder1.getCreateTime().toEpochSecond(ZoneOffset.of("+8"));
                if(route.getDistance() <= destToPassenger * 1000 || time <= endingTimeToUseTime * 60){
                    log.info("连环派单 {} 找到满足条件的车辆 {} 距离 {} 时间 {}", orderNo, vin, route.getDistance(), time);
                    log.info("上一单终点与当前订单起点距离 {} 米 {}", route.getDistance(), orderNo);
                    log.info("当前订单用车时间与上一单预估结束时间偏差 {} 秒 {}", time, orderNo);
                    // 设置接驾导航数据
                    //将上一单的剩余导航添加到接驾导航中
                    route.getPolyline().addAll(0, routeRemain.getPolyline());
@@ -1286,6 +1295,7 @@
                    xpOrder.setAcceptanceTime(LocalDateTime.now());
                    xpOrder.setStatus(2);
                    xpOrderClient.updateOrder(xpOrder);
                    log.info("连环派单 {} 修改订单状态为接单成功 {}", orderNo, xpOrder.getId());
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("orderId", xpOrder.getId());
@@ -1294,7 +1304,7 @@
                    redisService.setCacheObject(CacheConstants.nextOrder(xpOrder1.getId().toString()), jsonObject.toJSONString());
                    redisService.setCacheObject(CacheConstants.navigationStart(xpOrder.getAppUserId().toString()), JSON.toJSONString(route));
                    redisService.removeByPattern(quoteName,xpOrder.getOrderNumber());
                    log.info("将订单 {} 从队列 {} 弹出去", orderNo, quoteName);
                    log.info("连环派单 {} 设置下一单接驾导航数据 {}", orderNo, JSON.toJSONString(route));
                    //构建推送消息
                    Map<String, Object> params = new HashMap<>();