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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
| <?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.gk.hotwork.Mapper.DeviceLocationMapper" >
| <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.DeviceLocation" >
| <!-- -->
| <id column="id" property="id" jdbcType="BIGINT" />
| <id column="root_area_id" property="rootAreaId" jdbcType="BIGINT" />
| <id column="area_id" property="areaId" jdbcType="BIGINT" />
| <id column="gate_id" property="gateId" jdbcType="VARCHAR" />
| <id column="device_type" property="deviceType" jdbcType="VARCHAR" />
| <id column="tag_id" property="tagId" jdbcType="VARCHAR" />
| <id column="uid" property="uid" jdbcType="VARCHAR" />
| <id column="user_id" property="userId" jdbcType="VARCHAR" />
| <id column="router_id" property="routerId" jdbcType="VARCHAR" />
| <id column="raise_time" property="raiseTime" jdbcType="VARCHAR" />
| <id column="x" property="x" jdbcType="DECIMAL" />
| <id column="y" property="y" jdbcType="DECIMAL" />
| <id column="z" property="z" jdbcType="DECIMAL" />
| <id column="floor" property="floor" jdbcType="INTEGER" />
| <id column="direction" property="direction" jdbcType="INTEGER" />
| <id column="speed" property="speed" jdbcType="DECIMAL" />
| <id column="silent" property="silent" jdbcType="BOOLEAN" />
| <id column="longitude" property="longitude" jdbcType="DECIMAL" />
| <id column="altitude" property="altitude" jdbcType="DECIMAL" />
| <id column="latitude" property="latitude" jdbcType="DECIMAL" />
| <id column="gps_type" property="gpsType" jdbcType="VARCHAR" />
| <id column="mode" property="mode" jdbcType="VARCHAR" />
| <id column="create_time" property="createTime" jdbcType="DATE" />
|
| </resultMap>
|
| <sql id="base_columns">
| root_area_id,
| area_id,
| gate_id,
| device_type,
| tag_id,
| uid,
| user_id,
| router_id,
| raise_time,
| x,
| y,
| z,
| floor,
| direction,
| speed,
| silent,
| longitude,
| altitude,
| latitude,
| gps_type,
| mode,
| create_time
| </sql>
|
| <insert id="insertOne">
| insert into device_location_slice${slice}
| (<include refid="base_columns"></include>)
| values(
| #{location.rootAreaId},
| #{location.areaId},
| #{location.gateId},
| #{location.deviceType},
| #{location.tagId},
| #{location.uid},
| #{location.userId},
| #{location.routerId},
| #{location.raiseTime},
| #{location.x},
| #{location.y},
| #{location.z},
| #{location.floor},
| #{location.direction},
| #{location.speed},
| #{location.silent},
| #{location.longitude},
| #{location.altitude},
| #{location.latitude},
| #{location.gpsType},
| #{location.mode},
| #{location.createTime}
|
| )
|
|
| </insert>
| <delete id="deleteRecordBeforeDays">
| delete from device_location_slice${slice}
| where create_time < date_sub(now(),INTERVAL #{days} DAY)
| </delete>
| <select id="selectLatestUserLocation" resultMap="BaseResultMap">
|
| select
| <include refid="base_columns"/>
| from device_location_slice${slice}
| where uid = #{uid}
| order by raise_time desc
| limit 1
| </select>
| <select id="selectUserLocations" resultType="com.gk.hotwork.Domain.DeviceLocation">
| select
| <include refid="base_columns"/>
| from device_location_slice${slice}
| where
| uid = #{uid}
| and raise_time > #{starttime}
| and raise_time < #{endtime}
| order by raise_time
|
| </select>
|
|
| </mapper>
|
|