<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.api.mapper.RescueStationMapper">
    <select id="getListByLatLonDistance" resultType="com.yeejoin.amos.boot.module.tzs.api.dto.RescueStationDto">

    select * from (
    select tcb_rescue_station.sequence_nbr,
    tcb_rescue_station.name,
    tcb_rescue_station.address,
        tcb_rescue_station.rescue_leader_id,
        tcb_rescue_station.rescue_leader,
        tcb_rescue_station.rescue_leader_phone,
        	(
		ACOS(
			SIN(
				(#{lat} * PI()) / 180
			) * SIN(
				(
					tcb_rescue_station.latitude * PI()
				) / 180
			) + COS(
				(#{lat} * PI()) / 180
			) * COS(
				(
					tcb_rescue_station.latitude * PI()
				) / 180
			) * COS(
				(#{lon} * PI()) / 180 - (
					tcb_rescue_station.longitude * PI()
				) / 180
			)
		) * 6371
	) AS distance
	from tcb_rescue_station
  )  t
    where t.distance
    <![CDATA[ <= ]]>
        #{distance}





 </select>
</mapper>
