-- ----------------------------
-- 1、部门表
-- ----------------------------
drop table if exists sys_dept;
create table sys_dept (
  dept_id           bigint(20)      not null auto_increment    comment '部门id',
  parent_id         bigint(20)      default 0                  comment '父部门id',
  ancestors         varchar(50)     default ''                 comment '祖级列表',
  dept_name         varchar(30)     default ''                 comment '部门名称',
  order_num         int(4)          default 0                  comment '显示顺序',
  leader            varchar(20)     default null               comment '负责人',
  phone             varchar(11)     default null               comment '联系电话',
  email             varchar(50)     default null               comment '邮箱',
  status            char(1)         default '0'                comment '部门状态（0正常 1停用）',
  del_flag          char(1)         default '0'                comment '删除标志（0代表存在 2代表删除）',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  primary key (dept_id)
) engine=innodb auto_increment=200 comment = '部门表';

-- ----------------------------
-- 初始化-部门表数据
-- ----------------------------
insert into sys_dept values(100,  0,   '0',          '稷以科技',   0, '', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null);
insert into sys_dept values(101,  100, '0,100',      '销售部门', 1, '', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null);
insert into sys_dept values(102,  100, '0,100',      '生产部门', 2, '', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null);
insert into sys_dept values(103,  100, '0,100',      '售后部门', 3, '', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null);
insert into sys_dept values(104,  100, '0,100',      'IT部门', 3, '', '15888888888', 'ry@qq.com', '0', '0', 'admin', sysdate(), '', null);


-- ----------------------------
-- 2、用户信息表
-- ----------------------------
drop table if exists sys_user;
create table sys_user (
  user_id           bigint(20)      not null auto_increment    comment '用户ID',
  dept_id           bigint(20)      default null               comment '部门ID',
  user_name         varchar(30)     not null                   comment '用户账号',
  nick_name         varchar(30)     not null                   comment '用户昵称',
  user_type         varchar(2)      default '00'               comment '用户类型（00系统用户）',
  email             varchar(50)     default ''                 comment '用户邮箱',
  phonenumber       varchar(11)     default ''                 comment '手机号码',
  sex               char(1)         default '0'                comment '用户性别（0男 1女 2未知）',
  avatar            varchar(100)    default ''                 comment '头像地址',
  password          varchar(100)    default ''                 comment '密码',
  status            char(1)         default '0'                comment '帐号状态（0正常 1停用）',
  del_flag          char(1)         default '0'                comment '删除标志（0代表存在 2代表删除）',
  login_ip          varchar(128)    default ''                 comment '最后登录IP',
  login_date        datetime                                   comment '最后登录时间',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time       datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  remark            varchar(500)    default null               comment '备注',
  primary key (user_id)
) engine=innodb auto_increment=100 comment = '用户信息表';

-- ----------------------------
-- 初始化-用户信息表数据
-- ----------------------------
insert into sys_user values(1,  104, 'admin', '系统管理员', '00', 'admin@163.com', '15888888888', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null, '管理员');
INSERT INTO sys_user VALUES (2, 102, '杨吉克', '杨吉克', '00', '', '', '0', '', '$2a$10$mBWqVLOs/bmUKydiJZNRuOI71V6n/MJ91a2w.jb1kWkNZfygdaVFy', '0', '0', '', null, 'admin', '2024-01-31 02:59:58', '', null, null);
INSERT INTO sys_user VALUES (3, 103, '雷章波', '雷章波', '00', '', '', '0', '', '$2a$10$f.D8f1qxFZzdwW.iuT937ehGVXTGhqvc8LBt9vWS.kWbbdJRx8KYe', '0', '0', '', null, 'admin', '2024-01-31 03:00:40', '', null, null);

-- ----------------------------
-- 3、岗位信息表
-- ----------------------------
drop table if exists sys_post;
create table sys_post
(
  post_id       bigint(20)      not null auto_increment    comment '岗位ID',
  post_code     varchar(64)     not null                   comment '岗位编码',
  post_name     varchar(50)     not null                   comment '岗位名称',
  post_sort     int(4)          not null                   comment '显示顺序',
  status        char(1)         not null                   comment '状态（0正常 1停用）',
  create_by     varchar(64)     default ''                 comment '创建者',
  create_time   datetime                                   comment '创建时间',
  update_by     varchar(64)     default ''			       comment '更新者',
  update_time   datetime                                   comment '更新时间',
  remark        varchar(500)    default null               comment '备注',
  primary key (post_id)
) engine=innodb comment = '岗位信息表';

-- ----------------------------
-- 初始化-岗位信息表数据
-- ----------------------------
insert into sys_post values(1, 'ceo',  '董事长',    1, '0', 'admin', sysdate(), '', null, '');
insert into sys_post values(2, 'se',   '项目经理',  2, '0', 'admin', sysdate(), '', null, '');
insert into sys_post values(3, 'hr',   '人力资源',  3, '0', 'admin', sysdate(), '', null, '');
insert into sys_post values(4, 'user', '普通员工',  4, '0', 'admin', sysdate(), '', null, '');


-- ----------------------------
-- 4、角色信息表
-- ----------------------------
drop table if exists sys_role;
create table sys_role (
  role_id              bigint(20)      not null auto_increment    comment '角色ID',
  role_name            varchar(30)     not null                   comment '角色名称',
  role_key             varchar(100)    not null                   comment '角色权限字符串',
  role_sort            int(4)          not null                   comment '显示顺序',
  data_scope           char(1)         default '1'                comment '数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）',
  menu_check_strictly  tinyint(1)      default 1                  comment '菜单树选择项是否关联显示',
  dept_check_strictly  tinyint(1)      default 1                  comment '部门树选择项是否关联显示',
  status               char(1)         not null                   comment '角色状态（0正常 1停用）',
  del_flag             char(1)         default '0'                comment '删除标志（0代表存在 2代表删除）',
  create_by            varchar(64)     default ''                 comment '创建者',
  create_time          datetime                                   comment '创建时间',
  update_by            varchar(64)     default ''                 comment '更新者',
  update_time          datetime                                   comment '更新时间',
  remark               varchar(500)    default null               comment '备注',
  primary key (role_id)
) engine=innodb auto_increment=100 comment = '角色信息表';

-- ----------------------------
-- 初始化-角色信息表数据
-- ----------------------------
insert into sys_role values('1', '超级管理员',  'admin',  1, 1, 1, 1, '0', '0', 'admin', sysdate(), '', null, '超级管理员');

-- ----------------------------
-- 5、菜单权限表
-- ----------------------------
drop table if exists sys_menu;
create table sys_menu (
  menu_id           bigint(20)      not null auto_increment    comment '菜单ID',
  menu_name         varchar(50)     not null                   comment '菜单名称',
  parent_id         bigint(20)      default 0                  comment '父菜单ID',
  order_num         int(4)          default 0                  comment '显示顺序',
  path              varchar(200)    default ''                 comment '路由地址',
  component         varchar(255)    default null               comment '组件路径',
  query             varchar(255)    default null               comment '路由参数',
  is_frame          int(1)          default 1                  comment '是否为外链（0是 1否）',
  is_cache          int(1)          default 0                  comment '是否缓存（0缓存 1不缓存）',
  menu_type         char(1)         default ''                 comment '菜单类型（M目录 C菜单 F按钮）',
  visible           char(1)         default 0                  comment '菜单状态（0显示 1隐藏）',
  status            char(1)         default 0                  comment '菜单状态（0正常 1停用）',
  perms             varchar(100)    default null               comment '权限标识',
  icon              varchar(100)    default '#'                comment '菜单图标',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time       datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  remark            varchar(500)    default ''                 comment '备注',
  primary key (menu_id)
) engine=innodb auto_increment=2000 comment = '菜单权限表';

-- ----------------------------
-- 初始化-菜单信息表数据
-- ----------------------------
-- 一级菜单
insert into sys_menu values('1', '系统管理', '0', '1', 'system',           null, '', 1, 0, 'M', '0', '0', '', 'system',   'admin', sysdate(), '', null, '系统管理目录');
insert into sys_menu values('2', '系统监控', '0', '2', 'monitor',          null, '', 1, 0, 'M', '0', '0', '', 'monitor',  'admin', sysdate(), '', null, '系统监控目录');
insert into sys_menu values('3', '系统工具', '0', '3', 'tool',             null, '', 1, 0, 'M', '0', '0', '', 'tool',     'admin', sysdate(), '', null, '系统工具目录');
INSERT INTO sys_menu VALUES ('4', '设备管理', '0', '4', 'jetplasma',       null, '', 1, 0, 'M', '0', '0', '', 'logininfor', 'admin', sysdate(), 'admin', '2024-01-19 14:12:12', '业务目录');

