create table t_dm_module
(
    id              varchar(36) not null,
    modulename      varchar(50),
    moduletype      varchar(30),
    cycle           decimal(5, 0),
    modulenavconfig varchar(3072),
    predicttime     datetime,
    collecttime     datetime,
    create_time     datetime default current_timestamp,
    update_time     datetime default current_timestamp,
    traintime       datetime,
    primary key (id),
    UNIQUE INDEX uk_modulename (modulename),
    INDEX           idx_moduletype (moduletype)
) engine = innodb default character set utf8mb4 COMMENT = '管网表';


create table t_dm_module_item
(
    id         varchar(36) not null,
    moduleid   varchar(36),
    itemid     varchar(36),
    itemorder  bigint,
    status     bigint,
    categoryid varchar(64),
    primary key (id),
    key        idx_moduleid (moduleid)
) engine = innodb default character set utf8mb4 COMMENT = '管网预测项关系表';

create table t_mm_item_output
(
    id            varchar(36) not null,
    itemid        varchar(36),
    pointid       varchar(36),
    resulttableid varchar(36),
    tagname       varchar(50),
    outputorder   decimal(5, 0),
    primary key (id),
    INDEX         idx_itemid (itemid)
) engine = innodb default character set utf8mb4 COMMENT = '预测项输出表';

create table t_mm_item_type
(
    id            varchar(36) not null,
    itemtypename  varchar(50),
    itemclasstype varchar(100),
    assemblyname  varchar(64),
    primary key (id)
) engine = innodb default character set utf8mb4 COMMENT = '预测项类型表';

create table t_mm_model_arith_settings
(
    id        varchar(36) not null,
    modelid   varchar(36),
    `key`     varchar(36),
    value     varchar(1000),
    name      varchar(36),
    valuetype varchar(36),
    primary key (id),
    INDEX     idx_modelid (modelid)
) engine = innodb default character set utf8mb4 COMMENT = '预测模型设置参数表';

create table t_mm_model_param
(
    id                  varchar(36) not null,
    modelid             varchar(36),
    modelparamname      varchar(36),
    modelparamid        varchar(36),
    modelparamorder     integer,
    modelparamportorder integer,
    datalength          integer,
    modelparamtype      varchar(36),
    primary key (id),
    INDEX               idx_modelid (modelid)
) engine = innodb default character set utf8mb4 COMMENT = '预测模型输入参数表';

create table
    t_mm_predict_item
(
    id              varchar(36) not null,
    itemno          varchar(16),
    itemname        varchar(50),
    caltypeid       varchar(36),
    itemtypeid      varchar(36),
    predictlength   int,
    granularity     int,
    status          tinyint,
    isfuse          tinyint,
    predictphase    tinyint,
    workchecked     tinyint,
    unittransfactor decimal(16, 6),
    create_time     datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    update_time     datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    saveindex       varchar(16),
    primary key (id),
    UNIQUE INDEX uk_itemno (itemno),
    INDEX           uk_itemtypeid (itemtypeid)
) engine = innodb default character set utf8mb4 COMMENT = '预测项表';

create table
    t_mm_predict_merge_item
(
    id         varchar(36) not null,
    itemid     varchar(36),
    expression varchar(1000),
    num        integer,
    primary key (id),
    UNIQUE INDEX uk_itemid (itemid)
) engine = innodb default character set utf8mb4 COMMENT = '合并预测项表';

create table
    t_mm_predict_model
(
    id                  varchar(36) not null,
    modelno             varchar(32),
    modelname           varchar(50),
    itemid              varchar(36),
    arithid             varchar(36),
    trainsamplength     decimal(5, 0),
    predictsamplength   decimal(5, 0),
    isonlinetrain       decimal(5, 0),
    modelpath           varchar(256),
    isnormal            decimal(5, 0),
    normalmax           decimal(19, 3),
    normalmin           decimal(19, 3),
    status              decimal(5, 0),
    classname           varchar(256),
    methodname          varchar(64),
    modelparamstructure varchar(128),
    resultstrid         varchar(64),
    settingmap          varchar(256),
    trainmodelpath      varchar(256),
    pathstatus          decimal(5, 0),
    pdim                smallint,
    traninip            varchar(16),
    comparisonclassname varchar(256),
    primary key (id),
    INDEX               idx_modelno (modelno),
    UNIQUE INDEX idx_itemid (itemid)
) engine = innodb
  default character set utf8mb4 COMMENT = '预测项模型表';

create table t_mm_item_result_json
(
    id          varchar(36) not null,
    outputid    varchar(50),
    predicttime datetime,
    jsonvalue   text,
    cumulant    varchar(36),
    primary key (id),
    INDEX       idx_outputid (outputid),
    INDEX       idx_predicttime (predicttime)
) engine = innodb default character set utf8mb4 COMMENT = '预测JSON数据表';

