feat: 航线解析以及websocket订阅不关闭bug修复
This commit is contained in:
@@ -0,0 +1,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.central.device.mapper.DroneFlightTrackMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.device.entity.DroneFlightTrack">
|
||||
<id column="id" property="id" />
|
||||
<result column="device_sn" property="deviceSn" />
|
||||
<result column="job_id" property="jobId" />
|
||||
<result column="route_id" property="routeId" />
|
||||
<result column="longitude" property="longitude" />
|
||||
<result column="latitude" property="latitude" />
|
||||
<result column="altitude" property="altitude" />
|
||||
<result column="height" property="height" />
|
||||
<result column="horizontal_speed" property="horizontalSpeed" />
|
||||
<result column="vertical_speed" property="verticalSpeed" />
|
||||
<result column="heading" property="heading" />
|
||||
<result column="pitch" property="pitch" />
|
||||
<result column="roll" property="roll" />
|
||||
<result column="flight_mode" property="flightMode" />
|
||||
<result column="battery_percent" property="batteryPercent" />
|
||||
<result column="deviation_distance" property="deviationDistance" />
|
||||
<result column="is_deviation" property="isDeviation" />
|
||||
<result column="record_time" property="recordTime" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据设备SN和查询条件获取轨迹点 -->
|
||||
<select id="selectTrackPoints" resultMap="BaseResultMap">
|
||||
SELECT * FROM drone_flight_track
|
||||
WHERE 1=1
|
||||
<if test="deviceSn != null and deviceSn != ''">
|
||||
AND device_sn = #{deviceSn}
|
||||
</if>
|
||||
<if test="jobId != null and jobId != ''">
|
||||
AND job_id = #{jobId}
|
||||
</if>
|
||||
<if test="routeId != null and routeId != ''">
|
||||
AND route_id = #{routeId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND record_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND record_time <= #{endTime}
|
||||
</if>
|
||||
ORDER BY record_time ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据设备SN获取最新的轨迹点 -->
|
||||
<select id="selectLatestTrackPoint" resultMap="BaseResultMap">
|
||||
SELECT * FROM drone_flight_track
|
||||
WHERE device_sn = #{deviceSn}
|
||||
ORDER BY record_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据设备SN删除指定时间范围的轨迹 -->
|
||||
<delete id="deleteByDeviceSnAndTimeBefore">
|
||||
DELETE FROM drone_flight_track
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND record_time < #{beforeTime}
|
||||
</delete>
|
||||
|
||||
<!-- 统计轨迹点数量 -->
|
||||
<select id="countTrackPoints" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM drone_flight_track
|
||||
WHERE 1=1
|
||||
<if test="deviceSn != null and deviceSn != ''">
|
||||
AND device_sn = #{deviceSn}
|
||||
</if>
|
||||
<if test="jobId != null and jobId != ''">
|
||||
AND job_id = #{jobId}
|
||||
</if>
|
||||
<if test="routeId != null and routeId != ''">
|
||||
AND route_id = #{routeId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND record_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND record_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入轨迹点 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO drone_flight_track (
|
||||
device_sn, job_id, route_id, longitude, latitude, altitude, height,
|
||||
horizontal_speed, vertical_speed, heading, pitch, roll, flight_mode,
|
||||
battery_percent, deviation_distance, is_deviation, record_time,
|
||||
tenant_id, create_time
|
||||
) VALUES
|
||||
<foreach collection="trackPoints" item="item" separator=",">
|
||||
(
|
||||
#{item.deviceSn}, #{item.jobId}, #{item.routeId}, #{item.longitude}, #{item.latitude},
|
||||
#{item.altitude}, #{item.height}, #{item.horizontalSpeed}, #{item.verticalSpeed},
|
||||
#{item.heading}, #{item.pitch}, #{item.roll}, #{item.flightMode}, #{item.batteryPercent},
|
||||
#{item.deviationDistance}, #{item.isDeviation}, #{item.recordTime}, #{item.tenantId}, NOW()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据航线任务ID删除飞行轨迹 -->
|
||||
<delete id="deleteByRouteId">
|
||||
DELETE FROM drone_flight_track
|
||||
WHERE route_id = #{routeId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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.central.device.mapper.WaylineActionMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.device.entity.WaylineAction">
|
||||
<id column="id" property="id" />
|
||||
<result column="waypoint_id" property="waypointId" />
|
||||
<result column="route_id" property="routeId" />
|
||||
<result column="action_group_id" property="actionGroupId" />
|
||||
<result column="action_index" property="actionIndex" />
|
||||
<result column="action_type" property="actionType" />
|
||||
<result column="action_params" property="actionParams" />
|
||||
<result column="trigger_type" property="triggerType" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据航点ID查询动作列表 -->
|
||||
<select id="selectByWaypointId" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_action
|
||||
WHERE waypoint_id = #{waypointId}
|
||||
ORDER BY action_group_id ASC, action_index ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据航线任务ID查询动作列表 -->
|
||||
<select id="selectByRouteId" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_action
|
||||
WHERE route_id = #{routeId}
|
||||
ORDER BY action_group_id ASC, action_index ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据航线任务ID删除动作 -->
|
||||
<delete id="deleteByRouteId">
|
||||
DELETE FROM wayline_action
|
||||
WHERE route_id = #{routeId}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入动作 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO wayline_action (
|
||||
waypoint_id, route_id, action_group_id, action_index,
|
||||
action_type, action_params, trigger_type, tenant_id, create_time
|
||||
) VALUES
|
||||
<foreach collection="actions" item="item" separator=",">
|
||||
(
|
||||
#{item.waypointId}, #{item.routeId}, #{item.actionGroupId}, #{item.actionIndex},
|
||||
#{item.actionType}, #{item.actionParams}, #{item.triggerType}, #{item.tenantId}, NOW()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 统计动作数量 -->
|
||||
<select id="countByRouteId" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM wayline_action
|
||||
WHERE route_id = #{routeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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.central.device.mapper.WaylineRouteMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.device.entity.WaylineRoute">
|
||||
<id column="id" property="id" />
|
||||
<result column="route_id" property="routeId" />
|
||||
<result column="route_name" property="routeName" />
|
||||
<result column="file_wayline_id" property="fileWaylineId" />
|
||||
<result column="device_sn" property="deviceSn" />
|
||||
<result column="device_name" property="deviceName" />
|
||||
<result column="parse_status" property="parseStatus" />
|
||||
<result column="parse_error" property="parseError" />
|
||||
<result column="waypoint_count" property="waypointCount" />
|
||||
<result column="action_count" property="actionCount" />
|
||||
<result column="total_distance" property="totalDistance" />
|
||||
<result column="total_duration" property="totalDuration" />
|
||||
<result column="auto_flight_speed" property="autoFlightSpeed" />
|
||||
<result column="take_off_point" property="takeOffPoint" />
|
||||
<result column="finish_action" property="finishAction" />
|
||||
<result column="exit_on_rc_lost" property="exitOnRcLost" />
|
||||
<result column="global_rth_height" property="globalRthHeight" />
|
||||
<result column="coordinate_mode" property="coordinateMode" />
|
||||
<result column="height_mode" property="heightMode" />
|
||||
<result column="status" property="status" />
|
||||
<result column="remark" property="remark" />
|
||||
<result column="workspace_id" property="workspaceId" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据航迹文件ID查询航线任务列表 -->
|
||||
<select id="selectByFileWaylineId" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_route
|
||||
WHERE file_wayline_id = #{fileWaylineId}
|
||||
AND status = 1
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据设备SN查询绑定的航线任务列表 -->
|
||||
<select id="selectByDeviceSn" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_route
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND status = 1
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据航线任务ID查询 -->
|
||||
<select id="selectByRouteId" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_route
|
||||
WHERE route_id = #{routeId}
|
||||
</select>
|
||||
|
||||
<!-- 更新解析状态 -->
|
||||
<update id="updateParseStatus">
|
||||
UPDATE wayline_route
|
||||
SET parse_status = #{parseStatus},
|
||||
update_time = NOW()
|
||||
WHERE route_id = #{routeId}
|
||||
</update>
|
||||
|
||||
<!-- 更新解析状态和错误信息 -->
|
||||
<update id="updateParseStatusWithError">
|
||||
UPDATE wayline_route
|
||||
SET parse_status = #{parseStatus},
|
||||
parse_error = #{parseError},
|
||||
update_time = NOW()
|
||||
WHERE route_id = #{routeId}
|
||||
</update>
|
||||
|
||||
<!-- 更新航线任务统计信息 -->
|
||||
<update id="updateRouteStats">
|
||||
UPDATE wayline_route
|
||||
SET waypoint_count = #{waypointCount},
|
||||
action_count = #{actionCount},
|
||||
total_distance = #{totalDistance},
|
||||
total_duration = #{totalDuration},
|
||||
auto_flight_speed = #{autoFlightSpeed},
|
||||
update_time = NOW()
|
||||
WHERE route_id = #{routeId}
|
||||
</update>
|
||||
|
||||
<!-- 根据设备SN和航迹文件ID查询航线任务 -->
|
||||
<select id="selectByDeviceSnAndFileWaylineId" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_route
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND file_wayline_id = #{waylineId}
|
||||
AND status = 1
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 删除设备与航迹文件的绑定(级联删除相关数据) -->
|
||||
<delete id="deleteBindingByDeviceAndWayline">
|
||||
DELETE FROM wayline_route
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND file_wayline_id = #{waylineId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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.central.device.mapper.WaylineWaypointMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.device.entity.WaylineWaypoint">
|
||||
<id column="id" property="id" />
|
||||
<result column="route_id" property="routeId" />
|
||||
<result column="waypoint_index" property="waypointIndex" />
|
||||
<result column="longitude" property="longitude" />
|
||||
<result column="latitude" property="latitude" />
|
||||
<result column="height" property="height" />
|
||||
<result column="execute_height" property="executeHeight" />
|
||||
<result column="ellipsoid_height" property="ellipsoidHeight" />
|
||||
<result column="speed" property="speed" />
|
||||
<result column="heading_mode" property="headingMode" />
|
||||
<result column="heading_angle" property="headingAngle" />
|
||||
<result column="gimbal_pitch_angle" property="gimbalPitchAngle" />
|
||||
<result column="turn_mode" property="turnMode" />
|
||||
<result column="turn_damping_dist" property="turnDampingDist" />
|
||||
<result column="use_straight_line" property="useStraightLine" />
|
||||
<result column="is_risky" property="isRisky" />
|
||||
<result column="action_group_count" property="actionGroupCount" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据航线任务ID查询航点列表(按序号排序) -->
|
||||
<select id="selectByRouteIdOrderByIndex" resultMap="BaseResultMap">
|
||||
SELECT * FROM wayline_waypoint
|
||||
WHERE route_id = #{routeId}
|
||||
ORDER BY waypoint_index ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据航线任务ID删除航点 -->
|
||||
<delete id="deleteByRouteId">
|
||||
DELETE FROM wayline_waypoint
|
||||
WHERE route_id = #{routeId}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入航点 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO wayline_waypoint (
|
||||
route_id, waypoint_index, longitude, latitude, height,
|
||||
execute_height, ellipsoid_height, speed, heading_mode,
|
||||
heading_angle, gimbal_pitch_angle, turn_mode, turn_damping_dist,
|
||||
use_straight_line, is_risky, action_group_count, tenant_id, create_time
|
||||
) VALUES
|
||||
<foreach collection="waypoints" item="item" separator=",">
|
||||
(
|
||||
#{item.routeId}, #{item.waypointIndex}, #{item.longitude}, #{item.latitude}, #{item.height},
|
||||
#{item.executeHeight}, #{item.ellipsoidHeight}, #{item.speed}, #{item.headingMode},
|
||||
#{item.headingAngle}, #{item.gimbalPitchAngle}, #{item.turnMode}, #{item.turnDampingDist},
|
||||
#{item.useStraightLine}, #{item.isRisky}, #{item.actionGroupCount}, #{item.tenantId}, NOW()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 统计航点数量 -->
|
||||
<select id="countByRouteId" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM wayline_waypoint
|
||||
WHERE route_id = #{routeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,161 @@
|
||||
-- 大疆航线管理系统数据库表结构
|
||||
-- 创建时间: 2025-12-17
|
||||
-- 说明: 用于无人机航线管理与轨迹显示功能
|
||||
|
||||
-- 1. 航线任务表 (wayline_route)
|
||||
-- 存储航线任务信息,关联航迹文件和设备
|
||||
CREATE TABLE `wayline_route` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`route_id` VARCHAR(64) NOT NULL COMMENT '航线任务ID(UUID)',
|
||||
`route_name` VARCHAR(100) NOT NULL COMMENT '航线任务名称',
|
||||
`file_wayline_id` VARCHAR(64) NOT NULL COMMENT '关联航迹文件ID(wayline_file.wayline_id)',
|
||||
`device_sn` VARCHAR(64) DEFAULT NULL COMMENT '绑定设备SN',
|
||||
`device_name` VARCHAR(100) DEFAULT NULL COMMENT '设备名称(冗余)',
|
||||
`parse_status` TINYINT DEFAULT 0 COMMENT '解析状态:0-未解析,1-解析中,2-已解析,3-解析失败',
|
||||
`parse_error` VARCHAR(500) DEFAULT NULL COMMENT '解析错误信息',
|
||||
`waypoint_count` INT DEFAULT 0 COMMENT '航点数量',
|
||||
`action_count` INT DEFAULT 0 COMMENT '动作总数',
|
||||
`total_distance` DECIMAL(10,2) DEFAULT NULL COMMENT '总航程(m)',
|
||||
`total_duration` DECIMAL(10,2) DEFAULT NULL COMMENT '预计时长(s)',
|
||||
`auto_flight_speed` DECIMAL(6,2) DEFAULT NULL COMMENT '自动飞行速度(m/s)',
|
||||
`take_off_point` VARCHAR(100) DEFAULT NULL COMMENT '起飞点坐标(经度,纬度,高度)',
|
||||
`finish_action` VARCHAR(50) DEFAULT NULL COMMENT '完成动作:goHome/hover/landing',
|
||||
`exit_on_rc_lost` VARCHAR(50) DEFAULT NULL COMMENT '遥控器失联动作',
|
||||
`global_rth_height` DECIMAL(6,2) DEFAULT NULL COMMENT '全局返航高度(m)',
|
||||
`coordinate_mode` VARCHAR(20) DEFAULT 'WGS84' COMMENT '坐标系',
|
||||
`height_mode` VARCHAR(50) DEFAULT 'relativeToStartPoint' COMMENT '高度模式',
|
||||
`status` TINYINT DEFAULT 1 COMMENT '状态:0-禁用,1-启用',
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
`workspace_id` VARCHAR(64) DEFAULT NULL COMMENT '工作空间ID',
|
||||
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||
`create_by` VARCHAR(64) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` VARCHAR(64) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_route_id` (`route_id`),
|
||||
KEY `idx_file_wayline_id` (`file_wayline_id`),
|
||||
KEY `idx_device_sn` (`device_sn`),
|
||||
KEY `idx_parse_status` (`parse_status`),
|
||||
KEY `idx_tenant_id` (`tenant_id`),
|
||||
KEY `idx_workspace_id` (`workspace_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='航线任务表';
|
||||
|
||||
-- 2. 航点表 (wayline_waypoint)
|
||||
-- 存储解析后的航点数据
|
||||
CREATE TABLE `wayline_waypoint` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`route_id` VARCHAR(64) NOT NULL COMMENT '航线任务ID(关联wayline_route.route_id)',
|
||||
`waypoint_index` INT NOT NULL COMMENT '航点序号(从0开始)',
|
||||
`longitude` DECIMAL(12,9) NOT NULL COMMENT '经度',
|
||||
`latitude` DECIMAL(12,9) NOT NULL COMMENT '纬度',
|
||||
`height` DECIMAL(10,3) DEFAULT NULL COMMENT '相对高度(m)-相对起飞点',
|
||||
`execute_height` DECIMAL(10,3) DEFAULT NULL COMMENT '执行高度(m)',
|
||||
`ellipsoid_height` DECIMAL(10,3) DEFAULT NULL COMMENT '椭球高度(m)',
|
||||
`speed` DECIMAL(6,2) DEFAULT NULL COMMENT '飞行速度(m/s)',
|
||||
`heading_mode` VARCHAR(50) DEFAULT NULL COMMENT '航向模式',
|
||||
`heading_angle` DECIMAL(6,2) DEFAULT NULL COMMENT '航向角(度)',
|
||||
`gimbal_pitch_angle` DECIMAL(6,2) DEFAULT NULL COMMENT '云台俯仰角(度)',
|
||||
`turn_mode` VARCHAR(64) DEFAULT NULL COMMENT '转弯模式',
|
||||
`turn_damping_dist` DECIMAL(6,2) DEFAULT NULL COMMENT '转弯阻尼距离(m)',
|
||||
`use_straight_line` TINYINT DEFAULT 1 COMMENT '是否直线飞行:0-否,1-是',
|
||||
`is_risky` TINYINT DEFAULT 0 COMMENT '是否风险点:0-否,1-是',
|
||||
`action_group_count` INT DEFAULT 0 COMMENT '动作组数量',
|
||||
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_route_id` (`route_id`),
|
||||
KEY `idx_waypoint_index` (`route_id`, `waypoint_index`),
|
||||
KEY `idx_tenant_id` (`tenant_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='航线航点表';
|
||||
|
||||
-- 3. 航点动作表 (wayline_action)
|
||||
-- 存储航点的动作数据
|
||||
CREATE TABLE `wayline_action` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`waypoint_id` BIGINT NOT NULL COMMENT '航点ID(关联wayline_waypoint.id)',
|
||||
`route_id` VARCHAR(64) NOT NULL COMMENT '航线任务ID(冗余字段,便于查询)',
|
||||
`action_group_id` INT NOT NULL COMMENT '动作组ID',
|
||||
`action_index` INT NOT NULL COMMENT '动作序号(组内)',
|
||||
`action_type` VARCHAR(64) NOT NULL COMMENT '动作类型',
|
||||
`action_params` JSON DEFAULT NULL COMMENT '动作参数(JSON格式)',
|
||||
`trigger_type` VARCHAR(50) DEFAULT 'reachPoint' COMMENT '触发类型:reachPoint-到达航点,betweenAdjacentPoints-航点间',
|
||||
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_waypoint_id` (`waypoint_id`),
|
||||
KEY `idx_route_id` (`route_id`),
|
||||
KEY `idx_action_type` (`action_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='航点动作表';
|
||||
|
||||
-- 4. 飞行轨迹表 (drone_flight_track)
|
||||
-- 存储实时飞行轨迹数据
|
||||
CREATE TABLE `drone_flight_track` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`device_sn` VARCHAR(64) NOT NULL COMMENT '设备SN',
|
||||
`job_id` VARCHAR(64) DEFAULT NULL COMMENT '任务ID(关联wayline_job.job_id)',
|
||||
`route_id` VARCHAR(64) DEFAULT NULL COMMENT '航线任务ID(关联wayline_route.route_id)',
|
||||
`longitude` DECIMAL(12,9) NOT NULL COMMENT '经度',
|
||||
`latitude` DECIMAL(12,9) NOT NULL COMMENT '纬度',
|
||||
`altitude` DECIMAL(10,3) DEFAULT NULL COMMENT '海拔高度(m)',
|
||||
`height` DECIMAL(10,3) DEFAULT NULL COMMENT '相对高度(m)',
|
||||
`horizontal_speed` DECIMAL(6,2) DEFAULT NULL COMMENT '水平速度(m/s)',
|
||||
`vertical_speed` DECIMAL(6,2) DEFAULT NULL COMMENT '垂直速度(m/s)',
|
||||
`heading` DECIMAL(6,2) DEFAULT NULL COMMENT '航向角(度)',
|
||||
`pitch` DECIMAL(6,2) DEFAULT NULL COMMENT '俯仰角(度)',
|
||||
`roll` DECIMAL(6,2) DEFAULT NULL COMMENT '横滚角(度)',
|
||||
`flight_mode` INT DEFAULT NULL COMMENT '飞行模式',
|
||||
`battery_percent` INT DEFAULT NULL COMMENT '电池电量(%)',
|
||||
`deviation_distance` DECIMAL(10,3) DEFAULT NULL COMMENT '偏离距离(m)-与计划航线的偏离',
|
||||
`is_deviation` TINYINT DEFAULT 0 COMMENT '是否偏离:0-否,1-是',
|
||||
`record_time` DATETIME NOT NULL COMMENT '记录时间(无人机上报时间)',
|
||||
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_device_sn` (`device_sn`),
|
||||
KEY `idx_job_id` (`job_id`),
|
||||
KEY `idx_route_id` (`route_id`),
|
||||
KEY `idx_device_job` (`device_sn`, `job_id`),
|
||||
KEY `idx_record_time` (`record_time`),
|
||||
KEY `idx_tenant_id` (`tenant_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='无人机飞行轨迹表';
|
||||
|
||||
-- 添加外键约束(可选,根据实际需要决定是否添加)
|
||||
-- ALTER TABLE `wayline_route` ADD CONSTRAINT `fk_route_file_wayline` FOREIGN KEY (`file_wayline_id`) REFERENCES `wayline_file` (`wayline_id`);
|
||||
-- ALTER TABLE `wayline_waypoint` ADD CONSTRAINT `fk_waypoint_route` FOREIGN KEY (`route_id`) REFERENCES `wayline_route` (`route_id`);
|
||||
-- ALTER TABLE `wayline_action` ADD CONSTRAINT `fk_action_waypoint` FOREIGN KEY (`waypoint_id`) REFERENCES `wayline_waypoint` (`id`);
|
||||
|
||||
-- 插入示例数据
|
||||
INSERT INTO `wayline_route` (
|
||||
`route_id`, `route_name`, `file_wayline_id`, `device_sn`, `device_name`,
|
||||
`parse_status`, `waypoint_count`, `total_distance`, `total_duration`
|
||||
) VALUES (
|
||||
UUID(),
|
||||
'平安寨巡检航线-无人机A',
|
||||
'10df53e4b9114a87904fb010bc46922b',
|
||||
'1ZNBJ1D00C00GH',
|
||||
'巡检无人机A',
|
||||
2,
|
||||
8,
|
||||
52.79,
|
||||
114.7
|
||||
);
|
||||
|
||||
-- 插入示例航点数据
|
||||
INSERT INTO `wayline_waypoint` (
|
||||
`route_id`, `waypoint_index`, `longitude`, `latitude`, `height`,
|
||||
`speed`, `heading_angle`, `gimbal_pitch_angle`
|
||||
) VALUES
|
||||
('uuid-here', 0, 110.124939717, 25.760780235, 6.117, 0.3, -108.6, -36.73),
|
||||
('uuid-here', 1, 110.124939768, 25.760780392, 2.9, 0.3, -108.6, -36.73),
|
||||
('uuid-here', 2, 110.124939651, 25.760780383, 5.51, 0.3, -108.6, -36.73);
|
||||
|
||||
-- 插入示例动作数据
|
||||
INSERT INTO `wayline_action` (
|
||||
`waypoint_id`, `route_id`, `action_group_id`, `action_index`,
|
||||
`action_type`, `action_params`
|
||||
) VALUES
|
||||
(1, 'uuid-here', 0, 0, 'rotateYaw', '{"heading": -108.354}'),
|
||||
(1, 'uuid-here', 1, 0, 'takePhoto', '{}'),
|
||||
(2, 'uuid-here', 0, 0, 'takePhoto', '{}');
|
||||
Reference in New Issue
Block a user