From 904447d37a7ea9e3fadf1b56badc0ddbcf210bd0 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期六, 14 二月 2026 17:05:08 +0800
Subject: [PATCH] feat(management):菜单权限

---
 xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 111 insertions(+), 2 deletions(-)

diff --git a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java b/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java
index 035a3fa..ca1a4da 100644
--- a/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java
+++ b/xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpOperationsUserServiceImpl.java
@@ -1,18 +1,31 @@
 package com.xiaopeng.account.service.impl;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xiaopeng.account.mapper.XpOperationsRoleMapper;
 import com.xiaopeng.account.mapper.XpOperationsUserMapper;
 import com.xiaopeng.account.model.query.XpOperationsUserPageQuery;
 import com.xiaopeng.account.service.IXpOperationsUserService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xiaopeng.api.feignClient.maintenance.XpClockInClient;
+import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient;
+import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient;
 import com.xiaopeng.api.model.account.XpOperationsUser;
+import com.xiaopeng.api.model.vehicleConvoy.XpFleet;
+import com.xiaopeng.api.vo.account.FleetInfoVO;
+import com.xiaopeng.api.vo.account.XpOperationsUserProfileVO;
 import com.xiaopeng.api.vo.account.XpOperationsUserWithRoleVO;
+import com.xiaopeng.common.core.domain.R;
+import com.xiaopeng.common.core.exception.ServiceException;
 import com.xiaopeng.common.core.web.page.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -22,8 +35,22 @@
  * @author mitao
  * @since 2026-02-03
  */
+@Slf4j
 @Service
 public class XpOperationsUserServiceImpl extends ServiceImpl<XpOperationsUserMapper, XpOperationsUser> implements IXpOperationsUserService {
+
+    @Autowired
+    private XpFleetOperationsClient xpFleetOperationsClient;
+
+    @Autowired
+    private XpFleetClient xpFleetClient;
+
+    @Autowired
+    private XpOperationsRoleMapper xpOperationsRoleMapper;
+
+    @Autowired
+    private XpClockInClient xpClockInClient;
+
     @Override
     public List<XpOperationsUser> listByName(String nickName) {
         if (StringUtils.isBlank(nickName)) {
@@ -40,4 +67,86 @@
         pageInfo.setTotal(page.getTotal());
         return pageInfo;
     }
+
+    @Override
+    public XpOperationsUserProfileVO getUserProfile(Long userId) {
+        // 1. 查询运维人员基础信息
+        XpOperationsUser user = this.getById(userId);
+        if (user == null) {
+            throw new ServiceException("运维人员不存在");
+        }
+
+        XpOperationsUserProfileVO vo = new XpOperationsUserProfileVO();
+        BeanUtils.copyProperties(user, vo);
+
+        // 2. 查询关联的车队ID列表(一个运维人员只能关联一个车队)
+        R<List<Long>> fleetIdsResult = xpFleetOperationsClient.getFleetIdsByUserId(userId);
+        List<Long> fleetIds = fleetIdsResult.getData();
+
+        if (!CollectionUtils.isEmpty(fleetIds)) {
+            // 3. 获取第一个车队ID(因为只能关联一个车队)
+            Long fleetId = fleetIds.get(0);
+
+            // 4. 查询车队信息
+            R<List<XpFleet>> fleetsResult = xpFleetClient.listByIds(Collections.singletonList(fleetId));
+            List<XpFleet> fleets = fleetsResult.getData();
+
+            if (!CollectionUtils.isEmpty(fleets)) {
+                XpFleet fleet = fleets.get(0);
+
+                // 5. 组装车队信息VO
+                FleetInfoVO fleetVO = new FleetInfoVO();
+                fleetVO.setFleetId(fleet.getId());
+                fleetVO.setFleetName(fleet.getFleetName());
+                fleetVO.setProvinceName(fleet.getProvinceName());
+                fleetVO.setCityName(fleet.getCityName());
+                fleetVO.setDistrictName(fleet.getDistrictName());
+
+                // 6. 查询并填充车队队长信息
+                if (fleet.getOperationsUserId() != null) {
+                    XpOperationsUser captain = this.getById(fleet.getOperationsUserId());
+                    if (captain != null) {
+                        fleetVO.setCaptainId(captain.getId());
+                        fleetVO.setFleetLeaderName(captain.getNickName());
+                        fleetVO.setFleetLeaderAvatar(captain.getAvatar());
+                    }
+                }
+
+                vo.setFleet(fleetVO);
+            }
+        }
+
+        // 7. 查询是否上班中
+        try {
+            R<Boolean> workStatusResult = xpClockInClient.checkWorkStatus(userId);
+            if (workStatusResult != null && workStatusResult.getCode() == 200) {
+                vo.setWorkFlag(workStatusResult.getData());
+            } else {
+                // 调用失败,默认 false
+                vo.setWorkFlag(false);
+                log.warn("查询用户上班状态失败, userId={}, result={}", userId, workStatusResult);
+            }
+        } catch (Exception e) {
+            // 异常情况,默认 false
+            vo.setWorkFlag(false);
+            log.error("查询用户上班状态异常, userId={}", userId, e);
+        }
+
+        // 8. 查询角色信息
+        List<XpOperationsUserWithRoleVO> userWithRoles = xpOperationsRoleMapper.selectUsersWithRoleByIds(Collections.singletonList(userId));
+        if (!CollectionUtils.isEmpty(userWithRoles)) {
+            List<XpOperationsUserProfileVO.RoleInfoVO> roleVOs = userWithRoles.stream()
+                    .filter(r -> r.getRoleId() != null)
+                    .map(r -> {
+                        XpOperationsUserProfileVO.RoleInfoVO roleVO = new XpOperationsUserProfileVO.RoleInfoVO();
+                        roleVO.setRoleId(r.getRoleId());
+                        roleVO.setRoleName(r.getRoleName());
+                        return roleVO;
+                    })
+                    .collect(Collectors.toList());
+            vo.setRoles(roleVOs);
+        }
+
+        return vo;
+    }
 }

--
Gitblit v1.7.1