CREATE DATABASE clbs UPDATE 2;   
--位置表 
CREATE STABLE clbs.gps  ( ts timestamp,  monitor_name NCHAR(20), status BIGINT, alarm BIGINT, lat DOUBLE, lon DOUBLE, alt DOUBLE, dir DOUBLE, speed DOUBLE, mileage DOUBLE, address NCHAR(100), invalid INT, metrics NCHAR(4000), metrics_values NCHAR(4000), group_name NCHAR(200), org_id NCHAR(40), vehicle_type NCHAR(20), original_lon DOUBLE, original_lat DOUBLE, location_status INT, org_name NCHAR(32), professionals_name NCHAR(100), device_number NCHAR(30), sim_card NCHAR(30), recorder_speed DOUBLE, temp NCHAR(20), fuel_type NCHAR(20), air_condition_status NCHAR(10), upload_time BIGINT, battery_electricity INT, battery_voltage INT, signal_strength INT, terminal_version NCHAR(20), location_type INT, air_comp_status INT, protocol_type NCHAR(20), user_code NCHAR(32), alarm_sign INT, wifi_info NCHAR(1000), station_info NCHAR(1000), monitor_type INT, plate_color NCHAR(10), scheduled_status NCHAR(10), work_status NCHAR(10), reissue INT, city NCHAR(20), province NCHAR(20) )  TAGS (monitor_id NCHAR(40)); 
--风险表 
CREATE STABLE clbs.risk (  warning_time timestamp,  id NCHAR(40),  number NCHAR(30),  brand NCHAR(20),  plate_color INT,  level INT,  type NCHAR(50),  status INT,  coordinate NCHAR(30),  address NCHAR(100),  speed DOUBLE,  deal_id NCHAR(40),  driver_id NCHAR(40),  job NCHAR(10),  file_time BIGINT,  deal_time BIGINT,  result INT,  visit1 NCHAR(50),  visit2 NCHAR(50),  visit3 NCHAR(50),  visit4 NCHAR(50),  last_visit_time BIGINT,  driver_names NCHAR(20),  create_time BIGINT,  create_user NCHAR(20),  update_time BIGINT,  update_user NCHAR(20),  visit_times INT,  media_name NCHAR(30),  media_url NCHAR(100),  device_number NCHAR(32),  video_flag INT,  pic_flag INT,  weather NCHAR(20),  oversee_status INT,  transportation INT,  certification_code NCHAR(50),  deal_dead_time BIGINT,  accuracy INT,  driver_status INT,  intervention INT,  cooperation INT,  warn_status INT,  other NCHAR(50),  handle_type NCHAR(20),  is_remind_driver NCHAR(10),  business_scope NCHAR(30),  deal_people_id NCHAR(40),  deal_org_id NCHAR(40),  deal_org_name NCHAR(32) ) TAGS (monitor_id NCHAR(40)); 
--风险事件表
CREATE STABLE clbs.risk_event ( warn_time timestamp, id NCHAR(40), number NCHAR(30), event_id NCHAR(40), brand NCHAR(20), time BIGINT, risk_id NCHAR(40), risk_number NCHAR(30), media_id NCHAR(40), media_name NCHAR(30), media_url NCHAR(100), warn_id INT, sensor_id INT, status INT, type INT, level INT, sign_type INT, sign_data INT, fatigue_level INT, speed_limit INT, front_speed DOUBLE, front_distance DOUBLE, deviation INT, speed DOUBLE, altitude DOUBLE, latitude DOUBLE, longitude DOUBLE, vehicle_status INT, keeps INT, media_total INT, create_time BIGINT, create_user NCHAR(20), visit_times INT, result INT, risk_type NCHAR(50), driver_id NCHAR(40), dealer NCHAR(40), driver_name NCHAR(20), risk_level INT, address NCHAR(100), risk_speed DOUBLE, job NCHAR(30), deal_status INT, risk_time BIGINT, deal_time BIGINT, file_time BIGINT, video_flag INT, pic_flag INT, weather NCHAR(20), oversee_status INT, transportation INT, multimedia_number INT, sequence_number INT, attachment_status INT, media_info NCHAR(500), plateform_id NCHAR(40), msg_sn NCHAR(30), original_longitude DOUBLE, original_latitude DOUBLE, driver_no NCHAR(30), direction DOUBLE, grapher_speed DOUBLE, info_content NCHAR(30), handle_type NCHAR(20), remark NCHAR(20), plate_color INT, road_type INT, road_limit_speed DOUBLE, alarm_id NCHAR(40), drv_line_id INT, protocol_type INT, is_remind_driver INT, limit_speed INT, actual_load INT, limited_load INT ) TAGS (monitor_id NCHAR(40)); 
--风险附件表
CREATE STABLE clbs.risk_media ( upload_time timestamp, id NCHAR(40),  media_id BIGINT, risk_id NCHAR(40), risk_event_id NCHAR(40), risk_number NCHAR(30), event_number NCHAR(30), visit_id NCHAR(50), type INT, name NCHAR(50), url NCHAR(100), format_code INT, event_code INT, channel_id INT, brand NCHAR(30), source INT, event_id INT, address NCHAR(100), risk_type NCHAR(50), create_time BIGINT, create_user NCHAR(20), protocol_type INT, dealer NCHAR(40), result INT, risk_level INT, deal_status INT, driver_name NCHAR(20), file_size BIGINT, risk_time timestamp ) TAGS (monitor_id NCHAR(40));
