<!--查詢距離最近一個位置的接口--> <select id="getNearPosition" parameterType="com.king.dto.PositionNearQueryDTO" resultMap="PositionNearResDTO"> SELECT ACOS( SIN((CAST(#{latitude} AS DECIMAL(5,2)) * 3.1415) / 180 ) * SIN((CAST(t.latitude AS DECIMAL(5,2)) * 3.1415) / 180 ) + COS((CAST(#{latitude} as decimal(5,2)) * 3.1415) / 180 ) * COS((CAST(t.latitude AS DECIMAL(5,2)) * 3.1415) / 180 ) * COS((CAST(#{longitude} AS DECIMAL(5,2)) * 3.1415) / 180 - (CAST(t.longitude AS DECIMAL(4,2)) * 3.1415) / 180 ) ) * 6380 AS distance, t1.position_logo, t1.position_name, t1.position_code, t1.province_code, t1.city_code, t1.district_code, t1.detail_address, t.longitude, t.latitude, IF(t.`position` is null, '', t.`position`) as `position`, IF(t.`point_offset` is null, '', t.`point_offset`) as `point_offset`, t.operator FROM tb_position_config t INNER JOIN tb_position t1 on t1.position_code = t.position_code WHERE t1.deleted = 0 AND t.latitude is not null AND t.latitude != '' AND t.longitude is not null AND t.longitude != '' ORDER BY CAST(distance AS decimal(15,2)) ASC LIMIT 0,1 </select>
Mybatis根據經度、緯度查詢距離最近一個位置(Mysql )
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.