nnnjjj123
2021-01-28 71b6b716361c52af290493d365a328fc1a3467e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?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 &gt;= date( now( ) )
        AND stime &lt; 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 &lt;=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>