kaiyu
2021-09-08 f183af46a77eb7049a15e379eece4adbb59a9738
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
package com.moral.api.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moral.api.entity.HistorySecondUav;
import com.moral.api.mapper.HistorySecondUavMapper;
import com.moral.api.service.HistorySecondUavService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 * 无人机秒数据表 服务实现类
 * </p>
 *
 * @author moral
 * @since 2021-08-31
 */
@Service
public class HistorySecondUavServiceImpl extends ServiceImpl<HistorySecondUavMapper, HistorySecondUav> implements HistorySecondUavService {
 
    @Autowired
    HistorySecondUavMapper historySecondUavMapper;
 
    @Override
    public List<Date> queryDate(Integer organizationId) {
        //构造查询条件
        QueryWrapper<HistorySecondUav> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("organization_id",organizationId);
        //设置查询时间范围为180天
        Date endDate = new Date();
        Date startDate = DateUtils.addDays(endDate, -180);
        queryWrapper.between("batch",startDate,endDate);
        //设置查询字段
        queryWrapper.select("DISTINCT batch");
        //查询结果
        List<HistorySecondUav> historySecondUavs = historySecondUavMapper.selectList(queryWrapper);
        //结果转为Date集合
        List<Date> result = new ArrayList<>();
        for (HistorySecondUav historySecondUav : historySecondUavs) {
            result.add(historySecondUav.getBatch());
        }
        return result;
    }
}