DROP TABLE IF EXISTS yfsjglpt_common_parameter;
CREATE TABLE yfsjglpt_common_parameter (
    `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
    `common_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用名称',
    `common_type` int COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用类型',
    `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户ID',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='常用参数表';

DROP TABLE IF EXISTS yfsjglpt_model_common_parameters;
-- 新增机型参数常用参数表
CREATE TABLE yfsjglpt_model_common_parameters (
    `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
    `parameter_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数ID',
    `common_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用id',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='机型参数常用参数表';

DROP TABLE IF EXISTS yfsjglpt_analysis_common_parameters;
-- 新增分析常用参数表
CREATE TABLE yfsjglpt_analysis_common_parameters (
    `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
    `model_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品型号',
    `plate` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '板块',
    `platform` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '平台',
    `series` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '系列',
    `project_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '项目名称',
    `project_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目编号',
    `emission` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放',
    `displacement_min` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放下限',
    `displacement_max` bigint COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '排放上限',
    `combustion_type` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '燃烧类型',
    `common_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '常用id',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='统计分析常用参数表';


-- 角色表
DROP TABLE IF EXISTS yfsjglpt_model_roles;
CREATE TABLE yfsjglpt_model_roles(
    `id` VARCHAR(64) NOT NULL COMMENT 'ID',
    `role_name` VARCHAR(128) NOT NULL COMMENT '角色名称',
    `role_code` VARCHAR(128) COMMENT '角色代号',
    `role_description` VARCHAR(128) COMMENT '角色描述',
    `is_enabled` INT(128) DEFAULT 1 COMMENT '是否启用',
    `created_by` VARCHAR(64) COMMENT '创建人',
    `creation_date` DATETIME COMMENT '创建时间',
    `last_updated_by` VARCHAR(64) COMMENT '最后更新人',
    `last_update_date` DATETIME COMMENT '最后更新时间',
    PRIMARY KEY (`id`)
) COMMENT '角色表';

-- 菜单权限

DROP TABLE IF EXISTS yfsjglpt_model_menu_dictionary;
CREATE TABLE yfsjglpt_model_menu_dictionary(
    `id` VARCHAR(64) NOT NULL COMMENT 'ID',
    `parent_id` VARCHAR(64) COMMENT '上级ID',
    `menu_name` VARCHAR(64) COMMENT '菜单名称',
    `menu_code` VARCHAR(64) COMMENT '菜单代码',
    `menu_desc` VARCHAR(128) COMMENT '菜单描述',
    `is_enable` INT DEFAULT 1 COMMENT '是否可用',
    `created_by` VARCHAR(64) COMMENT '创建人',
    `creation_date` DATETIME COMMENT '创建时间',
    `last_updated_by` VARCHAR(64) COMMENT '最后更新人',
    `last_update_date` DATETIME COMMENT '最后更新时间',
    PRIMARY KEY (`id`)
) COMMENT '菜单字典表';


-- 菜单参数关联表(权限路径表)
DROP TABLE IF EXISTS yfsjglpt_model_menu_parameter;
CREATE TABLE yfsjglpt_model_menu_parameter(
    `id` VARCHAR(64) NOT NULL COMMENT 'ID',
    `menu_id` VARCHAR(128) COMMENT '菜单ID',
    `subsystem` VARCHAR(64) COMMENT '子系统',
    `parameter_id` VARCHAR(64) COMMENT '参数ID',
    `parameter_per` INT COMMENT '参数权限;1：查看；2：编辑',
    `created_by` VARCHAR(64) COMMENT '创建人',
    `creation_date` DATETIME COMMENT '创建时间',
    `last_updated_by` VARCHAR(64) COMMENT '最后更新人',
    `last_update_date` DATETIME COMMENT '最后更新时间',
    PRIMARY KEY (`id`)
) COMMENT '菜单参数关联表(权限路径表)';

-- 部门或用户关联角色表
DROP TABLE IF EXISTS yfsjglpt_model_dep_user_role;
CREATE TABLE yfsjglpt_model_dep_user_role(
    `id` VARCHAR(64) NOT NULL COMMENT 'ID',
    `user_or_dep` VARCHAR(64) COMMENT '用户或部门ID',
    `role_id` VARCHAR(64) COMMENT '角色ID',
    `is_dep` INT COMMENT '是否是部门;0：个人；1：部门',
    `is_enable` INT COMMENT '是否启用;0：未启用；1：启用',
    `created_by` VARCHAR(64) COMMENT '创建人',
    `creation_date` DATETIME COMMENT '创建时间',
    `last_updated_by` VARCHAR(64) COMMENT '最后更新人',
    `last_update_date` DATETIME COMMENT '最后更新时间',
    PRIMARY KEY (`id`)
) COMMENT '部门或用户关联角色表';


-- 角色权限关联表
DROP TABLE IF EXISTS yc_datasource_0.yfsjglpt_model_role_permission;
CREATE TABLE yc_datasource_0.yfsjglpt_model_role_permission(
    `id` VARCHAR(64) NOT NULL COMMENT 'ID',
    `role_id` VARCHAR(64) COMMENT '角色ID',
    `per_id` VARCHAR(64) COMMENT '权限路径ID',
    `is_enable` INT DEFAULT 1 COMMENT '是否启用;0：未启用；1：启用',
    `created_by` VARCHAR(64) COMMENT '创建人',
    `creation_date` DATETIME COMMENT '创建时间',
    `last_updated_by` VARCHAR(64) COMMENT '最后更新人',
    `last_update_date` DATETIME COMMENT '最后更新时间',
    PRIMARY KEY (`id`)
) COMMENT '角色权限关联表';

DELETE FROM yfsjglpt_model_template;
DELETE FROM yfsjglpt_model_parameter_and_template;
DELETE FROM yfsjglpt_model_parameter;
DELETE FROM yfsjglpt_model_revision_record;
DELETE FROM yfsjglpt_model_benchmarking_report;

DELETE FROM yfsjglpt_model_approval_flow;
DELETE FROM yfsjglpt_model_approval_record;

DELETE FROM yfsjglpt_model_responsible_person;



delete from data_entry_engine_model;
delete from engine_param_detail;
delete from todo_task;
delete from data_change_comment;
delete from approval_config ;
delete from engine_review_list;
delete from param_approval_record;