Pu Zhibing
2025-01-17 c80c0184b6e560d41d5aa5691874e07b681fa18f
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
package com.ruoyi.chargingPile.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.chargingPile.api.model.TCarport;
import com.ruoyi.chargingPile.api.model.TVehicleRamp;
import com.ruoyi.chargingPile.api.vo.TCarportVO;
import com.ruoyi.chargingPile.mapper.TCarportMapper;
import com.ruoyi.chargingPile.mapper.TVehicleRampMapper;
import com.ruoyi.chargingPile.service.TCarportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 车库 服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-06
 */
@Service
public class TCarportServiceImpl extends ServiceImpl<TCarportMapper, TCarport> implements TCarportService {
 
    @Autowired
    private TVehicleRampMapper vehicleRampMapper;
 
    @Override
    public List<TCarportVO> queryCarportByParkId(Integer parkingLotId) {
        // 查询车库信息
        List<TCarportVO> carportVOS = this.baseMapper.queryCarportByParkId(parkingLotId);
        List<TVehicleRamp> vehicleRamps = vehicleRampMapper.selectList(Wrappers.lambdaQuery(TVehicleRamp.class)
                .eq(TVehicleRamp::getParkingLotId, parkingLotId));
        // 查询车道信息
        carportVOS.forEach(carportVO -> {
            carportVO.setVehicleRamps(vehicleRamps.stream().filter(vehicleRamp -> vehicleRamp.getCarportId().equals(carportVO.getId())).collect(Collectors.toList()));
        });
        return carportVOS;
    }
}