DROP TABLE IF EXISTS `business_processing_log`;
CREATE TABLE `business_processing_log`
(
    `id`                        bigint(20) UNSIGNED                              NOT NULL AUTO_INCREMENT,
    `business_key`              bigint(20) UNSIGNED                              NULL     DEFAULT 0 COMMENT '业务信息ID',
    `business_type`             varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT '' COMMENT '业务类型',
    `historic_task_id`          varchar(64) CHARACTER SET utf8 COLLATE utf8_bin  NULL     DEFAULT '' COMMENT '历史任务ID',
    `task_name`                 varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT '' COMMENT '任务名称',
    `task_def_key`              varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT '' COMMENT '任务定义KEY',
    `form_business_id`          bigint(20) UNSIGNED                              NULL     DEFAULT NULL COMMENT '表单业务ID',
    `assignee_id`               bigint(20) UNSIGNED                              NULL     DEFAULT 0 COMMENT '办理人ID',
    `assignee_type`             varchar(20) CHARACTER SET utf8 COLLATE utf8_bin  NULL     DEFAULT '' COMMENT '办理人类型',
    `start_time`                datetime                                         NULL     DEFAULT NULL COMMENT '开始时间',
    `end_time`                  datetime                                         NULL     DEFAULT NULL COMMENT '完成时间',
    `overdue_days`              float(4, 1)                                      NULL     DEFAULT 0.0 COMMENT '逾期(单位：0.5天)',
    `is_working_day`            tinyint(3) UNSIGNED                              NULL     DEFAULT 0 COMMENT '是否工作日，默认0表示自然日，1表示工作日',
    `status`                    varchar(50) CHARACTER SET utf8 COLLATE utf8_bin  NULL     DEFAULT '0' COMMENT '任务状态',
    `dead_line_start`           varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT NULL COMMENT '倒计时开始时间',
    `approval_type`             int(1)                                           NULL     DEFAULT 0 COMMENT '审批类型 1 人工审批 0 自动通过',
    `approval_person`           int(1)                                           NULL     DEFAULT 0 COMMENT '审批人 0 指定成员 1 组织架构板块负责人 2 角色组',
    `oa_company_entity_info_id` bigint(20) UNSIGNED                              NULL     DEFAULT NULL COMMENT '付款公司主体ID',
    `oa_role_id`                bigint(20) UNSIGNED                              NULL     DEFAULT NULL COMMENT '（OA）角色id',
    `start_flag`                tinyint(3) UNSIGNED                              NULL     DEFAULT NULL COMMENT '是否发起节点 1 是 0 否',
    `oa_number`                 varchar(20) CHARACTER SET utf8 COLLATE utf8_bin  NULL     DEFAULT NULL COMMENT 'OA申请编号',
    `deleted`                   tinyint(4)                                       NOT NULL DEFAULT 0 COMMENT '逻辑删除',
    `create_by`                 varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT '' COMMENT '创建人',
    `gmt_create`                timestamp                                        NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`                 varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL     DEFAULT '' COMMENT '修改人',
    `gmt_modified`              timestamp                                        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_business_key` (`business_key`, `historic_task_id`) USING BTREE,
    INDEX `idx_task_def_key` (`task_def_key`, `historic_task_id`) USING BTREE,
    INDEX `idx_his_task_id` (`historic_task_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8
  COLLATE = utf8_bin COMMENT = '流程业务处理日志表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `flow_act_def`;
CREATE TABLE `flow_act_def`
(
    `id`               bigint(20) UNSIGNED                                     NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `proc_def_id`      varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL     DEFAULT '' COMMENT '流程定义id',
    `proc_def_key`     varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '流程定义key',
    `proc_def_version` int(11)                                                 NULL     DEFAULT 0 COMMENT '流程定义版本',
    `activity_key`     varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '活动定义key',
    `activity_name`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '活动名称',
    `activity_type`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '活动类型，如startEvent、userTask',
    `time_limit`       float(4, 1)                                             NULL     DEFAULT 0.0 COMMENT '时限（单位：0.5天）',
    `is_working_day`   tinyint(3) UNSIGNED                                     NULL     DEFAULT 0 COMMENT '是否是工作日，1是，0否',
    `deleted`          tinyint(4)                                              NOT NULL DEFAULT 0 COMMENT '逻辑删除',
    `create_by`        varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '创建人',
    `update_by`        varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '修改人',
    `gmt_create`       timestamp                                               NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified`     timestamp                                               NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_proc_def_id` (`proc_def_id`, `activity_key`, `proc_def_version`) USING BTREE,
    INDEX `idx_proc_def_key` (`proc_def_key`, `activity_key`, `proc_def_version`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '流程活动定义表'
  ROW_FORMAT = COMPACT;

DROP TABLE IF EXISTS `system_serial_num`;
CREATE TABLE `system_serial_num`
(
    `id`           bigint(20) UNSIGNED                                     NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `name`         varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci  NULL     DEFAULT ' ' COMMENT '编号名称（前缀）',
    `cur_num`      bigint(20) UNSIGNED                                     NULL     DEFAULT 0 COMMENT '当前序号值',
    `step`         tinyint(3) UNSIGNED                                     NULL     DEFAULT 1 COMMENT '步长',
    `remark`       varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT ' ' COMMENT '备注',
    `deleted`      tinyint(4)                                              NOT NULL DEFAULT 0 COMMENT '逻辑删除',
    `create_by`    varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '创建人',
    `gmt_create`   timestamp                                               NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`    varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL     DEFAULT '' COMMENT '修改人',
    `gmt_modified` timestamp                                               NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_name` (`name`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '系统编号记录表'
  ROW_FORMAT = DYNAMIC;
