yyy
2026-05-17 e02bf5a481c0301baf40f9f729ee49f1037a0854
修改定向服务查询
7个文件已修改
86 ■■■■■ 已修改文件
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpTargetedServiceClientFallbackFactory.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpTargetedServiceClient.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpTargetedServiceController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpTargetedServiceService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpTargetedServiceServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpTargetedServiceClientFallbackFactory.java
@@ -22,6 +22,15 @@
                log.error("根据用户ID和城市编码获取失败:{}", cause.getMessage());
                return R.fail("根据用户ID和城市编码获取失败");
            }
            @Override
            public R<Integer> getTargetedServiceWeight(Long appUserId, String cityCode) {
                log.error("获取定向服务权限失败:" + cause.getMessage());
                return R.fail("获取定向服务权限失败");
            }
        };
    }
}
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpTargetedServiceClient.java
@@ -24,4 +24,14 @@
    @GetMapping("/logan/inner/v1/targetedService/findListByUserIdAndCityCode")
    R<List<XpTargetedServiceVehicleVo>> findListByUserIdAndCityCode(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode);
    /**
     * 获取定向服务权限
     * @param appUserId
     * @param cityCode
     * @return
     */
    @GetMapping("/logan/inner/v1/targetedService/getTargetedServiceWeight")
    R<Integer> getTargetedServiceWeight(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode);
}
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -766,11 +766,10 @@
        }
        //获取定向服务配置
        R<List<XpTargetedServiceVehicleVo>> targetedServiceUserR = xpTargetedServiceClient.findListByUserIdAndCityCode(xpOrder.getAppUserId(), xpOrder.getCityCode());
        if(targetedServiceUserR.getCode() == R.SUCCESS && CollUtil.isNotEmpty(targetedServiceUserR.getData()) ){
        R<Integer> targetedServiceWeight = xpTargetedServiceClient.getTargetedServiceWeight(xpOrder.getAppUserId(), xpOrder.getCityCode());
        if(targetedServiceWeight.getCode() == R.SUCCESS && null != targetedServiceWeight.getData()){
            log.info("添加定向服务订单:{}", xpOrder.getOrderNumber());
            XpTargetedServiceVehicleVo xpTargetedServiceVehicleVo = targetedServiceUserR.getData().get(0);
            return addSpOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, xpTargetedServiceVehicleVo, orderId, currentTimeSlot, distance, duration, uid);
            return addSpOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, targetedServiceWeight.getData(), orderId, currentTimeSlot, distance, duration, uid);
        }else{
            log.info("添加普通订单:{}", xpOrder.getOrderNumber());
            return addOrderPush(xpOrder, xpPoint, xpRoutePlan, maxPushDistance, isPriorityDispatch, orderId, currentTimeSlot, distance, duration, uid);
@@ -861,7 +860,7 @@
     * @param xpPoint
     * @param xpRoutePlan
     * @param maxPushDistance
     * @param xpTargetedServiceVehicleVo
     * @param weight
     * @param orderId
     * @param currentTimeSlot
     * @param distance
@@ -870,7 +869,7 @@
     * @return
     */
    private String addSpOrderPush(XpOrder xpOrder, XpPoint xpPoint, XpRoutePlan xpRoutePlan, double maxPushDistance,
                                  XpTargetedServiceVehicleVo xpTargetedServiceVehicleVo, Long orderId, String currentTimeSlot, Integer distance, Integer duration, String uid){
                                  Integer weight, Long orderId, String currentTimeSlot, Integer distance, Integer duration, String uid){
        // 找出现在所有的队列 通过计算距离 算出目前应该放在那个队列  如果没有符合的新增一个队列  符合后看是否白名单账号 是则直接放在队列前端
        Set<String> quoteMatchName = redisService.getQuoteMatchName(CacheConstants.SP_QUEUE_POINT_ID);
        log.info("当前队列(定向服务):{}", quoteMatchName);
@@ -908,7 +907,7 @@
                redisQueuePointIdVo.setDistance(distance.toString());
                redisQueuePointIdVo.setDuration(duration.toString());
                redisQueuePointIdVo.setPlanRuleForQueue(xpRoutePlan.getRoutePlanRule().toString());
                redisQueuePointIdVo.setTargetedVal(xpTargetedServiceVehicleVo.getWeight());
                redisQueuePointIdVo.setTargetedVal(weight);
                ll.add(redisQueuePointIdVo);
                //排序
                ll.sort((o1, o2) -> o2.getTargetedVal() - o1.getTargetedVal());
@@ -938,9 +937,9 @@
        String key = CacheConstants.SP_QUEUE_POINT_ID + "-" + xpPoint.getId() + "-" + xpPoint.getPointLon() + "," + xpPoint.getPointLat();
        if(xpRoutePlan==null){
            redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + null + "_" + xpTargetedServiceVehicleVo.getWeight()));
            redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + null + "_" + weight));
        }else {
            redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + xpRoutePlan.getRoutePlanRule() + "_" + xpTargetedServiceVehicleVo.getWeight()));
            redisService.setCacheList(key, Arrays.asList(orderId + "_" + xpPoint.getPointLon() + "," + xpPoint.getPointLat() + "_0" + "_" + uid + "_" + xpOrder.getOrderNumber() + "_" + distance + "_" + duration + "_" + xpRoutePlan.getRoutePlanRule() + "_" + weight));
        }
        log.info("订单推单:{}   {}", key, redisService.getCacheList(key));
        xpOrder.setQueueName(key);
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceServiceImpl.java
@@ -644,6 +644,7 @@
                LambdaQueryWrapper<XpPoint> pendingEnableQuery = new LambdaQueryWrapper<>();
                pendingEnableQuery.eq(XpPoint::getElectronicAreaId, operationAreaIdToEnable)
                        .eq(XpPoint::getPointType, 1)
                        .isNotNull(XpPoint::getOperationType)
                        .eq(XpPoint::getOperationStatus, 3);
                List<XpPoint> pendingEnablePoints = xpPointMapper.selectList(pendingEnableQuery);
                int pendingCount = pendingEnablePoints == null ? 0 : pendingEnablePoints.size();
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpTargetedServiceController.java
@@ -177,6 +177,16 @@
    }
    /**
     * 获取定向服务权限
     * @param appUserId
     * @param cityCode
     * @return
     */
    @GetMapping("/logan/inner/v1/targetedService/getTargetedServiceWeight")
    public R<Integer> getTargetedServiceWeight(@RequestParam("appUserId") Long appUserId, @RequestParam("cityCode") String cityCode){
        Integer targetedServiceWeight = xpTargetedServiceService.getTargetedServiceWeight(appUserId, cityCode);
        return R.ok(targetedServiceWeight);
    }
}
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpTargetedServiceService.java
@@ -9,6 +9,7 @@
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.page.PageInfo;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Set;
@@ -33,4 +34,13 @@
    List<XpTargetedServiceVehicleVo> findListByUserIdAndCityCode(Long appUserId, String cityCode);
    List<String> findSetVehicleVinByUserIdAndCityCode(Long appUserId, String cityCode);
    /**
     * 获取定向服务权重
     * @param appUserId
     * @param cityCode
     * @return
     */
    Integer getTargetedServiceWeight(Long appUserId, String cityCode);
}
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpTargetedServiceServiceImpl.java
@@ -1,12 +1,14 @@
package com.xiaopeng.operation.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
import com.xiaopeng.api.model.account.SysUser;
import com.xiaopeng.api.model.operation.XpTargetedService;
import com.xiaopeng.api.model.operation.XpTargetedServiceVehicle;
import com.xiaopeng.api.model.operation.XpTargetedServiceWhitelist;
import com.xiaopeng.api.model.operation.XpWhitelist;
import com.xiaopeng.api.model.vehicleConvoy.XpVehicle;
import com.xiaopeng.api.query.operation.XpTargetedServiceQuery;
import com.xiaopeng.api.vo.operation.XpTargetedServiceVehicleVo;
@@ -16,6 +18,7 @@
import com.xiaopeng.common.core.utils.SensitiveDataCryptoUtil;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.operation.mapper.XpTargetedServiceMapper;
import com.xiaopeng.operation.service.IXpWhitelistService;
import com.xiaopeng.operation.service.XpTargetedServiceService;
import com.xiaopeng.operation.service.XpTargetedServiceVehicleService;
import com.xiaopeng.operation.service.XpTargetedServiceWhitelistService;
@@ -39,6 +42,9 @@
    XpVehicleClient xpVehicleClient;
    @Resource
    XpTargetedServiceMapper xpTargetedServiceMapper;
    @Resource
    private IXpWhitelistService xpWhitelistService;
    public List<XpTargetedServiceVehicle> listByTargetedServiceId(Long targetedServiceId) {
@@ -239,7 +245,22 @@
        return null;
    }
    @Override
    public Integer getTargetedServiceWeight(Long appUserId, String cityCode) {
        List<XpWhitelist> one = xpWhitelistService.list(new QueryWrapper<XpWhitelist>().eq("app_user_id", appUserId).eq("status", 1)
                .eq("is_deleted", 0).last(" and expire_time >= DATE(NOW()) or expire_time is null"));
        if(!one.isEmpty()){
            List<Long> collect = one.stream().map(XpWhitelist::getId).collect(Collectors.toList());
            List<XpTargetedServiceWhitelist> xpTargetedServiceWhitelists = xpTargetedServiceWhitelistService.list(new QueryWrapper<XpTargetedServiceWhitelist>().in("whitelist_id", collect));
            for (XpTargetedServiceWhitelist xpTargetedServiceWhitelist : xpTargetedServiceWhitelists) {
                XpTargetedService targetedServiceVo = this.getOne(new QueryWrapper<XpTargetedService>().eq("id", xpTargetedServiceWhitelist.getTargetedServiceId())
                        .eq("status", 1).eq("is_deleted", 0).eq("city_code", cityCode)
                        .last(" and (is_long_valid = 1 or now() between start_time and end_time)"));
                if(null != targetedServiceVo){
                    return xpTargetedServiceWhitelist.getWeight();
                }
            }
        }
        return null;
    }
}