package com.sikey.wa04.business.domain.usecase;

import com.sikey.wa04.business.domain.entity.Location;
import lombok.extern.slf4j.Slf4j;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

/**
 * 2025-08-15日直接使用时间在数据库中查询，此代码已无用，未删除时因为可以学习一下写法
 * @Author: qin
 * @Date: 2025/5/6
 * @Description: 定位日期
 */
@Slf4j
public class LocationDateRangeFilter {
    private final List<Location> locations;

    public LocationDateRangeFilter(List<Location> locations) {
        this.locations = locations;
    }

    public List<Location> getLocations(Instant from, Instant to) {
        List<Location> result = new ArrayList<>();
        for (Location location : locations) {
          //  log.info("[历史轨迹]开始时间：{}，结束时间：{}，定位时间：{}，时间比较值：{}",from,to,location.getPositionTime(),location.getPositionTime().isAfter(from) && location.getPositionTime().isBefore(to));
            if (location.getPositionTime().isAfter(from) && location.getPositionTime().isBefore(to)) {
                result.add(location);
            }
        }
        return result;
    }
}
