DB
业务员表-实时位置字段
Sql-更新
update 表名 set real_time_position=GeomFromText('POINT(187.07 36.45)') where id='1000006'
Mybatis-更新or插入
update
financial_service_salesman
set
receipt_flag = #{receiptFlag}
,real_time_position = GeomFromText('POINT(${realTimePosition})')
,position_update_time = #{positionUpdateTime}
where
user_id = #{userId}
* GeomFromText('POINT(${realTimePosition})')
Mybatis-查询
需求:查询出所有业务员根据业务员位置和用户位置计算距离进而排序
select
id,
user_name,
(
st_distance (
fss.real_time_position, <!-- 业务员位置经纬度 -->
point (#{longitude}, #{latitude}) <!-- 用户位置经(longitude)纬(latitude)度 -->
)
)*111.195 AS distance <!-- distance 距离、米数 -->
from
financial_service_salesman as fss
where del_flag = '0'
order by distance
MyBatis查询经纬度字段值
ASText(fss.real_time_position)
返回业务员列表
前端或后台将取的米数转换