From b68e39fbd1ce7038e02e9d1d3f4736446bc3d76e Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 15 四月 2026 18:32:28 +0800
Subject: [PATCH] Merge branch '1.0' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.0

---
 xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java |   93 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 64 insertions(+), 29 deletions(-)

diff --git a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java b/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java
index e4deeff..8a69c56 100644
--- a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCollectAddrServiceImpl.java
+++ b/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());

--
Gitblit v1.7.1