hpds_jkw_web/db_init.sql

138 lines
18 KiB
SQL

-- 创建人工智能诊断平台数据库
create database IF NOT EXISTS diagnostic_platform default character set utf8mb4 collate utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS brand (brand_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, brand_name VARCHAR(200) NOT NULL, brand_logo VARCHAR(200) NULL, brand_web VARCHAR(200) NULL, status INT(11) DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL, delete_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS dataset (dataset_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, dataset_name VARCHAR(200) NOT NULL, dataset_desc VARCHAR(200) NULL, category_id SMALLINT DEFAULT 1 NOT NULL, project_id INT(11) DEFAULT 0 NOT NULL, owner_id INT(11) DEFAULT 0 NOT NULL, creator INT(11) DEFAULT 0 NOT NULL, status SMALLINT DEFAULT 1 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE INDEX IDX_dataset_project_id ON dataset (project_id);
CREATE INDEX IDX_dataset_owner_id ON dataset (owner_id) ;
CREATE INDEX IDX_dataset_creator ON dataset (creator) ;
CREATE TABLE IF NOT EXISTS dataset_detail (detail_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, dataset_id INT(11) DEFAULT 0 NOT NULL, access_url VARCHAR(200) NULL, file_size BIGINT(20) NULL, file_md5 VARCHAR(64) NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE INDEX IDX_dataset_detail_dataset_id ON dataset_detail (dataset_id) ;
CREATE TABLE IF NOT EXISTS detection_task (task_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, task_code VARCHAR(64) NOT NULL, task_name VARCHAR(200) NOT NULL, parent_task_id INT(11) DEFAULT 0 NOT NULL, task_status INT(11) DEFAULT 0 NOT NULL, initiator_user_id INT(11) DEFAULT 0 NOT NULL, initiator_time BIGINT(20) NULL, completion_time DATETIME NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS device (device_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, device_name VARCHAR(64) NOT NULL, device_brand_id INT(11) DEFAULT 0 NOT NULL, device_imei VARCHAR(64) NOT NULL, device_sn VARCHAR(64) NOT NULL, device_type_id INT(11) DEFAULT 0 NOT NULL, butt_matter_id INT(11) DEFAULT 0 NOT NULL, butt_type INT(11) DEFAULT 0 NOT NULL, butt_address VARCHAR(200) NOT NULL, butt_port INT(11) DEFAULT 0 NOT NULL, longitude DECIMAL(18,6) NULL, latitude DECIMAL(18,6) NULL, device_desc VARCHAR(200) NULL, status INT(11) DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL, delete_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS device_type (type_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, type_name VARCHAR(200) NOT NULL, type_desc TEXT NULL, biz_type VARCHAR(200) NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL, delete_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS disease (disease_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, disease_name VARCHAR(200) NOT NULL, disease_type INT(11) DEFAULT 0 NOT NULL, category_id SMALLINT DEFAULT 1 NOT NULL, disease_level VARCHAR(20) NOT NULL, detection_method VARCHAR(200) NOT NULL, disease_desc TEXT NULL, reference VARCHAR(200) NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS disease_type (type_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, type_name VARCHAR(200) NOT NULL, category_id SMALLINT DEFAULT 1 NOT NULL, status INT(11) DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS file_manager (file_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, file_name VARCHAR(200) NULL, access_url VARCHAR(400) NULL, scene VARCHAR(40) NULL, file_size BIGINT(20) NULL, file_md5 VARCHAR(64) NULL, creator INT(11) NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE INDEX IDX_file_manager_creator ON file_manager (creator) ;
CREATE TABLE IF NOT EXISTS matter_attribute (attribute_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) NOT NULL, version_id INT(11) DEFAULT 0 NOT NULL, attribute_name VARCHAR(200) NOT NULL, attribute_key VARCHAR(200) NOT NULL, attribute_desc VARCHAR(200) NOT NULL, data_type INT(11) DEFAULT 0 NOT NULL, max_value VARCHAR(200) NULL, min_value VARCHAR(200) NULL, step_value VARCHAR(200) NULL, unit VARCHAR(200) NULL, is_only_read SMALLINT DEFAULT 0 NOT NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE INDEX IDX_matter_attribute_matter_id ON matter_attribute (matter_id);
CREATE TABLE IF NOT EXISTS matter_category (category_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, category_name VARCHAR(40) NOT NULL, category_desc VARCHAR(200) NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS matter_event (event_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) NOT NULL, version_id INT(11) NOT NULL, event_identifier VARCHAR(64) NOT NULL, event_type VARCHAR(200) NOT NULL, event_desc VARCHAR(200) NOT NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE INDEX IDX_matter_event_matter_id ON matter_event (matter_id);
CREATE TABLE IF NOT EXISTS matter_event_params (params_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) DEFAULT 0 NOT NULL, version_id INT(11) DEFAULT 0 NOT NULL, event_id INT(11) DEFAULT 0 NOT NULL, param_name VARCHAR(200) NOT NULL, param_identifier VARCHAR(64) NOT NULL, param_desc VARCHAR(200) NULL, data_type INT(11) DEFAULT 0 NOT NULL, max_value VARCHAR(200) NULL, min_value VARCHAR(200) NULL, step_value VARCHAR(200) NULL, unit VARCHAR(200) NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS matter_model (matter_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_name VARCHAR(200) NOT NULL, category_id INT(11) DEFAULT 0 NOT NULL, protocol INT(11) DEFAULT 0 NOT NULL, `connection` SMALLINT DEFAULT 0 NOT NULL, user_version INT(11) DEFAULT 0 NOT NULL, model_desc VARCHAR(200) NULL, status INT(11) DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE INDEX IDX_matter_model_category_id ON matter_model (category_id);
CREATE TABLE IF NOT EXISTS matter_service (service_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) NOT NULL, version_id INT(11) DEFAULT 0 NOT NULL, service_name VARCHAR(200) NOT NULL, service_identifier VARCHAR(64) NOT NULL, calling SMALLINT DEFAULT 0 NOT NULL, service_desc VARCHAR(200) NOT NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE INDEX IDX_matter_service_matter_id ON matter_service (matter_id) ;
CREATE TABLE IF NOT EXISTS matter_service_params (params_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) DEFAULT 0 NOT NULL, version_id INT(11) DEFAULT 0 NOT NULL, service_id INT(11) DEFAULT 0 NOT NULL, params_owner_type SMALLINT DEFAULT 0 NOT NULL, param_name VARCHAR(200) NOT NULL, param_identifier VARCHAR(64) NOT NULL, param_desc VARCHAR(200) NULL, data_type INT(11) DEFAULT 0 NOT NULL, max_value VARCHAR(200) NULL, min_value VARCHAR(200) NULL, step_value VARCHAR(200) NULL, unit VARCHAR(200) NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS matter_version (version_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, matter_id INT(11) DEFAULT 0 NOT NULL, version VARCHAR(50) NOT NULL, version_desc VARCHAR(200) NOT NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS model (model_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, model_name VARCHAR(200) NOT NULL, biz_type INT DEFAULT 1 NOT NULL, model_version VARCHAR(50) NOT NULL, model_desc VARCHAR(200) NOT NULL, model_files VARCHAR(200) NOT NULL, model_params_files VARCHAR(200) NULL, model_exec_script VARCHAR(200) NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS model_version (model_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, version_id INT(11) DEFAULT 0 NOT NULL, version VARCHAR(50) NOT NULL, model_desc VARCHAR(200) NOT NULL, update_desc VARCHAR(200) NOT NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS original_data (id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, equipment_ip VARCHAR(50) NULL, receipt_time VARCHAR(50) NULL, receipt_node_id VARCHAR(50) NULL, receipt_protocol VARCHAR(50) NULL, original_content TEXT NULL, create_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS owner (owner_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, owner_name VARCHAR(200) NOT NULL, charge_user VARCHAR(200) NOT NULL, phone VARCHAR(100) NOT NULL, creator INT(11) DEFAULT 0 NULL, modifier INT(11) DEFAULT 0 NULL, status SMALLINT DEFAULT 1 NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS project (project_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, project_name VARCHAR(200) NOT NULL, owner_id INT(11) DEFAULT 0 NOT NULL, line_name VARCHAR(200) NOT NULL, start_name VARCHAR(200) NOT NULL, end_name VARCHAR(200) NOT NULL, fixed_device_num INT(11) DEFAULT 0 NOT NULL, direction VARCHAR(200) NOT NULL, lane_num INT(4) DEFAULT 0 NOT NULL, start_point_lng DECIMAL(18,6) NULL, start_point_lat DECIMAL(18,6) NULL, end_point_lng DECIMAL(18,6) NULL, end_point_lat DECIMAL(18,6) NULL, status SMALLINT DEFAULT 1 NULL, creator INT(11) DEFAULT 0 NULL, modifier INT(11) DEFAULT 0 NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS system_menu (menu_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, menu_name VARCHAR(64) NULL, menu_path VARCHAR(200) NULL, component VARCHAR(64) NULL, redirect VARCHAR(200) DEFAULT '' NOT NULL, menu_url VARCHAR(200) DEFAULT '' NOT NULL, meta_title VARCHAR(128) NULL, meta_icon VARCHAR(200) NULL, always_show INT DEFAULT 1 NOT NULL, meta_affix INT DEFAULT 0 NOT NULL, type INT DEFAULT 1 NOT NULL, hidden INT DEFAULT 0 NOT NULL, pid INT(11) DEFAULT 0 NOT NULL, sort INT DEFAULT 0 NOT NULL, level INT(4) DEFAULT 0 NOT NULL, status SMALLINT DEFAULT 1 NOT NULL, meta_breadcrumb INT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS operation_log (id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, action VARCHAR(40) DEFAULT '' NOT NULL, category VARCHAR(40) DEFAULT '' NOT NULL, target_id VARCHAR(40) DEFAULT '' NOT NULL, old_value TEXT NOT NULL, new_value TEXT NOT NULL, operator VARCHAR(40) DEFAULT 'SYSDBA' NOT NULL, operate_addr VARCHAR(100) DEFAULT '' NOT NULL, operate_device VARCHAR(160) DEFAULT '' NOT NULL, operate_time BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS system_role_menu (role_menu_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, role_id INT(11) DEFAULT 1 NULL, menu_id INT(11) DEFAULT 1 NULL, status INT DEFAULT 1 NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS system_role_route (role_id INT(11) DEFAULT 1 NOT NULL, route_id INT(11) DEFAULT 1 NOT NULL, status INT DEFAULT 1 NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL, PRIMARY KEY (role_id,route_id)) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS system_role (role_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, role_name VARCHAR(32) NULL, role_value VARCHAR(32) NULL, alias_name VARCHAR(32) NULL, description VARCHAR(32) NULL, status INT DEFAULT 1 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4 ;
CREATE TABLE IF NOT EXISTS system_user (user_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, phone VARCHAR(16) NULL, avatar VARCHAR(200) NULL, `desc` VARCHAR(200) NULL, home_path VARCHAR(200) NULL, pass VARCHAR(128) NOT NULL, salt VARCHAR(32) NOT NULL, real_name VARCHAR(50) NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS system_user_role (user_role_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, user_id INT(11) NULL, role_id INT(11) NULL, status SMALLINT DEFAULT 0 NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE TABLE IF NOT EXISTS node(
node_id int auto_increment
primary key,
node_name varchar(100) null,
node_type smallint default 0 not null,
node_status smallint default 0 not null,
create_at bigint null,
update_at bigint null,
node_guid varchar(100) null,
platform varchar(100) null,
platform_version varchar(100) null,
c_p_u varchar(1000) null,
mem_total bigint null,
disk_total bigint null,
swap_total bigint null,
arch varchar(1000) null,
virtualization varchar(1000) null,
boot_time bigint null,
i_p varchar(100) null,
country_code varchar(100) null,
version varchar(100) null
);
create index IDX_node_node_guid on node (node_guid);
create table IF NOT EXISTS node_state(
uptime bigint not null,
node_name varchar(100) not null,
c_p_u decimal(18, 4) null,
mem_used bigint null,
swap_used bigint null,
disk_used bigint null,
net_in_transfer bigint null,
net_out_transfer bigint null,
net_in_speed bigint null,
net_out_speed bigint null,
load1 decimal(18, 4) null,
load5 decimal(18, 4) null,
load15 decimal(18, 4) null,
tcp_conn_count bigint null,
udp_conn_count bigint null,
process_count bigint null,
primary key (uptime, node_name)
);
CREATE TABLE IF NOT EXISTS task (task_id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL, model_id INT(11) NULL, node_id INT(11) NULL,task_desc VARCHAR(200) NULL, dataset_arr TEXT NULL, result_storage TEXT NULL, appointment_time VARCHAR(30) NULL, start_time BIGINT(20) NULL, finish_time BIGINT(20) NULL, status SMALLINT DEFAULT 0 NOT NULL, create_at BIGINT(20) NULL, update_at BIGINT(20) NULL) DEFAULT CHARSET utf8mb4;
CREATE INDEX IDX_task_model_id ON task (model_id);
CREATE INDEX IDX_task_node_id ON task (node_id);
-- 插入病害数据库
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (1, '横向拼接缝', 1, 1, 1673504353, 1673504353);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (2, '块裂', 1, 1, 1673504376, 1673504376);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (3, '开挖修补缝', 1, 1, 1673504480, 1673504480);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (4, '横向裂缝', 1, 1, 1673504487, 1673504487);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (5, '纵向裂缝', 1, 1, 1673504496, 1673504496);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (6, '龟裂', 1, 1, 1673504503, 1673504503);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (7, '管道修补缝', 1, 1, 1673504511, 1673504511);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (8, '结构裂缝', 2, 1, 1673504520, 1673504520);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (9, '蜂窝麻面', 2, 1, 1673504528, 1673504528);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (10, '剥落掉角', 2, 1, 1673504537, 1673504537);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (11, '空洞及孔洞', 2, 1, 1673504544, 1673504544);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (12, '破损露筋', 2, 1, 1673504553, 1673504553);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (13, '钢筋锈蚀', 2, 1, 1673504562, 1673504562);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (14, '衬砌漏水', 3, 1, 1673504570, 1673504570);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (15, '衬砌裂缝', 3, 1, 1673504578, 1673504578);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (16, '衬砌腐蚀', 3, 1, 1673504585, 1673504585);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (17, '衬砌开裂及剥落', 3, 1, 1673504594, 1673504594);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (18, '衬砌变形及位移', 3, 1, 1673504601, 1673504601);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (19, '隧道洞门裂损及洞口病害', 3, 1, 1673504609, 1673504609);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (20, '隧道运营通风不畅及照明不良', 3, 1, 1673504619, 1673504619);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (21, '崩塌', 4, 1, 1673504627, 1673504627);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (22, '滑坡', 4, 1, 1673504635, 1673504635);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (23, '错落', 4, 1, 1673504642, 1673504642);
INSERT INTO disease_type (type_id, type_name, category_id, status, create_at, update_at) VALUES (24, '坍塌', 4, 1, 1673504649, 1673504649);
-- 插入初始用户
INSERT INTO system_user (user_id, phone, avatar, `desc`, home_path, pass, salt, real_name, create_at, update_at) VALUES (1, '18906517788', null, null, null, 'NMIYXdSWsGXoz/+uRs5hdKGqVRc=', '69wBi9uU8FFa8OTW', '王剑', null, null);