create table t_mm_item_accuracy_rate
(
    id                varchar(36) not null,
    item_id           varchar(36) not null COMMENT '预测项ID',
    out_id            varchar(36) not null COMMENT '输出ID',
    sample_length     integer COMMENT '取样长度',
    value_type        integer COMMENT '值类型',
    begin_time        datetime COMMENT '开始统计时间',
    in_deviation      decimal(8, 3) COMMENT '精准误差',
    in_accuracy_rate  decimal(6, 4) COMMENT '精准度',
    out_deviation     decimal(8, 3) COMMENT '不可信误差',
    out_accuracy_rate decimal(6, 4) COMMENT '不可信率',
    is_enable         tinyint COMMENT '是否启用',
    create_time       datetime COMMENT '创建时间',
    update_time       datetime COMMENT '更新时间',
    primary key (id),
    INDEX             idx_item_id (item_id)
) engine = innodb
  default character set utf8mb4 COMMENT = '预测精准度表';

create table t_mm_item_accuracy_his
(
    id                varchar(36) not null,
    rate_id           varchar(36) not null COMMENT '预测精准度ID',
    in_deviation      decimal(8, 3) COMMENT '精准误差',
    in_accuracy_rate  decimal(6, 4) COMMENT '精准度',
    out_deviation     decimal(8, 3) COMMENT '不可信误差',
    out_accuracy_rate decimal(6, 4) COMMENT '不可信率',
    create_time       datetime COMMENT '创建时间',
    primary key (id),
    INDEX             idx_rate_id (rate_id)
) engine = innodb
  default character set utf8mb4 COMMENT = '预测精准度历史';

