liujie
2026-03-10 01a96cd1f631d69b423546d9a1994e2331f6b19e
修改bug
5个文件已修改
64 ■■■■■ 已修改文件
xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/operation/VehiclePositionByVinDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-common/xp-common-redis/src/main/java/com/xiaopeng/common/redis/service/RedisService.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/TaskOrderUtil.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/operation/VehiclePositionByVinDto.java
@@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Set;
@Data
@ApiModel(value = "筛选车辆信息Dto")
@@ -17,7 +18,7 @@
    private Long fenceId;
    // 车辆vin
    private List<String> vinList;
    private Set<String> vinList;
    // 数量
xp-robotaxi-common/xp-common-redis/src/main/java/com/xiaopeng/common/redis/service/RedisService.java
@@ -6,10 +6,7 @@
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.stereotype.Component;
@@ -214,6 +211,43 @@
        RedisScript<Long> script = new DefaultRedisScript<>(luaScript, Long.class);
        return redisTemplate.execute(script, Collections.singletonList(key), value);
    }
    /**
     * 从 List 中移除所有 value 包含指定关键字的元素
     * @param key Redis key
     * @param pattern 要匹配的关键字(如 "abc" 会匹配包含 "abc" 的所有元素)
     * @return 移除的数量
     */
    public Long removeByPattern(String key, String pattern) {
        ListOperations<String, String> listOps = redisTemplate.opsForList();
        // 1. 获取 List 长度
        Long size = listOps.size(key);
        if (size == null || size == 0) {
            return 0L;
        }
        // 2. 获取整个 List(小数据量可用,大数据量要优化)
        List<String> allValues = listOps.range(key, 0, -1);
        if (allValues == null || allValues.isEmpty()) {
            return 0L;
        }
        // 3. 找到匹配的元素并记录位置(从后往前删除,避免索引变化)
        long removedCount = 0;
        for (int i = allValues.size() - 1; i >= 0; i--) {
            String value = allValues.get(i);
            if (value != null && value.contains(pattern)) {
                // 使用 LREM 命令删除(从头部开始删除,count=1 表示只删一个)
                Long result = listOps.remove(key, 1, value);
                if (result != null && result > 0) {
                    removedCount++;
                }
            }
        }
        return removedCount;
    }
    /**
     * 缓存Set
     *
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -363,11 +363,11 @@
        }
        // 10. 检查等待时间
//        Integer waitTime = getWaitTime(routeAndFareDto.getOrigin().getLongitude(), routeAndFareDto.getOrigin().getLatitude());
//        if (waitTime > 3) {
//            throw new ServiceException("当前区域正在等待中,请耐心等待", I18nKeyConstant.WAITING_TIME);
//        }
//        fareVo.setWaitingTime(waitTime);
        Integer waitTime = getWaitTime(routeAndFareDto.getOrigin().getLongitude(), routeAndFareDto.getOrigin().getLatitude());
        if (waitTime > 3) {
            throw new ServiceException("当前区域正在等待中,请耐心等待", I18nKeyConstant.WAITING_TIME);
        }
        fareVo.setWaitingTime(waitTime);
        // 11. 生成订单ID并缓存
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/TaskOrderUtil.java
@@ -253,6 +253,9 @@
            return true;
        }
        XpOrder xpOrder = xpOrderR.getData();
        if(xpOrder.getStatus()==0){
            redisService.removeByPattern(quoteName,xpOrder.getOrderNumber());
        }
        // 找出围栏id
        Long xpElectronicFenceAreaId = xpOrder.getXpElectronicFenceAreaId();
@@ -272,7 +275,7 @@
            if (positionList.isEmpty()) {
                continue;
            }
            List<String> vinList = positionList.stream().map(VehiclePosition::getVin).collect(Collectors.toList());
            Set<String> vinList = positionList.stream().map(VehiclePosition::getVin).collect(Collectors.toSet());
            // 获取车辆的信息 筛选出可用车辆
            R<List<String>> vehiclePositionVos = xpVehicleClient.queryVehiclePositionByVin(new VehiclePositionByVinDto(xpElectronicFence.getId(), vinList, xpTradingStrategy.getSimultaneouslyOrderCount()));
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -1056,6 +1056,8 @@
        if (order.getStatus() > 5 || order.getStatus() < 1) {
            throw new ServiceException("订单状态错误", I18nKeyConstant.ORDER_STATUS_ERROR);
        }
        redisService.removeByPattern(order.getQueueName(),order.getOrderNumber());
        if (order.getStatus() == 1) {
            order.setStatus(0);
            order.setAppUserId(null);
@@ -1164,6 +1166,8 @@
        xpOrderCancel.setCreateTime(LocalDateTime.now());
        xpOrderCancelService.save(xpOrderCancel);
        redisService.removeByPattern(order.getQueueName(),order.getOrderNumber());
        R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(order.getVehicleId());
        XpVehicle xpVehicle = xpVehicleR.getData();