drop table if exists failure_t;
create table failure_t (
  id           bigint(20)      not null auto_increment    comment '序号',
  zq         varchar(255)      default ''                comment 'ZQ',
  j_jd_jxy         varchar(255)     default ''                 comment 'J/JD/XY',
  s         varchar(255)     default ''                 comment 'S',
  bdlt         varchar(255)     default ''                 comment 'LT',
  failure_date datetime                                   comment '故障日期',
  aircraft_type         varchar(255)     default ''                 comment '机型',
  discovery_time         varchar(255)     default ''                 comment '发现时机',
  major         varchar(255)     default ''                 comment '专业',
  failure_description         varchar(255)     default ''                 comment '故障描述',
  failure_cause         varchar(255)     default ''                 comment '故障原因',
  failure_name         varchar(255)     default ''                 comment '故障名称',
  unserviceable_comp_name         varchar(255)     default ''                 comment '故障件名称',
  unserviceable_comp_type         varchar(255)     default ''                 comment '故障件型别',
  unserviceable_comp_num         varchar(255)     default ''                 comment '故障件号码',
  unserviceable_comp_system         varchar(255)     default ''                 comment '故障件所属系统',
  failure_consequence         varchar(255)     default ''                 comment '故障后果',
  failure_duty         varchar(255)     default ''                 comment '故障责任',
  replacement_comp_name         varchar(255)     default ''                 comment '故换件名称',
  replacement_comp_type         varchar(255)     default ''                 comment '故换件型别',
  replacement_comp_num         varchar(255)     default ''                 comment '故换件号码',
  elimination_methods         varchar(255)     default ''                 comment '排除方法',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  primary key (id)
) engine=innodb auto_increment=200 comment = '故障记录表';


drop table if exists brand_t;
create table brand_t (
  brand_id           bigint(20)      not null auto_increment    comment '序号',
  brand_name         varchar(255)      default ''                comment '机型系列名称',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  primary key (brand_id)
) engine=innodb auto_increment=200 comment = '机型系列表';


drop table if exists aircraft_type_t;
create table aircraft_type_t (
  aircraft_type_id           bigint(20)      not null auto_increment    comment '序号',
  brand_id         bigint(20)      not null                comment '系列',
  aircraft_type_name         varchar(255)                  comment '机型',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  primary key (aircraft_type_id)
) engine=innodb auto_increment=200 comment = '机型表';


-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录', '2000', '1', 'failure', 'system/failure/index', 1, 0, 'C', '0', '0', 'system:failure:list', '#', 'admin', sysdate(), '', null, '故障记录菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'system:failure:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'system:failure:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'system:failure:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'system:failure:remove',       '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('故障记录导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'system:failure:export',       '#', 'admin', sysdate(), '', null, '');

-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列', '2000', '1', 'brand', 'system/brand/index', 1, 0, 'C', '0', '0', 'system:brand:list', '#', 'admin', sysdate(), '', null, '机型系列菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'system:brand:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'system:brand:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'system:brand:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'system:brand:remove',       '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型系列导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'system:brand:export',       '#', 'admin', sysdate(), '', null, '');

-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型', '2000', '1', 'aircraftType', 'system/aircraftType/index', 1, 0, 'C', '0', '0', 'system:aircraftType:list', '#', 'admin', sysdate(), '', null, '机型菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'system:aircraftType:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'system:aircraftType:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'system:aircraftType:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'system:aircraftType:remove',       '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('机型导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'system:aircraftType:export',       '#', 'admin', sysdate(), '', null, '');