GpsOrientationMapper.xml
4.55 KB
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
<?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.trash.gps.mapper.GpsOrientationMapper">
<resultMap type="GpsOrientation" id="GpsOrientationResult">
<result property="id" column="id" />
<result property="terminalNumber" column="terminal_number" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="createTime" column="create_time" />
<result property="carCode" column="car_code" />
<result property="speed" column="speed" />
</resultMap>
<sql id="selectGpsOrientationVo">
select id, terminal_number, longitude, latitude, create_time,car_code,speed from gps_orientation_${yearMonth}
</sql>
<select id="selectGpsOrientationList" parameterType="GpsOrientation" resultMap="GpsOrientationResult">
<include refid="selectGpsOrientationVo"/>
<where>
<if test="terminalNumber != null and terminalNumber != ''"> and terminal_number = #{terminalNumber}</if>
<if test="createTimeStart!=null and createTimeEnd!=null">create_time between #{createTimeStart} and #{createTimeEnd}</if>
<if test="carCode!=null and carCode != ''">and car_code = #{carCode}</if>
</where>
</select>
<select id="selectGpsOrientationById" parameterType="Long" resultMap="GpsOrientationResult">
<include refid="selectGpsOrientationVo"/>
where id = #{id}
</select>
<insert id="insertGpsOrientation" parameterType="GpsOrientation" useGeneratedKeys="true" keyProperty="id">
insert into gps_orientation_${yearMonth}
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="terminalNumber != null">terminal_number,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="createTime != null">create_time,</if>
<if test="carCode != null">car_code,</if>
<if test="speed != null">speed,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="terminalNumber != null">#{terminalNumber},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="createTime != null">#{createTime},</if>
<if test="carCode != null">#{carCode},</if>
<if test="speed != null">#{speed},</if>
</trim>
</insert>
<update id="updateGpsOrientation" parameterType="GpsOrientation">
update gps_orientation_${yearMonth}
<trim prefix="SET" suffixOverrides=",">
<if test="terminalNumber != null">terminal_number = #{terminalNumber},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="carCode != null">car_code = #{carCode},</if>
<if test="speed != null">speed = #{speed},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteGpsOrientationById" parameterType="Long">
delete from gps_orientation_${yearMonth} where id = #{id}
</delete>
<delete id="deleteGpsOrientationByIds" parameterType="String">
delete from gps_orientation_${yearMonth} where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectCarCodeList" parameterType="String" resultMap="GpsOrientationResult">
select terminal_number,car_code from gps_orientation_${yearMonth}
group by terminal_number,car_code
</select>
<update id="createGpsTable" parameterType="String">
CREATE TABLE IF NOT EXISTS gps_orientation_${yearMonth} (
id bigint(20) NOT NULL AUTO_INCREMENT,
terminal_number varchar(20) DEFAULT NULL COMMENT '终端号',
longitude varchar(20) DEFAULT NULL COMMENT '经度',
latitude varchar(20) DEFAULT NULL COMMENT '纬度',
create_time datetime DEFAULT NULL COMMENT '创建时间',
car_code varchar(20) DEFAULT NULL COMMENT '车牌号',
speed varchar(20) DEFAULT NULL COMMENT '速度km/h',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='gps定位表';
</update>
</mapper>