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