| | |
| | | if (excludeFleetId != null) { |
| | | wrapper.ne(XpFleetOperations::getFleetId, excludeFleetId); |
| | | } |
| | | wrapper.last("limit 1"); |
| | | XpFleetOperations operations = xpFleetOperationsService.getOne(wrapper); |
| | | if (operations != null) { |
| | | // 查询人员姓名和车队名称 |
| | |
| | | if (excludeFleetId != null) { |
| | | wrapper.ne(XpFleetVehicle::getFleetId, excludeFleetId); |
| | | } |
| | | wrapper.last("limit 1"); |
| | | XpFleetVehicle fleetVehicle = xpFleetVehicleService.getOne(wrapper); |
| | | if (fleetVehicle != null) { |
| | | // 车辆已绑定其他车队,自动解绑 |
| | |
| | | FleetDetailVO vo = new FleetDetailVO(); |
| | | BeanUtils.copyProperties(fleet, vo); |
| | | |
| | | // 3. 统计人员数量 |
| | | long userCount = xpFleetOperationsService.count(new LambdaQueryWrapper<XpFleetOperations>() |
| | | .eq(XpFleetOperations::getFleetId, id)); |
| | | vo.setUserCount((int) userCount); |
| | | // 3. 统计人员数量(过滤已删除人员) |
| | | List<Long> bindUserIds = xpFleetOperationsService.lambdaQuery() |
| | | .eq(XpFleetOperations::getFleetId, id) |
| | | .list() |
| | | .stream() |
| | | .map(XpFleetOperations::getOperationsUserId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | int userCount = 0; |
| | | if (!CollectionUtils.isEmpty(bindUserIds)) { |
| | | try { |
| | | R<List<XpOperationsUser>> usersResult = xpOperationUserClient.listByIds(bindUserIds); |
| | | if (usersResult != null && usersResult.getData() != null) { |
| | | userCount = usersResult.getData().size(); |
| | | } else { |
| | | userCount = bindUserIds.size(); |
| | | } |
| | | } catch (Exception e) { |
| | | userCount = bindUserIds.size(); |
| | | } |
| | | } |
| | | vo.setUserCount(userCount); |
| | | |
| | | // 4. 统计车辆数量 |
| | | long vehicleCount = xpFleetVehicleService.count(new LambdaQueryWrapper<XpFleetVehicle>() |
| | | .eq(XpFleetVehicle::getFleetId, id)); |
| | | vo.setVehicleCount((int) vehicleCount); |
| | | // 4. 统计车辆数量(过滤已删除车辆) |
| | | List<Long> bindVehicleIds = xpFleetVehicleService.lambdaQuery() |
| | | .eq(XpFleetVehicle::getFleetId, id) |
| | | .list() |
| | | .stream() |
| | | .map(XpFleetVehicle::getVehicleId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | int vehicleCount = 0; |
| | | if (!CollectionUtils.isEmpty(bindVehicleIds)) { |
| | | try { |
| | | R<List<XpVehicle>> vehiclesResult = xpVehicleClient.listByIds(bindVehicleIds); |
| | | if (vehiclesResult != null && vehiclesResult.getData() != null) { |
| | | vehicleCount = vehiclesResult.getData().size(); |
| | | } else { |
| | | vehicleCount = bindVehicleIds.size(); |
| | | } |
| | | } catch (Exception e) { |
| | | vehicleCount = bindVehicleIds.size(); |
| | | } |
| | | } |
| | | vo.setVehicleCount(vehicleCount); |
| | | |
| | | // 5. 查询负责人信息 |
| | | if (fleet.getOperationsUserId() != null) { |