create database if not exists uav_cloud_live DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
use uav_cloud_live;
delete from live_plugin_config where 1=1;

insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('1','personAi','人群计数','{\"plugin_args\":1}',b'1',b'1','2022-07-12 16:36:24','2024-06-24 14:00:01','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('2','vehicleAi','车流量识别','{\"plugin_args\":2}',b'1',b'1','2022-07-19 14:44:23','2024-06-24 14:23:10','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('3','personVehicleAi','人车识别','{\"plugin_args\":3}',b'1',b'1','2022-07-19 17:24:44','2024-06-24 14:23:14','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('4','vehicleTrackAi','车辆跟踪识别','{\"plugin_args\":4}',b'1',b'1','2022-09-20 14:15:49','2024-06-24 15:03:01','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('5','plateAi','车牌识别','{\"plugin_args\":8}',b'1',b'1','2022-07-12 16:11:42','2024-06-24 15:03:10','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('6','fireAi','火情识别','{\"plugin_args\":16}',b'1',b'1','2022-07-11 16:53:35','2024-06-24 15:03:18','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('7','smokeAi','烟雾识别','{\"plugin_args\":32}',b'0',b'0','2022-09-20 14:15:55','2022-09-20 14:28:38','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('8','file2rtmp','文件推流','{\"fileUrl\":\"请替换为文件下载地址\"}',b'0',b'0','2022-07-19 17:25:30','2022-09-20 14:20:44','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('9','gdr_server','GDR服务','{}',b'0',b'0','2022-07-19 14:47:18','2022-09-20 14:20:59','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('10','gdr_transcode','GDR转码','{}',b'0',b'0','2022-07-12 16:37:18','2022-09-20 14:28:38','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('11','createLive','创建视频流','{}',b'0',b'0','2022-07-25 14:13:38','2022-09-20 14:21:04','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('12','createTempLive','创建临时视频流','{}',b'0',b'0','2022-07-25 14:13:56','2022-09-20 14:21:06','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('13','safetyHatAi','安全帽识别','{\"plugin_args\":64}',b'0',b'0','2022-12-05 17:29:09','2022-12-05 17:40:10','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('14','excavatorAi','挖掘机识别','{\"plugin_args\":128}',b'0',b'0','2022-12-05 17:30:16','2022-12-05 17:40:10','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('15','highwayObstacleDetection','公路障碍物检测','{\"plugin_args\":172}',b'0',b'0','2024-06-24 14:25:00','2024-06-24 14:43:25','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('16','highwayPersonDetection','公路行人检测\n','{\"plugin_args\":173}',b'0',b'0','2024-06-24 14:26:24','2024-06-24 14:43:25','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('17','highwayManyVehicleDetection','公路密集车辆检测','{\"plugin_args\":174}',b'0',b'0','2024-06-24 14:27:31','2024-06-24 14:43:25','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('18','peopleCrowdDetection','密集人群检测\n','{\"plugin_args\":175}',b'0',b'0','2024-06-24 13:59:45','2024-06-24 14:43:25','1','1');
insert into `live_plugin_config` (`id`, `plugin_name`, `plugin_description`, `query_param`, `is_del`, `is_frozen`, `create_at`, `update_at`, `create_by`, `update_by`) values('20','ai_recognition','AI通用识别','{\"plugin_args\":\"112\",\"desc\":\"plugin_args取值由识别目标确定，如:112:红外人体识别,113:海上救援人员识别,114:周界入侵,122:空中目标检测\"}',b'0',b'0','2024-06-24 15:01:01','2024-06-24 15:09:21',NULL,NULL);

alter table `uav_cloud_live`.`video_merge_task` add column `task_source` varchar (16)  NULL  COMMENT '合成任务来源:ob:作业回传影像；flight:飞行记录; playback:数据回放&视频回放；other:其他' after `device_code`;
alter table `uav_cloud_live`.`video_merge_task` add index `idx_video_start_time` (`video_start_time`);
alter table `uav_cloud_live`.`video_segment` add column `file_size` bigint (20)  NULL  COMMENT '视频片段文件时长(B)' after `video_time`;
CREATE TABLE `video_merge_task_result` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `task_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '任务编号',
  `file_index` int DEFAULT NULL COMMENT '文件顺序号1，2，3',
  `file_name` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '存储文件名',
  `file_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '文件id',
  `file_size` bigint DEFAULT NULL COMMENT '文件大小（B）',
  `file_start_time` datetime DEFAULT NULL COMMENT '文件实际开始时间',
  `file_end_time` datetime DEFAULT NULL COMMENT '文件实际结束时间',
  `update_at` datetime DEFAULT NULL COMMENT '修改时间',
  `create_at` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_task_file` (`task_code`,`file_index`),
  KEY `idx_file_id` (`file_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin comment='视频文件明细表';
alter table `uav_cloud_live`.`stream_config` drop key `uniq_device_name`;
alter table `uav_cloud_live`.`stream_config` add index `idx_tenant_deviceName` (`tenant_id`, `device_name`);
update uav_cloud_live.stream_config t1 , uav_dev.uav_load_cam t2 set t1.device_name = t2.load_name where t1.device_code = t2.load_code and t2.load_type='LOAD_CAM_MODEL' and t2.load_name is not null ;  