<?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="org.springblade.modules.position.mapper.PositionMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="positionResultMap" type="org.springblade.modules.position.entity.Position">
|
<id column="id" property="id"/>
|
<result column="snumber" property="snumber"/>
|
<result column="sname" property="sname"/>
|
<result column="jd" property="jd"/>
|
<result column="wd" property="wd"/>
|
<result column="stime" property="stime"/>
|
<result column="coordinate" property="coordinate"/>
|
</resultMap>
|
|
|
<select id="selectPositionPage" resultMap="positionResultMap">
|
select id,sNumber,sName,jd,wd,sTime,ST_ASTEXT(coordinate) as coordinate from sys_position where is_deleted = 0
|
</select>
|
|
|
<!--获取安保人员实时位置信息-->
|
<select id="selectInfo" resultMap="positionResultMap">
|
SELECT * FROM sys_position WHERE snumber=#{snumber} ORDER BY sTime DESC LIMIT 1
|
</select>
|
|
<!--获取安保人员实时的所有位置信息-->
|
<select id="selectList" resultMap="positionResultMap">
|
SELECT
|
id,snumber,sname,jd,wd,stime,ST_ASTEXT(coordinate) as coordinate
|
FROM
|
sys_position
|
WHERE
|
stime >= date( now( ) )
|
AND stime < DATE_ADD( date( now( ) ), INTERVAL 1 DAY ) and sNumber=#{sNumber} ORDER BY sTime ASC
|
</select>
|
|
<insert id="s">
|
INSERT INTO sys_position (snumber,sname,jd,wd,stime,coordinate) VALUES (#{snumber},#{sname},#{jd},#{wd},#{stime},POINT(#{jd},#{wd}))
|
</insert>
|
|
<select id="selectry" resultType="java.util.HashMap">
|
SELECT
|
id,
|
sname,
|
snumber,
|
round( ( st_distance ( point ( jd, wd ), ${coordinate} ) / 0.0111 ) * 1000 ) / 1000 AS distance
|
FROM
|
sys_position
|
HAVING distance <=5
|
ORDER BY
|
distance
|
</select>
|
|
|
<update id="updateb">
|
update sys_position SET snumber=#{snumber},sname=#{sname},jd=#{jd},wd=#{wd},stime=#{stime},coordinate=POINT(#{jd},#{wd}) where snumber=#{snumber}
|
</update>
|
|
<!--查询是否存在安保人员位置-->
|
<select id="selectc" resultType="java.lang.Integer">
|
SELECT count(*) FROM sys_position WHERE snumber=#{snumber}
|
</select>
|
|
</mapper>
|