-- 二级菜单
insert into sys_menu values('100',  '用户管理', '1',   '1', 'user',       'system/user/index',        '', 1, 0, 'C', '0', '0', 'system:user:list',        'user',          'admin', sysdate(), '', null, '用户管理菜单');
insert into sys_menu values('101',  '角色管理', '1',   '2', 'role',       'system/role/index',        '', 1, 0, 'C', '0', '0', 'system:role:list',        'peoples',       'admin', sysdate(), '', null, '角色管理菜单');
insert into sys_menu values('102',  '菜单管理', '1',   '3', 'menu',       'system/menu/index',        '', 1, 0, 'C', '0', '0', 'system:menu:list',        'tree-table',    'admin', sysdate(), '', null, '菜单管理菜单');
insert into sys_menu values('103',  '部门管理', '1',   '4', 'dept',       'system/dept/index',        '', 1, 0, 'C', '0', '0', 'system:dept:list',        'tree',          'admin', sysdate(), '', null, '部门管理菜单');
insert into sys_menu values('104',  '岗位管理', '1',   '5', 'post',       'system/post/index',        '', 1, 0, 'C', '0', '0', 'system:post:list',        'post',          'admin', sysdate(), '', null, '岗位管理菜单');
insert into sys_menu values('105',  '字典管理', '1',   '6', 'dict',       'system/dict/index',        '', 1, 0, 'C', '0', '0', 'system:dict:list',        'dict',          'admin', sysdate(), '', null, '字典管理菜单');
insert into sys_menu values('106',  '参数设置', '1',   '7', 'config',     'system/config/index',      '', 1, 0, 'C', '0', '0', 'system:config:list',      'edit',          'admin', sysdate(), '', null, '参数设置菜单');
insert into sys_menu values('107',  '通知公告', '1',   '8', 'notice',     'system/notice/index',      '', 1, 0, 'C', '0', '0', 'system:notice:list',      'message',       'admin', sysdate(), '', null, '通知公告菜单');
insert into sys_menu values('108',  '日志管理', '1',   '9', 'log',        '',                         '', 1, 0, 'M', '0', '0', '',                        'log',           'admin', sysdate(), '', null, '日志管理菜单');
insert into sys_menu values('109',  '在线用户', '2',   '1', 'online',     'monitor/online/index',     '', 1, 0, 'C', '0', '0', 'monitor:online:list',     'online',        'admin', sysdate(), '', null, '在线用户菜单');
insert into sys_menu values('110',  '定时任务', '2',   '2', 'job',        'monitor/job/index',        '', 1, 0, 'C', '0', '0', 'monitor:job:list',        'job',           'admin', sysdate(), '', null, '定时任务菜单');
insert into sys_menu values('111',  '数据监控', '2',   '3', 'druid',      'monitor/druid/index',      '', 1, 0, 'C', '0', '0', 'monitor:druid:list',      'druid',         'admin', sysdate(), '', null, '数据监控菜单');
insert into sys_menu values('112',  '服务监控', '2',   '4', 'server',     'monitor/server/index',     '', 1, 0, 'C', '0', '0', 'monitor:server:list',     'server',        'admin', sysdate(), '', null, '服务监控菜单');
insert into sys_menu values('113',  '缓存监控', '2',   '5', 'cache',      'monitor/cache/index',      '', 1, 0, 'C', '0', '0', 'monitor:cache:list',      'redis',         'admin', sysdate(), '', null, '缓存监控菜单');
insert into sys_menu values('114',  '缓存列表', '2',   '6', 'cacheList',  'monitor/cache/list',       '', 1, 0, 'C', '0', '0', 'monitor:cache:list',      'redis-list',    'admin', sysdate(), '', null, '缓存列表菜单');
insert into sys_menu values('115',  '表单构建', '3',   '1', 'build',      'tool/build/index',         '', 1, 0, 'C', '0', '0', 'tool:build:list',         'build',         'admin', sysdate(), '', null, '表单构建菜单');
insert into sys_menu values('116',  '代码生成', '3',   '2', 'gen',        'tool/gen/index',           '', 1, 0, 'C', '0', '0', 'tool:gen:list',           'code',          'admin', sysdate(), '', null, '代码生成菜单');
insert into sys_menu values('117',  '系统接口', '3',   '3', 'swagger',    'tool/swagger/index',       '', 1, 0, 'C', '0', '0', 'tool:swagger:list',       'swagger',       'admin', sysdate(), '', null, '系统接口菜单');
-- 三级菜单
insert into sys_menu values('500',  '操作日志', '108', '1', 'operlog',    'monitor/operlog/index',    '', 1, 0, 'C', '0', '0', 'monitor:operlog:list',    'form',          'admin', sysdate(), '', null, '操作日志菜单');
insert into sys_menu values('501',  '登录日志', '108', '2', 'logininfor', 'monitor/logininfor/index', '', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor',    'admin', sysdate(), '', null, '登录日志菜单');
-- 用户管理按钮
insert into sys_menu values('1000', '用户查询', '100', '1',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1001', '用户新增', '100', '2',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1002', '用户修改', '100', '3',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1003', '用户删除', '100', '4',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:remove',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1004', '用户导出', '100', '5',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:export',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1005', '用户导入', '100', '6',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:import',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1006', '重置密码', '100', '7',  '', '', '', 1, 0, 'F', '0', '0', 'system:user:resetPwd',       '#', 'admin', sysdate(), '', null, '');
-- 角色管理按钮
insert into sys_menu values('1007', '角色查询', '101', '1',  '', '', '', 1, 0, 'F', '0', '0', 'system:role:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1008', '角色新增', '101', '2',  '', '', '', 1, 0, 'F', '0', '0', 'system:role:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1009', '角色修改', '101', '3',  '', '', '', 1, 0, 'F', '0', '0', 'system:role:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1010', '角色删除', '101', '4',  '', '', '', 1, 0, 'F', '0', '0', 'system:role:remove',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1011', '角色导出', '101', '5',  '', '', '', 1, 0, 'F', '0', '0', 'system:role:export',         '#', 'admin', sysdate(), '', null, '');
-- 菜单管理按钮
insert into sys_menu values('1012', '菜单查询', '102', '1',  '', '', '', 1, 0, 'F', '0', '0', 'system:menu:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1013', '菜单新增', '102', '2',  '', '', '', 1, 0, 'F', '0', '0', 'system:menu:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1014', '菜单修改', '102', '3',  '', '', '', 1, 0, 'F', '0', '0', 'system:menu:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1015', '菜单删除', '102', '4',  '', '', '', 1, 0, 'F', '0', '0', 'system:menu:remove',         '#', 'admin', sysdate(), '', null, '');
-- 部门管理按钮
insert into sys_menu values('1016', '部门查询', '103', '1',  '', '', '', 1, 0, 'F', '0', '0', 'system:dept:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1017', '部门新增', '103', '2',  '', '', '', 1, 0, 'F', '0', '0', 'system:dept:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1018', '部门修改', '103', '3',  '', '', '', 1, 0, 'F', '0', '0', 'system:dept:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1019', '部门删除', '103', '4',  '', '', '', 1, 0, 'F', '0', '0', 'system:dept:remove',         '#', 'admin', sysdate(), '', null, '');
-- 岗位管理按钮
insert into sys_menu values('1020', '岗位查询', '104', '1',  '', '', '', 1, 0, 'F', '0', '0', 'system:post:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1021', '岗位新增', '104', '2',  '', '', '', 1, 0, 'F', '0', '0', 'system:post:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1022', '岗位修改', '104', '3',  '', '', '', 1, 0, 'F', '0', '0', 'system:post:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1023', '岗位删除', '104', '4',  '', '', '', 1, 0, 'F', '0', '0', 'system:post:remove',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1024', '岗位导出', '104', '5',  '', '', '', 1, 0, 'F', '0', '0', 'system:post:export',         '#', 'admin', sysdate(), '', null, '');
-- 字典管理按钮
insert into sys_menu values('1025', '字典查询', '105', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1026', '字典新增', '105', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1027', '字典修改', '105', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1028', '字典删除', '105', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:remove',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1029', '字典导出', '105', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:dict:export',         '#', 'admin', sysdate(), '', null, '');
-- 参数设置按钮
insert into sys_menu values('1030', '参数查询', '106', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:query',        '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1031', '参数新增', '106', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:add',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1032', '参数修改', '106', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:edit',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1033', '参数删除', '106', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:remove',       '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1034', '参数导出', '106', '5', '#', '', '', 1, 0, 'F', '0', '0', 'system:config:export',       '#', 'admin', sysdate(), '', null, '');
-- 通知公告按钮
insert into sys_menu values('1035', '公告查询', '107', '1', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:query',        '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1036', '公告新增', '107', '2', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:add',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1037', '公告修改', '107', '3', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:edit',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1038', '公告删除', '107', '4', '#', '', '', 1, 0, 'F', '0', '0', 'system:notice:remove',       '#', 'admin', sysdate(), '', null, '');
-- 操作日志按钮
insert into sys_menu values('1039', '操作查询', '500', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:query',      '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1040', '操作删除', '500', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:remove',     '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1041', '日志导出', '500', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:operlog:export',     '#', 'admin', sysdate(), '', null, '');
-- 登录日志按钮
insert into sys_menu values('1042', '登录查询', '501', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:query',   '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1043', '登录删除', '501', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:remove',  '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1044', '日志导出', '501', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:export',  '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1045', '账户解锁', '501', '4', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:logininfor:unlock',  '#', 'admin', sysdate(), '', null, '');
-- 在线用户按钮
insert into sys_menu values('1046', '在线查询', '109', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:query',       '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1047', '批量强退', '109', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:batchLogout', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1048', '单条强退', '109', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:online:forceLogout', '#', 'admin', sysdate(), '', null, '');
-- 定时任务按钮
insert into sys_menu values('1049', '任务查询', '110', '1', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:query',          '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1050', '任务新增', '110', '2', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:add',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1051', '任务修改', '110', '3', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:edit',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1052', '任务删除', '110', '4', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:remove',         '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1053', '状态修改', '110', '5', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:changeStatus',   '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1054', '任务导出', '110', '6', '#', '', '', 1, 0, 'F', '0', '0', 'monitor:job:export',         '#', 'admin', sysdate(), '', null, '');
-- 代码生成按钮
insert into sys_menu values('1055', '生成查询', '116', '1', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:query',             '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1056', '生成修改', '116', '2', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:edit',              '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1057', '生成删除', '116', '3', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:remove',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1058', '导入代码', '116', '4', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:import',            '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1059', '预览代码', '116', '5', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:preview',           '#', 'admin', sysdate(), '', null, '');
insert into sys_menu values('1060', '生成代码', '116', '6', '#', '', '', 1, 0, 'F', '0', '0', 'tool:gen:code',              '#', 'admin', sysdate(), '', null, '');

INSERT INTO sys_menu VALUES (2001, '审核工作台', 2013, 1, 'approve', 'jetplasma/approve/index', null, 1, 0, 'C', '0', '0', 'jetplasma:approve:list', 'monitor', 'admin', '2024-01-18 16:32:02', 'admin', '2024-03-03 13:51:26', '');
INSERT INTO sys_menu VALUES (2002, '审核流程管理', 2013, 2, 'appflow', 'jetplasma/appflow/index', null, 1, 0, 'C', '0', '0', 'jetplasma:flow:list', 'peoples', 'admin', '2024-01-18 14:17:14', 'admin', '2024-03-03 13:51:33', '');
INSERT INTO sys_menu VALUES (2003, '设备信息', 4, 3, 'input', 'jetplasma/input/index', null, 1, 0, 'C', '0', '0', 'jetplasma:device:list', 'log', 'admin', '2024-01-07 17:21:58', 'admin', '2024-01-21 17:20:20', '订单查询');
INSERT INTO sys_menu VALUES (2004, '设备生产', 4, 4, 'install', 'jetplasma/install/index', null, 1, 0, 'C', '0', '0', 'jetplasma:device:list', 'documentation', 'admin', '2024-01-09 23:15:40', 'admin', '2024-01-21 17:20:48', '');
INSERT INTO sys_menu VALUES (2005, '查看发货清单', 2004, 0, '#', '', null, 1, 0, 'F', '0', '0', 'jetplasma:install:shippinglist', '#', 'admin', '2024-01-07 17:21:58', 'admin', '2024-03-03 14:53:54', '');
INSERT INTO sys_menu VALUES (2006, '下载核心物料清单', 2004, 1, '#', '', null, 1, 0, 'F', '0', '0', 'jetplasma:install:download', '#', 'admin', '2024-01-07 17:21:58', 'admin', '2024-03-03 14:53:23', '');
INSERT INTO sys_menu VALUES (2007, '设备验收', 4, 5, 'startup', 'jetplasma/startup/index', null, 1, 0, 'C', '0', '0', 'jetplasma:startup:list', 'component', 'admin', '2024-01-28 18:00:35', 'admin', '2024-01-28 18:00:44', '');
INSERT INTO sys_menu VALUES (2008, '设备售后', 4, 6, 'warranty', 'jetplasma/warranty/index', null, 1, 0, 'C', '0', '0', 'jetplasma:warranty:list', 'date', 'admin', '2024-01-28 19:58:16', '', null, '');
INSERT INTO sys_menu VALUES (2009, '下载协议附件', 2003, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:input:download', '#', 'admin', '2024-02-20 22:23:33', '', null, '');
INSERT INTO sys_menu VALUES (2010, '下载验收单', 2007, 1, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:start:download', '#', 'admin', '2024-02-20 22:23:53', '', null, '');
-- CIP菜单部分暂时去除
-- INSERT INTO sys_menu VALUES (2011, 'CIP管理', 0, 5, 'cip', null, null, 1, 0, 'M', '0', '0', null, 'build', 'admin', '2024-03-02 23:17:18', '', null, '');
-- INSERT INTO sys_menu VALUES (2012, 'CIP申请', 2011, 0, 'list', 'jetplasma/cip/cipList', null, 1, 0, 'C', '0', '0', '', 'component', 'admin', '2024-03-02 23:18:06', 'admin', '2024-03-02 23:18:44', '');
-- INSERT INTO sys_menu VALUES (2014, 'CIP执行', 2011, 1, 'cip', 'jetplasma/cip/cipExecute', null, 1, 0, 'C', '0', '0', null, 'job', 'admin', '2024-03-03 19:02:08', '', null, '');
INSERT INTO sys_menu VALUES (2013, '审核管理', 0, 6, 'approve', null, null, 1, 0, 'M', '0', '0', '', 'form', 'admin', '2024-03-03 13:50:19', 'admin', '2024-03-03 13:51:05', '');
INSERT INTO sys_menu VALUES (2015, '技术协议预览', 2003, 0, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:input:preview', '#', 'admin', '2024-03-03 14:44:50', '', null, '');
INSERT INTO sys_menu VALUES (2016, '验收单预览', 2007, 0, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:start:preview', '#', 'admin', '2024-03-03 14:47:37', '', null, '');
INSERT INTO sys_menu VALUES (2017, '核心物料清单预览', 2004, 2, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:install:preview', '#', 'admin', '2024-03-03 14:53:47', '', null, '');
INSERT INTO sys_menu VALUES (2018, '撤销审核', 2003, 2, '', null, null, 1, 0, 'F', '0', '0', 'jetplasma:input:rescind', '#', 'admin', '2024-03-08 09:46:06', '', null, '');
INSERT INTO sys_menu VALUES (2019, '附件下载历史', 4, 7, 'download', 'jetplasma/attachement/index', NULL, 1, 0, 'C', '1', '0', 'jetplasma:attachement:list', 'code', 'admin', '2024-03-18 11:17:45', 'admin', '2024-03-22 02:28:44', '');
INSERT INTO sys_menu VALUES (2020, '历史记录查询', 0, 7, 'download', 'jetplasma/attachement/index', NULL, 1, 0, 'C', '0', '0', 'jetplasma:attachement:list', 'documentation', 'admin', '2024-03-22 02:21:08', 'admin', '2024-03-22 02:28:04', '');
INSERT INTO sys_menu VALUES (2021, '下载EXCEL', 2020, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'jetplasma:attachement:downloadExcel', '#', 'admin', '2024-03-22 03:01:28', '', NULL, '');
INSERT INTO sys_menu VALUES (2022, '设备权限', 4, 8, 'config', 'jetplasma/config/index', NULL, 1, 0, 'C', '0', '0', 'jetplasma:config:list', 'lock', 'admin', '2024-03-22 16:14:37', '', NULL, '');

-- ----------------------------
-- 6、用户和角色关联表  用户N-1角色
-- ----------------------------
drop table if exists sys_user_role;
create table sys_user_role (
  user_id   bigint(20) not null comment '用户ID',
  role_id   bigint(20) not null comment '角色ID',
  primary key(user_id, role_id)
) engine=innodb comment = '用户和角色关联表';

-- ----------------------------
-- 初始化-用户和角色关联表数据
-- ----------------------------
insert into sys_user_role values ('1', '1');


-- ----------------------------
-- 7、角色和菜单关联表  角色1-N菜单
-- ----------------------------
drop table if exists sys_role_menu;
create table sys_role_menu (
  role_id   bigint(20) not null comment '角色ID',
  menu_id   bigint(20) not null comment '菜单ID',
  primary key(role_id, menu_id)
) engine=innodb comment = '角色和菜单关联表';

-- ----------------------------
-- 8、角色和部门关联表  角色1-N部门
-- ----------------------------
drop table if exists sys_role_dept;
create table sys_role_dept (
  role_id   bigint(20) not null comment '角色ID',
  dept_id   bigint(20) not null comment '部门ID',
  primary key(role_id, dept_id)
) engine=innodb comment = '角色和部门关联表';



-- ----------------------------
-- 9、用户与岗位关联表  用户1-N岗位
-- ----------------------------
drop table if exists sys_user_post;
create table sys_user_post
(
  user_id   bigint(20) not null comment '用户ID',
  post_id   bigint(20) not null comment '岗位ID',
  primary key (user_id, post_id)
) engine=innodb comment = '用户与岗位关联表';

-- ----------------------------
-- 初始化-用户与岗位关联表数据
-- ----------------------------
insert into sys_user_post values ('1', '1');


-- ----------------------------
-- 10、操作日志记录
-- ----------------------------
drop table if exists sys_oper_log;
create table sys_oper_log (
  oper_id           bigint(20)      not null auto_increment    comment '日志主键',
  title             varchar(50)     default ''                 comment '模块标题',
  business_type     int(2)          default 0                  comment '业务类型（0其它 1新增 2修改 3删除）',
  method            varchar(100)    default ''                 comment '方法名称',
  request_method    varchar(10)     default ''                 comment '请求方式',
  operator_type     int(1)          default 0                  comment '操作类别（0其它 1后台用户 2手机端用户）',
  oper_name         varchar(50)     default ''                 comment '操作人员',
  dept_name         varchar(50)     default ''                 comment '部门名称',
  oper_url          varchar(255)    default ''                 comment '请求URL',
  oper_ip           varchar(128)    default ''                 comment '主机地址',
  oper_location     varchar(255)    default ''                 comment '操作地点',
  oper_param        varchar(2000)   default ''                 comment '请求参数',
  json_result       varchar(2000)   default ''                 comment '返回参数',
  status            int(1)          default 0                  comment '操作状态（0正常 1异常）',
  error_msg         varchar(2000)   default ''                 comment '错误消息',
  oper_time         datetime                                   comment '操作时间',
  cost_time         bigint(20)      default 0                  comment '消耗时间',
  primary key (oper_id),
  key idx_sys_oper_log_bt (business_type),
  key idx_sys_oper_log_s  (status),
  key idx_sys_oper_log_ot (oper_time)
) engine=innodb auto_increment=100 comment = '操作日志记录';


-- ----------------------------
-- 11、字典类型表
-- ----------------------------
drop table if exists sys_dict_type;
create table sys_dict_type
(
  dict_id          bigint(20)      not null auto_increment    comment '字典主键',
  dict_name        varchar(100)    default ''                 comment '字典名称',
  dict_type        varchar(100)    default ''                 comment '字典类型',
  status           char(1)         default '0'                comment '状态（0正常 1停用）',
  create_by        varchar(64)     default ''                 comment '创建者',
  create_time      datetime                                   comment '创建时间',
  update_by        varchar(64)     default ''                 comment '更新者',
  update_time      datetime                                   comment '更新时间',
  remark           varchar(500)    default null               comment '备注',
  primary key (dict_id),
  unique (dict_type)
) engine=innodb auto_increment=100 comment = '字典类型表';

insert into sys_dict_type values(1,  '用户性别', 'sys_user_sex',        '0', 'admin', sysdate(), '', null, '用户性别列表');
insert into sys_dict_type values(2,  '菜单状态', 'sys_show_hide',       '0', 'admin', sysdate(), '', null, '菜单状态列表');
insert into sys_dict_type values(3,  '系统开关', 'sys_normal_disable',  '0', 'admin', sysdate(), '', null, '系统开关列表');
insert into sys_dict_type values(4,  '任务状态', 'sys_job_status',      '0', 'admin', sysdate(), '', null, '任务状态列表');
insert into sys_dict_type values(5,  '任务分组', 'sys_job_group',       '0', 'admin', sysdate(), '', null, '任务分组列表');
insert into sys_dict_type values(6,  '系统是否', 'sys_yes_no',          '0', 'admin', sysdate(), '', null, '系统是否列表');
insert into sys_dict_type values(7,  '通知类型', 'sys_notice_type',     '0', 'admin', sysdate(), '', null, '通知类型列表');
insert into sys_dict_type values(8,  '通知状态', 'sys_notice_status',   '0', 'admin', sysdate(), '', null, '通知状态列表');
insert into sys_dict_type values(9,  '操作类型', 'sys_oper_type',       '0', 'admin', sysdate(), '', null, '操作类型列表');
insert into sys_dict_type values(10, '系统状态', 'sys_common_status',   '0', 'admin', sysdate(), '', null, '登录状态列表');

INSERT INTO sys_dict_type VALUES (11, '设备模块', 'device_module', '0', 'admin', '2024-01-21 11:40:56', '', null, null);
INSERT INTO sys_dict_type VALUES (12, '问题类型', 'problem_type', '0', 'admin', '2024-01-21 13:39:08', '', null, null);
INSERT INTO sys_dict_type VALUES (13, '测试阶段', 'test_stage', '0', 'admin', '2024-01-25 16:05:04', '', null, null);
INSERT INTO sys_dict_type VALUES (14, '紧急程度', 'urgency', '0', 'admin', '2024-01-30 23:47:21', '', null, null);
INSERT INTO sys_dict_type VALUES (15, '严重程度', 'critical', '0', 'admin', '2024-01-30 23:47:34', '', null, null);
INSERT INTO sys_dict_type VALUES (16, '设备类型', 'device_type', '0', 'admin', '2024-03-07 09:39:24', '', NULL, NULL);

-- ----------------------------
-- 12、字典数据表
-- ----------------------------
drop table if exists sys_dict_data;
create table sys_dict_data
(
  dict_code        bigint(20)      not null auto_increment    comment '字典编码',
  dict_sort        int(4)          default 0                  comment '字典排序',
  dict_label       varchar(100)    default ''                 comment '字典标签',
  dict_value       varchar(100)    default ''                 comment '字典键值',
  dict_type        varchar(100)    default ''                 comment '字典类型',
  css_class        varchar(100)    default null               comment '样式属性（其他样式扩展）',
  list_class       varchar(100)    default null               comment '表格回显样式',
  is_default       char(1)         default 'N'                comment '是否默认（Y是 N否）',
  status           char(1)         default '0'                comment '状态（0正常 1停用）',
  create_by        varchar(64)     default ''                 comment '创建者',
  create_time      datetime                                   comment '创建时间',
  update_by        varchar(64)     default ''                 comment '更新者',
  update_time      datetime                                   comment '更新时间',
  remark           varchar(500)    default null               comment '备注',
  primary key (dict_code)
) engine=innodb auto_increment=100 comment = '字典数据表';

insert into sys_dict_data values(1,  1,  '男',       '0',       'sys_user_sex',        '',   '',        'Y', '0', 'admin', sysdate(), '', null, '性别男');
insert into sys_dict_data values(2,  2,  '女',       '1',       'sys_user_sex',        '',   '',        'N', '0', 'admin', sysdate(), '', null, '性别女');
insert into sys_dict_data values(3,  3,  '未知',     '2',       'sys_user_sex',        '',   '',        'N', '0', 'admin', sysdate(), '', null, '性别未知');
insert into sys_dict_data values(4,  1,  '显示',     '0',       'sys_show_hide',       '',   'primary', 'Y', '0', 'admin', sysdate(), '', null, '显示菜单');
insert into sys_dict_data values(5,  2,  '隐藏',     '1',       'sys_show_hide',       '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '隐藏菜单');
insert into sys_dict_data values(6,  1,  '正常',     '0',       'sys_normal_disable',  '',   'primary', 'Y', '0', 'admin', sysdate(), '', null, '正常状态');
insert into sys_dict_data values(7,  2,  '停用',     '1',       'sys_normal_disable',  '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '停用状态');
insert into sys_dict_data values(8,  1,  '正常',     '0',       'sys_job_status',      '',   'primary', 'Y', '0', 'admin', sysdate(), '', null, '正常状态');
insert into sys_dict_data values(9,  2,  '暂停',     '1',       'sys_job_status',      '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '停用状态');
insert into sys_dict_data values(10, 1,  '默认',     'DEFAULT', 'sys_job_group',       '',   '',        'Y', '0', 'admin', sysdate(), '', null, '默认分组');
insert into sys_dict_data values(11, 2,  '系统',     'SYSTEM',  'sys_job_group',       '',   '',        'N', '0', 'admin', sysdate(), '', null, '系统分组');
insert into sys_dict_data values(12, 1,  '是',       'Y',       'sys_yes_no',          '',   'primary', 'Y', '0', 'admin', sysdate(), '', null, '系统默认是');
insert into sys_dict_data values(13, 2,  '否',       'N',       'sys_yes_no',          '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '系统默认否');
insert into sys_dict_data values(14, 1,  '通知',     '1',       'sys_notice_type',     '',   'warning', 'Y', '0', 'admin', sysdate(), '', null, '通知');
insert into sys_dict_data values(15, 2,  '公告',     '2',       'sys_notice_type',     '',   'success', 'N', '0', 'admin', sysdate(), '', null, '公告');
insert into sys_dict_data values(16, 1,  '正常',     '0',       'sys_notice_status',   '',   'primary', 'Y', '0', 'admin', sysdate(), '', null, '正常状态');
insert into sys_dict_data values(17, 2,  '关闭',     '1',       'sys_notice_status',   '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '关闭状态');
insert into sys_dict_data values(18, 99, '其他',     '0',       'sys_oper_type',       '',   'info',    'N', '0', 'admin', sysdate(), '', null, '其他操作');
insert into sys_dict_data values(19, 1,  '新增',     '1',       'sys_oper_type',       '',   'info',    'N', '0', 'admin', sysdate(), '', null, '新增操作');
insert into sys_dict_data values(20, 2,  '修改',     '2',       'sys_oper_type',       '',   'info',    'N', '0', 'admin', sysdate(), '', null, '修改操作');
insert into sys_dict_data values(21, 3,  '删除',     '3',       'sys_oper_type',       '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '删除操作');
insert into sys_dict_data values(22, 4,  '授权',     '4',       'sys_oper_type',       '',   'primary', 'N', '0', 'admin', sysdate(), '', null, '授权操作');
insert into sys_dict_data values(23, 5,  '导出',     '5',       'sys_oper_type',       '',   'warning', 'N', '0', 'admin', sysdate(), '', null, '导出操作');
insert into sys_dict_data values(24, 6,  '导入',     '6',       'sys_oper_type',       '',   'warning', 'N', '0', 'admin', sysdate(), '', null, '导入操作');
insert into sys_dict_data values(25, 7,  '强退',     '7',       'sys_oper_type',       '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '强退操作');
insert into sys_dict_data values(26, 8,  '生成代码', '8',       'sys_oper_type',       '',   'warning', 'N', '0', 'admin', sysdate(), '', null, '生成操作');
insert into sys_dict_data values(27, 9,  '清空数据', '9',       'sys_oper_type',       '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '清空操作');
insert into sys_dict_data values(28, 1,  '成功',     '0',       'sys_common_status',   '',   'primary', 'N', '0', 'admin', sysdate(), '', null, '正常状态');
insert into sys_dict_data values(29, 2,  '失败',     '1',       'sys_common_status',   '',   'danger',  'N', '0', 'admin', sysdate(), '', null, '停用状态');

INSERT INTO sys_dict_data VALUES (30, 0, 'TM', 'TM', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:24', '', null, null);
INSERT INTO sys_dict_data VALUES (31, 1, 'PM', 'PM', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:25', '', null, null);
INSERT INTO sys_dict_data VALUES (32, 2, 'EFEM', 'EFEM', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:25', '', null, null);
INSERT INTO sys_dict_data VALUES (33, 3, 'ACRock', 'ACRock', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:26', 'admin', '2024-01-26 05:30:18', null);
INSERT INTO sys_dict_data VALUES (34, 4, '生产', 'install', 'device_execute_step', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:27', 'admin', '2024-02-02 04:00:23', null);
INSERT INTO sys_dict_data VALUES (36, 5, '测试', 'test', 'device_execute_step', null, 'default', 'N', '0', 'admin', '2024-01-21 11:41:27', '', null, null);
INSERT INTO sys_dict_data VALUES (37, 6, 'RFRock', 'RFRock', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-26 05:30:36', 'admin', '2024-01-26 05:30:42', null);
INSERT INTO sys_dict_data VALUES (38, 7, 'GasBox', 'GasBox', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-26 05:30:57', '', null, null);
INSERT INTO sys_dict_data VALUES (39, 8, '其它', '其它', 'device_module', null, 'default', 'N', '0', 'admin', '2024-01-26 05:31:11', '', null, null);

INSERT INTO sys_dict_data VALUES (40, 1, '设计问题', '1', 'problem_type', null, 'default', 'N', '0', 'admin', '2024-01-21 20:55:47', 'admin', '2024-01-26 06:09:16', null);
INSERT INTO sys_dict_data VALUES (41, 2, '人为问题', '2', 'problem_type', null, 'default', 'N', '0', 'admin', '2024-01-21 20:56:00', 'admin', '2024-01-26 05:20:20', null);
INSERT INTO sys_dict_data VALUES (42, 3, '设备问题', '3', 'problem_type', null, 'default', 'N', '0', 'admin', '2024-01-26 05:20:41', '', null, null);
INSERT INTO sys_dict_data VALUES (43, 4, '物料问题', '4', 'problem_type', '', 'default', 'N', '0', 'admin', '2024-01-26 05:20:56', 'admin', '2024-01-26 05:21:28', null);
INSERT INTO sys_dict_data VALUES (44, 5, '作业问题', '5', 'problem_type', null, 'default', 'N', '0', 'admin', '2024-01-26 05:21:48', '', null, null);
INSERT INTO sys_dict_data VALUES (45, 6, '其它问题', '6', 'problem_type', null, 'default', 'N', '0', 'admin', '2024-01-26 05:22:14', '', null, null);

INSERT INTO sys_dict_data VALUES (46, 1, '电气测试', '1', 'test_stage', null, 'default', 'N', '0', 'admin', '2024-01-25 16:05:05', 'admin', '2024-01-28 09:48:45', null);
INSERT INTO sys_dict_data VALUES (47, 3, '硬件测试', '3', 'test_stage', null, 'default', 'N', '0', 'admin', '2024-01-25 16:05:06', 'admin', '2024-01-28 09:50:20', null);
INSERT INTO sys_dict_data VALUES (48, 4, '工艺测试', '4', 'test_stage', null, 'default', 'N', '0', 'admin', '2024-01-25 16:05:07', 'admin', '2024-01-28 09:50:56', null);
INSERT INTO sys_dict_data VALUES (49, 2, '软件测试', '2', 'test_stage', null, 'default', 'N', '0', 'admin', '2024-01-26 05:33:18', 'admin', '2024-01-28 09:50:16', null);

INSERT INTO sys_dict_data VALUES (50, 1, '高', '1', 'urgency', null, 'default', 'N', '0', 'admin', '2024-01-25 16:05:07', 'admin', '2024-01-28 09:50:56', null);
INSERT INTO sys_dict_data VALUES (51, 2, '一般', '2', 'urgency', null, '', 'N', '0', 'admin', '2024-01-26 05:33:18', 'admin', '2024-01-28 09:50:16', null);
INSERT INTO sys_dict_data VALUES (54, 3, '低', '3', 'urgency', null, '', 'N', '0', 'admin', '2024-01-26 05:33:18', 'admin', '2024-01-28 09:50:16', null);

INSERT INTO sys_dict_data VALUES (52, 1, '一般', '1', 'critical', null, 'default', 'N', '0', 'admin', '2024-01-25 16:05:07', 'admin', '2024-01-28 09:50:56', null);
INSERT INTO sys_dict_data VALUES (53, 2, '严重', '2', 'critical', null, '', 'N', '0', 'admin', '2024-01-26 05:33:18', 'admin', '2024-01-28 09:50:16', null);

INSERT INTO sys_dict_data VALUES (56, 1, 'Triton40', 'Triton40', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:41:27', 'admin', NULL, NULL);
INSERT INTO sys_dict_data VALUES (57, 2, 'Triton160', 'Triton160', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (58, 3, 'VirgoA', 'VirgoA', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (59, 4, 'VirgoB', 'VirgoB', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (60, 5, 'HESTIA', 'HESTIA', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (61, 6, 'Virgo', 'Virgo', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (62, 7, 'TRITON', 'TRITON', 'device_type', NULL, 'default', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);

INSERT INTO sys_dict_data VALUES (63, 0, '查询', '10', 'sys_oper_type', NULL, 'info', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);
INSERT INTO sys_dict_data VALUES (64, 0, '提交', '11', 'sys_oper_type', NULL, 'info', 'N', '0', 'admin', '2024-03-07 09:42:01', '', NULL, NULL);

-- ----------------------------
-- 13、参数配置表
-- ----------------------------
drop table if exists sys_config;
create table sys_config (
  config_id         int(5)          not null auto_increment    comment '参数主键',
  config_name       varchar(100)    default ''                 comment '参数名称',
  config_key        varchar(100)    default ''                 comment '参数键名',
  config_value      varchar(500)    default ''                 comment '参数键值',
  config_type       char(1)         default 'N'                comment '系统内置（Y是 N否）',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time       datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  remark            varchar(500)    default null               comment '备注',
  primary key (config_id)
) engine=innodb auto_increment=100 comment = '参数配置表';

insert into sys_config values(1, '主框架页-默认皮肤样式名称',     'sys.index.skinName',            'skin-blue',     'Y', 'admin', sysdate(), '', null, '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow' );
insert into sys_config values(2, '用户管理-账号初始密码',         'sys.user.initPassword',         '123456',        'Y', 'admin', sysdate(), '', null, '初始化密码 123456' );
insert into sys_config values(3, '主框架页-侧边栏主题',           'sys.index.sideTheme',           'theme-dark',    'Y', 'admin', sysdate(), '', null, '深色主题theme-dark，浅色主题theme-light' );
insert into sys_config values(4, '账号自助-验证码开关',           'sys.account.captchaEnabled',    'true',          'Y', 'admin', sysdate(), '', null, '是否开启验证码功能（true开启，false关闭）');
insert into sys_config values(5, '账号自助-是否开启用户注册功能', 'sys.account.registerUser',      'false',         'Y', 'admin', sysdate(), '', null, '是否开启注册用户功能（true开启，false关闭）');
insert into sys_config values(6, '用户登录-黑名单列表',           'sys.login.blackIPList',         '',              'Y', 'admin', sysdate(), '', null, '设置登录IP黑名单限制，多个匹配项以;分隔，支持匹配（*通配、网段）');


-- ----------------------------
-- 14、系统访问记录
-- ----------------------------
drop table if exists sys_logininfor;
create table sys_logininfor (
  info_id        bigint(20)     not null auto_increment   comment '访问ID',
  user_name      varchar(50)    default ''                comment '用户账号',
  ipaddr         varchar(128)   default ''                comment '登录IP地址',
  login_location varchar(255)   default ''                comment '登录地点',
  browser        varchar(50)    default ''                comment '浏览器类型',
  os             varchar(50)    default ''                comment '操作系统',
  status         char(1)        default '0'               comment '登录状态（0成功 1失败）',
  msg            varchar(255)   default ''                comment '提示消息',
  login_time     datetime                                 comment '访问时间',
  primary key (info_id),
  key idx_sys_logininfor_s  (status),
  key idx_sys_logininfor_lt (login_time)
) engine=innodb auto_increment=100 comment = '系统访问记录';


-- ----------------------------
-- 15、定时任务调度表
-- ----------------------------
drop table if exists sys_job;
create table sys_job (
  job_id              bigint(20)    not null auto_increment    comment '任务ID',
  job_name            varchar(64)   default ''                 comment '任务名称',
  job_group           varchar(64)   default 'DEFAULT'          comment '任务组名',
  invoke_target       varchar(500)  not null                   comment '调用目标字符串',
  cron_expression     varchar(255)  default ''                 comment 'cron执行表达式',
  misfire_policy      varchar(20)   default '3'                comment '计划执行错误策略（1立即执行 2执行一次 3放弃执行）',
  concurrent          char(1)       default '1'                comment '是否并发执行（0允许 1禁止）',
  status              char(1)       default '0'                comment '状态（0正常 1暂停）',
  create_by           varchar(64)   default ''                 comment '创建者',
  create_time         datetime                                 comment '创建时间',
  update_by           varchar(64)   default ''                 comment '更新者',
  update_time         datetime                                 comment '更新时间',
  remark              varchar(500)  default ''                 comment '备注信息',
  primary key (job_id, job_name, job_group)
) engine=innodb auto_increment=100 comment = '定时任务调度表';

insert into sys_job values(1, '系统默认（无参）', 'DEFAULT', 'ryTask.ryNoParams',        '0/10 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, '');
insert into sys_job values(2, '系统默认（有参）', 'DEFAULT', 'ryTask.ryParams(\'ry\')',  '0/15 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, '');
insert into sys_job values(3, '系统默认（多参）', 'DEFAULT', 'ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)',  '0/20 * * * * ?', '3', '1', '1', 'admin', sysdate(), '', null, '');


-- ----------------------------
-- 16、定时任务调度日志表
-- ----------------------------
drop table if exists sys_job_log;
create table sys_job_log (
  job_log_id          bigint(20)     not null auto_increment    comment '任务日志ID',
  job_name            varchar(64)    not null                   comment '任务名称',
  job_group           varchar(64)    not null                   comment '任务组名',
  invoke_target       varchar(500)   not null                   comment '调用目标字符串',
  job_message         varchar(500)                              comment '日志信息',
  status              char(1)        default '0'                comment '执行状态（0正常 1失败）',
  exception_info      varchar(2000)  default ''                 comment '异常信息',
  create_time         datetime                                  comment '创建时间',
  primary key (job_log_id)
) engine=innodb comment = '定时任务调度日志表';


-- ----------------------------
-- 17、通知公告表
-- ----------------------------
drop table if exists sys_notice;
create table sys_notice (
  notice_id         int(4)          not null auto_increment    comment '公告ID',
  notice_title      varchar(50)     not null                   comment '公告标题',
  notice_type       char(1)         not null                   comment '公告类型（1通知 2公告）',
  notice_content    longblob        default null               comment '公告内容',
  status            char(1)         default '0'                comment '公告状态（0正常 1关闭）',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time       datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  remark            varchar(255)    default null               comment '备注',
  primary key (notice_id)
) engine=innodb auto_increment=10 comment = '通知公告表';

-- ----------------------------
-- 初始化-公告信息表数据
-- ----------------------------

-- ----------------------------
-- 18、代码生成业务表
-- ----------------------------
drop table if exists gen_table;
create table gen_table (
  table_id          bigint(20)      not null auto_increment    comment '编号',
  table_name        varchar(200)    default ''                 comment '表名称',
  table_comment     varchar(500)    default ''                 comment '表描述',
  sub_table_name    varchar(64)     default null               comment '关联子表的表名',
  sub_table_fk_name varchar(64)     default null               comment '子表关联的外键名',
  class_name        varchar(100)    default ''                 comment '实体类名称',
  tpl_category      varchar(200)    default 'crud'             comment '使用的模板（crud单表操作 tree树表操作）',
  tpl_web_type      varchar(30)     default ''                 comment '前端模板类型（element-ui模版 element-plus模版）',
  package_name      varchar(100)                               comment '生成包路径',
  module_name       varchar(30)                                comment '生成模块名',
  business_name     varchar(30)                                comment '生成业务名',
  function_name     varchar(50)                                comment '生成功能名',
  function_author   varchar(50)                                comment '生成功能作者',
  gen_type          char(1)         default '0'                comment '生成代码方式（0zip压缩包 1自定义路径）',
  gen_path          varchar(200)    default '/'                comment '生成路径（不填默认项目路径）',
  options           varchar(1000)                              comment '其它生成选项',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  remark            varchar(500)    default null               comment '备注',
  primary key (table_id)
) engine=innodb auto_increment=1 comment = '代码生成业务表';


-- ----------------------------
-- 19、代码生成业务表字段
-- ----------------------------
drop table if exists gen_table_column;
create table gen_table_column (
  column_id         bigint(20)      not null auto_increment    comment '编号',
  table_id          bigint(20)                                 comment '归属表编号',
  column_name       varchar(200)                               comment '列名称',
  column_comment    varchar(500)                               comment '列描述',
  column_type       varchar(100)                               comment '列类型',
  java_type         varchar(500)                               comment 'JAVA类型',
  java_field        varchar(200)                               comment 'JAVA字段名',
  is_pk             char(1)                                    comment '是否主键（1是）',
  is_increment      char(1)                                    comment '是否自增（1是）',
  is_required       char(1)                                    comment '是否必填（1是）',
  is_insert         char(1)                                    comment '是否为插入字段（1是）',
  is_edit           char(1)                                    comment '是否编辑字段（1是）',
  is_list           char(1)                                    comment '是否列表字段（1是）',
  is_query          char(1)                                    comment '是否查询字段（1是）',
  query_type        varchar(200)    default 'EQ'               comment '查询方式（等于、不等于、大于、小于、范围）',
  html_type         varchar(200)                               comment '显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',
  dict_type         varchar(200)    default ''                 comment '字典类型',
  sort              int                                        comment '排序',
  create_by         varchar(64)     default ''                 comment '创建者',
  create_time 	    datetime                                   comment '创建时间',
  update_by         varchar(64)     default ''                 comment '更新者',
  update_time       datetime                                   comment '更新时间',
  primary key (column_id)
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';

-- ----------------------------
-- 1、设备表
-- ----------------------------
drop table if exists `jetplasma_device`;
create table `jetplasma_device` (
  `id`            bigint(20)  not null AUTO_INCREMENT primary key comment '设备ID',
  `device_no`     varchar(20) NOT NULL COMMENT '设备编号',
  `name`          varchar(50) NOT NULL COMMENT '设备名称',
  `proj_number`   varchar(30) COMMENT '项目号',
  `order_no`      varchar(20) COMMENT '订单编号',
  `customer_name` varchar(50) COMMENT '客户名称',
  `serial_number` varchar(30) COMMENT '序列号',
  `create_user`   varchar(30) NOT NULL COMMENT '录入人员',
  `delivery_date` varchar(10) NOT NULL COMMENT '交付日期',
  `planned_date` varchar(10) COMMENT '计划交付日期',
  `acceptance_date` varchar(10) COMMENT '验收日期',
  `maintain_date` varchar(10) COMMENT '维保日期',
  `maintain_start` varchar(10) COMMENT '维保开始日期',
  `maintain_end` varchar(10) COMMENT '维保结束日期',
  `device_type` varchar(10) COMMENT '设备类型',
  `attach_first` varchar(100) COMMENT '技术协议',
  `attach_inventory` varchar(100) COMMENT '核心物料清单',
  `attach_receipt` varchar(100) COMMENT '验收单',
  `status`      int(2) NOT NULL COMMENT '设备状态, 1: 录入， 2: 安装， 3: 验收前， 4：验收后， 5：过保  -1:作废',
  `in_approve` bigint(20) COMMENT '审核状态： 1：创建  2：审批中  3:审批不通过 4.审批通过',
  `approve_type` bigint(20) COMMENT '在途审核类型',
  `create_at`   timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = '设备表';
-- ----------------------------
-- 1、核心物料清单
-- ----------------------------
drop table if exists `jetplasma_device_list`;
create table `jetplasma_device_list` (
  `id`            bigint(20)  not null AUTO_INCREMENT primary key comment '设备ID',
  `device_id`     bigint(20) NOT NULL COMMENT '设备编号',
  `sntrace`          varchar(50) NOT NULL COMMENT 'S/N序列号',
  `comp_number`          varchar(50) NOT NULL COMMENT '部件编号',
  `name`          varchar(50) NOT NULL COMMENT '名称',
  `number`      varchar(20) COMMENT '数量',
  `sn1` varchar(50) COMMENT 'sn1',
  `sn2` varchar(50) COMMENT 'sn2',
  `sn3` varchar(50) COMMENT 'sn3',
  `sn4` varchar(50) COMMENT 'sn4',
   `remark` varchar(50) COMMENT '备注'
) engine=innodb comment = '设备核心物料清单';

-- 审核相关表
-- ----------------------------
-- 1、审核主表
-- ----------------------------

drop table if exists `app_flow`;
create table `app_flow` (
  `id`            bigint(20)      not null auto_increment primary key comment '审核ID',
  `name`     varchar(20) NOT NULL COMMENT '审核流程名称',
  `create_at`     timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = '审核流类型表';
insert into app_flow (id, name) values(1,  '设备录入审核');
insert into app_flow (id, name)  values(2,  '核心物料清单审核');
insert into app_flow (id, name)  values(3,  '验收单审核');
INSERT INTO app_flow (id, name) VALUES (4, 'CIP验证报告审核');
INSERT INTO app_flow (id, name) VALUES (5, '缺陷发货审核');



drop table if exists `app_master`;
create table `app_master` (
  `id`            bigint(20)      not null auto_increment primary key comment '审核ID',
  `importance_id`     bigint(20) NOT NULL COMMENT '重要审核ID',
  `device_id`     bigint(20) NOT NULL COMMENT '设备编号',
  `cip_id`        bigint(20)  COMMENT '设备编号',
  `problem_id`    bigint(20)  COMMENT '问题编号',
  `app_flow_id`   bigint(20) NOT NULL COMMENT '审核流ID',
  `status`        int(1) NOT NULL COMMENT '审核状态，1 - 审核中，2 - 审核通过 3 - 审核不通过',
  `approver`  bigint(20) NOT NULL COMMENT '当前审核人',
  `create_user` bigint(20) NOT NULL COMMENT '提交人',
  `create_at`     timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = '审核主表';


DROP TABLE IF EXISTS `jetplasma_device_attachment`;
CREATE TABLE `jetplasma_device_attachment`  (
   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
   `device_id` bigint(20) NULL DEFAULT NULL COMMENT '产品id',
   `files_type` varchar(50)  NULL DEFAULT NULL COMMENT '文件类型',
   `files_url` varchar(200)  NULL DEFAULT NULL COMMENT '文件路径',
   `creat_time` varchar(50)  NULL DEFAULT NULL COMMENT '创建时间',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  COMMENT = '产品附件表';


DROP TABLE IF EXISTS `approve_importance`;
CREATE TABLE `approve_importance`  (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,
   `is_countersign` int(2) NULL DEFAULT NULL COMMENT '流程是否为指定性审核，1-是指定的 ；2非指定的',
   `is_appoint` int(2) NULL DEFAULT NULL COMMENT '是否已指定下一审批人 ， 1-指定 ；2未指定',
   `is_end` int(2) NULL DEFAULT NULL COMMENT '是否流程已结束，1-已结束；2未结束',
   `user_organize` varchar(255)  NULL DEFAULT NULL COMMENT '下一阶段审批人',
   PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB  COMMENT = '审批信息主表' ;



drop table if exists `app_approver`;
create table `app_approver` (
  `id`            bigint(20)      not null auto_increment primary key comment '审核ID',
  `app_flow_id`      bigint(20) NOT NULL COMMENT '审核流ID',
  `user_id`     varchar(50) NOT NULL COMMENT '岗位审核人ID',
  `seq`         int(2) NOT NULL COMMENT '序号',
  `create_at`   timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = '审核人';

drop table if exists app_approve_history;
create table `app_approve_history` (
  `id`            bigint(20)      not null auto_increment primary key comment '审核意见ID',
  `app_id`            bigint(20)      not null  comment '审核主表ID',
  `result`     varchar(20) NOT NULL COMMENT '审核结果：TRUE - 审核通过，FALSE - 拒绝',
  `remark` varchar(20) COMMENT '备注',
  `create_user` bigint(20) NOT NULL COMMENT '审核人',
  `create_at`   timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) engine=innodb comment = '审核意见表';


drop table if exists `jetplasma_device_problem_install`;
create table `jetplasma_device_problem_install` (
  `id`            bigint(20)      not null auto_increment primary key comment '问题ID',
  `pro_no`     varchar(50) COMMENT '问题编号',
  `device_id`     bigint(20)      not null  comment '设备ID',
  `type` varchar(20) NOT NULL COMMENT '问题类型',
  `depart_id` bigint(20) NOT NULL COMMENT '提出部门',
  `user_id` bigint(20) NOT NULL COMMENT '提出人',
  `principal` bigint(20) NOT NULL COMMENT '负责人',
  `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `complete_date` datetime COMMENT '实际完成日期',
  `subject` varchar(50) null comment '主题',
  `description` longtext NOT NULL COMMENT '问题描述',
  `reply_date` varchar(12) COMMENT '回复日期',
  `status` int(1) COMMENT '状态,1 - 待处理, 2 - 已解决, 3 - 关闭,4 - 审核中,5 - 审核不通过，6-审核通过',

  `module_type`     varchar(20) COMMENT '所属模块',

  `remark` varchar(20) COMMENT '备注'
) engine=innodb comment = '设备组装问题登记表';


drop table if exists `jetplasma_device_problem_test`;
create table `jetplasma_device_problem_test` (
  `id`            bigint(20)      not null auto_increment primary key comment '问题ID',
  `pro_no`     varchar(50) COMMENT '问题编号',
  `device_id`     bigint(20)      not null  comment '设备ID',
  `type` varchar(20) NOT NULL COMMENT '问题类型',
  `depart_id` bigint(20) NOT NULL COMMENT '提出部门',
  `user_id` bigint(20) NOT NULL COMMENT '提出人',
  `principal` bigint(20) NOT NULL COMMENT '负责人',
  `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `complete_date` datetime COMMENT '实际完成日期',
  `subject` varchar(50) null comment '主题',
  `description` longtext NOT NULL COMMENT '问题描述',
  `reply_date` varchar(12) COMMENT '回复日期',
  `status` int(1) COMMENT '状态,1 - 待处理, 2 - 已解决, 3 - 关闭',

  `test_stage` varchar(8) COMMENT '测试阶段',
  `test_version` varchar(8) COMMENT '测试软件版本',
  `plc_version` varchar(8) COMMENT 'PLC程序版本',
  `system_version` varchar(8) COMMENT '系统版本',
  `esd_version` varchar(8) COMMENT '电气原理图版本',
  `test_result` varchar(8) COMMENT '测试结果',
  `test_report` varchar(100) COMMENT '测试报告',

  `remark` varchar(20) COMMENT '备注'
) engine=innodb comment = '设备测试问题登记表';


drop table if exists `jetplasma_device_problem_check`;
create table `jetplasma_device_problem_check` (
  `id`            bigint(20)      not null auto_increment primary key comment '问题ID',
  `pro_no`     varchar(50) COMMENT '问题编号',
  `device_id`     bigint(20)      not null  comment '设备ID',
  `type` varchar(20) NOT NULL COMMENT '问题类型',
  `depart_id` bigint(20) NOT NULL COMMENT '提出部门',
  `user_id` bigint(20) NOT NULL COMMENT '提出人',
  `principal` bigint(20) NOT NULL COMMENT '负责人',
  `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `complete_date` datetime COMMENT '实际完成日期',
  `subject` varchar(50) null comment '主题',
  `description` longtext NOT NULL COMMENT '问题描述',
  `reply_date` varchar(12) COMMENT '回复日期',
  `status` int(1) COMMENT '状态,1 - 待处理, 2 - 已解决, 3 - 关闭',


  `check_stage` varchar(3) null comment '验收阶段',
  `device_status` varchar(8) null comment '设备状态',

  `remark` varchar(20) COMMENT '备注'
) engine=innodb comment = '设备组装问题登记表';

drop table if exists `jetplasma_device_problem_sale`;
create table `jetplasma_device_problem_sale` (
  `id`            bigint(20)      not null auto_increment primary key comment '问题ID',
  `pro_no`     varchar(50) COMMENT '问题编号',
  `device_id`     bigint(20)      not null  comment '设备ID',
  `type` varchar(20) NOT NULL COMMENT '问题类型',
  `depart_id` bigint(20) NOT NULL COMMENT '提出部门',
  `user_id` bigint(20) NOT NULL COMMENT '提出人',
  `principal` bigint(20) NOT NULL COMMENT '负责人',
  `create_at`   datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `complete_date` datetime COMMENT '实际完成日期',
  `subject` varchar(50) null comment '主题',
  `description` longtext NOT NULL COMMENT '问题描述',
  `reply_date` varchar(12) COMMENT '回复日期',
  `status` int(1) COMMENT '状态,1 - 待处理, 2 - 已解决, 3 - 关闭',

  `device_status` varchar(8) null comment '设备状态',
  `urgency` varchar(20) null comment '紧急程度',
  `critical` varchar(20) null comment '严重程度',
  `expect_date` varchar(12) COMMENT '期望完成日期',
  `remark` varchar(20) COMMENT '备注'
) engine=innodb comment = '设备售后问题登记表';

drop table if exists jetplasma_device_problem_reply;
create table `jetplasma_device_problem_reply` (
  `id`            bigint(20)      not null auto_increment primary key comment '审核意见ID',
  `pro_id`            bigint(20)      not null  comment '问题',
  `type`            varchar(10)      not null  comment '类型',
  `reply`     longtext  COMMENT '解决方案',
  `reply_user`     bigint(20) COMMENT '回复人',
  `attachment`   varchar(100) COMMENT '附件',
  `reply_date`   timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '回复日期'
) engine=innodb comment = '设备问题登记表';


alter table jetplasma_device add extended_date varchar(60) null comment '延保日期' after maintain_date;

drop table if exists `jetplasma_device_component`;
CREATE TABLE `jetplasma_device_component` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '设备ID',
  `device_id` bigint(20) NOT NULL COMMENT '设备编号',
  `sntrace` varchar(50) NOT NULL COMMENT 'S/N序列号',
  `comp_number` varchar(50) NOT NULL COMMENT '部件编号',
  `name` varchar(50) NOT NULL COMMENT '名称',
  `number` varchar(20) DEFAULT NULL COMMENT '数量',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备核心物料清单';

drop table if exists `jetplasma_device_sn`;
CREATE TABLE `jetplasma_device_sn` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'SN_ID',
  `component_id` bigint(20) NOT NULL COMMENT '部件ID',
  `device_id` bigint(20) NOT NULL COMMENT '设备ID',
  `sn_name` varchar(50) DEFAULT NULL COMMENT 'SN名称',
  `sn_value` varchar(50) DEFAULT NULL COMMENT 'SN值',
  `remark` varchar(50) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备部件SN列表';


alter table jetplasma_device_problem_install add deliver_status varchar(2) null comment '缺陷发货 0 - 是, 1 - 否' after status;
alter table jetplasma_device_problem_install add station varchar(20) null comment '工位' after deliver_status;

drop table if exists `jetplasma_cip`;
CREATE TABLE `jetplasma_cip` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'CIP唯一ID',
  `no` varchar(20) NOT NULL COMMENT '编号',
  `subject` varchar(200) NOT NULL COMMENT '主题',
  `description` longtext NOT NULL COMMENT '描述',
  `verify_result` varchar(1) DEFAULT NULL COMMENT '验证结果：N - 不通过，Y: 通过',
  `status` varchar(1) DEFAULT NULL COMMENT '状态：1 - 创建, 2 - 审核中, 3 - 审核通过, 4 - 审核不通过',
  `report` varchar(200) DEFAULT NULL COMMENT '验证报告',
  create_at timestamp default current_timestamp,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CIP申请';

alter table app_master
    modify device_id varchar(20) null comment '设备编号';

drop table if exists `jetplasma_cip_exec`;
CREATE TABLE `jetplasma_cip_exec` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '执行ID',
  `cip_id` bigint(20) NOT NULL COMMENT 'CIP唯一标识',
  `cip_no` varchar(20) NOT NULL COMMENT 'CIP编号',
  `description` longtext NOT NULL COMMENT '执行过程描述',
  `attachment` varchar(200) DEFAULT NULL COMMENT '上传附件',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='CIP申请';
drop table if exists `jetplasma_cip_exec_device_rel`;
CREATE TABLE `jetplasma_cip_exec_device_rel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '执行ID',
  `exec_id` bigint(20) NOT NULL COMMENT 'CIP执行唯一标识',
  `device_id` bigint(20) NOT NULL COMMENT '设备ID',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='执行与设备关联关系';


-- ----------------------------
-- 附件下载历史表
-- ----------------------------
drop table if exists jetplasma_download_hist;
create table jetplasma_download_hist (
  id           bigint(20)      not null auto_increment    comment '日志主键',
  file_name    varchar(200) not null comment '下载文件名',
  device_id bigint(20) not null comment '设备ID',
  device_no varchar(20) not null comment '设备编号',
  device_name varchar(20) not null comment '设备名称',
  user_name    varchar(50)    default ''                comment '用户账号',
  ipaddr       varchar(128)   default ''                comment '登录IP地址',
  location     varchar(255)   default ''                comment '登录地点',
  browser      varchar(50)    default ''                comment '浏览器类型',
  os           varchar(50)    default ''                comment '操作系统',
  download_time     datetime    default current_timestamp comment '下载时间',
  primary key (id)
) engine=innodb comment = '附件下载历史表';


alter table app_flow
    add redirable boolean null comment '是否允许指定下一审批人' after name;

alter table app_master
    modify approver bigint null comment '当前审核人';

ALTER TABLE jetplasma_device_problem_sale MODIFY COLUMN expect_date datetime COMMENT '期望完成日期' DEFAULT NULL;
ALTER TABLE jetplasma_device_problem_check MODIFY COLUMN CREATE_AT DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE jetplasma_device_problem_install MODIFY COLUMN CREATE_AT DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE jetplasma_device_problem_test MODIFY COLUMN CREATE_AT DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE jetplasma_device_problem_sale MODIFY COLUMN CREATE_AT DATETIME DEFAULT CURRENT_TIMESTAMP;



drop view if exists jetplasma_device_problem_all;
CREATE VIEW jetplasma_device_problem_all AS
select pro_no, device_id, type, subject, depart_id, user_id, principal, create_at, complete_date, status, null as expect_date, "install" as pro_type from jetplasma_device_problem_install union all
select pro_no, device_id, type, subject, depart_id, user_id, principal, create_at, complete_date, status, null as expect_date, "test" as pro_type from jetplasma_device_problem_test union all
select pro_no, device_id, type, subject, depart_id, user_id, principal, create_at, complete_date, status, null as expect_date, "check" as pro_type from jetplasma_device_problem_check union all
select pro_no, device_id, type, subject, depart_id, user_id, principal, create_at, complete_date, status, expect_date,  "sale" as pro_type from jetplasma_device_problem_sale;


-- ----------------------------
-- 设备类型与用户的权限配置表
-- ----------------------------
drop table if exists jetplasma_device_user;
create table jetplasma_device_user (
  id           bigint(20)      not null auto_increment    comment '日志主键',
  user_id    bigint(20) not null comment '用户ID',
  device_type varchar(20) not null comment '设备类型',
  primary key (id)
) engine=innodb comment = '设备类型与用户的权限配置表';

-- 修改test问题中软件版本长度过长的问题
ALTER TABLE jetplasma_device_problem_test
  MODIFY test_stage varchar(50) COMMENT '测试阶段',
  MODIFY test_version varchar(50) COMMENT '测试软件版本',
  MODIFY plc_version varchar(50) COMMENT 'PLC程序版本',
  MODIFY system_version varchar(50) COMMENT '系统版本',
  MODIFY esd_version varchar(50) COMMENT '电气原理图版本',
  MODIFY test_result varchar(50) COMMENT '测试结果',
  MODIFY remark varchar(200) COMMENT '备注';


-- ----------------------------
-- 设备问题表case_id自增 20240407
-- ----------------------------

ALTER TABLE jetplasma_device_problem_check ADD case_id varchar(6) COMMENT '问题自增序列号';
ALTER TABLE jetplasma_device_problem_install ADD case_id varchar(6) COMMENT '问题自增序列号';
ALTER TABLE jetplasma_device_problem_reply ADD case_id varchar(6) COMMENT '问题自增序列号';
ALTER TABLE jetplasma_device_problem_sale ADD case_id varchar(6) COMMENT '问题自增序列号';
ALTER TABLE jetplasma_device_problem_test ADD case_id varchar(6) COMMENT '问题自增序列号';


-- ----------------------------
-- 修改残件管理信息
-- ----------------------------
UPDATE `app_flow` SET `name` = '残件信息审核' WHERE `id` = 5;


-- ----------------------------
-- 审批表增加业务id字段
-- ----------------------------
ALTER TABLE app_master ADD business_id varchar(50) COMMENT '业务id';

-- ----------------------------
-- 创建残件管理表
-- ----------------------------
drop table if exists jetplasma_device_defect;
CREATE TABLE `jetplasma_device_defect`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `serial_number` bigint NOT NULL COMMENT '序号',
  `materiel_no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL COMMENT '物料编码',
  `materiel_desc` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '物料描述',
  `quantity` bigint NULL DEFAULT NULL COMMENT '数量',
  `delivery_date` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '交期',
  `principal` bigint NULL DEFAULT NULL COMMENT '负责人',
  `pro_no` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '问题编号',
  `pro_table` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '问题表名',
	`device_id` bigint COMMENT '设备ID',
	`approve_status` int COMMENT '状态,1 - 待处理, 2 - 已解决, 3 - 关闭,4 - 审核中,5 - 审核不通过，6-审核通过',
  PRIMARY KEY (`id`) USING BTREE
)  engine=innodb comment = '设备残件管理表';

-- ----------------------------
-- 对视图增加case_id字段
-- ----------------------------
ALTER VIEW jetplasma_device_problem_all AS select `jetplasma_device_problem_install`.`pro_no` AS `pro_no`,`jetplasma_device_problem_install`.`device_id` AS `device_id`,`jetplasma_device_problem_install`.`type` AS `type`,`jetplasma_device_problem_install`.`subject` AS `subject`,`jetplasma_device_problem_install`.`depart_id` AS `depart_id`,`jetplasma_device_problem_install`.`user_id` AS `user_id`,`jetplasma_device_problem_install`.`principal` AS `principal`,`jetplasma_device_problem_install`.`CREATE_AT` AS `create_at`,`jetplasma_device_problem_install`.`complete_date` AS `complete_date`,`jetplasma_device_problem_install`.`status` AS `status`,NULL AS `expect_date`,'install' AS `pro_type`,`jetplasma_device_problem_install`.`case_id` AS `case_id` from `jetplasma_device_problem_install` union all select `jetplasma_device_problem_test`.`pro_no` AS `pro_no`,`jetplasma_device_problem_test`.`device_id` AS `device_id`,`jetplasma_device_problem_test`.`type` AS `type`,`jetplasma_device_problem_test`.`subject` AS `subject`,`jetplasma_device_problem_test`.`depart_id` AS `depart_id`,`jetplasma_device_problem_test`.`user_id` AS `user_id`,`jetplasma_device_problem_test`.`principal` AS `principal`,`jetplasma_device_problem_test`.`CREATE_AT` AS `create_at`,`jetplasma_device_problem_test`.`complete_date` AS `complete_date`,`jetplasma_device_problem_test`.`status` AS `status`,NULL AS `expect_date`,'test' AS `pro_type`,`jetplasma_device_problem_test`.`case_id` AS `case_id` from `jetplasma_device_problem_test` union all select `jetplasma_device_problem_check`.`pro_no` AS `pro_no`,`jetplasma_device_problem_check`.`device_id` AS `device_id`,`jetplasma_device_problem_check`.`type` AS `type`,`jetplasma_device_problem_check`.`subject` AS `subject`,`jetplasma_device_problem_check`.`depart_id` AS `depart_id`,`jetplasma_device_problem_check`.`user_id` AS `user_id`,`jetplasma_device_problem_check`.`principal` AS `principal`,`jetplasma_device_problem_check`.`CREATE_AT` AS `create_at`,`jetplasma_device_problem_check`.`complete_date` AS `complete_date`,`jetplasma_device_problem_check`.`status` AS `status`,NULL AS `expect_date`,'check' AS `pro_type`,`jetplasma_device_problem_check`.`case_id` AS `case_id` from `jetplasma_device_problem_check` union all select `jetplasma_device_problem_sale`.`pro_no` AS `pro_no`,`jetplasma_device_problem_sale`.`device_id` AS `device_id`,`jetplasma_device_problem_sale`.`type` AS `type`,`jetplasma_device_problem_sale`.`subject` AS `subject`,`jetplasma_device_problem_sale`.`depart_id` AS `depart_id`,`jetplasma_device_problem_sale`.`user_id` AS `user_id`,`jetplasma_device_problem_sale`.`principal` AS `principal`,`jetplasma_device_problem_sale`.`CREATE_AT` AS `create_at`,`jetplasma_device_problem_sale`.`complete_date` AS `complete_date`,`jetplasma_device_problem_sale`.`status` AS `status`,`jetplasma_device_problem_sale`.`expect_date` AS `expect_date`,'sale' AS `pro_type`,`jetplasma_device_problem_sale`.`case_id` AS `case_id` from `jetplasma_device_problem_sale`


-- ----------------------------
-- 设备问题表增加description_files问题描述附件字段 20240419
-- ----------------------------
ALTER TABLE jetplasma_device_problem_check ADD description_files varchar(1000) COMMENT '问题描述附件';
ALTER TABLE jetplasma_device_problem_install ADD description_files varchar(1000) COMMENT '问题描述附件';
ALTER TABLE jetplasma_device_problem_sale ADD description_files varchar(1000) COMMENT '问题描述附件';
ALTER TABLE jetplasma_device_problem_test ADD description_files varchar(1000) COMMENT '问题描述附件';
