jinpengyong
2023-11-13 471f693ac87a6ed6a2b00e93472b025266c0271f
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java
@@ -27,6 +27,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
 * <p>
@@ -59,28 +60,27 @@
    public List<Date> queryDate(Integer organizationId) {
        //构造查询条件
        QueryWrapper<HistorySecondUav> queryWrapper = new QueryWrapper<>();
        //List<Integer> childrenId = new ArrayList<>();
        List<Integer> children = organizationService.orgIdList(organizationId);
        //获取子组织id
        List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        /*List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        List<Integer> childrenId = new ArrayList<>();
        for (Organization child : children) {
            childrenId.add(child.getId());
        }
        childrenId.add(organizationId);
        queryWrapper.in("organization_id", childrenId);
        childrenId.add(organizationId);*/
        queryWrapper.in("organization_id", children);
        //设置查询时间范围为180天
        Date endDate = new Date();
        Date startDate = DateUtils.addDays(endDate, -180);
        queryWrapper.between("batch", startDate, endDate);
        //设置查询字段
        queryWrapper.select("DISTINCT batch");
        queryWrapper.select("DISTINCT DATE_FORMAT(batch,'%Y-%m-%d') batch ");
        queryWrapper.orderByDesc("batch");
        //查询结果
        List<HistorySecondUav> historySecondUavs = historySecondUavMapper.selectList(queryWrapper);
        //结果转为Date集合
        List<Date> result = new ArrayList<>();
        for (HistorySecondUav historySecondUav : historySecondUavs) {
            result.add(historySecondUav.getBatch());
        }
        List<Date> result = historySecondUavs.stream().map(HistorySecondUav::getBatch).collect(Collectors.toList());
        return result;
    }
@@ -94,12 +94,9 @@
        Date endDate = form.getEndDate();
        QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>();
        //获取子组织id
        List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        List<Integer> children = organizationService.orgIdList(organizationId);
        List<Integer> childrenId = new ArrayList<>();
        for (Organization child : children) {
            childrenId.add(child.getId());
        }
        childrenId.add(organizationId);
        childrenId.addAll(children);
        childrenId.addAll(integerList);
        wrapper.in("organization_id", childrenId);
        //查询根据batch查,因为可能会有跨天飞行的情况。