/*
SQLyog Ultimate v13.1.1 (64 bit)
MySQL - 8.0.34 : Database - uav_iot_dispatcher
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`uav_iot_dispatcher` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `uav_iot_dispatcher`;

/*Table structure for table `cmii_uav_perception_position_node` */

DROP TABLE IF EXISTS `cmii_uav_perception_position_node`;

CREATE TABLE `cmii_uav_perception_position_node` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'cmii_uav_perception_task的主键id',
  `latitude` double NOT NULL COMMENT '纬度',
  `longitude` double NOT NULL COMMENT '经度',
  `altitude` float NOT NULL COMMENT '海拔',
  `height` float NOT NULL COMMENT '相对地面高度',
  `speed_x` float NOT NULL COMMENT 'x轴方向速度，北',
  `speed_y` float NOT NULL COMMENT 'y轴方向速度，东',
  `speed_z` float NOT NULL COMMENT 'z轴方向速度，地',
  `distance` float DEFAULT NULL COMMENT '传感源到目标距离',
  `timestamp` datetime(6) NOT NULL COMMENT '该条记录创建的时间戳，精确到毫秒',
  `data_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '感知数据的id',
  `radar_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '仅针对5G-A感知，作为感知源设备的id，即雷达自己的id',
  `device_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '摄像头跟踪的设备id，即摄像头自己的id',
  `company_id` int NOT NULL COMMENT '公司ID，用于数据隔离',
  PRIMARY KEY (`id`),
  KEY `ix_cmii_uav_perception_position_node_data_id` (`data_id`),
  KEY `ix_cmii_uav_perception_position_node_task_id` (`task_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;

/*Table structure for table `cmii_uav_perception_task` */

DROP TABLE IF EXISTS `cmii_uav_perception_task`;

