puzhibing
2026-04-15 7e51270fca4138abf3df51e08085c253ba7c0e93
合并代码
3个文件已添加
3个文件已修改
196 ■■■■■ 已修改文件
xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-account-boot/src/main/resources/mapper/account/XpAppUserCollectAddrMapper.xml 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/map/XpStationClientFallbackFactory.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/map/XpStationClient.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpStationController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java
@@ -9,11 +9,18 @@
import com.xiaopeng.account.model.vo.CollectAddrTargetVO;
import com.xiaopeng.account.model.vo.XpAppUserCollectAddrVO;
import com.xiaopeng.account.service.IXpAppUserCollectAddrService;
import com.xiaopeng.api.dto.map.XpPointExportExcelQuery;
import com.xiaopeng.api.feignClient.map.XpStationClient;
import com.xiaopeng.api.feignClient.operation.XpPointClient;
import com.xiaopeng.api.model.account.XpAppUserCollectAddr;
import com.xiaopeng.api.model.operation.XpPoint;
import com.xiaopeng.api.model.operation.XpStation;
import com.xiaopeng.common.core.exception.ServiceException;
import com.xiaopeng.common.core.web.page.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -35,6 +42,16 @@
    private static final int ITEM_TYPE_STATION = 2;
    private static final int COLLECT_LIMIT = 50;
    @Resource
    private XpPointClient xpPointClient;
    @Resource
    private XpStationClient xpStationClient;
    /**
     * 收藏地址。
     * 收藏表显式保存 item_type / station_id:
@@ -45,42 +62,42 @@
    @Override
    public Boolean collectAddr(CollectAddrDTO dto, String uid) {
        Long userId = Long.parseLong(uid);
        CollectAddrTargetVO target = resolveCollectTarget(dto);
        if (target == null || target.getPointId() == null || target.getItemType() == null) {
            throw new ServiceException("收藏目标不存在");
        if(dto.getItemType() == 1){
            XpPointExportExcelQuery xpPointExportExcelQuery = new XpPointExportExcelQuery();
            xpPointExportExcelQuery.setPointIds(Arrays.asList(dto.getPointId()));
            List<XpPoint> data = xpPointClient.getByIds(xpPointExportExcelQuery).getData();
            if(null == data || data.size() == 0){
                throw new ServiceException("站点不存在");
            }
        }
        if(dto.getItemType() == 2){
            XpStation data = xpStationClient.getXpStationById(dto.getStationId()).getData();
            if(null == data){
                throw new ServiceException("场站不存在");
            }
        }
        LambdaQueryWrapper<XpAppUserCollectAddr> sameTargetWrapper = buildSameTargetWrapper(userId, target);
        if (COLLECT_TYPE_ADD == dto.getType()) {
            Long count = this.count(new LambdaQueryWrapper<XpAppUserCollectAddr>()
                    .eq(XpAppUserCollectAddr::getAppUserId, userId)
                    .eq(XpAppUserCollectAddr::getDeleted, 0));
            if (count >= COLLECT_LIMIT) {
                throw new ServiceException("收藏夹已满,请先删除旧地址");
            }
            if (this.count(sameTargetWrapper) > 0) {
                return true;
            }
        if(1 == dto.getType()){
            XpAppUserCollectAddr collectAddr = new XpAppUserCollectAddr();
            collectAddr.setAppUserId(userId);
            collectAddr.setItemType(target.getItemType());
            collectAddr.setPointId(target.getPointId());
            collectAddr.setStationId(target.getStationId());
            collectAddr.setLongitude(target.getLongitude());
            collectAddr.setLatitude(target.getLatitude());
            collectAddr.setItemType(dto.getItemType());
            collectAddr.setPointId(dto.getPointId());
            collectAddr.setStationId(dto.getStationId());
            collectAddr.setLongitude(dto.getLongitude());
            collectAddr.setLatitude(dto.getLatitude());
            return this.save(collectAddr);
        }
        if (COLLECT_TYPE_CANCEL == dto.getType()) {
            XpAppUserCollectAddr collectAddr = this.getOne(sameTargetWrapper.last("limit 1"));
            if (collectAddr == null) {
                return true;
        }else{
            if(dto.getItemType() == 1){
                return this.remove(new LambdaQueryWrapper<XpAppUserCollectAddr>().eq(XpAppUserCollectAddr::getAppUserId, userId)
                        .eq(XpAppUserCollectAddr::getPointId, dto.getPointId()));
            }
            return this.removeById(collectAddr.getId());
        }
            if(dto.getItemType() == 2){
                return this.remove(new LambdaQueryWrapper<XpAppUserCollectAddr>().eq(XpAppUserCollectAddr::getAppUserId, userId)
                        .eq(XpAppUserCollectAddr::getStationId, dto.getStationId()));
            }
        throw new ServiceException("不支持的操作类型");
        }
        return false;
    }
    /**
@@ -91,6 +108,24 @@
    public PageInfo<XpAppUserCollectAddrVO> userCollectAddrList(XpUserCollectAddrListQuery query, String uid) {
        Page<XpAppUserCollectAddrVO> page = new Page<>(query.getPageNum(), query.getPageSize());
        Page<XpAppUserCollectAddrVO> pageData = this.baseMapper.userCollectAddrPageList(page, query, Long.parseLong(uid));
        pageData.getRecords().forEach(xpAppUserCollectAddrVO -> {
            if(xpAppUserCollectAddrVO.getItemType() == 1){
                XpPointExportExcelQuery xpPointExportExcelQuery = new XpPointExportExcelQuery();
                xpPointExportExcelQuery.setPointIds(Arrays.asList(xpAppUserCollectAddrVO.getPointId()));
                List<XpPoint> data = xpPointClient.getByIds(xpPointExportExcelQuery).getData();
                if(null != data && data.size() > 0){
                    xpAppUserCollectAddrVO.setPointName(data.get(0).getPointName());
                    xpAppUserCollectAddrVO.setPointAddress(data.get(0).getPointAddress());
                }
            }
            if(xpAppUserCollectAddrVO.getItemType() == 2){
                XpStation data = xpStationClient.getXpStationById(xpAppUserCollectAddrVO.getStationId()).getData();
                if(null != data){
                    xpAppUserCollectAddrVO.setPointName(data.getStationName());
                }
            }
        });
        PageInfo<XpAppUserCollectAddrVO> resultPage = new PageInfo<>(query.getPageNum(), query.getPageSize());
        resultPage.setTotal(pageData.getTotal());
xp-robotaxi-account-boot/src/main/resources/mapper/account/XpAppUserCollectAddrMapper.xml
@@ -10,30 +10,8 @@
            c.latitude,
            c.point_id as pointId,
            c.station_id as stationId,
            case
                when c.item_type = 2 then s.station_name
                else p.point_name
            end as pointName,
            case
                when c.item_type = 2 then coalesce(dp.point_address, fp.point_address, p.point_address)
                else p.point_address
            end as pointAddress
            c.item_type = 2
        from xp_app_user_collect_addr c
        left join xp_point p on p.id = c.point_id and p.is_deleted = 0
        left join xp_station s on s.id = c.station_id and s.is_deleted = 0
        left join xp_point dp on dp.id = s.default_point_id and dp.is_deleted = 0
        left join xp_point fp on fp.id = (
            select p1.id
            from xp_point p1
            where p1.station_id = s.id
              and p1.is_deleted = 0
              and p1.point_type = 1
              and p1.operation_status = 2
            order by case when s.default_point_id is not null and p1.id = s.default_point_id then 0 else 1 end,
                     p1.station_sort_no asc,
                     p1.id asc
            limit 1
        )
        where c.app_user_id = #{uid}
          and c.is_deleted = 0
        order by c.create_time asc
xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/map/XpStationClientFallbackFactory.java
New file
@@ -0,0 +1,22 @@
package com.xiaopeng.api.factory.map;
import com.xiaopeng.api.feignClient.map.XpStationClient;
import com.xiaopeng.api.model.operation.XpStation;
import com.xiaopeng.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@Slf4j
public class XpStationClientFallbackFactory implements FallbackFactory<XpStationClient> {
    @Override
    public XpStationClient create(Throwable cause) {
        return new XpStationClient(){
            @Override
            public R<XpStation> getXpStationById(Long id) {
                log.error("根据id获取数据失败", cause);
                return R.fail("根据id获取数据失败");
            }
        };
    }
}
xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/map/XpStationClient.java
New file
@@ -0,0 +1,21 @@
package com.xiaopeng.api.feignClient.map;
import com.xiaopeng.api.factory.map.XpStationClientFallbackFactory;
import com.xiaopeng.api.model.operation.XpStation;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(contextId = "XpStationClient", value = ServiceNameConstantsEnum.XP_MAP_SERVICE, fallbackFactory = XpStationClientFallbackFactory.class)
public interface XpStationClient {
    /**
     * 根据id获取数据
     * @param id
     * @return
     */
    @GetMapping("/logan/inner/v1/xpStation/getXpStationById")
    R<XpStation> getXpStationById(@PathVariable("id") Long id);
}
xp-robotaxi-api/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -51,4 +51,5 @@
com.xiaopeng.api.factory.operation.XpRoutePlanClientFallbackFactory
com.xiaopeng.api.factory.order.XpTestOrderClientFallbackFactory
com.xiaopeng.api.factory.map.AdcFencePushClientFallbackFactory
com.xiaopeng.api.factory.account.UserRoutePlanRuleClientFallbackFactory
com.xiaopeng.api.factory.account.UserRoutePlanRuleClientFallbackFactory
com.xiaopeng.api.factory.map.XpStationClientFallbackFactory
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpStationController.java
New file
@@ -0,0 +1,33 @@
package com.xiaopeng.map.controller;
import com.xiaopeng.api.model.operation.XpStation;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.map.service.XpStationService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
 * 场站
 */
@RestController
@RequestMapping
public class XpStationController {
    @Resource
    private XpStationService xpStationService;
    /**
     * 根据id获取数据
     * @param id
     * @return
     */
    @GetMapping("/logan/inner/v1/xpStation/getXpStationById")
    public R<XpStation> getXpStationById(@PathVariable("id") Long id){
        XpStation xpStation = xpStationService.getById(id);
        return R.ok(xpStation);
    }
}