DROP TABLE IF EXISTS `blade_device_type`;
CREATE TABLE `blade_device_type`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '类型编码（唯一）',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '机器类型'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_employee`;
CREATE TABLE `blade_employee`
(
    `id`              bigint(0) NOT NULL,
    `tenant_id`       varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `code`            varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工编号',
    `name`            varchar(32) 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 '邮箱',
    `tel`             varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话',
    `hire_date`       datetime(0) NULL DEFAULT NULL COMMENT '入职日期',
    `job_number`      varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '工卡号',
    `pin_code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        'PIN码',
    `organization_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
        '数据权限',
    `post_id`         varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '岗位ID',
    `user_id`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号ID',
    `role_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`     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) NULL DEFAULT NULL COMMENT '数据状态',
    `is_deleted`      int(0) NULL DEFAULT NULL,
    `avatar`          varchar(1000) 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_employee_post`;
CREATE TABLE `blade_employee_post`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `employee_id` bigint(0) NULL DEFAULT 0 COMMENT '员工ID',
    `post_id`     bigint(0) NULL DEFAULT 0 COMMENT '岗位ID',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '员工岗位表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_maintain_item`;
CREATE TABLE `blade_maintain_item`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保养编码',
    `name`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保养项',
    `requirement` varchar(350) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '保养项信息'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_maintain_project`;
CREATE TABLE `blade_maintain_project`
(
    `id`               bigint(0) NOT NULL COMMENT '主键',
    `status`           tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`       int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`        varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `device_type_id`   bigint(0) NULL DEFAULT NULL COMMENT '机器类型Id',
    `device_type_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '机器类型名称',
    `code`             varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保养项目编码',
    `name`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保养项目名称',
    `interval_time`    int(0) NULL DEFAULT NULL COMMENT '周期（天）',
    `pre_warning_days` int(0) NULL DEFAULT NULL COMMENT '保养预警提示（天）',
    `remark`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '保养项目'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_maintain_project_item`;
CREATE TABLE `blade_maintain_project_item`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `project_id`  bigint(0) NULL DEFAULT NULL COMMENT '保养项目Id',
    `item_id`     bigint(0) NULL DEFAULT NULL COMMENT '保养项Id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '保养项目保养项'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_malfunction_type`;
