DROP TABLE IF EXISTS `blade_log_error`;
CREATE TABLE `blade_log_error`
(
    `id`             bigint(0)                                                      NOT NULL COMMENT '编号',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT '000000' COMMENT '租户ID',
    `service_id`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '服务ID',
    `server_host`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '服务器名',
    `server_ip`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '服务器IP地址',
    `env`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '系统环境',
    `method`         varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '操作方式',
    `request_uri`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '请求URI',
    `user_agent`     varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户代理',
    `stack_trace`    text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci          NULL COMMENT '堆栈',
    `exception_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '异常名',
    `message`        text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci          NULL COMMENT '异常信息',
    `line_number`    int(0)                                                         NULL DEFAULT NULL COMMENT '错误行数',
    `remote_ip`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '操作IP地址',
    `method_class`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '方法类',
    `file_name`      varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名',
    `method_name`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '方法名',
    `params`         text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci          NULL COMMENT '操作提交的数据',
    `create_by`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '创建者',
    `create_time`    datetime(0)                                                    NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '错误日志表'
  ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `blade_client`;
CREATE TABLE `blade_client`
(
    `id`                      bigint(0)                                                      NOT NULL COMMENT '主键',
    `client_id`               varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NOT NULL COMMENT '客户端id',
    `client_secret`           varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '客户端密钥',
    `resource_ids`            varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '资源集合',
    `scope`                   varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '授权范围',
    `authorized_grant_types`  varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '授权类型',
    `web_server_redirect_uri` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '回调地址',
    `authorities`             varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '权限',
    `access_token_validity`   int(0)                                                         NOT NULL COMMENT '令牌过期秒数',
    `refresh_token_validity`  int(0)                                                         NOT NULL COMMENT '刷新令牌过期秒数',
    `additional_information`  varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '附加说明',
    `autoapprove`             varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '自动授权',
    `create_user`             bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`             bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`             timestamp(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`             bigint(0)                                                      NULL DEFAULT NULL COMMENT '修改人',
    `update_time`             timestamp(0)                                                   NULL DEFAULT NULL COMMENT '修改时间',
    `status`                  int(0)                                                         NOT NULL COMMENT '状态',
    `is_deleted`              int(0)                                                         NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '客户端表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_i18n_data`;
CREATE TABLE `blade_i18n_data`
(
    `id`           bigint(0)                                                     NOT NULL COMMENT '主键',
    `language_tag` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '语言标签',
    `code`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '唯一标识 = 业务:关键词',
    `message`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文本值，可以使用 { } 加角标，作为占位符',
    `remark`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `create_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建人',
    `update_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '修改人',
    `create_time`  datetime(0)                                                   NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
    `update_time`  datetime(0)                                                   NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_tenant`;
CREATE TABLE `blade_tenant`
(
    `id`             bigint(0)                                                      NOT NULL COMMENT '主键',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT '000000' COMMENT '租户ID',
    `tenant_name`    varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NOT NULL COMMENT '租户名称',
    `domain_name`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '域名地址',
    `background_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统背景',
    `linkman`        varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '联系人',
    `contact_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '联系电话',
    `address`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '联系地址',
    `account_number` int(0)                                                         NULL DEFAULT -1 COMMENT '账号额度',
    `expire_time`    timestamp(0)                                                   NULL DEFAULT NULL COMMENT '过期时间',
    `datasource_id`  bigint(0)                                                      NULL DEFAULT NULL COMMENT '数据源ID',
    `license_key`    varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '授权码',
    `create_user`    bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`    bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`    timestamp(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`    bigint(0)                                                      NULL DEFAULT NULL COMMENT '修改人',
    `update_time`    timestamp(0)                                                   NULL DEFAULT NULL COMMENT '修改时间',
    `status`         int(0)                                                         NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`     int(0)                                                         NULL DEFAULT NULL,
    `blade_license`  varchar(3000) COLLATE utf8mb4_general_ci                            DEFAULT NULL COMMENT '单体授权码',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '租户表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_menu`;
CREATE TABLE `blade_menu`
(
    `id`                  bigint(0)                                                     NOT NULL COMMENT '主键',
    `parent_id`           bigint(0)                                                     NULL     DEFAULT 0 COMMENT '父级菜单',
    `code`                varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '菜单编号',
    `name`                varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '菜单名称',
    `alias`               varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '菜单别名',
    `path`                varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '请求地址',
    `source`              varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '菜单资源',
    `sort`                int(0)                                                        NULL     DEFAULT NULL COMMENT '排序',
    `category`            int(0)                                                        NULL     DEFAULT NULL COMMENT '菜单类型',
    `action`              int(0)                                                        NULL     DEFAULT 0 COMMENT '操作按钮类型',
    `is_open`             int(0)                                                        NULL     DEFAULT 1 COMMENT '是否打开新页面',
    `remark`              varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '备注',
    `belong_application`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'CPS' COMMENT '所属应用',
    `keep_alive`          int(4)                                                        NULL     DEFAULT 1 COMMENT '路由缓存 1启用缓冲 0 停用缓冲',
    `is_deleted`          int(0)                                                        NULL     DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '菜单表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_dept`;
CREATE TABLE `blade_dept`
(
    `id`            bigint(0)                                                      NOT NULL COMMENT '主键',
    `tenant_id`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT '000000' COMMENT '租户ID',
    `parent_id`     bigint(0)                                                      NULL DEFAULT 0 COMMENT '父主键',
    `ancestors`     varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '祖级列表',
    `dept_category` int(0)                                                         NULL DEFAULT NULL COMMENT '部门类型',
    `dept_name`     varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '部门名',
    `full_name`     varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '部门全称',
    `sort`          int(0)                                                         NULL DEFAULT NULL COMMENT '排序',
    `remark`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '备注',
    `is_deleted`    int(0)                                                         NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '机构表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_user`;
CREATE TABLE `blade_user`
(
    `id`                 bigint(0)                                                      NOT NULL COMMENT '主键',
    `tenant_id`          varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT '000000' COMMENT '租户ID',
    `code`               varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '用户编号',
    `user_type`          int(0)                                                         NULL DEFAULT NULL COMMENT '用户平台',
    `account`            varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '账号',
    `password`           varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '密码',
    `name`               varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '昵称',
    `real_name`          varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '真名',
    `avatar`             varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '头像',
    `email`              varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '邮箱',
    `phone`              varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '手机',
    `birthday`           timestamp(0)                                                   NULL DEFAULT NULL COMMENT '生日',
    `sex`                int(0)                                                         NULL DEFAULT NULL COMMENT '性别',
    `role_id`            varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色id',
    `dept_id`            varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '部门id',
    `post_id`            varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '岗位id',
    `create_user`        bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`        bigint(0)                                                      NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`        timestamp(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`        bigint(0)                                                      NULL DEFAULT NULL COMMENT '修改人',
    `update_time`        timestamp(0)                                                   NULL DEFAULT NULL COMMENT '修改时间',
    `status`             int(0)                                                         NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`         int(0)                                                         NULL DEFAULT 0 COMMENT '是否已删除',
    `pwd_security_level` tinyint(0)                                                     NULL DEFAULT NULL COMMENT '密码安全级别（0初始  1弱 2安全 3很安全）记录当前密码存储时候等级，如果后面更改密码等级时候是否需要强制修改',
    `pwd_update_date`    timestamp(0)                                                   NULL DEFAULT NULL COMMENT '密码最后更新时间',
    `pwd_update_record`  text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci          NULL COMMENT '密码修改记录，每次修改时候记录原密码，以逗号分隔开，防止以后要做不允许输入以往密码',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '用户表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_oss`;
CREATE TABLE `blade_oss`
(
    `id`          bigint(0)                                                     NOT NULL COMMENT '主键',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT '000000' COMMENT '租户ID',
    `category`    int(0)                                                        NULL DEFAULT NULL COMMENT '分类',
    `oss_code`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '资源编号',
    `endpoint`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源地址',
    `access_key`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'accessKey',
    `secret_key`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'secretKey',
    `bucket_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '空间名',
    `app_id`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用ID',
    `region`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地域简称',
    `remark`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `create_user` bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建人',
    `create_dept` bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time` timestamp(0)                                                  NULL DEFAULT NULL COMMENT '创建时间',
    `update_user` bigint(0)                                                     NULL DEFAULT NULL COMMENT '修改人',
    `update_time` timestamp(0)                                                  NULL DEFAULT NULL COMMENT '修改时间',
    `status`      int(0)                                                        NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0)                                                        NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '对象存储表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_common_group`;
CREATE TABLE `blade_common_group`
(
    `id`                   bigint(0)                                                     NOT NULL COMMENT '主键',
    `tenant_id`            varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT '000000' COMMENT
        '租户ID',
    `parent_id`            bigint(0)                                                     NULL     DEFAULT 0 COMMENT '父主键',
    `extend_id`            varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT
        '扩展ID，例如 DMP UUID',
    `code`                 varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT
        '拼接的虚拟路径字符串代码',
    `group_type`           varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '组别,
                对应字典编号',
    `group_category`       tinyint(0)                                                    NULL     DEFAULT NULL COMMENT '组子类，对应字典项',
    `group_tag`            varchar(32)                                                   NULL     DEFAULT NULL COMMENT '工位组标签(fms_beltline,beltline)',
    `name`                 varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '组名',
    `full_name`            varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT
        '组完整名称',
    `sort`                 int(0)                                                        NULL     DEFAULT NULL COMMENT '排序',
    `remark`               varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '备注',
    `is_deleted`           int(0)                                                        NULL     DEFAULT NULL,
    `production_line_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '产线类型：fms_beltline 柔性产线/ beltline 产线',
    `status`               tinyint(4)                                                    NOT NULL DEFAULT 1 COMMENT '业务状态 1启用 0 停用',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '组'
  ROW_FORMAT =
      Dynamic;


DROP TABLE IF EXISTS `blade_interface_config_field`;
CREATE TABLE `blade_interface_config_field`
(
    `id`               bigint(0)                                                     NOT NULL,
    `status`           int(0)                                                        NOT NULL DEFAULT 1 COMMENT '业务状态',
    `is_deleted`       bigint(0) UNSIGNED                                            NULL     DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`      bigint(0)                                                     NULL     DEFAULT NULL COMMENT '创建人',
    `create_dept`      bigint(0)                                                     NULL     DEFAULT NULL COMMENT '创建部门',
    `create_time`      datetime(0)                                                   NULL     DEFAULT NULL COMMENT '创建时间',
    `update_user`      bigint(0)                                                     NULL     DEFAULT NULL COMMENT '更新人',
    `update_time`      datetime(0)                                                   NULL     DEFAULT NULL COMMENT '更新时间',
    `config_id`        bigint(0)                                                     NOT NULL COMMENT '接口配置id',
    `label`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '字段标题',
    `name`             varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '字段名称',
    `is_required`      tinyint(0)                                                    NOT NULL DEFAULT 0 COMMENT '是否必填： 0 - 不必填；1 - 必填',
    `data_type`        int(0)                                                        NOT NULL COMMENT '0-文本；1-数值；2-下拉；3-日期； 4-树选择',
    `data_source`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '当数据类型是下拉，树选择的时候指定数据源的地址。用于获取这些选项的数据。',
    `is_single_choice` tinyint(1)                                                    NULL     DEFAULT 0 COMMENT '当下拉选择的时候指定是否单选：- 0 多选； 1 - 单选',
    `checked_parent`   tinyint(1)                                                    NULL     DEFAULT NULL COMMENT '树选择的情况下是否可选择父节点',
    `relation_field`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '依赖字段',
    `method`           varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL     DEFAULT NULL COMMENT '请求方法',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '接口字段表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_interface_config`;
CREATE TABLE `blade_interface_config`
(
    `id`           bigint(0)                                                     NOT NULL,
    `status`       tinyint(0)                                                    NULL DEFAULT 1 COMMENT '业务状态 1启用 0 停用',
    `is_deleted`   bigint(0) UNSIGNED                                            NULL DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`  bigint(0)                                                     NULL DEFAULT NULL COMMENT '更新人',
    `update_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `url`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '接口url',
    `url_name`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '接口中文名',
    `url_type`     int(0)                                                        NOT NULL COMMENT '接口类型 0 - POST； 1 - PUT； 2 - GET',
    `owning_chart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '1图表类型 bar-柱状 line-折线图 pie-饼图 GanttChart 甘特图 table-表格',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '接口配置表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_visual`;
CREATE TABLE `blade_visual`
(
    `id`             bigint(0)                                                     NOT NULL COMMENT '主键',
    `title`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '大屏标题',
    `background_url` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci     NULL COMMENT '大屏背景',
    `category`       int(0)                                                        NULL DEFAULT NULL COMMENT '大屏类型',
    `password`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发布密码',
    `create_user`    bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`    bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`    bigint(0)                                                     NULL DEFAULT NULL COMMENT '修改人',
    `update_time`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '修改时间',
    `status`         int(0)                                                        NOT NULL COMMENT '状态',
    `is_deleted`     int(0)                                                        NULL DEFAULT NULL,
    `group_name`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '大屏分组名称',
    `group_index`    int(0)                                                        NULL DEFAULT NULL COMMENT '大屏分组顺序',
    `sliding_second` int(0)                                                        NULL DEFAULT NULL COMMENT '大屏轮播间隔',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci COMMENT = '可视化表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_param`;
CREATE TABLE `blade_param`
(
    `id`          bigint(0)                                                     NOT NULL COMMENT '主键',
    `param_name`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数名',
    `param_key`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数键',
    `param_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数值',
    `remark`      varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `create_user` bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建人',
    `create_dept` bigint(0)                                                     NULL DEFAULT NULL COMMENT '创建部门',
    `create_time` timestamp(0)                                                  NULL DEFAULT NULL COMMENT '创建时间',
    `update_user` bigint(0)                                                     NULL DEFAULT NULL COMMENT '修改人',
    `update_time` timestamp(0)                                                  NULL DEFAULT NULL COMMENT '修改时间',
    `status`      int(0)                                                        NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0)                                                        NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '参数表'
  ROW_FORMAT = Dynamic;

-- 添加应用列表
DROP TABLE IF EXISTS `blade_application`;
CREATE TABLE `blade_application`
(
    `id`             bigint(20)                                                     NOT NULL,
    `name`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '应用名称',
    `code`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '应用标识',
    `logo`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '应用Logo',
    `background_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用系统背景',
    `domain_url`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '访问域名或地址',
    `is_default`     tinyint(255)                                                   NULL DEFAULT NULL COMMENT '是否默认应用',
    `is_show`        tinyint(2)                                                     NULL DEFAULT '2' COMMENT '是否显示 1显示 2关闭',
    `sort`           int(11)                                                        NULL DEFAULT NULL COMMENT '排序',
    `remark`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '备注',
    `is_deleted`     int(11)                                                        NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

-- 第三方应用配置
DROP TABLE IF EXISTS `blade_outer_app_config`;
CREATE TABLE `blade_outer_app_config`
(
    `id`                  bigint(20)                                                    NOT NULL,
    `wx_corp_id`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信企业corpId',
    `wx_app_secret`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信应用secret',
    `wx_book_secret`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信通讯录secret',
    `wx_callback_token`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信回调配置token',
    `wx_agent_id`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信应用的AgentId',
    `wx_aes_key`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '企业微信回调配置加解密aes_key',
    `ding_app_key`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉应用key',
    `ding_app_secret`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉应用secret',
    `ding_aes_key`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉加解密aes_key',
    `ding_callback_token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉回调token',
    `ding_corp_id`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉企业corpId',
    `app_type`            int(11)                                                       NULL     DEFAULT NULL COMMENT '应用类型 1企业微信 2钉钉',
    `last_sync_time`      datetime(0)                                                   NULL     DEFAULT NULL COMMENT '上次同步时间',
    `domain_url`          varchar(255)                                                  NULL     DEFAULT NULL COMMENT '第三方回调域名',
    `status`              int(11)                                                       NOT NULL DEFAULT 1 COMMENT '状态',
    `create_user`         bigint(20)                                                    NULL     DEFAULT NULL COMMENT '创建人',
    `create_dept`         bigint(20)                                                    NULL     DEFAULT NULL COMMENT '创建部门',
    `create_time`         datetime(0)                                                   NULL     DEFAULT NULL COMMENT '创建时间',
    `update_user`         bigint(20)                                                    NULL     DEFAULT NULL COMMENT '更新人',
    `update_time`         datetime(0)                                                   NULL     DEFAULT NULL COMMENT '更新时间',
    `remark`              varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '备注/说明',
    `is_deleted`          int(11)                                                       NULL     DEFAULT NULL,
    `ding_agent_id`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL     DEFAULT NULL COMMENT '钉钉应用AgentId',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `appTypeUnique` (`app_type`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

-- 脚本
-- 初始化脚本
-- 客户端
INSERT INTO `blade_client`(`id`, `client_id`, `client_secret`, `resource_ids`, `scope`,
                           `authorized_grant_types`, `web_server_redirect_uri`, `authorities`,
                           `access_token_validity`, `refresh_token_validity`, `additional_information`,
                           `autoapprove`, `create_user`, `create_dept`, `create_time`, `update_user`,
                           `update_time`, `status`, `is_deleted`)
VALUES (1123598811738675201, 'sword', 'sword_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8888', NULL, 3600, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:40:55', 1123598815738675201,
        '2019-03-24 10:40:59', 1, 0),
       (1123598811738675202, 'saber', 'saber_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8080', NULL, 3600, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:42:29', 1123598815738675201,
        '2019-03-24 10:42:32', 1, 0),
       (1123598811738675203, 'h5', 'h5_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8080', NULL, 604800, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:42:29', 1123598815738675201,
        '2019-03-24 10:42:32', 1, 0);


-- ----------------------------
-- 初始化应用列表数据
-- ----------------------------
INSERT INTO `blade_application`
VALUES (1001, 'CPS', 'CPS', '', '', '', 1, 1, 2, '离散线', 0);
INSERT INTO `blade_application`
VALUES (1002, '大屏', 'VISION', '', '', '', 1, 2, 2, '可视化大屏', 0);
INSERT INTO `blade_application`
VALUES (1003, 'HMI', 'HMI', '', '', '', 1, 2, 3, 'HMI', 0);

-- 积木报表
DROP TABLE IF EXISTS `jimu_dict`;
CREATE TABLE `jimu_dict`
(
    `id`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL,
    `dict_name`   varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典名称',
    `dict_code`   varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典编码',
    `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
    `del_flag`    int(1)                                                  NULL DEFAULT NULL COMMENT '删除状态',
    `create_by`   varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '创建人',
    `create_time` datetime                                                NULL DEFAULT NULL COMMENT '创建时间',
    `update_by`   varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '更新人',
    `update_time` datetime                                                NULL DEFAULT NULL COMMENT '更新时间',
    `type`        int(1) UNSIGNED ZEROFILL                                NULL DEFAULT 0 COMMENT '字典类型0为string,1为number',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uk_sd_dict_code` (`dict_code`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_dict_item`;
CREATE TABLE `jimu_dict_item`
(
    `id`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL,
    `dict_id`     varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '字典id',
    `item_text`   varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典项文本',
    `item_value`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典项值',
    `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
    `sort_order`  int(10)                                                 NULL DEFAULT NULL COMMENT '排序',
    `status`      int(11)                                                 NULL DEFAULT NULL COMMENT '状态（1启用 0不启用）',
    `create_by`   varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL,
    `create_time` datetime                                                NULL DEFAULT NULL,
    `update_by`   varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL,
    `update_time` datetime                                                NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_sdi_role_dict_id` (`dict_id`) USING BTREE,
    INDEX `idx_sdi_role_sort_order` (`sort_order`) USING BTREE,
    INDEX `idx_sdi_status` (`status`) USING BTREE,
    INDEX `idx_sdi_dict_val` (`dict_id`, `item_value`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report`;
CREATE TABLE `jimu_report`
(
    `id`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL COMMENT '主键',
    `code`        varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '编码',
    `name`        varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '名称',
    `note`        varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '说明',
    `status`      varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '状态',
    `type`        varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '类型',
    `json_str`    longtext CHARACTER SET utf8 COLLATE utf8_general_ci     NULL COMMENT 'json字符串',
    `api_url`     varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求地址',
    `thumb`       text CHARACTER SET utf8 COLLATE utf8_general_ci         NULL COMMENT '缩略图',
    `create_by`   varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '创建人',
    `create_time` datetime                                                NULL DEFAULT NULL COMMENT '创建时间',
    `update_by`   varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '修改人',
    `update_time` datetime                                                NULL DEFAULT NULL COMMENT '修改时间',
    `del_flag`    tinyint(1)                                              NULL DEFAULT NULL COMMENT '删除标识0-正常,1-已删除',
    `api_method`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求方法0-get,1-post',
    `api_code`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求编码',
    `template`    tinyint(1)                                              NULL DEFAULT NULL COMMENT '是否是模板 0-是,1-不是',
    `view_count`  bigint(15)                                              NULL DEFAULT 0 COMMENT '浏览次数',
    `css_str`     text CHARACTER SET utf8 COLLATE utf8_general_ci         NULL COMMENT 'css增强',
    `js_str`      text CHARACTER SET utf8 COLLATE utf8_general_ci         NULL COMMENT 'js增强',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniq_jmreport_code` (`code`) USING BTREE,
    INDEX `uniq_jmreport_createby` (`create_by`) USING BTREE,
    INDEX `uniq_jmreport_delflag` (`del_flag`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '在线excel设计器'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_data_source`;
CREATE TABLE `jimu_report_data_source`
(
    `id`            varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL,
    `name`          varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据源名称',
    `report_id`     varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报表_id',
    `code`          varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '编码',
    `remark`        varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `db_type`       varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '数据库类型',
    `db_driver`     varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '驱动类',
    `db_url`        varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据源地址',
    `db_username`   varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名',
    `db_password`   varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
    `create_by`     varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '创建人',
    `create_time`   datetime                                                      NULL DEFAULT NULL COMMENT '创建日期',
    `update_by`     varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '更新人',
    `update_time`   datetime                                                      NULL DEFAULT NULL COMMENT '更新日期',
    `connect_times` int(1) UNSIGNED                                               NULL DEFAULT 0 COMMENT '连接失败次数',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_jmdatasource_report_id` (`report_id`) USING BTREE,
    INDEX `idx_jmdatasource_code` (`code`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_db`;
CREATE TABLE `jimu_report_db`
(
    `id`               varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL COMMENT 'id',
    `jimu_report_id`   varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '主键字段',
    `create_by`        varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '创建人登录名称',
    `update_by`        varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '更新人登录名称',
    `create_time`      datetime                                                NULL DEFAULT NULL COMMENT '创建日期',
    `update_time`      datetime                                                NULL DEFAULT NULL COMMENT '更新日期',
    `db_code`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据集编码',
    `db_ch_name`       varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据集名字',
    `db_type`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据源类型',
    `db_table_name`    varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据库表名',
    `db_dyn_sql`       longtext CHARACTER SET utf8 COLLATE utf8_general_ci     NULL COMMENT '动态查询SQL',
    `db_key`           varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据源KEY',
    `tb_db_key`        varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '填报数据源',
    `tb_db_table_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '填报数据表',
    `java_type`        varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT 'java类数据集  类型（spring:springkey,class:java类名）',
    `java_value`       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'java类数据源  数值（bean key/java类名）',
    `api_url`          varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求地址',
    `api_method`       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '请求方法0-get,1-post',
    `is_list`          varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT '0' COMMENT '是否是列表0否1是 默认0',
    `is_page`          varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '是否作为分页,0:不分页，1:分页',
    `db_source`        varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据源',
    `db_source_type`   varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据库类型 MYSQL ORACLE SQLSERVER',
    `json_data`        text CHARACTER SET utf8 COLLATE utf8_general_ci         NULL COMMENT 'json数据，直接解析json内容',
    `api_convert`      varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'api转换器',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_jmreportdb_db_key` (`db_key`) USING BTREE,
    INDEX `idx_jimu_report_id` (`jimu_report_id`) USING BTREE,
    INDEX `idx_db_source_id` (`db_source`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_db_field`;
CREATE TABLE `jimu_report_db_field`
(
    `id`                varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL COMMENT 'id',
    `create_by`         varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '创建人登录名称',
    `create_time`       datetime                                                NULL DEFAULT NULL COMMENT '创建日期',
    `update_by`         varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '更新人登录名称',
    `update_time`       datetime                                                NULL DEFAULT NULL COMMENT '更新日期',
    `jimu_report_db_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '数据源ID',
    `field_name`        varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '字段名',
    `field_text`        varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '字段文本',
    `widget_type`       varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '控件类型',
    `widget_width`      int(10)                                                 NULL DEFAULT NULL COMMENT '控件宽度',
    `order_num`         int(3)                                                  NULL DEFAULT NULL COMMENT '排序',
    `search_flag`       int(3)                                                  NULL DEFAULT 0 COMMENT '查询标识0否1是 默认0',
    `search_mode`       int(3)                                                  NULL DEFAULT NULL COMMENT '查询模式1简单2范围',
    `dict_code`         varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典编码支持从表中取数据',
    `search_value`      varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '查询默认值',
    `search_format`     varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '查询时间格式化表达式',
    `ext_json`          text CHARACTER SET utf8 COLLATE utf8_general_ci         NULL COMMENT '参数配置',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_jrdf_jimu_report_db_id` (`jimu_report_db_id`) USING BTREE,
    INDEX `idx_dbfield_order_num` (`order_num`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_db_param`;
CREATE TABLE `jimu_report_db_param`
(
    `id`                  varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci   NOT NULL,
    `jimu_report_head_id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci   NOT NULL COMMENT '动态报表ID',
    `param_name`          varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci   NOT NULL COMMENT '参数字段',
    `param_txt`           varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '参数文本',
    `param_value`         varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数默认值',
    `order_num`           int(11)                                                  NULL DEFAULT NULL COMMENT '排序',
    `create_by`           varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '创建人登录名称',
    `create_time`         datetime                                                 NULL DEFAULT NULL COMMENT '创建日期',
    `update_by`           varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '更新人登录名称',
    `update_time`         datetime                                                 NULL DEFAULT NULL COMMENT '更新日期',
    `search_flag`         int(1)                                                   NULL DEFAULT NULL COMMENT '查询标识0否1是 默认0',
    `widget_type`         varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '查询控件类型',
    `search_mode`         int(1)                                                   NULL DEFAULT NULL COMMENT '查询模式1简单2范围',
    `dict_code`           varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '字典',
    `search_format`       varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '查询时间格式化表达式',
    `ext_json`            text CHARACTER SET utf8 COLLATE utf8_general_ci          NULL COMMENT '参数配置',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_jmrheadid` (`jimu_report_head_id`) USING BTREE,
    INDEX `idx_jrdp_jimu_report_head_id` (`jimu_report_head_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_link`;
CREATE TABLE `jimu_report_link`
(
    `id`            varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NOT NULL COMMENT '主键id',
    `report_id`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '积木设计器id',
    `parameter`     text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci          NULL COMMENT '参数',
    `eject_type`    varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '弹出方式（0 当前页面 1 新窗口）',
    `link_name`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '链接名称',
    `api_method`    varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '请求方法0-get,1-post',
    `link_type`     varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '链接方式(0 网络报表 1 网络连接 2 图表联动)',
    `api_url`       varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '外网api',
    `link_chart_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '联动图表的ID',
    `expression`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '表达式',
    `requirement`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '条件',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `uniq_link_reportid` (`report_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '超链接配置表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_map`;
CREATE TABLE `jimu_report_map`
(
    `id`           varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NOT NULL COMMENT '主键',
    `label`        varchar(125) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地图名称',
    `name`         varchar(125) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地图编码',
    `data`         longtext CHARACTER SET utf8 COLLATE utf8_general_ci     NULL COMMENT '地图数据',
    `create_by`    varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '创建人',
    `create_time`  datetime                                                NULL DEFAULT NULL COMMENT '创建时间',
    `update_by`    varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '修改人',
    `update_time`  datetime                                                NULL DEFAULT NULL COMMENT '修改时间',
    `del_flag`     varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci   NULL DEFAULT NULL COMMENT '0表示未删除,1表示删除',
    `sys_org_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL DEFAULT NULL COMMENT '所属部门',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniq_jmreport_map_name` (`name`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '地图配置表'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `jimu_report_share`;
CREATE TABLE `jimu_report_share`
(
    `id`               varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NOT NULL COMMENT '主键',
    `report_id`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '在线excel设计器id',
    `preview_url`      varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预览地址',
    `preview_lock`     varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '密码锁',
    `last_update_time` datetime                                                       NULL DEFAULT NULL COMMENT '最后更新时间',
    `term_of_validity` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '有效期(0:永久有效，1:1天，2:7天)',
    `status`           varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci    NULL DEFAULT NULL COMMENT '是否过期(0未过期，1已过期)',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '积木报表预览权限表'
  ROW_FORMAT = Dynamic;



