package com.xiaopeng.operation.repository;
|
|
import com.xiaopeng.api.model.operation.XpGeoQueryEntity;
|
import org.springframework.data.geo.Distance;
|
import org.springframework.data.geo.Point;
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
import org.springframework.data.mongodb.repository.Query;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* MongoDB Repository 接口
|
* 用于支持地理空间查询和其他操作
|
*/
|
public interface XpGeoQueryEntityRepository extends MongoRepository<XpGeoQueryEntity, String> {
|
|
/**
|
* 通过经纬度查询范围1000米内、一周内、状态>1的数据
|
* @param point 中心点坐标
|
* @param distance 距离范围
|
* @param startTime 开始时间(一周前)
|
* @param status 状态阈值
|
* @return 符合条件的实体列表
|
*/
|
@Query("{ 'location' : { '$nearSphere' : ?0, '$maxDistance' : ?1 }, 'timestamp' : { '$gte' : ?2 } }")
|
List<XpGeoQueryEntity> findByLocationNearAndTimestampAfterAndStatusGreaterThan(
|
Point point,
|
Distance distance,
|
Date startTime,
|
Integer status
|
);
|
|
/**
|
* 通过经纬度查询范围500米内、一周内、指定时段、状态>1的数据
|
* @param point 中心点坐标
|
* @param distance 距离范围
|
* @param startTime 开始时间(一周前)
|
* @param time 时段(格式:HH-HH)
|
* @param status 状态阈值
|
* @return 符合条件的实体列表
|
*/
|
@Query("{ 'location' : { '$nearSphere' : ?0, '$maxDistance' : ?1 }, 'timestamp' : { '$gte' : ?2 }, 'time' : ?3 }")
|
List<XpGeoQueryEntity> findByLocationNearAndTimestampAfterAndTimeAndStatusGreaterThan(
|
Point point,
|
Integer distance,
|
Date startTime,
|
String time,
|
Integer status
|
);
|
|
/**
|
* 通过时间范围和状态查询数据
|
* @param startTime 开始时间
|
* @param endTime 结束时间
|
* @param status 状态阈值
|
* @return 符合条件的实体列表
|
*/
|
List<XpGeoQueryEntity> findByTimestampBetweenAndStatusGreaterThan(
|
Date startTime,
|
Date endTime,
|
Integer status
|
);
|
}
|