create table t_mm_predict_alarm_config
(
    id            varchar(36) not null,
    title         varchar(20) COMMENT '消息标题',
    alarm_obj     varchar(36) COMMENT '监控对象',
    item_id       varchar(36) COMMENT '预测项ID',
    out_id        varchar(36) COMMENT '输出ID',
    comp_length   int COMMENT '比较长度',
    upper_limit   decimal(10, 4) COMMENT '上限',
    lower_limit   decimal(10, 4) COMMENT '下限',
    unit          varchar(10) COMMENT '单位',
    coefficient   decimal(10, 4) COMMENT '转换系数',
    schedule_id      varchar(36) COMMENT '调度方案',
    is_enable     tinyint     NOT NULL COMMENT '是否启用（0禁用 1启用）',
    `creator`     varchar(64) NOT NULL DEFAULT '' COMMENT '创建者',
    `create_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64)          DEFAULT '' COMMENT '更新者',
    `update_time` datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    primary key (id)
) engine = innodb
  default character set utf8mb4 COMMENT = '预警配置表';

create table t_mm_predict_alarm_message
(
    id            varchar(36) not null,
    config_id     varchar(36) COMMENT '配置ID',
    title         varchar(36) COMMENT '消息标题',
    content       varchar(128) COMMENT '消息内容',
    alarm_obj     varchar(36) COMMENT '监控对象',
    point_id      varchar(36) COMMENT '监控点位ID',
    item_id       varchar(36) COMMENT '预测项ID',
    out_id        varchar(36) COMMENT '输出ID',
    current_value decimal(18, 4) COMMENT '当前值',
    out_time      datetime COMMENT '超出时间',
    out_value     decimal(18, 4) COMMENT '超出值',
    alarm_type    varchar(10) COMMENT '预警类型',
    alarm_time    datetime COMMENT '预警时间',
    create_time   datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    primary key (id),
    INDEX         idx_item_id (item_id),
    INDEX         idx_config_id (config_id),
    INDEX         idx_alarm_obj (alarm_obj),
    INDEX         idx_alarm_time (alarm_time)
) engine = innodb
  default character set utf8mb4 COMMENT = '预警消息表';


-- 调度模块

create table t_st_schedule_scheme
(
    `id`                varchar(36) not null COMMENT 'ID',
    `code`              varchar(20) not null COMMENT '编号',
    `name`              varchar(20) not null COMMENT '名称',
    `trigger_method`    varchar(20) COMMENT '触发方式',
    `trigger_condition` varchar(20) COMMENT '触发条件',
    `schedule_obj`      varchar(20) COMMENT '调整对象',
    `schedule_type`     varchar(20) COMMENT '调整类型',
    `schedule_strategy` varchar(20) COMMENT '调整策略',
    `model_id`          varchar(36) COMMENT '调度模型',
    `schedule_time`     datetime COMMENT '调度时间',
    `status`            tinyint     NOT NULL DEFAULT 0 COMMENT '方案状态（0正常 1停用）',
    `remark`            varchar(100) COMMENT '备注',
    `creator`           varchar(64) NOT NULL DEFAULT '' COMMENT '创建者',
    `create_time`       datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`           varchar(64) NULL     DEFAULT '' COMMENT '更新者',
    `update_time`       datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`           bit(1)      NOT NULL DEFAULT b'0' COMMENT '是否删除',
    primary key (id),
    UNIQUE INDEX `uk_code` (`code` ASC) USING BTREE
) engine = innodb
  default character set utf8mb4 COMMENT = '调度方案表';

create table t_st_schedule_model
(
    `id`              varchar(36) not null COMMENT 'ID',
    `model_code`      varchar(64) not null COMMENT '模型编号',
    `model_name`      varchar(64) not null COMMENT '模型名称',
    `model_type`      varchar(64) COMMENT '模型类型',
    `class_name`      varchar(128) COMMENT '类名',
    `method_name`     varchar(64) COMMENT '方法名',
    `port_length`     integer COMMENT '输入数量',
    `param_structure` varchar(256) COMMENT '参数构造',
    `model_path`      varchar(256) COMMENT '路径',
    `result_str_id`   varchar(64) COMMENT '结果ID',
    `invocation`      varchar(64) COMMENT '调用方式',
    `status`          tinyint     NOT NULL DEFAULT 0 COMMENT '状态（0正常 1停用）',
    `creator`         varchar(64) NOT NULL DEFAULT '' COMMENT '创建者',
    `create_time`     datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`         varchar(64) NULL     DEFAULT '' COMMENT '更新者',
    `update_time`     datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`         bit(1)      NOT NULL DEFAULT b'0' COMMENT '是否删除',
    primary key (id),
    UNIQUE INDEX `uk_model_code` (`model_code` ASC) USING BTREE
) engine = innodb default character set utf8mb4 COMMENT = '调度模型表';

create table
    t_st_schedule_model_param
(
    id                  varchar(36) not null,
    modelid             varchar(64) not null,
    modelparamname      varchar(64),
    modelparamid        varchar(64),
    modelparamorder     integer,
    modelparamportorder integer,
    datalength          integer,
    modelparamtype      varchar(64),
    primary key (id)
) engine = innodb
  default character set utf8mb4 COMMENT = '调度模型输入参数表';


create table
    t_st_schedule_model_setting
(
    `id`        varchar(36) not null,
    `modelid`   varchar(64) not null,
    `key`       varchar(64),
    `value`     varchar(64),
    `valuetype` varchar(64),
    `name`      varchar(64),
    `sort`      integer,
    primary key (id),
    key         idx_modelid (modelid)
) engine = innodb
  default character set utf8mb4 COMMENT = '调度模型设置参数表';

create table
    t_st_schedule_suggest
(
    id                varchar(36) not null,
    title             varchar(50) COMMENT '标题',
    content           varchar(256) COMMENT '内容',
    sort              integer COMMENT '排序',
    scheme_id         varchar(36) COMMENT '方案ID',
    alarm_id          varchar(36) COMMENT '预警ID',
    item_id           varchar(36) COMMENT '预测项ID',
    model_id          varchar(36) COMMENT '模型ID',
    schedule_obj      varchar(20) COMMENT '调整对象',
    schedule_type     varchar(20) COMMENT '调整类型',
    schedule_strategy varchar(20) COMMENT '调整策略',
    adjust_mode       varchar(20) COMMENT '调整方式',
    adjust_value      decimal(18, 4) COMMENT '调整值',
    adjust_unit       varchar(20) COMMENT '调整单位',
    adjust_times      decimal(18, 4) COMMENT '持续时长',
    adjust_start      datetime COMMENT '调整开始时间',
    adjust_end        datetime COMMENT '调整结束时间',
    schedule_time     datetime COMMENT '调度时间',
    status            tinyint     NOT NULL COMMENT '状态（0未处理 1已采纳 2已忽略）',
    handler           varchar(36) COMMENT '处理人',
    handle_time       datetime COMMENT '处理时间',
    create_time       datetime default current_timestamp COMMENT '创建时间',
    primary key (id),
    INDEX             idx_scheme_id (scheme_id),
    INDEX             idx_alarm_id (alarm_id),
    INDEX             idx_item_id (item_id),
    INDEX             idx_model_id (model_id),
    INDEX             idx_schedule_obj (schedule_obj),
    INDEX             idx_schedule_type (schedule_type)
) engine = innodb
  default character set utf8mb4 COMMENT = '调度建议表';


create table
    t_st_schedule_record
(
    `id`            varchar(36) not null,
    `scheme_id`     varchar(36) COMMENT '方案ID',
    `model_id`      varchar(36) COMMENT '模型ID',
    `model_name`    varchar(64) COMMENT '模型名称',
    `schedule_time` datetime COMMENT '调度时间',
    `create_time`   datetime default current_timestamp COMMENT '创建时间',
    primary key (id),
    INDEX           idx_scheme_id (scheme_id),
    INDEX           idx_model_id (model_id),
    INDEX           idx_schedule_time (schedule_time)
) engine = innodb
  default character set utf8mb4 COMMENT = '调度记录表';


create table
    t_st_schedule_record_detail
(
    `id`            varchar(36) not null,
    `record_id`     varchar(36),
    `scheme_id`     varchar(64),
    `model_id`      varchar(36) COMMENT '模型ID',
    `result_key`    varchar(64),
    `result_value`  text,
    `schedule_time` datetime COMMENT '调度时间',
    primary key (id),
    key             idx_record_id (record_id),
    key             idx_scheme_id (scheme_id),
    key             idx_model_id (model_id)
) engine = innodb
  default character set utf8mb4 COMMENT = '调度记录详情表';

-- mpk

-- menu
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416369, '模型库', '', 2, 20, 1803317368415416363, 'mpk', 'ep:folder', 'mpk/mpk', 'Mpk', 0, b'1',
        b'1', b'1', '1', '2024-08-31 16:50:38', '1', '2024-09-10 14:53:17', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416370, 'MPK查询', 'mpk:query', 3, 0, 1803317368415416369, '', '', '', '', 0, b'1', b'1', b'1',
        '1', '2024-09-02 10:14:00', '1', '2024-09-06 11:50:19', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416371, 'MPK新增', 'mpk:create', 3, 1, 1803317368415416369, '', '', '', '', 0, b'1', b'1', b'1',
        '1', '2024-09-02 10:14:25', '1', '2024-09-06 11:50:28', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416372, 'MPK修改', 'mpk:update', 3, 2, 1803317368415416369, '', '', '', '', 0, b'1', b'1', b'1',
        '1', '2024-09-02 10:14:44', '1', '2024-09-06 11:50:38', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416373, 'MPK删除', 'mpk:delete', 3, 3, 1803317368415416369, '', '', '', '', 0, b'1', b'1', b'1',
        '1', '2024-09-02 10:15:04', '1', '2024-09-06 11:50:46', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416374, '项目管理', '', 2, 30, 1803317368415416363, 'project', 'ep:document-copy', 'mpk/project',
        'Project', 0, b'1', b'1', b'1', '1', '2024-09-10 14:44:54', '1', '2024-09-10 14:53:26', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416375, '项目查询', 'project:query', 3, 0, 1803317368415416374, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-09-10 14:45:53', '1', '2024-09-10 14:45:53', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416376, '项目新增', 'project:create', 3, 1, 1803317368415416374, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-09-10 14:46:16', '1', '2024-09-10 14:46:16', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416377, '项目修改', 'project:update', 3, 2, 1803317368415416374, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-09-10 14:46:33', '1', '2024-09-10 14:46:33', b'0');
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`)
VALUES (1803317368415416378, '项目删除', 'project:delete', 3, 3, 1803317368415416374, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-09-10 14:46:47', '1', '2024-09-10 14:46:47', b'0');


-- config
--INSERT INTO `iailab_plat_system`.`infra_config` (`id`, `category`, `type`, `name`, `config_key`, `value`, `visible`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (13, 'model', 2, 'model文件备份路径', 'mpkBakFilePath', 'C:\\DLUT\\mpkBakFile', b'1', 'model文件备份路径', '1', '2024-09-12 11:10:25', '1', '2024-09-12 11:10:25', b'0');

-- dist
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`, `deleted_time`)
VALUES (618, '模型方法', 'model_method', 0, '', '1', '2024-09-09 16:11:55', '1', '2024-09-09 16:11:55', b'0',
        '1970-01-01 00:00:00');
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`, `deleted_time`)
VALUES (619, '模型类型', 'model_type', 0, '', '1', '2024-09-13 14:14:26', '1', '2024-09-13 14:14:26', b'0',
        '1970-01-01 00:00:00');
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`, `deleted_time`)
VALUES (620, '模型方法输入类型', 'model_method_setting_type', 0, '', '1', '2024-09-13 15:41:38', '1',
        '2024-09-13 15:41:38', b'0', '1970-01-01 00:00:00');
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`, `deleted_time`)
VALUES (621, '模型方法参数类型', 'model_method_setting_value_type', 0, '', '1', '2024-09-13 15:42:27', '1',
        '2024-09-13 15:42:27', b'0', '1970-01-01 00:00:00');


INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1536, 1, 'train', 'train', 'model_method', 0, '', '', '', '1', '2024-09-09 16:12:42', '1',
        '2024-09-09 16:12:42', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1537, 3, 'control', 'control', 'model_method', 0, '', '', '', '1', '2024-09-09 16:12:54', '1',
        '2024-09-09 16:13:10', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1538, 2, 'predict', 'predict', 'model_method', 0, '', '', '', '1', '2024-09-09 16:13:05', '1',
        '2024-09-09 16:13:05', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1539, 1, '预测模型', 'predict', 'model_type', 0, '', '', '', '1', '2024-09-13 14:14:58', '1',
        '2024-09-13 14:14:58', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1540, 2, '调度模型', 'schedul', 'model_type', 0, '', '', '', '1', '2024-09-13 14:17:53', '1',
        '2024-09-13 14:17:53', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1541, 1, 'input', 'input', 'model_method_setting_type', 0, '', '', '', '1', '2024-09-13 15:44:08', '1',
        '2024-09-13 15:44:08', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1542, 2, 'select', 'select', 'model_method_setting_type', 0, '', '', '', '1', '2024-09-13 15:44:17', '1',
        '2024-09-13 15:44:17', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1543, 3, 'file', 'file', 'model_method_setting_type', 0, '', '', '', '1', '2024-09-13 15:44:24', '1',
        '2024-09-13 15:44:24', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1544, 1, 'int', 'int', 'model_method_setting_value_type', 0, '', '', '', '1', '2024-09-13 15:44:42', '1',
        '2024-09-13 15:44:42', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1545, 5, 'file', 'file', 'model_method_setting_value_type', 0, '', '', '', '1', '2024-09-13 15:44:57', '1',
        '2024-09-14 14:16:24', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1546, 3, 'decimal', 'decimal', 'model_method_setting_value_type', 0, '', '', '', '1', '2024-09-13 15:45:21',
        '1', '2024-09-13 15:45:21', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1547, 4, 'decimalArray', 'decimalArray', 'model_method_setting_value_type', 0, '', '', '', '1',
        '2024-09-13 15:45:26', '1', '2024-09-13 15:45:26', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1548, 2, 'string', 'string', 'model_method_setting_value_type', 0, '', '', '', '1', '2024-09-13 15:45:36', '1',
        '2024-09-14 14:16:30', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`,
                                                     `color_type`, `css_class`, `remark`, `creator`, `create_time`,
                                                     `updater`, `update_time`, `deleted`)
VALUES (1549, 4, 'schedul', 'schedul', 'model_method', 0, '', '', '', '1', '2024-09-14 14:56:44', '1',
        '2024-09-14 14:56:44', b'0');


-- 业务表
DROP TABLE IF EXISTS `t_mpk_file`;
CREATE TABLE `t_mpk_file`
(
    `id`              varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `py_name`         varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型名称',
    `py_chinese_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型中文名称',
    `file_path`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '源文件保存路径',
    `py_type`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型类型',
    `pkg_name`        varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包名',
    `class_name`      varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类名',
    `py_module`       varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型路径',
    `icon`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'icon图片名',
    `menu_name`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属菜单',
    `group_name`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属组',
    `remark`          varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `creator`         bigint NULL DEFAULT NULL COMMENT '创建者',
    `create_date`     datetime NULL DEFAULT NULL COMMENT '创建时间',
    `updater`         bigint NULL DEFAULT NULL COMMENT '更新者',
    `update_date`     datetime NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uk_py_name`(`py_name` ASC) USING BTREE,
    INDEX             `idx_create_date`(`create_date` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'MDK模型文件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for t_mpk_generator_code_history
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_generator_code_history`;
CREATE TABLE `t_mpk_generator_code_history`
(
    `id`          varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `mdk_id`      varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'mdk_id',
    `file_name`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名',
    `file_path`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件保存路径',
    `remark`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `create_time` datetime NULL DEFAULT NULL COMMENT '生成时间',
    PRIMARY KEY (`id`, `mdk_id`) USING BTREE,
    INDEX         `del_code_history`(`mdk_id` ASC) USING BTREE,
    CONSTRAINT `del_code_history` FOREIGN KEY (`mdk_id`) REFERENCES `t_mpk_file` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '生成代码记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for t_mpk_model_method
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_model_method`;
CREATE TABLE `t_mpk_model_method`
(
    `id`          varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `mpk_file_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模型文件id',
    `method_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型方法名',
    `data_length` int NULL DEFAULT 1 COMMENT '输入个数',
    `model`       int NULL DEFAULT 0 COMMENT '是否有model(0:否,1:是)',
    `result_key`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '结果key',
    `sort`        integer,
    PRIMARY KEY (`id`, `mpk_file_id`) USING BTREE,
    INDEX         `id`(`id` ASC) USING BTREE,
    INDEX         `idx_method`(`mpk_file_id` ASC) USING BTREE,
    CONSTRAINT `del_method` FOREIGN KEY (`mpk_file_id`) REFERENCES `t_mpk_file` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mpk_method_setting
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_method_setting`;
CREATE TABLE `t_mpk_method_setting`
(
    `id`          varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `method_id`   varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '方法id',
    `setting_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'key',
    `name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数名称',
    `value`       varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数默认值',
    `type`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '输入类型',
    `value_type`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数类型',
    `max`         int NULL DEFAULT NULL COMMENT '最大值',
    `min`         int NULL DEFAULT NULL COMMENT '最小值',
    `sort`        integer,
    PRIMARY KEY (`id`, `method_id`) USING BTREE,
    INDEX         `del_setting`(`method_id` ASC) USING BTREE,
    INDEX         `id`(`id` ASC) USING BTREE,
    CONSTRAINT `del_setting` FOREIGN KEY (`method_id`) REFERENCES `t_mpk_model_method` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '方法参数关联表' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for t_mpk_setting_select
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_setting_select`;
CREATE TABLE `t_mpk_setting_select`
(
    `id`         varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `setting_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参数id',
    `select_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'key',
    `name`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
    `sort`       integer,
    PRIMARY KEY (`id`, `setting_id`) USING BTREE,
    INDEX        `del_select`(`setting_id` ASC) USING BTREE,
    CONSTRAINT `del_select` FOREIGN KEY (`setting_id`) REFERENCES `t_mpk_method_setting` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '参数选项关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_mpk_project
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_project`;
CREATE TABLE `t_mpk_project`
(
    `id`           varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `project_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目名称',
    `project_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目编码',
    `create_time`  datetime NULL DEFAULT NULL COMMENT '创建时间',
    `update_time`  datetime NULL DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for t_mpk_project_model
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_project_model`;
CREATE TABLE `t_mpk_project_model`
(
    `id`         varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `project_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目id',
    `model_id`   varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '模型id',
    PRIMARY KEY (`id`, `project_id`, `model_id`) USING BTREE,
    INDEX        `del_p`(`project_id` ASC) USING BTREE,
    INDEX        `del_m`(`model_id` ASC) USING BTREE,
    CONSTRAINT `del_m` FOREIGN KEY (`model_id`) REFERENCES `t_mpk_file` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
    CONSTRAINT `del_p` FOREIGN KEY (`project_id`) REFERENCES `t_mpk_project` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目模型关联表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for t_mpk_project_package_history
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_project_package_history`;
CREATE TABLE `t_mpk_project_package_history`
(
    `id`          varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `project_id`  varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目id',
    `file_name`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件名',
    `file_path`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件路径',
    `version`     varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本号',
    `log`         varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新日志',
    `model_names` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '打包模型名称（“，”分割）',
    `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`, `project_id`) USING BTREE,
    INDEX         `del_package_history`(`project_id` ASC) USING BTREE,
    CONSTRAINT `del_package_history` FOREIGN KEY (`project_id`) REFERENCES `t_mpk_project` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '项目打包历史记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for t_mpk_project_package_history_model
-- ----------------------------
DROP TABLE IF EXISTS `t_mpk_project_package_history_model`;
CREATE TABLE `t_mpk_project_package_history_model`
(
    `id`                 varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id',
    `project_id`         varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目id',
    `package_history_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '打包历史id',
    `py_name`            varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型名称',
    `pkg_name`           varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '包名',
    `py_module`          varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型路径',
    `remark`             varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模型备注',
    `method_info`        text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '模型方法信息',
    PRIMARY KEY (`id`, `project_id`) USING BTREE,
    INDEX                `del_package_model`(`project_id` ASC) USING BTREE,
    CONSTRAINT `del_package_model` FOREIGN KEY (`project_id`) REFERENCES `t_mpk_project` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '打包历史模型关联表' ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `t_mpk_icon`;
CREATE TABLE `t_mpk_icon`
(
    `id`        varchar(36) NOT NULL COMMENT 'id',
    `icon_name` varchar(36) NOT NULL COMMENT '图标名称',
    `icon_desc` varchar(36) DEFAULT NULL COMMENT '图标描述',
    `sort`      integer     DEFAULT NULL COMMENT '排序',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'MDK平台图标' ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `t_mpk_file_menu`;
CREATE TABLE `t_mpk_file_menu`
(
    `id`   varchar(36) NOT NULL COMMENT 'id',
    `name` varchar(36) NOT NULL COMMENT '名称',
    `sort` integer 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 `t_mpk_file_group`;
CREATE TABLE `t_mpk_file_group`
(
    `id`      varchar(36) NOT NULL COMMENT 'id',
    `menu_id` varchar(36) NOT NULL COMMENT '菜单',
    `name`    varchar(36) NOT NULL COMMENT '名称',
    `sort`    integer DEFAULT NULL COMMENT '排序',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '模型文件分组' ROW_FORMAT = Dynamic;

alter table t_mm_predict_model
    add column `mpkprojectid` varchar(36) DEFAULT NULL;

-- chart 图表配置

-- menu
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416399, '图表管理', '', 1, 40, 1803317368415416363, 'chart', 'fa:align-left', '', '', 0, b'1',
        b'1', b'1', '1', '2024-11-05 11:57:25', '1', '2024-11-05 11:57:49', b'0', 0, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416400, '图表配置', '', 2, 1, 1803317368435416399, 'chartParam', 'fa-solid:cogs',
        'model/chart/index', 'ChartParam', 0, b'1', b'1', b'1', '1', '2024-11-05 12:01:59', '1', '2024-11-06 08:45:17',
        b'0', 0, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416401, '查询', 'model:chart:query', 3, 1, 1803317368435416400, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-11-05 15:36:48', '1', '2024-11-05 15:36:48', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416402, '新增', 'model:chart:create', 3, 2, 1803317368435416400, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-11-05 15:37:03', '1', '2024-11-05 15:37:03', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416403, '修改', 'model:chart:update', 3, 3, 1803317368435416400, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-11-05 15:37:20', '1', '2024-11-05 15:37:20', b'0', NULL, 1);
INSERT INTO `iailab_plat_system`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`,
                                                `component`, `component_name`, `status`, `visible`, `keep_alive`,
                                                `always_show`, `creator`, `create_time`, `updater`, `update_time`,
                                                `deleted`, `app_id`, `tenant_id`)
VALUES (1803317368435416404, '删除', 'model:chart:delete', 3, 4, 1803317368435416400, '', '', '', '', 0, b'1', b'1',
        b'1', '1', '2024-11-05 15:37:38', '1', '2024-11-05 15:37:38', b'0', NULL, 1);

-- table
CREATE TABLE `t_chart`
(
    `id`          varchar(36) NOT NULL,
    `chart_name`  varchar(100) DEFAULT NULL COMMENT '图表名称',
    `chart_code`  varchar(100) DEFAULT NULL COMMENT '图表编码',
    `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
    `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_chart_code` (`chart_code`),
    KEY           `index_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='图表配置';

CREATE TABLE `t_chart_param`
(
    `id`          varchar(36) NOT NULL,
    `chart_id`    varchar(36) NOT NULL COMMENT '图表id',
    `param_name`  varchar(255)  DEFAULT NULL COMMENT '参数名称',
    `param_code`  varchar(100)  DEFAULT NULL COMMENT '参数编码',
    `param_value` varchar(1000) DEFAULT NULL COMMENT '参数值',
    `remark`      varchar(255)  DEFAULT NULL COMMENT '备注',
    `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
    `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`, `chart_id`) USING BTREE,
    KEY           `index_chart_id` (`chart_id`),
    CONSTRAINT `chart_id` FOREIGN KEY (`chart_id`) REFERENCES `t_chart` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='图表参数配置';


DROP TABLE IF EXISTS `t_mpk_pack`;
CREATE TABLE `t_mpk_pack`
(
    `id`         varchar(36) NOT NULL COMMENT 'id',
    `pack_name`  varchar(50) NOT NULL COMMENT '包名称',
    `pack_desc`  varchar(50) DEFAULT NULL COMMENT '包描述',
    `model_path` varchar(50) DEFAULT NULL COMMENT '模型路径',
    `sort`       integer     DEFAULT NULL COMMENT '排序',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX uk_pack_name (pack_name)
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'MDK包名管理' ROW_FORMAT = Dynamic;


create table
    t_mm_item_status
(
    id        varchar(36) not null COMMENT 'id',
    item_id   varchar(36) COMMENT '预测项ID',
    last_time datetime DEFAULT NULL COMMENT '最新运行时间',
    status    smallint DEFAULT NULL COMMENT '运行状态',
    duration  bigint(20)  DEFAULT NULL COMMENT '耗时(s)',
    primary key (id),
    UNIQUE INDEX uk_item_id (item_id)
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '测项状态表' ROW_FORMAT = Dynamic;

-- 模型输出
ALTER TABLE t_mm_predict_model DROP COLUMN `resultstrid`;
alter table t_mm_item_output add column `resultstr` varchar(50) DEFAULT NULL;
alter table t_mm_item_output add column `result_type` smallint DEFAULT NULL COMMENT '参数类型{1：一维数组；2：二维数组}';
alter table t_mm_item_output add column `result_index` int DEFAULT NULL;

-- 字典
INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (644, '模型结果数据类型', 'model_result_type', 0, '', '141', '2024-11-11 15:16:58', '141', '2024-11-11 15:16:58', b'0', '1970-01-01 00:00:00');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1628, 1, 'double[]', '1', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:05', '141', '2024-11-11 15:21:05', b'0');
INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1629, 2, 'double[][]', '2', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:17', '141', '2024-11-11 15:21:17', b'0');


alter table t_mm_item_output add column `result_name` varchar(50) DEFAULT NULL;


alter table t_st_schedule_scheme add column `mpkprojectid` varchar(36) DEFAULT NULL;

alter table t_st_schedule_record add column `result_code` varchar(10) DEFAULT NULL;
alter table t_st_schedule_record add column `result_data` text DEFAULT NULL;

CREATE TABLE `t_st_schedule_model_out` (
                                  `id` varchar(36) NOT NULL COMMENT 'id',
                                  `model_id` varchar(36) DEFAULT NULL COMMENT '模型ID',
                                  `result_key` varchar(36) DEFAULT NULL COMMENT '输出key',
                                  `result_type` varchar(36) DEFAULT NULL COMMENT '数据类型（double,double[],double[][]）',
                                  `result_port` int DEFAULT NULL COMMENT 'port',
                                  `result_index` int DEFAULT NULL COMMENT 'index',
                                  `is_write` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否下发',
                                  `point_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '下发的点位',
                                  `sort` int DEFAULT NULL COMMENT '排序',
                                  `disturbance_point_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '无扰切换点位',
                                  PRIMARY KEY (`id`) USING BTREE,
                                  INDEX `ind_model_id`(`model_id` ASC) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模型下发信息表';

alter table t_st_schedule_scheme add column `run_status` varchar(4) DEFAULT NULL COMMENT '运行状态';

alter table t_mm_predict_alarm_config add column `cul_upper` decimal(10, 4) COMMENT '累计值上限';
alter table t_mm_predict_alarm_config add column `cul_lower` decimal(10, 4) COMMENT '累计值下限';

alter table t_st_schedule_scheme modify column  `trigger_condition` varchar(50) COMMENT '触发条件'


CREATE TABLE `t_electricity_price_segmented` (
                                                 `id` varchar(36) NOT NULL COMMENT 'ID',
                                                 `i_time_id` varchar(36) DEFAULT NULL,
                                                 `rec_id` varchar(36) DEFAULT NULL,
                                                 `media_id` varchar(36) DEFAULT NULL COMMENT '能介编号',
                                                 `ref_media_id` varchar(20) DEFAULT NULL,
                                                 `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
                                                 `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
                                                 `year` varchar(26) DEFAULT NULL,
                                                 `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
                                                 `update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
                                                 PRIMARY KEY (`id`) USING BTREE,
                                                 INDEX `ind_i_time_id`(`i_time_id` ASC) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='电价时段配置数据';


alter table t_mm_item_output add column `iscumulant` tinyint default false COMMENT '是否累计';
alter table t_mm_item_output add column `cumuldivisor` int DEFAULT NULL COMMENT '累计除数';
alter table t_mm_item_output add column `cumulpoint` varchar(36) DEFAULT NULL, COMMENT '累计测点';


CREATE TABLE `t_st_adjust_config` (
                                      `id` varchar(36) NOT NULL COMMENT 'ID',
                                      `schedule_model_id` varchar(36) DEFAULT NULL COMMENT '调度模型ID',
                                      `remark` varchar(200) DEFAULT NULL COMMENT '备注',
                                      `status`          tinyint DEFAULT 1 COMMENT '状态',
                                      create_time     datetime default current_timestamp,
                                      update_time     datetime default current_timestamp,
                                      PRIMARY KEY (`id`) USING BTREE,
                                      INDEX `idx_schedule_model_id`(`schedule_model_id` ASC) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整配置表';

CREATE TABLE `t_st_adjust_config_det` (
                                      `id` varchar(36) NOT NULL COMMENT 'ID',
                                      `config_id` varchar(36) DEFAULT NULL COMMENT '配置ID',
                                      `item_type_id` varchar(36) DEFAULT NULL COMMENT '预测项类型',
                                      `predict_item_id` varchar(36) DEFAULT NULL COMMENT '预测项ID',
                                      `out_key` varchar(50) DEFAULT NULL COMMENT '输出KEY',
                                      `out_name` varchar(50) DEFAULT NULL COMMENT '输出名称',
                                      `model_param_order`     integer DEFAULT NULL COMMENT '参数排序',
                                      `model_param_port_order` integer DEFAULT NULL COMMENT '输入排序',
                                      `sort`              integer COMMENT '执行顺序',
                                      PRIMARY KEY (`id`) USING BTREE,
                                      INDEX `idx_config_id`(`config_id` ASC) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整配置详细表';

CREATE TABLE `t_st_adjust_result` (
                                                 `id` varchar(36) NOT NULL COMMENT 'ID',
                                                 `config_id` varchar(36) DEFAULT NULL COMMENT '配置ID',
                                                 `output_id` varchar(36) DEFAULT NULL COMMENT '预测项输出ID',
                                                 `schedule_model_id` varchar(36) DEFAULT NULL COMMENT '调度模型ID',
                                                 `adjust_time` datetime NULL DEFAULT NULL COMMENT '模拟调整时间',
                                                 `adjust_value` varchar(500) DEFAULT NULL COMMENT '模拟调整值',
                                                 `json_value` varchar(1000) DEFAULT NULL COMMENT '模拟调整结果',
                                                 PRIMARY KEY (`id`) USING BTREE,
                                                 INDEX `idx_output_id`(`output_id` ASC) USING BTREE,
                                                 INDEX `idx_schedule_model_id`(`schedule_model_id` ASC) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模拟调整结果表';

