liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.xiaopeng.vehicleConvoy.controller;
 
import com.xiaopeng.api.model.vehicleConvoy.XpFleet;
import com.xiaopeng.api.model.vehicleConvoy.XpFleetOperations;
import com.xiaopeng.api.model.vehicleConvoy.XpFleetVehicle;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.vehicleConvoy.service.IXpFleetOperationsService;
import com.xiaopeng.vehicleConvoy.service.IXpFleetService;
import com.xiaopeng.vehicleConvoy.service.IXpFleetVehicleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 车队人员管理 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2026-02-03
 */
@RestController
@Api(tags = "车队人员管理")
public class XpFleetOperationsController {
 
    @Resource
    private IXpFleetService xpFleetService;
    @Resource
    private IXpFleetOperationsService xpFleetOperationsService;
    @Resource
    private IXpFleetVehicleService xpFleetVehicleService;
 
 
    /**
     * 根据人员id 获取所属车队下关联的车辆ids
     *
     * @param id 运维人员id
     * @return 车辆isd
     */
    @GetMapping("/logan/inner/fleet-operations/getVehicleByUserId/{id}")
    public R<List<Long>> getVehicleByUserId(@PathVariable("id") Long id){
        List<Long> fleetIds = xpFleetOperationsService.lambdaQuery().eq(XpFleetOperations::getOperationsUserId, id)
                .list().stream().map(XpFleetOperations::getFleetId).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(fleetIds)){
            return R.ok(new ArrayList<>());
        }
        List<Long> vehicleIds = xpFleetVehicleService.lambdaQuery().in(XpFleetVehicle::getVehicleId, fleetIds)
                .list().stream().map(XpFleetVehicle::getVehicleId).collect(Collectors.toList());
        return R.ok(vehicleIds);
    }
 
    /**
     * 根据人员id 获取所属车队
     *
     * @param id 运维人员id
     * @return 车辆isd
     */
    @GetMapping("/logan/inner/fleet-operations/getFleetByUserId/{id}")
    public R<List<XpFleet>> getFleetByUserId(@PathVariable("id") Long id){
        List<Long> fleetIds = xpFleetOperationsService.lambdaQuery().eq(XpFleetOperations::getOperationsUserId, id)
                .list().stream().map(XpFleetOperations::getFleetId).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(fleetIds)){
            return R.ok(new ArrayList<>());
        }
 
        List<XpFleet> xpFleets = xpFleetService.listByIds(fleetIds);
        return R.ok(xpFleets);
    }
 
 
    /**
     * 根据人员id 获取所属车队
     *
     * @param userIds 运维人员id
     * @return
     */
    @PostMapping("/logan/inner/fleet-operations/findListByUserIds")
    public R<List<XpFleetOperations>> findListByUserIds(@RequestBody List<Long> userIds){
 
        List<XpFleetOperations> listByUserIds = xpFleetOperationsService.findListByUserIds(userIds);
        return R.ok(listByUserIds);
    }
 
 
    /**
     * 根据运维人员ID查询关联的车队ID列表(内部接口)
     *
     * @param userId 运维人员ID
     * @return 车队ID列表
     */
    @ApiOperation(value = "根据运维人员ID查询关联的车队ID列表", tags = {"内部接口"})
    @GetMapping("/logan/inner/fleet-operations/getFleetIdsByUserId/{userId}")
    public R<List<Long>> getFleetIdsByUserId(@PathVariable("userId") Long userId) {
        List<Long> fleetIds = xpFleetOperationsService.lambdaQuery()
                .eq(XpFleetOperations::getOperationsUserId, userId)
                .list()
                .stream()
                .map(XpFleetOperations::getFleetId)
                .distinct()
                .collect(Collectors.toList());
        return R.ok(fleetIds);
    }
 
 
    /**
     * 根据车队ID查询关联的运维人员ID列表(内部接口)
     *
     * @param fleetId 车队ID
     * @return 运维人员ID列表
     */
    @GetMapping("/logan/inner/fleet-operations/getOperationsIdsByFleetId/{fleetId}")
    public R<List<Long>> getOperationsIdsByFleetId(@PathVariable("fleetId") Long fleetId) {
        List<Long> operationsIds = xpFleetOperationsService.lambdaQuery()
                .eq(XpFleetOperations::getFleetId, fleetId)
                .list()
                .stream()
                .map(XpFleetOperations::getOperationsUserId)
                .distinct()
                .collect(Collectors.toList());
        return R.ok(operationsIds);
    }
    /**
     * 根据车队ID集合查询关联的运维人员ID列表
     *
     * @param fleetIds 车队ID集合
     * @return 运维人员ID列表
     */
    @PostMapping("/logan/inner/fleet-operations/getOperationsIdsByFleetIds")
    public R<List<XpFleetOperations>> getOperationsIdsByFleetIds(@RequestBody List<Long> fleetIds){
        List<XpFleetOperations> fleetOperations = xpFleetOperationsService.lambdaQuery()
                .in(XpFleetOperations::getFleetId, fleetIds)
                .list();
        return R.ok(fleetOperations);
    }
}