-- 为任务操作日志表添加GPS和位置信息字段
-- ----------------------------

USE ruoyi-vue;

-- 添加GPS和位置信息相关字段
ALTER TABLE sys_task_log 
ADD COLUMN latitude DECIMAL(10, 6) COMMENT '纬度' AFTER ip_address,
ADD COLUMN longitude DECIMAL(10, 6) COMMENT '经度' AFTER latitude,
ADD COLUMN location_address VARCHAR(500) COMMENT '位置地址' AFTER longitude,
ADD COLUMN location_province VARCHAR(50) COMMENT '省份' AFTER location_address,
ADD COLUMN location_city VARCHAR(50) COMMENT '城市' AFTER location_province,
ADD COLUMN location_district VARCHAR(50) COMMENT '区县' AFTER location_city,
ADD COLUMN gps_accuracy DECIMAL(10, 2) COMMENT 'GPS精度（米）' AFTER location_district,
ADD COLUMN altitude DECIMAL(10, 2) COMMENT '海拔高度（米）' AFTER gps_accuracy,
ADD COLUMN speed DECIMAL(10, 2) COMMENT '速度（米/秒）' AFTER altitude,
ADD COLUMN heading DECIMAL(10, 2) COMMENT '方向角度（0-360）' AFTER speed;

-- 添加索引
ALTER TABLE sys_task_log 
ADD INDEX idx_location (latitude, longitude),
ADD INDEX idx_operation_time_location (operation_time, latitude, longitude);

-- 添加注释
ALTER TABLE sys_task_log COMMENT='任务操作日志表（含GPS定位信息）';