CREATE TABLE `blade_malfunction_type`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '故障类型编号',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '故障类型信息'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_material`;
CREATE TABLE `blade_material`
(
    `id`             bigint NOT NULL COMMENT '主键',
    `status`         tinyint unsigned DEFAULT NULL COMMENT '状态',
    `is_deleted`     int                                                           DEFAULT NULL,
    `create_user`    bigint                                                        DEFAULT NULL COMMENT '创建人',
    `create_dept`    bigint                                                        DEFAULT NULL COMMENT '创建部门',
    `create_time`    datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `update_user`    bigint                                                        DEFAULT NULL COMMENT '更新人',
    `update_time`    datetime                                                      DEFAULT NULL COMMENT '更新时间',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '所属租户',
    `code`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物料编码',
    `bar_code`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '物料条码',
    `name`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '物料名称',
    `type_id`        bigint                                                        DEFAULT NULL COMMENT '物料类型id',
    `unit`           varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '计量单位',
    `stuff`          varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '材质',
    `standard_model` varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '规格',
    `remark`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
    `lower_limit`    decimal(20, 2)                                                DEFAULT NULL,
    `upper_limit`    decimal(20, 2)                                                DEFAULT NULL,
    `is_must_check`  int                                                           DEFAULT NULL COMMENT '是否必检：0-非必检，1-必检',
    `property`       int                                                           DEFAULT NULL COMMENT '物料性质：1-原材料、2-半成品、3-成品、4-备品备件、5-辅助用品、9-其它',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='物料';

DROP TABLE IF EXISTS `blade_material_type`;
CREATE TABLE `blade_material_type`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物料类型编码',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '物料类型'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_notice`;
CREATE TABLE `blade_notice`
(
    `id`           bigint(0) NOT NULL COMMENT '主键',
    `tenant_id`    varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `title`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题',
    `category`     int(0) NULL DEFAULT NULL COMMENT '类型',
    `release_time` timestamp(0) NULL DEFAULT NULL COMMENT '发布时间',
    `content`      varchar(2000) 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_notify_history`;
CREATE TABLE `blade_notify_history`
(
    `id`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL,
    `state`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通知状态',
    `notify_type`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '通知类型',
    `notifier_id`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '通知ID',
    `notify_time`  datetime(6) NULL DEFAULT NULL COMMENT '通知时间',
    `provider`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NOT NULL COMMENT '提供商',
    `template_id`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '模板id',
    `template`     longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '模板内容',
    `retry_times`  int(0) NULL DEFAULT NULL COMMENT '重试次数',
    `error_type`   varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '错误类型',
    `context_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知数据',
    `error_stack`  text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci 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) NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`   int(0) NULL DEFAULT NULL,
    `trance_id`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '追溯ID',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX          `idx_nt_his_notifier_id` (`notifier_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_notify_notifications`;
CREATE TABLE `blade_notify_notifications`
(
    `id`           varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `subscribe_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订阅追溯Id',
    `subscriber`   varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订阅得用户ID',
    `businessKey`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT
        '主题标识,如:device_alarm',
    `businessName` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '主题名称',
    `message`      text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知消息内容',
    `notify_time`  bigint(0) NOT NULL COMMENT '通知时间',
    `state`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通知状态',
    `description`  varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `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) NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`   int(0) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX          `idx_ntfc_subscribe` (`subscriber`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_notify_subscribers`;
CREATE TABLE `blade_notify_subscribers`
(
    `id`            varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `tenant_id`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `subscriber`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订阅者ID',
    `business_key`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT
        '业务主题,如:device_alarm',
    `business_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '主题名称,如:设备告警',
    `notify_type`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '订阅通知类型',
    `description`   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`   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) NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`    int(0) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX           `idx_nfy_subs_subscriber` (`subscriber`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_process`;
CREATE TABLE `blade_process`
(
    `id`          bigint(0) NOT NULL,
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工序编号',
    `name`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工序名称',
    `type`        int(0) NULL DEFAULT NULL COMMENT '工序类型',
    `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '工序描述',
    `is_import`   tinyint(0) NULL DEFAULT NULL COMMENT '是否导入',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
    `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user` bigint(0) NULL DEFAULT NULL COMMENT '更新人',
    `create_dept` bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `status`      int(0) NULL DEFAULT NULL COMMENT '业务状态',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '生产工序信息；'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_process_association`;
CREATE TABLE `blade_process_association`
(
    `id`         bigint(0) NOT NULL COMMENT '主键id',
    `type`       tinyint(0) NULL DEFAULT NULL COMMENT '业务类型：1、工位，2、库区，3、供应商',
    `biz_id`     bigint(0) NULL DEFAULT NULL COMMENT '业务id',
    `process_id` bigint(0) NULL DEFAULT NULL COMMENT '工序id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工序关系表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS blade_product;
CREATE TABLE `blade_product`
(
    `id`             BIGINT(20) NOT NULL COMMENT '产品ID',
    `tenant_id`      VARCHAR(12) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '000000' COMMENT '所属租户',
    `code`           VARCHAR(128) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品编号',
    `name`           VARCHAR(255) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品名称',
    `parent_id`      BIGINT(20) DEFAULT NULL COMMENT '上级产品ID',
    `type_id`        BIGINT(20) NOT NULL COMMENT '产品类型',
    `unit`           VARCHAR(10) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '计量单位',
    `standard_model` VARCHAR(255) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规格型号',
    `description`    VARCHAR(255) CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品描述',
    `documents`      text CHARACTER
        SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '产品文档',
    `extend_field`   json                      DEFAULT NULL COMMENT '扩展字段',
    `create_user`    BIGINT(20) DEFAULT NULL COMMENT '创建人',
    `create_dept`    BIGINT(20) DEFAULT NULL COMMENT '创建部门',
    `create_time`    datetime                  DEFAULT NULL COMMENT '创建时间',
    `update_user`    BIGINT(20) DEFAULT NULL COMMENT '更新人',
    `update_time`    datetime                  DEFAULT NULL COMMENT '更新时间',
    `status`         INT(2) DEFAULT NULL COMMENT '状态：1启用 0停用',
    `is_deleted`     INT(11) DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE,
    KEY              `type_id_index` (`type_id`) USING BTREE
) ENGINE = INNODB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT = '产品信息';

-- 产品类型表
DROP TABLE IF EXISTS `blade_product_type`;
CREATE TABLE `blade_product_type`
(
    `id`          bigint(20) NOT NULL COMMENT '主键',
    `status`      tinyint(3) UNSIGNED NULL DEFAULT 1 COMMENT '状态: 1为启动，0为停用',
    `is_deleted`  int(11) NULL DEFAULT NULL,
    `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 '更新时间',
    `name`        varchar(64) 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 '备注/说明',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueNameIndex` (`name`, `is_deleted`) USING BTREE COMMENT '名称唯一索引'
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '产品类型'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_production_calendar`;
CREATE TABLE `blade_production_calendar`
(
    `id`          bigint NOT NULL,
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '日历编号',
    `name`        varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '日历名称',
    `year`        int                                                           DEFAULT NULL COMMENT '应用年份',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '租户id',
    `is_deleted`  int                                                           DEFAULT NULL,
    `create_dept` bigint                                                        DEFAULT NULL COMMENT '部门',
    `status`      tinyint                                                       DEFAULT NULL COMMENT '启用禁用(0:禁用，1:启用)',
    `create_user` bigint                                                        DEFAULT NULL COMMENT '创建人',
    `create_time` datetime                                                      DEFAULT NULL COMMENT '创建日期',
    `update_user` bigint                                                        DEFAULT NULL COMMENT '更新人',
    `update_time` datetime                                                      DEFAULT NULL COMMENT '更新日期',
    PRIMARY KEY (`id`) USING BTREE,
    KEY           `codeIndex` (`code`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='生产日历';

DROP TABLE IF EXISTS `blade_production_calendar_day`;
CREATE TABLE `blade_production_calendar_day`
(
    `id`               bigint NOT NULL,
    `calendar_id`      bigint   DEFAULT NULL COMMENT '生产日历id',
    `calendar_date`    date     DEFAULT NULL COMMENT '生产日历日期',
    `start_time`       datetime DEFAULT NULL COMMENT '班次日开始时间',
    `end_time`         datetime DEFAULT NULL COMMENT '班次日结束时间',
    `week`             int      DEFAULT NULL COMMENT '属于当年的第几周',
    `month`            int      DEFAULT NULL COMMENT '属于当年的第几月',
    `year`             int      DEFAULT NULL COMMENT '属于哪一年',
    `model_id`         bigint   DEFAULT NULL COMMENT '班次模型id',
    `is_deleted`       int      DEFAULT NULL,
    `is_high_priority` tinyint  DEFAULT NULL COMMENT '是否高优先级(0:否,1:是)',
    `is_off_day`       tinyint  DEFAULT NULL COMMENT '是否是休息日(0:否,1:是)',
    `off_id`           bigint   DEFAULT NULL COMMENT '休息日id',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                `calendarDateIndex` (`calendar_date`) USING BTREE,
    KEY                `calendarIdIndex` (`calendar_id`) USING BTREE,
    KEY                `modelIndex` (`model_id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='生产日历日信息';

DROP TABLE IF EXISTS `blade_production_calendar_daytime`;
CREATE TABLE `blade_production_calendar_daytime`
(
    `id`               bigint(0) NOT NULL,
    `calendar_id`      bigint(0) NULL DEFAULT NULL COMMENT '生产日历id',
    `calendar_day_id`  bigint(0) NULL DEFAULT NULL COMMENT '生产日历具体id',
    `calendar_date`    date NULL DEFAULT NULL COMMENT '生产日历日期',
    `start_time`       datetime(0) NULL DEFAULT NULL COMMENT '班次开始时间',
    `end_time`         datetime(0) NULL DEFAULT NULL COMMENT '班次结束时间',
    `shift_index`      tinyint(0) NULL DEFAULT NULL COMMENT '班次序号',
    `shift_type`       tinyint(0) NULL DEFAULT NULL COMMENT '班次类型(1-工作时段,2-休息时段,0-工厂日内未定义时段,3-工厂日外未定义时段)',
    `week`             int(0) NULL DEFAULT NULL COMMENT '属于当年的第几周',
    `month`            int(0) NULL DEFAULT NULL COMMENT '属于当年第几月',
    `year`             int(0) NULL DEFAULT NULL COMMENT '年',
    `create_time`      datetime(0) NULL DEFAULT NULL COMMENT '本条记录创建时间',
    `create_user`      bigint(0) NULL DEFAULT NULL COMMENT '创建人',
    `is_high_priority` tinyint(0) NULL DEFAULT NULL COMMENT '是否高优先级(0:否,1:是)',
    `is_undefined`     tinyint(0) NULL DEFAULT NULL COMMENT '是否未定义工厂日(0:否,1:是)',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX              `calendarDateIndex` (`calendar_date`) USING BTREE,
    INDEX              `calendarIdIndex` (`calendar_id`) USING BTREE,
    INDEX              `shift_time_index` (`calendar_id`, `start_time`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '生产日历日时间段定义'
  ROW_FORMAT
      = Dynamic;

DROP TABLE IF EXISTS `blade_production_capacity_group`;
CREATE TABLE `blade_production_capacity_group`
(
    `id`            bigint(0) NOT NULL COMMENT '主键',
    `tenant_id`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `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 '备注',
    `calendar_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `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_region`;
CREATE TABLE `blade_region`
(
    `code`          varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '区划编号',
    `parent_code`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '父区划编号',
    `ancestors`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '祖区划编号',
    `name`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区划名称',
    `province_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '省级区划编号',
    `province_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '省级名称',
    `city_code`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '市级区划编号',
    `city_name`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '市级名称',
    `district_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '区级区划编号',
    `district_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '区级名称',
    `town_code`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '镇级区划编号',
    `town_name`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '镇级名称',
    `village_code`  varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '村级区划编号',
    `village_name`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '村级名称',
    `region_level`  int(0) 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 '备注',
    PRIMARY KEY (`code`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '行政区划表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_shift_detail`;
CREATE TABLE `blade_shift_detail`
(
    `id`               bigint NOT NULL,
    `model_id`         bigint                                                 DEFAULT NULL COMMENT '班次模型id',
    `shift_index`      tinyint                                                DEFAULT NULL COMMENT '班次序号',
    `shift_start_time` int                                                    DEFAULT NULL COMMENT '班次开始时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    `shift_end_time`   int                                                    DEFAULT NULL COMMENT '班次开始时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    `rest_number`      tinyint                                                DEFAULT NULL COMMENT '班次休息时段数量',
    `index_name`       varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '下标名称',
    PRIMARY KEY (`id`) USING BTREE,
    KEY                `modelIndex` (`model_id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `blade_shift_model`;
CREATE TABLE `blade_shift_model`
(
    `id`           bigint(0) NOT NULL,
    `code`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '班次编号',
    `name`         varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班次名称',
    `shift_number` tinyint(0) NULL DEFAULT NULL COMMENT '班次数量',
    `colour`       varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班次颜色',
    `start_time`   int(0) NULL DEFAULT NULL COMMENT '班次日开始时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    `end_time`     int(0) NULL DEFAULT NULL COMMENT '班次日结束时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    `tenant_id`    varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
    `is_deleted`   int(0) NULL DEFAULT NULL,
    `is_default`   tinyint(0) NULL DEFAULT NULL COMMENT '是否是默认班次(0-默认,1-非默认)默认班次不可编辑,不可删除',
    `create_user`  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 '更新日期',
    `create_dept`  bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `status`       int(0) NULL DEFAULT NULL COMMENT '业务状态',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_shift_rest_time`;
CREATE TABLE `blade_shift_rest_time`
(
    `id`              bigint(0) NOT NULL,
    `model_id`        bigint(0) NULL DEFAULT NULL COMMENT '模型Id',
    `rest_index`      int(0) NULL DEFAULT NULL COMMENT '休息时段序号',
    `shift_id`        bigint(0) NULL DEFAULT NULL COMMENT '班次Id',
    `rest_start_time` int(0) NULL DEFAULT NULL COMMENT '休息时段开始时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    `rest_end_time`   int(0) NULL DEFAULT NULL COMMENT '休息时段结束时间的偏移量(以当日0点为基准的偏移量的分钟数）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_stock_in_type`;
CREATE TABLE `blade_stock_in_type`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '入库类型编码',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '入库类型'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_stock_out_type`;
CREATE TABLE `blade_stock_out_type`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出库类型编码',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '出库类型'
  ROW_FORMAT =
      Dynamic;


DROP TABLE IF EXISTS `blade_supplier`;
CREATE TABLE `blade_supplier`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商编码',
    `name`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商名称',
    `address`     varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '供应商地址',
    `tel`         varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系方式',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '供应商'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_tool`;
CREATE TABLE `blade_tool`
(
    `id`                bigint(20) NOT NULL COMMENT '主键',
    `status`            tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`        int(11) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除，1-已删除',
    `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 '更新时间',
    `tenant_id`         varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
    `tool_category_id`  bigint(20) NULL DEFAULT NULL COMMENT '刀具类型id',
    `tool_model_id`     bigint(20) NULL DEFAULT NULL COMMENT '刀具型号id',
    `tool_prefix_code`  varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '刀具前缀编号',
    `life_count_method` int(11) NULL DEFAULT NULL COMMENT '寿命计数方式(1.按次数 2.按时间)',
    `initial_life`      int(45) NULL DEFAULT NULL COMMENT '初始寿命',
    `used_life`         int(45) NULL DEFAULT NULL COMMENT '已用寿命',
    `remain_life`       int(45) NULL DEFAULT NULL COMMENT '剩余寿命',
    `warning_value`     int(45) NULL DEFAULT NULL COMMENT '预警值',
    `life_state`        int(4) NULL DEFAULT NULL COMMENT '寿命状态(1.正常 2.警告 3.报警)',
    `use_state`         int(4) NULL DEFAULT NULL COMMENT '使用状态(2.新增 1.已装刀 0.已卸刀)',
    `workstation_id`    bigint(20) NULL DEFAULT NULL COMMENT '工位Id',
    `workstation_code`  varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工位编号',
    `workstation_name`  varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工位名称',
    `tool_position`     int(11) NULL DEFAULT NULL COMMENT '机床刀位',
    `parameter1`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数1',
    `parameter2`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数2',
    `parameter3`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数3',
    `parameter4`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数4',
    `parameter5`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数5',
    `parameter6`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数6',
    `parameter7`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数7',
    `parameter8`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数8',
    `parameter9`        varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数9',
    `parameter10`       varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数10',
    `code`              varchar(255) 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_tool_category`;
CREATE TABLE `blade_tool_category`
(
    `id`               bigint(20) NOT NULL COMMENT '主键',
    `status`           tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`       int(11) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除',
    `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 '更新时间',
    `tenant_id`        varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
    `parent_id`        bigint(20) NULL DEFAULT 0 COMMENT '父主键',
    `name`             varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组名',
    `sort`             int(10) NULL DEFAULT NULL COMMENT '顺序',
    `tool_prefix_code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '编码规则前缀',
    `code_length`      varchar(45) 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_tool_model`;
CREATE TABLE `blade_tool_model`
(
    `id`                bigint(20) NOT NULL COMMENT '主键',
    `status`            tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`        int(11) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除，1-已删除',
    `create_user`       bigint(20) NULL DEFAULT NULL COMMENT '创建人',
    `create_dept`       bigint(20) NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`       datetime NULL DEFAULT NULL COMMENT '创建时间',
    `update_user`       bigint(20) NULL DEFAULT NULL COMMENT '更新人',
    `update_time`       datetime NULL DEFAULT NULL COMMENT '更新时间',
    `tenant_id`         varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
    `tool_category_id`  bigint(20) NULL DEFAULT NULL COMMENT '刀具类型id',
    `tool_prefix_code`  varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '刀具前缀编号',
    `life_count_method` int(11) NULL DEFAULT NULL COMMENT '寿命计数方式(1.按次数 2.按时间)',
    `initial_life`      int(45) NULL DEFAULT NULL COMMENT '初始寿命',
    `warning_value`     int(45) NULL DEFAULT NULL COMMENT '预警值',
    `parameter1`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数1',
    `parameter2`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数2',
    `parameter3`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数3',
    `parameter4`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数4',
    `parameter5`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数5',
    `parameter6`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数6',
    `parameter7`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数7',
    `parameter8`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数8',
    `parameter9`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数9',
    `parameter10`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '参数10',
    `model`             varchar(255) 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_workstation`;
CREATE TABLE `blade_workstation`
(
    `id`                        bigint                                                        NOT NULL,
    `tenant_id`                 varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci            DEFAULT NULL COMMENT '所属租户',
    `code`                      varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '工位编号',
    `name`                      varchar(32) CHARACTER SET gbk COLLATE gbk_chinese_ci          NOT NULL COMMENT '工位名称',
    `avatar`                    varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci         DEFAULT NULL COMMENT '头像',
    `type`                      int                                                           NOT NULL DEFAULT '1' COMMENT '工位类型：机器、人, 来自字典 workstation_type',
    `calendar_code`             varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '#default#' COMMENT '生产日历',
    `standard_efficiency`       decimal(5, 2)                                                          DEFAULT NULL COMMENT '标准效率',
    `production_capacity_group` bigint                                                                 DEFAULT NULL COMMENT '产能组',
    `calendar_code_waiting`     varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci           DEFAULT NULL COMMENT '生产日历等待更新',
    `status`                    int                                                                    DEFAULT NULL COMMENT '业务状态',
    `create_dept`               bigint                                                                 DEFAULT NULL COMMENT '创建单位',
    `is_deleted`                int                                                                    DEFAULT NULL,
    `create_time`               datetime                                                               DEFAULT NULL COMMENT '创建时间',
    `create_user`               bigint                                                                 DEFAULT NULL COMMENT '创建人',
    `update_time`               datetime                                                               DEFAULT NULL COMMENT '更新时间',
    `update_user`               bigint                                                                 DEFAULT NULL COMMENT '更新人',
    `support_cnc_rw`            tinyint                                                                DEFAULT NULL COMMENT '是否支持文件写入(1 支持 0 不支持)',
    `device_type`               int                                                                    DEFAULT NULL COMMENT '加工设备类型',
    `properties`                int                                                                    DEFAULT NULL COMMENT '加工属性',
    `transmission_method`       int                                                                    DEFAULT 1 COMMENT '程序传输方式：1 FTP 2 串口',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE,
    KEY                         `calendarIndex` (`calendar_code`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='工位';

DROP TABLE IF EXISTS `blade_workstation_of_machine`;
CREATE TABLE `blade_workstation_of_machine`
(
    `id`             bigint(0) NOT NULL,
    `workstation_id` bigint(0) NOT NULL,
    `machine_id`     bigint(0) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '机器工位'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_workstation_of_workstation_group`;
CREATE TABLE `blade_workstation_of_workstation_group`
(
    `id`                   bigint(0) NOT NULL,
    `workstation_id`       bigint(0) NOT NULL,
    `workstation_group_id` bigint(0) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工位-工位组对应表'
  ROW_FORMAT
      = Dynamic;

DROP TABLE IF EXISTS `blade_workstation_wcs`;
CREATE TABLE `blade_workstation_wcs`
(
    `id`                   bigint NOT NULL COMMENT '主键id',
    `tenant_id`            varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `workstation_id`       bigint NULL DEFAULT NULL COMMENT '工位id',
    `data_item`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工位变量名称',
    `data_type`            int NULL DEFAULT NULL COMMENT '采集用途',
    `dmp_variables_id`     bigint NULL DEFAULT NULL COMMENT '采集项id',
    `status`               int NULL DEFAULT NULL COMMENT '业务状态',
    `collect_item`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `create_dept`          bigint NULL DEFAULT NULL COMMENT '创建部门',
    `create_time`          datetime NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`          bigint NULL DEFAULT NULL COMMENT '创建人',
    `update_time`          datetime NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`          bigint NULL DEFAULT NULL COMMENT '更新人',
    `is_deleted`           int NULL DEFAULT NULL,
    `data_item_crc`        varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '校验值',
    `collect_setting_item` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '采集项',
    `big_screen`           tinyint(0) NULL DEFAULT 1 COMMENT '大屏',
    `real_time_data`       tinyint(0) NULL DEFAULT 1 COMMENT '实时数据',
    `process_parameter`    tinyint(0) NULL DEFAULT 1 COMMENT '过程参数',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工况参数'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_gallery`;
CREATE TABLE `blade_gallery`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `name`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图库名称',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '图库'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_gallery_item`;
CREATE TABLE `blade_gallery_item`
(
    `id`            bigint(0) NOT NULL COMMENT '主键',
    `gallery_id`    bigint(0) NULL DEFAULT NULL COMMENT '图库类别ID',
    `name`          varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '名称',
    `original_name` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件原名',
    `thumbnail`     text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '缩略图，base64存储',
    `link`          varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件地址',
    `extension`     varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '附件拓展名',
    `status`        tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '数据状态，1启用/0停用',
    `is_deleted`    int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '图库'
  ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `blade_check_item`;
CREATE TABLE `blade_check_item`
(
    `id`               bigint(0) NOT NULL COMMENT '主键',
    `status`           tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`       int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`        varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `check_project_id` bigint(0) NULL DEFAULT NULL COMMENT '点检项目Id',
    `name`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '点检项',
    `value_type`       varchar(64) 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
        '点检要求',
    `standard_value`   varchar(64) 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_check_project`;
CREATE TABLE `blade_check_project`
(
    `id`          bigint(0) NOT NULL COMMENT '主键',
    `status`      tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '点检项目编码',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '点检项目信息'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_machine`;
CREATE TABLE `blade_machine`
(
    `id`                        bigint(0) NOT NULL,
    `tenant_id`                 varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户ID',
    `extend_id`                 varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '扩展id',
    `machine_code`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '机器编号',
    `machine_name`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '机器名称',
    `collect_switch`            tinyint(0) NOT NULL DEFAULT 0 COMMENT '采集开关：0关/1开',
    `collect_driver`            varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '采集驱动',
    `type_name`                 varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型',
    `machine_type`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型',
    `machine_model`             varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '机器规格',
    `machine_life_status`       tinyint(0) NULL DEFAULT NULL COMMENT '生命状态 字典 machine_life_status',
    `machine_use_status`        tinyint(0) NULL DEFAULT NULL COMMENT '使用状态 字典 machine_use_status',
    `factory_no`                varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出厂编号',
    `assets_code`               varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资产编号',
    `brand`                     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '品牌',
    `nameplate`                 varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '铭牌',
    `avatar`                    varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像',
    `serial_no`                 varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '序列号',
    `factory_file`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出厂档案',
    `manufacturer`              varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制造厂商',
    `country_of_manufacture`    varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产地国别',
    `system_name`               varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统名称',
    `software_version`          varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '软件版本',
    `net_weight`                decimal(19, 2) NULL DEFAULT NULL COMMENT '净重kg',
    `power`                     decimal(19, 2) NULL DEFAULT NULL COMMENT '功率kw',
    `voltage`                   decimal(19, 2) NULL DEFAULT NULL COMMENT '电压v',
    `dimensions`                varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '轮廓尺寸(CM)',
    `production_time`           datetime(0) NULL DEFAULT NULL COMMENT '生产日期',
    `delivery_time`             datetime(0) NULL DEFAULT NULL COMMENT '交付日期',
    `depreciation_year`         int(0) NULL DEFAULT NULL COMMENT '折旧年限',
    `turn_to_fixed_assets_time` datetime(0) NULL DEFAULT NULL COMMENT '转固日期',
    `invoice_value`             decimal(19, 2) NULL DEFAULT NULL COMMENT '发票金额',
    `ovfa`                      decimal(19, 2) NULL DEFAULT NULL COMMENT '资产原值',
    `net_asset_value`           decimal(19, 2) NULL DEFAULT NULL COMMENT '资产净值',
    `organization`              bigint(0) NULL DEFAULT NULL COMMENT '使用部门',
    `custodian`                 bigint(0) NULL DEFAULT NULL COMMENT '保管人',
    `management_class`          tinyint(0) NULL DEFAULT NULL COMMENT '管理等级，字典 machine_management_class',
    `elaborate_equipment`       tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '是否是特种设备，1是/0否',
    `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) NULL DEFAULT NULL COMMENT '业务状态',
    `is_deleted`                int(0) NULL DEFAULT NULL,
    `pin_code`                  char(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'PIN码',
    `short_code`                varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '短编码',
    `last_repair_time`          datetime(0) NULL DEFAULT NULL COMMENT '维修日期',
    `employee_id`               bigint(0) NULL DEFAULT NULL COMMENT '责任人',
    `production_line`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '生产线',
    `organization_id`           bigint(0) NULL DEFAULT NULL COMMENT '使用部门',
    `remark`                    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `machine_type_id`           bigint(0) NULL DEFAULT NULL COMMENT '机器类型id',
    `group_id`                  bigint(0) NULL DEFAULT NULL COMMENT '所属机器组id',
    `last_maintain_time`        datetime(0) NULL DEFAULT NULL COMMENT '最后保养时间',
    `next_maintain_time`        datetime(0) NULL DEFAULT NULL COMMENT '下次保养时间',
    `last_check_time`           datetime(0) NULL DEFAULT NULL COMMENT '最后点检时间',
    `installation_location`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '安装位置',
    `maintenance_time`          datetime(0) NULL DEFAULT NULL COMMENT '保养日期',
    `repair_status`             tinyint(0) NULL DEFAULT NULL COMMENT '维修状态',
    `maintenance_status`        tinyint(0) NULL DEFAULT NULL COMMENT '保养状态',
    `external_key`              varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备外部标识（用户可更改，用于标识该设备,唯一标识，可使用该Key进行检索设备）',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX                       `employee_id` (`employee_id`) USING BTREE,
    INDEX                       `employee_id_2` (`employee_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '机器'
  ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `blade_shift_off_day`;
CREATE TABLE `blade_shift_off_day`
(
    `id`            bigint(0) NOT NULL COMMENT '主键',
    `status`        tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`    int(0) UNSIGNED NULL DEFAULT 0 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 '更新时间',
    `start_off_day` date NULL DEFAULT NULL COMMENT '休息日-开始',
    `end_off_day`   date NULL DEFAULT NULL COMMENT '休息日-结束',
    `remark`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注/说明',
    `year`          int(0) UNSIGNED 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_fixture`;
CREATE TABLE `blade_fixture`
(
    `id`             bigint                                                        NOT NULL,
    `tenant_id`      varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `code`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '夹具编号',
    `name`           varchar(32) CHARACTER SET gbk COLLATE gbk_chinese_ci          NOT NULL COMMENT '夹具名称',
    `fixture_status` int NULL DEFAULT NULL COMMENT '夹具状态',
    `description`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
    `avatar`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图像',
    `in_use`         tinyint NULL DEFAULT 0 COMMENT '是否在使用',
    `status`         int NULL DEFAULT NULL COMMENT '业务状态',
    `create_dept`    bigint NULL DEFAULT NULL COMMENT '创建单位',
    `is_deleted`     int NULL DEFAULT NULL,
    `create_time`    datetime NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`    bigint NULL DEFAULT NULL COMMENT '创建人',
    `update_time`    datetime NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`    bigint NULL DEFAULT NULL COMMENT '更新人',
    `remark`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工装夹具'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `blade_warehouse_area`;
CREATE TABLE `blade_warehouse_area`
(
    `id`          bigint(20) NOT NULL COMMENT '主键',
    `status`      tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `parent_id`   bigint(20) NOT NULL COMMENT '父级id',
    `is_deleted`  int(11) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `code`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库区编码',
    `name`        varchar(64) 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 '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '库区'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for blade_warehouse_area_of_material_type
-- ----------------------------
DROP TABLE IF EXISTS `blade_warehouse_area_of_material_type`;
CREATE TABLE `blade_warehouse_area_of_material_type`
(
    `id`                bigint(0) NOT NULL COMMENT '主键',
    `warehouse_area_id` bigint(0) NULL DEFAULT NULL COMMENT '库区id',
    `material_type_id`  bigint(0) NULL DEFAULT NULL COMMENT '物料类型id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '库区物料类型连接表'
  ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `blade_code`;
CREATE TABLE `blade_code`
(
    `id`            bigint(0) NOT NULL COMMENT '主键',
    `datasource_id` bigint(0) NULL DEFAULT NULL COMMENT '数据源主键',
    `service_name`  varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务名称',
    `code_name`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模块名称',
    `table_name`    varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表名',
    `table_prefix`  varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表前缀',
    `pk_name`       varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主键名',
    `package_name`  varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '后端包名',
    `base_mode`     int(0) NULL DEFAULT NULL COMMENT '基础业务模式',
    `wrap_mode`     int(0) NULL DEFAULT NULL COMMENT '包装器模式',
    `api_path`      varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '后端路径',
    `web_path`      varchar(2000) 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_device_type_check_project`;
CREATE TABLE `blade_device_type_check_project`
(
    `id`               bigint(0) NOT NULL COMMENT '主键',
    `status`           tinyint(0) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`       int(0) NULL DEFAULT NULL,
    `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 '更新时间',
    `tenant_id`        varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '所属租户',
    `device_type_id`   bigint(0) NULL DEFAULT NULL COMMENT '设备类型id',
    `check_project_id` bigint(0) NULL DEFAULT NULL COMMENT '点检项目id',
    `interval_time`    int(0) 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_warehouse_grid`;
CREATE TABLE `blade_warehouse_grid`
(
    `id`          bigint(20) NOT NULL COMMENT 'id',
    `tenant_id`   varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `station_id`  bigint(20) NOT NULL COMMENT '库位id',
    `code`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '货格编号',
    `name`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '货格名称',
    `status`      int(11) NULL DEFAULT NULL COMMENT '业务状态',
    `create_dept` bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
    `is_deleted`  int(11) NULL DEFAULT NULL,
    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
    `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
    `remark`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unique_code_index` (`code`, `is_deleted`) USING BTREE,
    INDEX         `station_index` (`station_id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '库区货格'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_warehouse_station`;
CREATE TABLE `blade_warehouse_station`
(
    `id`             bigint(20) NOT NULL COMMENT 'id',
    `tenant_id`      varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `area_id`        bigint(20) NOT NULL COMMENT '库区id',
    `warehouse_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库位编号',
    `warehouse_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '库位名称',
    `status`         int(11) NULL DEFAULT NULL COMMENT '业务状态',
    `create_dept`    bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
    `is_deleted`     int(11) NULL DEFAULT NULL,
    `create_time`    datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`    bigint(20) NULL DEFAULT NULL COMMENT '创建人',
    `update_time`    datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`    bigint(20) NULL DEFAULT NULL COMMENT '更新人',
    `remark`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `avatar`         varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`area_id`, `warehouse_code`, `is_deleted`) USING BTREE COMMENT '库位编号唯一索引',
    UNIQUE INDEX `uniqueNameIndex` (`area_id`, `warehouse_name`, `is_deleted`) USING BTREE COMMENT '库位名称唯一索引'
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '库区库位'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_tray`;
CREATE TABLE `blade_tray`
(
    `id`             bigint NOT NULL,
    `code`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '编码',
    `name`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称',
    `picture`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图片',
    `tray_status`    tinyint                                                       DEFAULT '1' COMMENT '托盘状态 1 - 空载 0 - 负载',
    `description`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '托盘描述',
    `in_use`         tinyint                                                       DEFAULT '0' COMMENT '是否使用 默认为1',
    `category`       tinyint                                                       DEFAULT NULL COMMENT '托盘类别',
    `standard_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规格',
    `availability`   tinyint                                                       DEFAULT NULL COMMENT '可用状态 1-激活 0-冻结',
    `remark`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
    `status`         tinyint                                                       DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`     bigint unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`    bigint                                                        DEFAULT NULL COMMENT '创建人',
    `create_dept`    bigint                                                        DEFAULT NULL COMMENT '创建部门',
    `create_time`    datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `update_user`    bigint                                                        DEFAULT NULL COMMENT '更新人',
    `update_time`    datetime                                                      DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uniqueCodeIndex` (`code`, `is_deleted`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='托盘';

-- 托盘面-托盘
DROP TABLE IF EXISTS `blade_tray_surface`;
CREATE TABLE `blade_tray_surface`
(
    `id`           bigint NOT NULL,
    `tray_id`      bigint                                                        DEFAULT NULL COMMENT '托盘id',
    `name`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '托盘面名称',
    `code`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '托盘面编号',
    `program_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '偏移程序编号',
    `in_use`       tinyint                                                       DEFAULT '0' COMMENT '是否使用 默认为1',
    `status`       tinyint                                                       DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`   bigint unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`  bigint                                                        DEFAULT NULL COMMENT '创建人',
    `create_dept`  bigint                                                        DEFAULT NULL COMMENT '创建部门',
    `create_time`  datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `update_user`  bigint                                                        DEFAULT NULL COMMENT '更新人',
    `update_time`  datetime                                                      DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='托盘面';

-- 托盘面-夹具
DROP TABLE IF EXISTS `blade_tray_fixture`;
CREATE TABLE `blade_tray_fixture`
(
    `id`          bigint NOT NULL,
    `tray_id`     bigint   DEFAULT NULL COMMENT '托盘id',
    `face_id`     bigint   DEFAULT NULL COMMENT '托盘面id',
    `fix_id`      bigint   DEFAULT NULL COMMENT '夹具id',
    `status`      tinyint  DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`  bigint unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user` bigint   DEFAULT NULL COMMENT '创建人',
    `create_dept` bigint   DEFAULT NULL COMMENT '创建部门',
    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
    `update_user` bigint   DEFAULT NULL COMMENT '更新人',
    `update_time` datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='托盘面-夹具';

DROP TABLE IF EXISTS `blade_workstation_workbench`;
CREATE TABLE `blade_workstation_workbench`
(
    `id`                bigint(0) NOT NULL COMMENT '主键',
    `status`            tinyint(0) NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`        int(0) NULL DEFAULT NULL COMMENT '删除',
    `create_user`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci 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 '更新时间',
    `tenant_id`         varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户',
    `workstation_id`    bigint(0) NULL DEFAULT NULL COMMENT '工位id',
    `sort`              int(0) NULL DEFAULT NULL COMMENT '排序',
    `name`              varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工作台名称',
    `workbench_default` int(0) NULL DEFAULT NULL 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_tool_appendix`;
CREATE TABLE `blade_tool_appendix`
(
    `id`           bigint NOT NULL,
    `tenant_id`    varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '所属租户',
    `parent_id`    bigint                                                        DEFAULT NULL COMMENT '父id',
    `file_length`  bigint                                                        DEFAULT NULL COMMENT '文件大小',
    `file_name`    varchar(255) COLLATE utf8mb4_general_ci                       DEFAULT NULL COMMENT '文件名称',
    `object_key`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件key',
    `file_link`    varchar(255) COLLATE utf8mb4_general_ci                       DEFAULT NULL COMMENT '文件链接',
    `content_type` varchar(255) COLLATE utf8mb4_general_ci                       DEFAULT NULL COMMENT '文件mini类型',
    `status`       int                                                           DEFAULT NULL COMMENT '业务状态',
    `create_dept`  bigint                                                        DEFAULT NULL COMMENT '创建单位',
    `is_deleted`   int                                                           DEFAULT NULL,
    `create_time`  datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `create_user`  bigint                                                        DEFAULT NULL COMMENT '创建人',
    `update_time`  datetime                                                      DEFAULT NULL COMMENT '更新时间',
    `update_user`  bigint                                                        DEFAULT NULL COMMENT '更新人',
    `remark`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uniqueCodeIndex` (`id`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='附件文件';

DROP TABLE IF EXISTS `blade_tray_storage`;
CREATE TABLE `blade_tray_storage`
(
    `id`                   bigint NOT NULL,
    `tray_id`              bigint   DEFAULT NULL COMMENT '托盘id',
    `warehouse_station_id` bigint   DEFAULT NULL COMMENT '库位id',
    `status`               tinyint  DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`           bigint unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`          bigint   DEFAULT NULL COMMENT '创建人',
    `create_dept`          bigint   DEFAULT NULL COMMENT '创建部门',
    `create_time`          datetime DEFAULT NULL COMMENT '创建时间',
    `update_user`          bigint   DEFAULT NULL COMMENT '更新人',
    `update_time`          datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='托盘存放';

DROP TABLE IF EXISTS `blade_production_craft_version`;
CREATE TABLE `blade_production_craft_version`
(
    `id`             bigint(20) NOT NULL,
    `tenant_id`      varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `name`           varchar(32) CHARACTER SET gbk COLLATE gbk_chinese_ci NOT NULL COMMENT '版本名称',
    `description`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本描述',
    `craft_id`       bigint(20) NULL NULL COMMENT '工艺路线id',
    `edition_status` int(11) NULL DEFAULT 0 COMMENT '是否定版(0:否 1:是)',
    `status`         int(11) NULL DEFAULT NULL COMMENT '业务状态',
    `create_dept`    bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
    `is_deleted`     bigint(20) NULL DEFAULT NULL,
    `create_time`    datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`    bigint(20) NULL DEFAULT NULL COMMENT '创建人',
    `update_time`    datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`    bigint(20) NULL DEFAULT NULL COMMENT '更新人',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '产品工艺版本'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for blade_production_craft_process_related_tool
-- ----------------------------
DROP TABLE IF EXISTS `blade_production_craft_process_related_tool`;
CREATE TABLE `blade_production_craft_process_related_tool`
(
    `id`                 bigint(20) NOT NULL COMMENT '主键',
    `tool_id`            bigint(20) NULL DEFAULT NULL COMMENT '刀具ID',
    `version_process_id` bigint(20) NULL DEFAULT NULL COMMENT '产品工艺工序ID',
    `tool_code`          varchar(128) NULL DEFAULT NULL COMMENT '刀具编号',
    `tool_model_name`    varchar(64) NULL DEFAULT NULL COMMENT '刀具型号名称',
    `tool_category_name` varchar(45) NULL DEFAULT NULL COMMENT '刀具类型名称',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '产品工艺工序关联刀具'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for blade_production_craft_process_related_fixture
-- ----------------------------
DROP TABLE IF EXISTS `blade_production_craft_process_related_fixture`;
CREATE TABLE `blade_production_craft_process_related_fixture`
(
    `id`                 bigint(20) NOT NULL COMMENT '主键',
    `fixture_id`         bigint(20) NULL DEFAULT NULL COMMENT '夹具ID',
    `version_process_id` bigint(20) NULL DEFAULT NULL COMMENT '产品工艺工序ID',
    `fixture_group_name` varchar(45) null,
    `fixture_code`       varchar(128) null,
    `fixture_name`       varchar(32) null,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '产品工艺工序关联夹具'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for blade_production_craft_process_file
-- ----------------------------
DROP TABLE IF EXISTS `blade_production_craft_process_file`;
CREATE TABLE `blade_production_craft_process_file`
(
    `id`                 bigint(20) NOT NULL,
    `version_process_id` bigint(20) NULL DEFAULT NULL COMMENT '产品工艺工序ID',
    `file_name`          varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名称',
    `object_key`         varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件key',
    `content_type`       varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件mini类型',
    `link`               varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件外链',
    `file_size`          varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件大小',
    `upload_time`        datetime(0) NULL DEFAULT NULL COMMENT '上传时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '产品工艺工序文件'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for blade_production_craft_process
-- ----------------------------
DROP TABLE IF EXISTS `blade_production_craft_process`;
CREATE TABLE `blade_production_craft_process`
(
    `id`                bigint(20) NOT NULL COMMENT '主键',
    `tenant_id`         varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `version_id`        bigint(20) NULL DEFAULT NULL COMMENT '所属工艺版本',
    `process_id`        bigint(20) NULL DEFAULT NULL COMMENT '所属生产工序',
    `sort`              int(11) NULL DEFAULT NULL COMMENT '工序顺序',
    `program_name`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '程序名称',
    `standard_time`     int(11) NULL DEFAULT NULL COMMENT '标准工时（秒）',
    `prepare_time`      int(11) NULL DEFAULT 0 COMMENT '准备工时',
    `disassembly_time`  int(11) NULL DEFAULT 0 COMMENT '拆卸工时',
    `transport_time`    int(11) NULL DEFAULT 0 COMMENT '运输工时',
    `source_id`         varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源ID',
    `target_id`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目标ID',
    `x_coordinate`      varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'x坐标',
    `y_coordinate`      varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'y坐标',
    `is_deleted`        bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_time`       datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`       bigint(20) NULL DEFAULT NULL COMMENT '创建人',
    `update_time`       datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`       bigint(20) NULL DEFAULT NULL COMMENT '更新人',
    `create_dept`       bigint(20) NULL DEFAULT NULL COMMENT '创建部门',
    `status`            int(11) NULL DEFAULT NULL COMMENT '业务状态',
    `process_name`      varchar(32) null comment '工序名称',
    `process_code`      varchar(128) null comment '工序编号',
    `process_desc`      varchar(255) null comment '工序描述',
    `process_type`      int null comment '工种',
    `process_type_name` varchar(32) null comment '工种名称',
    `program_id`        bigint null comment '程序id',
    `mea_method`        varchar(20) null comment '测量方式',
    `mea_method_value`  int null comment '测量方式维护的值',
    `handler_method`    int null comment '不合格品处理方式',
    `main_sequence_id`  bigint null comment '主序id（当主序id不为空时，代表工序是子序）',
    `whether_test`      int default 0 null comment '是否质检：默认 0 否 1 是',
    `whether_parallel`  int default 0 null comment '是否并行：默认 0 否 1 是',
    `bag_id`            bigint null comment '工艺包id',
    `bag_name`          varchar(64) null comment '工艺包名称',
    `height`            int(11) 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_material_storage`;
CREATE TABLE `blade_material_storage`
(
    `id`                   bigint(20) NOT NULL,
    `material_id`          bigint(20) DEFAULT NULL COMMENT '物料id',
    `warehouse_station_id` bigint(20) DEFAULT NULL COMMENT '库位id',
    `status`               tinyint(4) DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`           bigint(20) unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`          bigint(20) DEFAULT NULL COMMENT '创建人',
    `create_dept`          bigint(20) DEFAULT NULL COMMENT '创建部门',
    `create_time`          datetime DEFAULT NULL COMMENT '创建时间',
    `update_user`          bigint(20) DEFAULT NULL COMMENT '更新人',
    `update_time`          datetime DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='物料存放';

DROP TABLE IF EXISTS `blade_bom_material`;
CREATE TABLE `blade_bom_material`
(
    `id`          bigint(20) NOT NULL COMMENT '主键',
    `status`      tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`  bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除，1-已删除',
    `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 '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `version_id`  bigint(20) NULL DEFAULT NULL COMMENT 'bom版本id',
    `material_id` bigint(20) NULL DEFAULT NULL COMMENT '物料id',
    `parent_id`   bigint(20) NULL DEFAULT NULL COMMENT '父级Id',
    `all_path`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'allPath',
    `remark`      varchar(255) 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 = 'bom物料'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_bom_process`;
CREATE TABLE `blade_bom_process`
(
    `id`              bigint(20) NOT NULL COMMENT '主键',
    `status`          tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`      bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除，1-已删除',
    `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 '更新时间',
    `tenant_id`       varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `bom_material_id` bigint(20) NULL DEFAULT NULL COMMENT 'bom物料Id',
    `molecule`        int(11) NULL DEFAULT NULL COMMENT '用量分子',
    `denominator`     int(11) NULL DEFAULT NULL COMMENT '用量分母',
    `process_id`      bigint(20) NULL DEFAULT NULL COMMENT '用料工序id',
    `loss`            decimal(10, 2) NULL DEFAULT NULL COMMENT '固定损耗',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = 'bom物料工序'
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_bom_version`;
CREATE TABLE `blade_bom_version`
(
    `id`             bigint(20) NOT NULL COMMENT '主键',
    `status`         tinyint(3) UNSIGNED NULL DEFAULT NULL COMMENT '状态',
    `is_deleted`     bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '删除状态：0-未删除，1-已删除',
    `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 '更新时间',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属租户',
    `product_id`     bigint(20) NULL DEFAULT NULL COMMENT '产品id',
    `version`        varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本',
    `version_status` int(11) NULL DEFAULT 0 COMMENT '版本状态(0：未定版，1：已定版)',
    `craft_id`       bigint(20) NULL DEFAULT NULL COMMENT '工艺版本id',
    `craft_version`  varchar(32) 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 '备注',
    `description`    varchar(255) 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 = 'bom版本'
  ROW_FORMAT = Dynamic;

-- 工艺路线版本产线表
drop table if exists `blade_craft_version_line`;
CREATE TABLE `blade_craft_version_line`
(
    `id`          bigint NOT NULL COMMENT '主键',
    `status`      tinyint unsigned DEFAULT NULL COMMENT '状态',
    `is_deleted`  int                                                          DEFAULT NULL,
    `create_user` bigint                                                       DEFAULT NULL COMMENT '创建人',
    `create_dept` bigint                                                       DEFAULT NULL COMMENT '创建部门',
    `create_time` datetime                                                     DEFAULT NULL COMMENT '创建时间',
    `update_user` bigint                                                       DEFAULT NULL COMMENT '更新人',
    `update_time` datetime                                                     DEFAULT NULL COMMENT '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属租户',
    `craft_id`    bigint                                                       DEFAULT NULL COMMENT '工艺路线id',
    `version_id`  bigint                                                       DEFAULT NULL COMMENT '工艺路线版本id',
    `group_id`    bigint                                                       DEFAULT NULL COMMENT '产线id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='工艺路线版本产线表';

-- 工艺路线表
drop table if exists `blade_craft_routing`;
CREATE TABLE `blade_craft_routing`
(
    `id`          bigint NOT NULL COMMENT '主键',
    `status`      tinyint unsigned DEFAULT NULL COMMENT '状态',
    `is_deleted`  int                                                           DEFAULT NULL,
    `create_user` bigint                                                        DEFAULT NULL COMMENT '创建人',
    `create_dept` bigint                                                        DEFAULT NULL COMMENT '创建部门',
    `create_time` datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `update_user` bigint                                                        DEFAULT NULL COMMENT '更新人',
    `update_time` datetime                                                      DEFAULT NULL COMMENT '更新时间',
    `tenant_id`   varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '所属租户',
    `name`        varchar(48) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '名称',
    `description` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述',
    `product_id`  bigint                                                        DEFAULT NULL COMMENT '产品id',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uniqueCodeIndex` (`name`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='工艺路线';

DROP TABLE IF EXISTS `blade_dnc_fixed_space`;
CREATE TABLE `blade_dnc_fixed_space`
(
    `id`             bigint(20) NOT NULL COMMENT '主键',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT '000000' COMMENT '租户ID',
    `parent_id`      bigint(20) DEFAULT '0' COMMENT '父主键',
    `name`           varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '固定空间目录名称',
    `all_path`       varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '全路径(包含自身)',
    `is_deleted`     int(11) DEFAULT NULL,
    `status`         int(11) DEFAULT NULL COMMENT '状态',
    `create_time`    datetime                                                      DEFAULT NULL COMMENT '创建时间',
    `create_user`    bigint(20) DEFAULT NULL COMMENT '创建人',
    `update_time`    datetime                                                      DEFAULT NULL COMMENT '更新时间',
    `update_user`    bigint(20) DEFAULT NULL COMMENT '更新人',
    `create_dept`    bigint(20) DEFAULT NULL COMMENT '创建部门',
    `td_id`          bigint(20) DEFAULT NULL COMMENT '工位目录id',
    `space_location` int(11) DEFAULT NULL COMMENT '目录属性: 1 常规（根节点）2 固定',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='工位目录关联固定空间表';

DROP TABLE IF EXISTS `blade_dnc_transfer_directory`;
CREATE TABLE `blade_dnc_transfer_directory`
(
    `id`             bigint(0) NOT NULL,
    `group_all_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '工位文件组的all_path',
    `dept_id`        bigint(0) NULL DEFAULT NULL COMMENT '职权域id',
    `group_id`       bigint(0) NULL DEFAULT NULL COMMENT '工位文件分组Id',
    `name`           varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工位文件名称',
    `tenant_id`      varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `create_user`    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 '更新时间',
    `is_deleted`     int(0) NULL DEFAULT NULL,
    `create_dept`    bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `status`         int(0) NULL DEFAULT NULL COMMENT '业务状态',
    `resource_id`    bigint(0) NULL DEFAULT NULL COMMENT '资源id',
    `workstation_id` bigint(0) NULL DEFAULT NULL COMMENT '工位id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工位目录表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_dnc_transfer_directory_file`;
CREATE TABLE `blade_dnc_transfer_directory_file`
(
    `id`                    bigint(0) NOT NULL,
    `transfer_directory_id` bigint(0) NOT NULL COMMENT '工位目录Id',
    `file_source`           tinyint(0) NULL DEFAULT NULL COMMENT '文件来源 1 我的文档 2 本地文件 3 工艺管理',
    `file_type`             int(0) NULL DEFAULT NULL COMMENT '文件类别(1:加工文件,2:工艺文件)',
    `original_filename`     varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '原始文件名称',
    `filename`              varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件名称',
    `content_length`        bigint(0) NULL DEFAULT NULL,
    `content_md5`           varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件md5值',
    `last_modified`         datetime(0) NULL DEFAULT NULL COMMENT '最后修改时间',
    `content_type`          varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `object_key`            varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件的objectKey',
    `suffix`                varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `create_user`           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 '更新时间',
    `is_deleted`            int(0) NULL DEFAULT NULL,
    `create_dept`           bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `status`                int(0) NULL DEFAULT NULL COMMENT '业务状态',
    `link`                  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件地址',
    `is_current`            int(0) NULL DEFAULT NULL COMMENT '是否为当前版本,1是0否',
    `workstation_id`        bigint(0) NOT NULL COMMENT '工位Id',
    `cover_time`            datetime(0) NULL DEFAULT NULL COMMENT '文件时间',
    `craft_file_id`         bigint(0) NULL DEFAULT NULL COMMENT '文档文件id',
    `tenant_id`             varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT
        '租户ID',
    `version`               int(0) NULL DEFAULT NULL COMMENT '版本号',
    `storage_space`         int(0) NULL DEFAULT NULL COMMENT '存储位置：1 常规空间 2 固定空间',
    `whether_archive`       int(0) NULL DEFAULT NULL COMMENT '文件是否归档：1 未归档 2 已归档',
    `storage_space_id`      bigint(0) NULL DEFAULT NULL COMMENT '固定空间目录id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工位目录文件表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_dnc_transfer_directory_group`;
CREATE TABLE `blade_dnc_transfer_directory_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 '父主键',
    `name`                 varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工位文件组名',
    `all_path`             varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '全路径(包含自身)',
    `is_deleted`           int(0) NULL DEFAULT NULL,
    `status`               int(0) NULL DEFAULT NULL COMMENT '状态',
    `create_time`          datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`          bigint(0) NULL DEFAULT NULL COMMENT '创建人',
    `update_time`          datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`          bigint(0) NULL DEFAULT NULL COMMENT '更新人',
    `create_dept`          bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `workstation_group_id` bigint(0) NULL DEFAULT NULL COMMENT '工位组id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工位组目录表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_dnc_ws_relation_td`;
CREATE TABLE `blade_dnc_ws_relation_td`
(
    `id`                   bigint(20) NOT NULL,
    `tenant_id`            varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '000000' COMMENT '租户ID',
    `create_user`          bigint(20) DEFAULT NULL COMMENT '创建人',
    `create_time`          datetime                                                     DEFAULT NULL COMMENT '创建时间',
    `update_user`          bigint(20) DEFAULT NULL COMMENT '更新人',
    `update_time`          datetime                                                     DEFAULT NULL COMMENT '更新时间',
    `is_deleted`           int(11) DEFAULT NULL,
    `create_dept`          bigint(20) DEFAULT NULL COMMENT '创建部门',
    `status`               int(11) DEFAULT NULL COMMENT '业务状态',
    `transfer_director_id` bigint(20) DEFAULT NULL COMMENT 'FTP目录id',
    `workstation_id`       bigint(20) DEFAULT NULL COMMENT '工位id',
    PRIMARY KEY (`id`),
    UNIQUE KEY `workstation_id` (`workstation_id`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='FTP目录与工位关系表';

-- 菜单脚本
INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`,
                         `category`, `action`, `is_open`, `remark`, `is_deleted`, `belong_application`, `keep_alive`)
VALUES (1469141105228611586, 1503998309035220994, 'shift_calendar', '班制日历', 'shift_calendar',
        '/console/base/shift-calendar', 'iconfont iconicon_work', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1470274120439566338, 1503966666579030018, 'organization', '员工-部门-岗位', 'organization',
        '/master/person/main/index', 'iconfont iconicon_group', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1471285883018977281, 1503992936900796418, 'workstation', '工位', 'workstation', '/console/workstation/index',
        'iconfont icon-wxbgongju', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1483632111746801666, 0, 'basic_data', '主数据', 'basic_data', '/console/basic-data',
        'iconfont saber-zhushuju', 2, 0, 0, 1, '', 0, 'CPS', 1),
       (1483642077594710017, 1503992936900796418, 'machine_data', '机器管理数据', 'machine_data',
        '/console/basic-data/tpm-data', 'iconfont icon-rizhi', 3, 1, 0, 1, '', 0, 'CPS', 1),
       (1485491717025140738, 1503992936900796418, 'machine_ledger', '机器台账', 'machine_ledger', '/tpm/machine-management',
        'iconfont iconicon_airplay', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1493759281711730689, 1504027069390331905, 'supplier', '供应商', 'supplier', '/console/basic-data/supplier-info',
        'iconfont iconicon_community_line', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1503195854444433409, 1504027069390331905, 'gallery', '图库', 'gallery', '/console/basic-data/gallery',
        'iconfont iconicon_namecard', 4, 1, 0, 1, '', 0, 'CPS', 1),
       (1503215833683517442, 1503998309035220994, 'day_off', '休息日', 'day_off', '/master/time/day-off/index',
        'iconfont iconicon_more', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1503546274154123265, 1504003518490812418, 'area_location', '库区库位', 'area_location',
        '/console/basic-data/material-warehousing-data/reservoir-location/reservoir-location', 'iconfont iconicon_work',
        3, 1, 0, 1, '', 0, 'CPS', 1),
       (1503621096733990913, 1503992936900796418, 'work_condition', '工位采集模板', 'menu',
        '/console/basic-data/working-condition/index', 'iconfont icon-liuliangyunpingtaitubiao08', 4, 1, 0, 1, '', 0,
        'CPS', 1),
       (1503966666579030018, 1483632111746801666, 'staff', '人', 'staff', '/console/basic-data/staff',
        'iconfont iconicon_principal', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1503992936900796418, 1483632111746801666, 'machine', '机', 'machine', '/console/basic-data/machine',
        'iconfont iconicon_setting', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1503996684083601409, 1483632111746801666, 'material', '料', 'material', '/console/basic-data/material',
        'iconfont iconicon_work', 3, 1, 0, 1, '', 0, 'CPS', 1),
       (1503998309035220994, 1483632111746801666, 'production_time', '时间', 'production_time',
        '/console/basic-data/production-time', 'iconfont iconicon_send', 4, 1, 0, 1, '', 0, 'CPS', 1),
       (1504003518490812418, 1483632111746801666, 'warehouse', '仓储', 'warehouse', '/console/basic-data/warehouse',
        'iconfont iconicon_cspace', 6, 1, 0, 1, '', 0, 'CPS', 1),
       (1504027069390331905, 1483632111746801666, 'other', '其他', 'other', '/console/basic-data/other',
        'iconfont iconicon_im_keyboard', 8, 1, 0, 1, '', 0, 'CPS', 1),
       (1497086897538789377, 1503996684083601409, 'materials', '物料信息', 'materials',
        '/console/basic-data/material-warehousing-data/material-info', 'iconfont iconicon_compile', 1, 1, 0, 1, '', 0,
        'CPS', 1),
       (1519129245830651905, 1518929460899213313, 'tray_fixture', '托盘夹具', 'tray_fixture',
        '/console/tooling/tray-fixture', 'iconfont iconicon_savememo', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1522048292781465601, 1518929460899213313, 'tray_storage', '托盘存放', 'tray_storage',
        '/master/frock/tray-deposit/index', 'iconfont iconicon_setting', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1522390934839029761, 1504025044741070849, 'processes', '工序管理', 'processes', '/console/basic-data/work-process',
        'iconfont iconicon_send', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1504025044741070849, 1483632111746801666, 'product_process', '产品工艺', 'product_process',
        '/console/basic-data/product-process', 'iconfont iconicon_namecard', 7, 1, 0, 1, '', 0, 'CPS', 1),
       (1522823470509395969, 1504025044741070849, 'product', '产品', 'product', '/console/basic-data/product',
        'iconfont iconicon_coinpurse_line', 55, 1, 0, 1, '', 0, 'CPS', 1),
       (1523489440260923394, 1504025044741070849, 'process_route', '工艺路线', 'process_route',
        '/console/product-process/process-route', 'iconfont iconicon_exchange', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1526736219864084482, 1523489440260923394, 'cancel_fixed', '取消定版', 'cancel_fixed', '',
        'iconfont iconicon_safety', 1, 2, 0, 1, '', 0, 'CPS', 1),
       (1527115790989488129, 1503996684083601409, 'material_storage', '物料存放', 'material_storage',
        '/console/basic-data/material-warehousing-data/material-storage', 'iconfont iconicon_send', 4, 1, 0, 1, '', 0,
        'CPS', 1),
       (1526031760774340609, 1504025044741070849, 'bom_list', 'BOM 清单', 'menu', '/console/bom-list/index',
        'iconfont icon-caidan', 3, 1, 0, 1, '', 0, 'CPS', 1),
       (1526040185400328193, 1504003518490812418, 'issue_receipt_type', '出入库类型', 'issue_receipt_type',
        '/console/basic-data/material-warehousing-data/Material-warehousing-data', 'iconfont iconicon_more', 4, 1, 0, 1,
        '', 0, 'CPS', 1),
       (1535168094212694017, 1526031760774340609, 'fix_version', '定版', 'fix_version', '', '', 1, 2, 0, 1, '', 0, 'CPS',
        1),
       (1535169198577131521, 1526031760774340609, 'cancel_version', '取消定版', 'cancel_version', '', '', 2, 2, 0, 1, '',
        0, 'CPS', 1),
       (1535242977381232642, 1526031760774340609, 'delete_version', '删除版本', 'delete_version', '', '', 3, 2, 0, 1, '',
        0, 'CPS', 1),
       (1535243543318671362, 1526031760774340609, 'add_process', '添加工序', 'add_process', '', '', 4, 2, 0, 1, '', 0,
        'CPS', 1),
       (1535244130533814273, 1526031760774340609, 'add_material', '添加物料', 'add_material', '', '', 5, 2, 0, 1, '', 0,
        'CPS', 1),
       (1535246268496392194, 1526031760774340609, 'add_version', '新增版本', 'add_version', '', '', 6, 2, 0, 1, '', 0,
        'CPS', 1),
       (1541661765077213185, 1523489440260923394, 'craft_route_create', '新建工艺路线', 'craft_route_create', '', '', 10, 2,
        0, 1, '', 0, 'CPS', 1),
       (1541662062897963010, 1523489440260923394, 'craft_route_edit', '编辑工艺路线', 'craft_route_edit', '', '', 11, 2, 0, 1,
        '', 0, 'CPS', 1),
       (1541662253902372865, 1523489440260923394, 'craft_route_delete', '删除工艺路线', 'craft_route_delete', '', '', 12, 2,
        0, 1, '', 0, 'CPS', 1),
       (1541668488361975810, 1522823470509395969, 'view_craft', '查看工艺路线', 'view_craft', '', '', 10, 2, 0, 1, '', 0,
        'CPS', 1),
       (1541668794567139329, 1522823470509395969, 'view_bom', '查看bom清单', 'view_bom', '', '', 11, 2, 0, 1, '', 0, 'CPS',
        1),
       (1541668925542670337, 1522823470509395969, 'bind_craft', '绑定工艺路线', 'bind_craft', '', '', 12, 2, 0, 1, '', 0,
        'CPS', 1),
       (1541669017884467201, 1522823470509395969, 'unbind_craft', '解绑工艺路线', 'unbind_craft', '', '', 13, 2, 0, 1, '', 0,
        'CPS', 1);


INSERT
INTO `blade_warehouse_area`
VALUES (1, 0, 0, 0, 1123598821738675201, 1123598813738675201, '2022-04-25 10:25:51', 1123598821738675201,
        '2022-04-25 10:25:56', '000000', '所有的', '所有的', NULL);

DROP TABLE IF EXISTS `blade_dnc_art_bag`;
CREATE TABLE `blade_dnc_art_bag`
(
    `id`           bigint(0) NOT NULL,
    `remark`       varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
    `create_user`  bigint(0) NULL DEFAULT NULL,
    `create_dept`  bigint(0) NULL DEFAULT NULL,
    `create_time`  datetime(0) NULL DEFAULT NULL,
    `update_user`  bigint(0) NULL DEFAULT NULL,
    `update_time`  datetime(0) NULL DEFAULT NULL,
    `status`       int(0) NULL DEFAULT NULL,
    `is_deleted`   int(0) NULL DEFAULT NULL,
    `tenant_id`    varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '000000',
    `name`         varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工艺包名称',
    `code`         varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工艺包编码',
    `catalogue_id` bigint(0) NULL DEFAULT NULL COMMENT '工艺目录id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `blade_dnc_art_file`;
CREATE TABLE `blade_dnc_art_file`
(
    `id`                 bigint(0) NOT NULL,
    `remark`             varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
    `create_user`        bigint(0) NULL DEFAULT NULL,
    `create_dept`        bigint(0) NULL DEFAULT NULL,
    `create_time`        datetime(0) NULL DEFAULT NULL,
    `update_user`        bigint(0) NULL DEFAULT NULL,
    `update_time`        datetime(0) NULL DEFAULT NULL,
    `status`             int(0) NULL DEFAULT NULL,
    `is_deleted`         int(0) NULL DEFAULT NULL,
    `tenant_id`          varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '000000',
    `file_id`            bigint(0) NULL DEFAULT NULL COMMENT '文件id',
    `art_bag_id`         bigint(0) NULL DEFAULT NULL COMMENT '工艺包id',
    `source_type`        int(0) NULL DEFAULT NULL COMMENT '文件来源 1 我的文档 2 工位文件 3 本地上传 4 归档文件',
    `file_type`          int(0) NULL DEFAULT NULL COMMENT '文件类别(1:程序,2 文档)',
    `original_filename`  varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '原始文件名称',
    `filename`           varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件名称',
    `content_length`     bigint(0) NULL DEFAULT NULL,
    `content_md5`        varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件md5值',
    `content_type`       varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件类型',
    `object_key`         varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件的objectKey',
    `suffix`             varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件后缀',
    `document_ownership` int(0) NULL DEFAULT NULL COMMENT '文件归属：1 工位 2 工厂',
    `is_current`         int(0) NULL DEFAULT NULL COMMENT '是否为当前版本,1是0否',
    `link`               varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件链接',
    `storage_space`      int(0) NULL DEFAULT NULL COMMENT '存储位置：1 常规空间 2 固定空间',
    `version`            int(0) 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_employee_on_off_work`;
CREATE TABLE `blade_employee_on_off_work`
(
    `id`                  bigint(20) NOT NULL,
    `online_time`         datetime                                                       DEFAULT NULL COMMENT '上线时间',
    `on_employee_id`      bigint(20) DEFAULT NULL COMMENT '上线员工id',
    `on_employee_code`    varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '上线员工编号',
    `on_employee_name`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '上线员工名称',
    `on_employee_avatar`  varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上线员工头像',
    `workstation_id`      bigint(20) DEFAULT NULL COMMENT '工位id',
    `workstation_code`    varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '工位编号',
    `workstation_name`    varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '工位名称',
    `workstation_avatar`  varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '工位名称头像',
    `offline_time`        datetime                                                       DEFAULT NULL COMMENT '下线时间',
    `off_employee_id`     bigint(20) DEFAULT NULL COMMENT '下线员工id',
    `off_employee_code`   varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '下线员工编号',
    `off_employee_name`   varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '下线员工名称',
    `off_employee_avatar` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '下线员工头像',
    `online_type`         tinyint(4) DEFAULT '0' COMMENT '上下线类型 0-上线 1-下线',
    `time_type`           tinyint(4) DEFAULT '0' COMMENT '按时间/班次上下线 0-时间 1-班次',
    `status`              tinyint(4) DEFAULT '1' COMMENT '业务状态 1激活 0 冻结',
    `is_deleted`          bigint(20) unsigned DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_user`         bigint(20) DEFAULT NULL COMMENT '创建人',
    `create_dept`         bigint(20) DEFAULT NULL COMMENT '创建部门',
    `create_time`         datetime                                                       DEFAULT NULL COMMENT '创建时间',
    `update_user`         bigint(20) DEFAULT NULL COMMENT '更新人',
    `update_time`         datetime                                                       DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci
  ROW_FORMAT = DYNAMIC COMMENT ='员工上下线表';

DROP TABLE IF EXISTS `blade_dnc_process_catalogue`;
CREATE TABLE `blade_dnc_process_catalogue`
(
    `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 '父主键',
    `name`        varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工艺目录名称',
    `all_path`    varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '全路径(包含自身)',
    `is_deleted`  int(0) NULL DEFAULT NULL,
    `status`      int(0) NULL DEFAULT NULL COMMENT '状态',
    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
    `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
    `update_user` bigint(0) NULL DEFAULT NULL COMMENT '更新人',
    `create_dept` bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
    `dept_id`     bigint(0) NULL DEFAULT NULL COMMENT '职权域id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '工艺目录表'
  ROW_FORMAT =
      Dynamic;

-- 数据标签关系表
ALTER TABLE `blade_workstation_wcs`
    ADD COLUMN `usage_id` bigint NULL COMMENT '数据标签ID' AFTER `data_type`;
-- 增加数据标签关系表
CREATE TABLE `blade_workstation_wcs_usage`
(
    `id`           bigint(20) NOT NULL COMMENT '主键',
    `collect_type` tinyint(4) DEFAULT NULL COMMENT '计算方法',
    `usage_name`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据标签名称',
    `usage_code`   varchar(50) COLLATE utf8mb4_general_ci                        DEFAULT NULL COMMENT '数据标签编号',
    `parameter`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据标签执行参数',
    `create_time`  datetime                                                      DEFAULT NULL,
    `create_user`  bigint(255) DEFAULT NULL,
    `update_time`  datetime                                                      DEFAULT NULL,
    `update_user`  bigint(20) DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

-- 增加数据标签初始化数据
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604657686328061954, 0, '无', '0', NULL, '2022-12-19 09:59:40', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659202451517442, 1, '状态', '1', NULL, '2022-12-19 10:05:42', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659243140460545, 2, '产量', '2', NULL, '2022-12-19 10:05:51', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659295900610562, 3, '报警', '3', NULL, '2022-12-19 10:06:04', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659380000600066, 5, '脉冲产量', '5', NULL, '2022-12-19 10:06:24', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659442676084737, 6, '报警号', '6', NULL, '2022-12-19 10:06:39', NULL, NULL, NULL);
INSERT INTO `blade_workstation_wcs_usage` (`id`, `collect_type`, `usage_name`, `usage_code`, `parameter`, `create_time`,
                                           `create_user`, `update_time`, `update_user`)
VALUES (1604659517745737729, 7, '报警信息', '7', NULL, '2022-12-19 10:06:57', NULL, NULL, NULL);
-- 修改字典名称
INSERT INTO `blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`,
                          `is_deleted`)
VALUES (1600787418029592578, 1473111864757952513, 'workstation_param_type', '8', '差值计算', 10, '', 0, 0);
INSERT INTO `blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`,
                          `is_deleted`)
VALUES (1600787468336074754, 1473111864757952513, 'workstation_param_type', '9', '脉冲计算', 11, '', 0, 0);
-- 数据标签增加大屏接口
INSERT INTO blade_interface_config (id, status, is_deleted, create_user, create_dept, create_time, update_user,
                                    update_time, url, url_name, url_type, owning_chart)
VALUES (1602849539512963073, 1, 0, 1123598821738675201, 1123598813738675201, '2022-12-14 10:14:44', 1123598821738675201,
        '2022-12-14 10:14:44', '/api/blade-visual/output/usage-type', '脉冲、计数显示用途统计', 0, '3');

INSERT INTO blade_interface_config_field (id, status, is_deleted, create_user, create_dept, create_time, update_user,
                                          update_time, config_id, label, name, is_required, data_type, data_source,
                                          is_single_choice, checked_parent, relation_field, method)
VALUES (1602849545779253250, 1, 0, 1123598821738675201, 1123598813738675201, '2022-12-14 10:14:46', 1123598821738675201,
        '2022-12-19 14:19:12', 1602849539512963073, '数据标签', 'usageCode', 1, 2,
        '/api/blade-cps/workstation-wcs-usage/visual-usage-code', 1, NULL, NULL, 'get');
INSERT INTO blade_interface_config_field (id, status, is_deleted, create_user, create_dept, create_time, update_user,
                                          update_time, config_id, label, name, is_required, data_type, data_source,
                                          is_single_choice, checked_parent, relation_field, method)
VALUES (1602853136015396866, 1, 0, 1123598821738675201, 1123598813738675201, '2022-12-14 10:29:02', 1123598821738675201,
        '2022-12-14 10:29:02', 1602849539512963073, '工位列表', 'workStationIdList', 1, 4,
        '/api/blade-visual/data-source/workstation', 0, NULL, NULL, 'get');
INSERT INTO blade_interface_config_field (id, status, is_deleted, create_user, create_dept, create_time, update_user,
                                          update_time, config_id, label, name, is_required, data_type, data_source,
                                          is_single_choice, checked_parent, relation_field, method)
VALUES (1602853344312922113, 1, 0, 1123598821738675201, 1123598813738675201, '2022-12-14 10:29:52', 1123598821738675201,
        '2022-12-14 10:36:19', 1602849539512963073, '查询策略', 'policy', 1, 2,
        '/api/blade-cps/workstation-wcs-usage/visual-usage-policy', 1, NULL, NULL, 'get');
INSERT INTO blade_interface_config_field (id, status, is_deleted, create_user, create_dept, create_time, update_user,
                                          update_time, config_id, label, name, is_required, data_type, data_source,
                                          is_single_choice, checked_parent, relation_field, method)
VALUES (1602853823713480706, 1, 0, 1123598821738675201, 1123598813738675201, '2022-12-14 10:31:46', 1123598821738675201,
        '2022-12-14 10:31:46', 1602849539512963073, '近n小时/天', 'timeLevel', 0, 2,
        '/api/blade-visual/data-source/time-level', 1, NULL, NULL, 'get');
-- 接口权限
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015416735895553, 1510094368595181569, 'visual_output.get_count_pulse_output', '设备 脉冲 计数 相关数据标签统计',
        '/blade-visual/output/usage-type', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:41:10', 1123598821738675201, '2022-12-20 09:41:10', 1, 0);
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015071330766850, 1475761204784312321, 'workstation_wcs_usage.list', '获取所有数据数据标签数据',
        '/blade-cps/workstation-wcs-usage/list', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:39:47', 1123598821738675201, '2022-12-20 09:39:47', 1, 0);
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015071339155458, 1475761204784312321, 'workstation_wcs_usage.params_config', '获取计算方式的参数配置',
        '/blade-cps/workstation-wcs-usage/params-config/*', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:39:47', 1123598821738675201, '2022-12-20 09:39:47', 1, 0);
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015071347544065, 1475761204784312321, 'workstation_wcs_usage.remove', '删除数据标签',
        '/blade-cps/workstation-wcs-usage', NULL, NULL, 'DELETE', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:39:47', 1123598821738675201, '2022-12-20 09:39:47', 1, 0);
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015071355932674, 1475761204784312321, 'workstation_wcs_usage.save', '保存数据标签',
        '/blade-cps/workstation-wcs-usage', NULL, NULL, 'PUT', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:39:47', 1123598821738675201, '2022-12-20 09:39:47', 1, 0);
INSERT INTO `blade_scope_api` (`id`, `menu_id`, `resource_code`, `scope_name`, `scope_path`, `scope_type`, `remark`,
                               `http_method`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`,
                               `status`, `is_deleted`)
VALUES (1605015071368515585, 1475761204784312321, 'workstation_wcs_usage.update', '更新数据标签',
        '/blade-cps/workstation-wcs-usage', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201,
        '2022-12-20 09:39:47', 1123598821738675201, '2022-12-20 09:39:47', 1, 0);
DROP TABLE IF EXISTS `blade_fms_real_time_tray`;
CREATE TABLE `blade_fms_real_time_tray`
(
    `id`                      bigint(20)                                                    NOT NULL,
    `tenant_id`               varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   NULL DEFAULT NULL COMMENT '所属租户',
    `tray_code`               varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '托盘号',
    `fixture_id`              bigint(128)                                                   NULL DEFAULT NULL COMMENT '夹具id',
    `current_position`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前位置',
    `current_station`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前工作台 1,2',
    `current_type`            int(11)                                                       NULL DEFAULT NULL COMMENT '当前位置类型 1-库位,2-位置',
    `target_position`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目标位置',
    `target_station`          varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目标工作台 1,2',
    `tray_state`              int(11)                                                       NULL DEFAULT NULL COMMENT '1-满托,2-空托',
    `sche_state`              int(11)                                                       NULL DEFAULT NULL COMMENT '调度状态 1-将要去,2-到达',
    `arrive_time`             datetime(0)                                                   NULL DEFAULT NULL COMMENT '到达时间 异常不更新',
    `status`                  int(11)                                                       NULL DEFAULT NULL COMMENT '业务状态',
    `order_id`                bigint(20)                                                    NULL DEFAULT NULL COMMENT '工单ID',
    `order_code`              varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工单号',
    `order_process_id`        bigint(20)                                                    NULL DEFAULT NULL COMMENT '工单工序ID',
    `process_code`            varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工序号',
    `program_no`              varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '程序号',
    `program_offset`          varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '程序偏移',
    `will_order_id`           bigint(20)                                                    NULL DEFAULT NULL COMMENT '将要去的工单ID',
    `will_order_code`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '将要去的工单',
    `will_order_process_id`   bigint(20)                                                    NULL DEFAULT NULL COMMENT '将要去的工单工序ID',
    `will_process_code`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '将要去的工序',
    `will_program_no`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '将要去的程序号',
    `will_program_offset`     varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '将要去的程序偏移',
    `part_type`               tinyint(4)                                                    NULL DEFAULT NULL COMMENT '产品状态 1-待加工,2-加工中,3-加工完成,4-半成品,5-不合格品',
    `part_type_time`          datetime(0)                                                   NULL DEFAULT NULL COMMENT '状态改变时间',
    `components_number`       bigint(20)                                                    NULL DEFAULT NULL COMMENT '当前工件号',
    `last_load_complete_time` datetime(0)                                                   NULL DEFAULT NULL COMMENT '上一次装料完成时间',
    `last_cnc_complete_time`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '上一次加工完成时间',
    `is_deleted`              int(11) UNSIGNED                                              NULL DEFAULT NULL COMMENT '删除标记：0-未删除，1-已删除',
    `create_time`             datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `create_user`             bigint(20)                                                    NULL DEFAULT NULL COMMENT '创建人',
    `update_time`             datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `update_user`             bigint(20)                                                    NULL DEFAULT NULL COMMENT '更新人',
    `create_dept`             bigint(20)                                                    NULL DEFAULT NULL COMMENT '创建部门',
    `is_first_empty_return`   tinyint(4)                                                    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_andon_record`;
CREATE TABLE `blade_andon_record` (
                                      `id` bigint(20) NOT NULL COMMENT '主键',
                                      `status` tinyint(4) DEFAULT NULL COMMENT '状态',
                                      `is_deleted` int(11) DEFAULT '0' COMMENT '删除状态：0-未删除，1-已删除',
                                      `create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
                                      `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
                                      `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                      `update_user` bigint(20) DEFAULT NULL COMMENT '更新人',
                                      `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                      `type_id` bigint(20) DEFAULT NULL COMMENT '安灯类型id',
                                      `type_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '安灯类型编号',
                                      `type_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '安灯类型名称',
                                      `reason_id` bigint(20) DEFAULT NULL COMMENT '安灯原因id',
                                      `reason_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '安灯原因编号',
                                      `reason_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '安灯原因名称',
                                      `workstation_id` bigint(20) DEFAULT NULL COMMENT '工位id',
                                      `workstation_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '工位名称',
                                      `workstation_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '工位编号',
                                      `call_emp_id` bigint(20) DEFAULT NULL COMMENT '呼叫人员id',
                                      `call_emp_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '呼叫人员编号',
                                      `call_emp_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '呼叫人员名称',
                                      `hand_emp_id` bigint(20) DEFAULT NULL COMMENT '处理人员id',
                                      `hand_emp_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理人员编号',
                                      `hand_emp_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理人员名称',
                                      `complete_emp_id` bigint(20) DEFAULT NULL COMMENT '完成人员id',
                                      `complete_emp_code` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '完成人员编号',
                                      `complete_emp_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '完成人员名称',
                                      `call_time` datetime DEFAULT NULL COMMENT '呼叫时间(开始时间)',
                                      `response_time` datetime DEFAULT NULL COMMENT '响应时间',
                                      `end_time` datetime DEFAULT NULL COMMENT '结束时间',
                                      `remark` varchar(140) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
                                      `cur_status` tinyint(4) DEFAULT '0' COMMENT '当前状态 0-当前无状态 1-已发起，待接收 2-已接收，待完成 3-完成',
                                      `shift_index` int(11) DEFAULT NULL COMMENT '所在班次',
                                      `index_name` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '班次名称',
                                      PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='安灯原因表';

CREATE TABLE `blade_device_andon_type` (
                                           `id` bigint(20) NOT NULL COMMENT '主键',
                                           `status` tinyint(4) DEFAULT NULL COMMENT '状态',
                                           `is_deleted` int(11) DEFAULT '0' COMMENT '删除状态：0-未删除，1-已删除',
                                           `create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
                                           `create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
                                           `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                           `update_user` bigint(20) DEFAULT NULL COMMENT '更新人',
                                           `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                           `andon_type_id` bigint(20) DEFAULT NULL COMMENT '安灯类型id',
                                           `device_type_id` bigint(20) DEFAULT NULL COMMENT '机器类型id',
                                           PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='机器类型安灯类型关联表';
