官方链接
<insert id="insertTable" parameterType="com.ioc.orm.ck.model.TableModel">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
<if test="driverId != null">
<if test="longitude != null">
<if test="latitude != null">
<if test="altitude != null">
<if test="direction != null">
<if test="mileage != null">
<if test="satellites != null">
<if test="alarm != null">
<if test="signalStatus != null">
<if test="gmtCreate != null">
<if test="plate != null and plate!=''">
<if test="deviceGroupId != null">
<if test="status != null">
<if test="mobile != null and mobile!=''">
<if test="provinceId != null">
<if test="cityId != null">
<if test="districtId != null">
<if test="address != null and address!=''">
<if test="bdLongitude != null">
<if test="bdLatitude != null">
<if test="gdLongitude != null">
<if test="gdLatitude != null">
<if test="speed != null">
<if test="speed2 != null">
<if test="mileage2 != null">
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">
<if test="driverId != null">
<if test="longitude != null">
<if test="latitude != null">
<if test="altitude != null">
<if test="direction != null">
<if test="mileage != null">
<if test="satellites != null">
<if test="alarm != null">
<if test="signalStatus != null">
<if test="gmtCreate != null">
<if test="plate != null and plate!=''">
<if test="deviceGroupId != null">
<if test="status != null">
<if test="mobile != null and mobile!=''">
<if test="provinceId != null">
<if test="cityId != null">
<if test="districtId != null">
<if test="address != null and address!=''">
<if test="bdLongitude != null">
<if test="bdLatitude != null">
<if test="gdLongitude != null">
<if test="gdLatitude != null">
<if test="speed != null">
<if test="speed2 != null">
<if test="mileage2 != null">
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-09 11:09:10.567', 5451280, 18730, 125.497977, 43.922478, 272, 120, 1212139.1, 4, 31, 0, 0, '2023-10-10 01:40:27', 2, 0.0, '浙A5Z086', 1765, 1, 786435, '14270593027', 220000, 220100, 220105, '吉林省长春市二道区英俊镇', 125.51080260372358, 43.93105415890568, 125.5043880599486, 43.92479494828726, 0.0, 0.0, 0.0);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:37:44', 5452662, 53124, 120.647793, 30.688315, 14, 76, 1211098.1, 4, 28, 0, 0, '2023-10-10 01:38:17', 2, 0.0, '浙A8Z987', 1765, 1, 786435, '14465049051', 330000, 330400, 330411, '浙江省嘉兴市秀洲区洪合镇登发超市东北217米', 120.65852330812179, 30.691511861460846, 120.65195821842615, 30.68584701544459, 0.0, 0.0, 0.0);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:33:10', 5448636, 52822, 123.195897, 41.775379, 53, 242, 423534.6, 4, 33, 0, 0, '2023-10-10 01:35:00', 2, 0.0, '辽LB1869', 1765, 1, 4980739, '14270526232', 210000, 210100, 210114, '辽宁省沈阳市于洪区沙岭街道沈阳中联电气设备有限公司(沙和路)南333米', 123.20830242649883, 41.78353508290512, 123.20173472609495, 41.77768495701079, 72.0, 0.0, 0.0489275);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:43:08', 5447681, 52913, 114.314814, 31.953241, 83, 313, 1201920.4, 5, 28, 0, 0, '2023-10-10 01:43:36', 2, 0.0, '浙A0Z730', 1765, 1, 4980739, '14270593155', 410000, 411500, 411521, '河南省信阳市罗山县灵山镇张楼小学西南489米', 114.32695907373498, 31.95706819668387, 114.32039364601484, 31.951228147198893, 80.0, 0.0, 0.0482153);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:10:02', 5542108, 53123, 114.070679, 31.052708, 48, 194, 228622.8, 4, 35, 0, 0, '2023-10-10 01:10:24', 2, 0.0, '浙A72F17', 0, 1, 4980739, '14270568822', 420000, 420900, 420902, '湖北省孝感市孝南区杨店镇孝昌县三葱文化传媒有限公司东南259米', 114.08300286555479, 31.0564264158298, 114.07646151237014, 31.050654449671725, 90.0, 89.0, 0.0543662);
INSERT INTO table_name(ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:54:03', 5540470, 53371, 112.057787, 32.107862, 53, 59, 433417.2, 0, 0, 0, 0, '2023-10-10 06:23:53', 2, 0.0, '鄂ADC062', 1758, 0, 786434, '14267957981', 420000, 420600, 420606, '湖北省襄阳市樊城区牛首镇襄阳双虎粮油北166米', 112.07029240384568, 32.11207992510232, 112.06386214037852, 32.10585844164688, 0.0, 0.0, 0.0388412);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 01:07:17', 431, 0, 117.440221, 39.122015, 44, 16, 241156.3, 27, 0, 0, 0, '2023-10-10 01:21:27', 2, 0.0, '浙A7Y317', 1739, 0, 2, '13955922198', 120000, 120100, 120110, '天津市东丽区军粮城街道', 117.45327611753122, 39.129101067458585, 117.44675313519525, 39.12315963816809, 0.0, 0.0, 0.0);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-10 00:14:49', 5542154, 57466, 121.481904, 38.965008, 82, 307, 149958.3, 5, 30, 524288, 0, '2023-10-10 00:16:52', 2, 0.0, '京AVC721', 0, 0, 786434, '14449802955', 210000, 210200, 210211, '辽宁省大连市甘井子区辛寨子街道世亚食品有限公司东北140米', 121.49374431242279, 38.971754503842966, 121.48717144677192, 38.96604576911434, 0.0, 0.0, 0.0);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-09 09:03:16', 4123188, 206228, 0.0, 0.0, 34, 0, 0.0, 0, 0, 0, 0, '1970-01-01 00:00:00', 0, 0.0, '', 0, 0, 0, '', 0, 0, 0, '山东省济宁市任城区接庄街道山东济宁九星无纺材料有限公司东南262米', 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
INSERT INTO table_name (ts, device_id, driver_id, longitude, latitude, altitude, direction, mileage, rssi, satellites, alarm, signal_status, gmt_create, kind, oil, plate, device_group_id, acc, status, mobile, province_id, city_id, district_id, address, bd_longitude, bd_latitude, gd_longitude, gd_latitude, speed, speed2, mileage2) VALUES('2023-10-09 12:57:27', 5455275, 53167, 117.1148, 36.873241, 13, 290, 842586.9, 4, 28, 0, 0, '2023-10-09 12:57:33', 2, 0.0, '浙A29A29', 1765, 0, 786434, '14270596428', 370000, 370100, 370115, '山东省济南市济阳区崔寨街道', 117.12736400914778, 36.88018065214984, 117.12095579687728, 36.873823843206324, 0.0, 0.0, 0.0);
WHERE (device_id , ts) IN (
WHERE (device_id , ts) IN (
INNER JOIN table_name b ON a.ts=b.ts AND a.device_id=b.device_id
WHERE device_id = 5540465
AND ts >= '2023-10-09 19:00:00'
AND ts <= '2023-10-11 09:21:21'
where device_id = 5540465
AND ts >= '2023-10-09 19:00:00'
AND ts <= '2023-10-11 09:21:21'
where device_id = 5540465
AND ts >= '2023-10-09 19:00:00'
AND ts <= '2023-10-11 09:21:21'
SELECT device_id as deviceId,
(last(mileage) - first(mileage)) as mileage,
(last(mileage2) - first(mileage2)) as mileage2,
first(mileage) firstMile,
first(mileage2) firstMile2,
where ts >= '2023-10-09 19:00:00'
AND ts <= '2023-10-11 09:21:21'
SELECT device_id as deviceId,
first_value(mileage) firstMile,
last_value(mileage) lastMile,
first_value(mileage2) firstMile2,
last_value(mileage2) lastMile2
where ts >= '2023-10-09 19:00:00'
AND ts <= '2023-10-11 09:21:21'