CREATE TABLE `cmii_uav_perception_task` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `project_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '项目编号',
  `group_id` varchar(96) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '该组（探测任务）的编号，非唯一的，可以重复',
  `origin_topic` varchar(96) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '原始引导源',
  `shared_topic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '共享引导源',
  `publish_topic` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'IoT设备通知主题',
  `lifecycle_is_started` tinyint(1) NOT NULL COMMENT '任务是否开始',
  `lifecycle_is_completed` tinyint(1) NOT NULL COMMENT '任务是否完成',
  `lifecycle_created_time` datetime(6) NOT NULL COMMENT '任务创建时间',
  `lifecycle_completed_time` datetime(6) DEFAULT NULL COMMENT '任务结束时间',
  `lifecycle_max_lifetime` int NOT NULL COMMENT '任务最大存活时间(单位秒)',
  `device_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '当前摄像头跟踪的设备id，即摄像头自己的id',
  `company_id` int NOT NULL COMMENT '公司ID，用于数据隔离',
  PRIMARY KEY (`id`),
  KEY `ix_cmii_uav_perception_task_group_id` (`group_id`),
  KEY `ix_cmii_uav_perception_task_lifecycle_is_completed` (`lifecycle_is_completed`),
  KEY `ix_cmii_uav_perception_task_lifecycle_is_started` (`lifecycle_is_started`),
  KEY `ix_cmii_uav_perception_task_project_id` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;

/*Table structure for table `cmii_uav_servo_device` */

DROP TABLE IF EXISTS `cmii_uav_servo_device`;

CREATE TABLE `cmii_uav_servo_device` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '主键id',
  `camera_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头的名字',
  `camera_device_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头的设备id',
  `camera_project_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头的项目所属id',
  `camera_ip` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头的ip',
  `camera_port` int NOT NULL COMMENT '摄像头的port',
  `camera_rtsp_port` int NOT NULL COMMENT '摄像头rtsp推流端口',
  `onvif_user` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'onvif连接摄像头的用户名',
  `onvif_passwd` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'onvif连接摄像头的密码',
  `camera_pan_range_min` float NOT NULL COMMENT '摄像头的水平最小度数',
  `camera_pan_range_max` float NOT NULL COMMENT '摄像头的水平最大度数',
  `camera_tilt_range_min` float NOT NULL COMMENT '摄像头的垂直最小度数',
  `camera_tilt_range_max` float NOT NULL COMMENT '摄像头的垂直最大度数',
  `camera_pan_speed_min` float NOT NULL COMMENT '摄像头的水平最小速度',
  `camera_pan_speed_max` float NOT NULL COMMENT '摄像头的水平最大速度',
  `camera_tilt_speed_min` float NOT NULL COMMENT '摄像头的垂直最小速度',
  `camera_tilt_speed_max` float NOT NULL COMMENT '摄像头的垂直最大速度',
  `camera_zoom_range_min` float NOT NULL COMMENT '摄像头的变焦最小倍数',
  `camera_zoom_range_max` float NOT NULL COMMENT '摄像头的变焦最大倍数',
  `dist_min` float NOT NULL COMMENT '摄像头观测目标的最小距离',
  `dist_max` float NOT NULL COMMENT '摄像头观测目标的最大距离',
  `dist_min_zoom_index` float NOT NULL COMMENT '摄像头的最小变焦步长',
  `dist_max_zoom_index` float NOT NULL COMMENT '摄像头的最大变焦步长',
  `zoom_coeff` float NOT NULL COMMENT '摄像头的变焦系数',
  `camera_latitude` double DEFAULT NULL COMMENT '摄像头所在的纬度',
  `camera_longitude` double DEFAULT NULL COMMENT '摄像头所在的经度',
  `camera_altitude` float DEFAULT NULL COMMENT '摄像头所在的海拔',
  `camera_height` float DEFAULT NULL COMMENT '摄像头所在的高度（相对地面高度）',
  `camera_delay` float NOT NULL COMMENT '摄像头延迟',
  `camera_zoom_method` float NOT NULL COMMENT '触发变焦的方式，默认为1',
  `camera_pan_trime` float NOT NULL COMMENT '摄像头的水平偏差度',
  `camera_tilt_trime` float NOT NULL COMMENT '摄像头的垂直偏差度',
  `camera_reverse` float NOT NULL COMMENT '摄像头是否反转，默认不反转',
  `camera_hfov` float NOT NULL COMMENT '摄像头的水平视场角',
  `camera_vfov` float NOT NULL COMMENT '摄像头的垂直视场角',
  `camera_focal_len_min` float NOT NULL COMMENT '摄像头最小焦距',
  `camera_focal_len_max` float NOT NULL COMMENT '摄像头最大焦距',
  `mqtt_username` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头连接mqtt的账号名',
  `mqtt_password` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头连接mqtt的密码',
  `mqtt_host` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头连接mqtt的地址',
  `mqtt_port` int NOT NULL COMMENT '摄像头连接mqtt的端口',
  `mqtt_keep_alive_interval` int NOT NULL COMMENT '会话心跳时间,单位为秒',
  `mqtt_qos` int NOT NULL COMMENT '服务质量,0代表“至多一次”',
  `dispatcher_topic` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '下发到边端设备的topic',
  `reporting_topic` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '边端设备上传回来的topic',
  `auto_cam_connect` tinyint(1) NOT NULL COMMENT '任务是否开始',
  `auto_push_stream` tinyint(1) NOT NULL COMMENT '任务是否开始',
  `media_push_stream` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '摄像头的推流地址',
  `media_pull_stream` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '前端的拉流地址',
  `media_ai_pull_stream` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '前端的AI流拉流地址',
  `created_at` datetime(6) DEFAULT NULL COMMENT '记录创建时间',
  `updated_at` datetime(6) DEFAULT NULL COMMENT '记录更新时间',
  `company_id` int NOT NULL COMMENT '公司ID，用于数据隔离',
  `user_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户ID，用于数据隔离',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ix_cmii_uav_servo_device_camera_device_id` (`camera_device_id`),
  KEY `ix_cmii_uav_servo_device_media_ai_pull_stream` (`media_ai_pull_stream`),
  KEY `ix_cmii_uav_servo_device_media_pull_stream` (`media_pull_stream`),
  KEY `ix_cmii_uav_servo_device_media_push_stream` (`media_push_stream`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
