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);
|
}
|
}
|