package com.base.plan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.plan.model.entity.GridInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface GridInfoMapper extends BaseMapper<GridInfo> {


    /**
     * 根据纬度编码及左上右下点经度求网格编码
     * @param codeLat
     * @param leftTopLon
     * @param rbLon
     * @return
     */
    @Select("select * from grid_info a where (a.code_lat = #{codeLat} and a.lt_lon <= #{leftTopLon} and a.rb_lon >= #{rbLon})")
    List<GridInfo> findByCodeLatLon(@Param("codeLat") String codeLat, @Param("leftTopLon") double leftTopLon, @Param("rbLon") double rbLon);
    /**
     * 根据纬度编码及左上右下点经度求网格编码
     * @param codeLat
     * @param leftTopLon
     * @param rbLon
     * @return
     */
    @Select("select * from grid_info a where a.code_lat = #{codeLat} and a.lt_lon >= #{leftTopLon} and a.rb_lon >= #{rbLon}")
    List<GridInfo> findByCodeLatLon2(@Param("codeLat")String codeLat,@Param("leftTopLon")double leftTopLon,@Param("rbLon")double rbLon);

    /**
     * 根据纬度序列求网格编码
     * @param codeLat
     * @param startlatNum
     * @param endlatNum
     * @return
     */
    @Select("select * from grid_info a where (a.code_lat = #{codeLat}) and (a.lat_num >= #{startlatNum}) and (a.lat_num <= #{endlatNum}) order by lat_num asc")
    List<GridInfo> findByLatNum(@Param("codeLat")String codeLat,@Param("startlatNum")double startlatNum,@Param("endlatNum")double endlatNum);


}
