luodangjia
2024-09-12 c5462d60b99823adb10d9e9eda671920118538f7
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
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.Site;
import com.ruoyi.chargingPile.api.model.TParkingLot;
import com.ruoyi.chargingPile.api.model.TParkingRecord;
import com.ruoyi.chargingPile.api.query.ParkingRecordQuery;
import com.ruoyi.chargingPile.api.vo.TParkingLotVO;
import com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO;
import com.ruoyi.chargingPile.api.vo.TParkingRecordVO;
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.dto.ParkingRecordQueryDto;
import com.ruoyi.chargingPile.mapper.SiteMapper;
import com.ruoyi.chargingPile.mapper.TParkingLotMapper;
import com.ruoyi.chargingPile.mapper.TParkingRecordMapper;
import com.ruoyi.chargingPile.service.TParkingRecordService;
import com.ruoyi.common.core.web.page.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-08
 */
@Service
public class TParkingRecordServiceImpl extends ServiceImpl<TParkingRecordMapper, TParkingRecord> implements TParkingRecordService {
 
    @Autowired
    private SiteMapper siteMapper;
    @Autowired
    private TParkingLotMapper parkingLotMapper;
 
    @Override
    public BigDecimal getSum(LocalDate sixBefore) {
        return this.baseMapper.getSum(sixBefore);
    }
 
    @Override
    public TParkingRecordPageInfoVO pageList(ParkingRecordQuery query) {
        // 查询站点的停车场id
        if(Objects.nonNull(query.getSiteId())){
            Site site = siteMapper.selectById(query.getSiteId());
            if (site!=null){
                List<TParkingLot> tParkingLots = parkingLotMapper.selectList(Wrappers.lambdaQuery(TParkingLot.class)
                        .eq(TParkingLot::getSiteId, site.getId()));
                List<Integer> lotIds = tParkingLots.stream().map(TParkingLot::getId).collect(Collectors.toList());
                query.setLotIds(lotIds);
            }
 
        }
        PageInfo<TParkingRecordVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
        List<TParkingRecordVO> list = this.baseMapper.pageList(query,pageInfo);
        pageInfo.setRecords(list);
        // 查询总数
        TParkingRecordPageInfoVO infoVO = this.baseMapper.getParkingRecordCount(query);
        if (infoVO==null){
            infoVO = new TParkingRecordPageInfoVO();
            infoVO.setTimeoutAmountSum(new BigDecimal("0"));
            infoVO.setOrderCount(0);
            infoVO.setParkingDurationSum(0);
            infoVO.setFeeDurationSum(0);
        }
        infoVO.setParkingRecordVOS(pageInfo);
        return infoVO;
    }
 
    @Override
    public List<Map<String, Object>> parkingData(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.parkingData(parkingRecordQueryDto);
    }
 
    @Override
    public List<Map<String, Object>> parkingDataByDate(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.parkingDataByDate(parkingRecordQueryDto);
    }
 
    @Override
    public List<Map<String, Object>> getCarColor(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.getCarColor(parkingRecordQueryDto);
    }
 
    @Override
    public List<Map<String, Object>> getOutType(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.getOutType(parkingRecordQueryDto);
    }
 
    @Override
    public List<Map<String, Object>> getIsCharge(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.getIsCharge(parkingRecordQueryDto);
    }
 
    @Override
    public List<Map<String, Object>> income(ParkingRecordQueryDto parkingRecordQueryDto) {
        return this.baseMapper.income(parkingRecordQueryDto);
    }
}