use kgraph;

DROP TABLE
IF
	EXISTS entity_class;
CREATE TABLE entity_class (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类ID',
	`name` VARCHAR ( 255 ) NULL COMMENT '实体类名称',
	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类描述',
	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类背景颜色',
	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
	create_time datetime NULL COMMENT '创建时间',
	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
	update_time datetime NULL COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类';

DROP TABLE
IF
	EXISTS entity_class_relation;
CREATE TABLE entity_class_relation (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类关系ID',
	`name` VARCHAR ( 255 ) NULL COMMENT '实体类关系名称',
	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类关系描述',
	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类关系背景颜色',
	start_id BIGINT ( 20 ) COMMENT '起点实体类id',
	end_id BIGINT ( 20 ) COMMENT '起点实体类id',
	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
	create_time datetime NULL COMMENT '创建时间',
	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
	update_time datetime NULL COMMENT '更新时间',
PRIMARY KEY ( id )
) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类关系';

DROP TABLE
IF
	EXISTS t_build_entity_relation;
CREATE TABLE t_build_entity_relation (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	sub_task_id BIGINT ( 20 ) COMMENT '子任务id',
	sub_entity_class_id BIGINT ( 20 ) COMMENT '主体实体类id',
	obj_entity_class_id BIGINT ( 20 ) COMMENT '客体实体类id',
	entity_class_rel_id BIGINT ( 20 ) COMMENT '实体类关系id',
	sub_entity VARCHAR ( 511 ) COMMENT '主体',
	obj_entity VARCHAR ( 511 ) 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 = 1 COMMENT = '实体构建表';

DROP TABLE IF EXISTS `t_check_piont`;
CREATE TABLE `t_check_piont`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '序号',
  `code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '编码',
  `check_piont` varchar(1023) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '检查点',
  `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '检查点管理' ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `t_build_flow`;
CREATE TABLE `t_build_flow`  (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '序号',
  `sub_task_id` bigint NULL DEFAULT NULL COMMENT '子任务id',
  `error_appearance` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '故障现象',
  `error_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '故障编码',
  `flow_encode` varchar(1023) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '排故流程数据编码',
  `flow_tree_json` tinytext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '流程树json',
  `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '构建流程' ROW_FORMAT = Dynamic;


DROP TABLE
IF
	EXISTS t_question_record;
CREATE TABLE t_question_record (
	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
	question VARCHAR ( 255 ) DEFAULT '' COMMENT '问题',
	result VARCHAR ( 511 ) 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 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('实体类', '2066', '1', 'class', 'neo4j/class/index', 1, 0, 'C', '0', '0', 'neo4j:class: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', 'neo4j:class: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', 'neo4j:class: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', 'neo4j:class: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', 'neo4j:class: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', 'neo4j:class: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('实体类关系', '2066', '1', 'class_relation', 'neo4j/class_relation/index', 1, 0, 'C', '0', '0', 'neo4j:class_relation: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', 'neo4j:class_relation: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', 'neo4j:class_relation: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', 'neo4j:class_relation: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', 'neo4j:class_relation: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', 'neo4j:class_relation: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('构建流程', '2066', '1', 'flow', 'suport/flow/index', 1, 0, 'C', '0', '0', 'suport:flow: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('检查点管理', '2066', '1', 'piont', 'suport/piont/index', 1, 0, 'C', '0', '0', 'suport:piont: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', 'suport:piont: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', 'suport:piont: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', 'suport:piont: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', 'suport:piont: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', 'suport:piont:export',       '#', 'admin', sysdate(), '', null, '');

-- 子任务数据字典
INSERT INTO `kgraph`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (143, 2, '故障构建', '2', 'extract_sub_task_list', NULL, 'default', 'N', '0', 'admin', '2023-05-23 08:06:49', 'admin', '2023-05-26 02:56:34', NULL);
INSERT INTO `kgraph`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (144, 3, '排故流程构建', '3', 'extract_sub_task_list', NULL, 'default', 'N', '0', 'admin', '2023-05-23 08:07:16', '', NULL, NULL);

commit;