DROP TABLE IF EXISTS `blade_check_record`;
CREATE TABLE `blade_check_record`
(
    `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_code`         varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '点检记录编码',
    `device_id`          bigint(0) NULL DEFAULT NULL COMMENT '机器id',
    `device_type_id`     bigint(0) NULL DEFAULT NULL COMMENT '机器类型id',
    `check_user_id`      bigint(0) NULL DEFAULT NULL COMMENT '检验人员id',
    `check_time`         datetime(0) NULL DEFAULT NULL COMMENT '点检时间',
    `check_result`       tinyint(0) UNSIGNED NULL DEFAULT 1 COMMENT '点检结果：0-不正常，1-正常',
    `check_project_id`   bigint(0) NULL DEFAULT NULL COMMENT '点检项目id',
    `remark`             varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `device_code`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '机器编码',
    `device_name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '机器名称',
    `device_type_name`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '机器类型名称',
    `check_user_name`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '检验人员名称',
    `check_project_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '点检项目编码',
    `check_project_name` varchar(255) 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
        '机器规格',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`check_code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '点检记录'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_check_record_file`;
CREATE TABLE `blade_check_record_file`
(
    `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_record_id` bigint(0) NULL DEFAULT NULL COMMENT '点检记录id',
    `file_name`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件名称',
    `object_key`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '文件key',
    `link`            varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件link',
    `content_type`    varchar(255) 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 '上传时间',
    `file_type`       int(0) NULL DEFAULT NULL COMMENT '文件类型(1:图片 2 附件)',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '点检记录点检项'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_check_record_item`;
CREATE TABLE `blade_check_record_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_record_id` bigint(0) NULL DEFAULT NULL COMMENT '点检记录id',
    `item_id`         bigint(0) NULL DEFAULT NULL COMMENT '点检项id',
    `check_value`     varchar(255) 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 '点检项',
    `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_maintain_plan`;
CREATE TABLE `blade_maintain_plan`
(
    `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 '计划任务编码',
    `device_id`          bigint(0) NULL DEFAULT NULL COMMENT '机器Id',
    `device_code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '机器编码',
    `device_name`        varchar(64) 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 '机器类型名称',
    `project_id`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养项目id',
    `project_code`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养项目编号',
    `project_name`       varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养项目名称',
    `maintain_date`      datetime(0) NULL DEFAULT NULL COMMENT '下次保养日期',
    `pre_warning_days`   int(0) NULL DEFAULT NULL COMMENT '保养预警提示（天）',
    `plan_status`        int(0) NULL DEFAULT NULL COMMENT '计划状态（1：正常；2：待执行；3：执行中；4：待确认；5：已确认）',
    `is_auto`            int(0) NULL DEFAULT NULL COMMENT '是否自动生成计划（0：否；1：是）',
    `interval_time`      int(0) NULL DEFAULT NULL COMMENT '周期（天）',
    `pre_maintain_time`  datetime(0) NULL DEFAULT NULL COMMENT '上一次保养时间',
    `machine_model`      varchar(128) 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 '备注',
    `maintain_nature`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保养性质（1:厂内,2:委外）',
    `maintain_user_id`   bigint(0) NULL DEFAULT NULL COMMENT '保养负责人',
    `maintain_user_name` 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_plan_item`;
CREATE TABLE `blade_maintain_plan_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
        '所属租户',
    `plan_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_maintain_record`;
CREATE TABLE `blade_maintain_record`
(
    `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
        '所属租户',
    `record_code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养记录单号',
    `plan_id`            bigint(0) NULL DEFAULT NULL COMMENT '计划任务Id',
    `start_time`         datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
    `end_time`           datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
    `is_delay`           int(0) NULL DEFAULT 0 COMMENT '是否延期（0：未延期；1：已延期）',
    `delay_days`         int(0) NULL DEFAULT NULL COMMENT '延期天数',
    `maintain_user_id`   bigint(0) NULL DEFAULT NULL COMMENT '保养负责人Id',
    `maintain_user_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '保养负责人名称',
    `delay_reason`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '延期原因',
    `record_status`      int(0) NULL DEFAULT NULL COMMENT '保养记录状态（1：待确认；2：已确认）',
    `plan_code`          varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '计划单号',
    `device_id`          bigint(0) NULL DEFAULT NULL COMMENT '机器Id',
    `device_code`        varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '机器编码',
    `device_name`        varchar(64) 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 '机器类型名称',
    `project_id`         varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养项目id',
    `project_code`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养项目编号',
    `project_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 '备注',
    `maintain_nature`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '保养性质（1:厂内,2:委外）',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`record_code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '保养记录表'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_maintain_record_item`;
CREATE TABLE `blade_maintain_record_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
        '所属租户',
    `record_id`   bigint(0) NULL DEFAULT NULL COMMENT '保养记录单号',
    `item_id`     bigint(0) NULL DEFAULT NULL COMMENT '保养项Id',
    `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(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '保养要求',
    `remark`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
    `is_execute`  int(0) NULL DEFAULT NULL COMMENT '保养判定（0：否，1：是）',
    `is_default`  int(0) NULL DEFAULT NULL COMMENT '是否默认（0：否，1：是）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '保养记录保养项'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_repair_apply`;
CREATE TABLE `blade_repair_apply`
(
    `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
        '所属租户',
    `apply_code`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '维修申请编号',
    `device_id`        bigint(0) NULL DEFAULT NULL COMMENT '设备id',
    `device_code`      varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '设备编码',
    `device_name`      varchar(64) 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 '设备类型名称',
    `apply_user_id`    bigint(0) NULL DEFAULT NULL COMMENT '维修申请人id',
    `apply_user_name`  varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '维修申请人姓名',
    `repair_user_id`   bigint(0) NULL DEFAULT NULL COMMENT '维修负责人id',
    `repair_user_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '维修负责人姓名',
    `is_affect`        int(0) NULL DEFAULT NULL COMMENT '影响生产：是-1，否-2',
    `malfunction_time` datetime(0) NULL DEFAULT NULL COMMENT '故障发生时间',
    `urgency`          int(0) NULL DEFAULT NULL COMMENT '紧急度：高-3，中-2，低-1',
    `description`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '故障描述',
    `apply_status`     int(0) NULL DEFAULT NULL COMMENT '申请单状态：待执行-1，执行中-2，待确认-3，已确认-4',
    `malfunction_id`   bigint(0) NULL DEFAULT NULL COMMENT '所属故障类型',
    `malfunction_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '故障类型编码',
    `malfunction_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '故障类型',
    `repair_nature`    int(0) NULL DEFAULT NULL COMMENT '维修性质（1:厂内,2:委外）',
    `start_time`       datetime(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` (`apply_code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '维修申请信息'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_repair_apply_file`;
CREATE TABLE `blade_repair_apply_file`
(
    `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
        '所属租户',
    `repair_apply_id` bigint(0) 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;

DROP TABLE IF EXISTS `blade_repair_record`;
CREATE TABLE `blade_repair_record`
(
    `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
        '所属租户',
    `repair_apply_id`       bigint(0) NULL DEFAULT NULL COMMENT '维修申请id',
    `record_code`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '维修记录编号',
    `record_status`         int(0) NULL DEFAULT NULL COMMENT '维修记录状态：待确认-1 已确认-2',
    `record_type`           int(0) NULL DEFAULT NULL COMMENT '维修记录类型：临时-1 例行-2',
    `error_code`            varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '故障码',
    `repair_start_time`     datetime(0) NULL DEFAULT NULL COMMENT '维修开始时间',
    `repair_end_time`       datetime(0) NULL DEFAULT NULL COMMENT '维修完成时间',
    `repair_time`           int(0) NULL DEFAULT NULL COMMENT '维修用时（分钟）',
    `repair_user_id`        bigint(0) NULL DEFAULT NULL COMMENT '维修负责人id',
    `repair_user_name`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '维修负责人姓名',
    `malfunction_details`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '故障详情',
    `malfunction_time`      datetime(0) NULL DEFAULT NULL COMMENT '发生时间(例行维修)',
    `is_affect`             int(0) NULL DEFAULT NULL COMMENT '影响生产：是 1   否 2（例行维修）',
    `device_id`             bigint(0) NULL DEFAULT NULL COMMENT '设备id',
    `device_code`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT
        '设备编码',
    `device_name`           varchar(64) 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 '设备类型名称',
    `malfunction_id`        bigint(0) NULL DEFAULT NULL COMMENT '所属故障类型',
    `malfunction_code`      varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '类型编码',
    `malfunction_name`      varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '故障类型',
    `urgency`               int(0) NULL DEFAULT NULL COMMENT '紧急度：高-3，中-2，低-1',
    `repair_nature`         int(0) NULL DEFAULT NULL COMMENT '维修性质（1:厂内,2:委外）',
    `real_malfunction_id`   bigint(0) NULL DEFAULT NULL COMMENT '实际所属故障类型',
    `real_malfunction_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
        COMMENT '实际故障类型编码',
    `real_malfunction_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 '备注',
    `apply_time`            datetime(0) NULL DEFAULT NULL COMMENT '需要删除',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `codeIndex` (`record_code`) USING BTREE,
    UNIQUE INDEX `uniqueCodeIndex` (`record_code`, `is_deleted`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '维修记录信息'
  ROW_FORMAT =
      Dynamic;

DROP TABLE IF EXISTS `blade_repair_record_file`;
CREATE TABLE `blade_repair_record_file`
(
    `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
        '所属租户',
    `repair_record_id` bigint(0) 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;

DROP TABLE IF EXISTS `blade_device_material_record`;
CREATE TABLE `blade_device_material_record`
(
    `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 '所属租户',
    `record_id`     bigint(0) NULL DEFAULT NULL COMMENT '保养记录Id/维修单Id',
    `material_id`   bigint(0) NULL DEFAULT NULL COMMENT '备件Id',
    `material_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备件编码',
    `material_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备件名称',
    `record_number` int(0) NULL DEFAULT NULL COMMENT '数量',
    `biz_type`      int(0) NULL DEFAULT NULL COMMENT '数据来源（1：维修单；2：保养记录）',
    `device_id`     bigint(0) NULL DEFAULT NULL COMMENT '设备Id',
    `user_id`       bigint(0) NULL DEFAULT NULL COMMENT '使用人员id',
    `user_name`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '使用人员姓名',
    `usage_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;


-- 菜单脚本
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 (1483604280849457153, 0, 'tpm', '维护保养', 'tpm', '/tpm', 'iconfont saber-weixiubaoyang', 3, 0, 0, 1, '', 0,
        'CPS',
        1),
       (1491221708245405697, 1504059536042172417, 'check_record', '点检记录', 'check_record', '/tpm/check/record/index',
        'iconfont iconicon_savememo', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1491282994091601922, 1504060956569051137, 'repair_apply', '维修申请', 'repair_apply', '/tpm/repair/apply/index',
        'iconfont iconicon_setting', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1491309591410286594, 1504030750424768514, 'maintain_plan', '保养计划', 'maintain_plan', '/tpm/maintain/plan/index',
        'iconfont iconicon_work', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1491940085082005505, 1504030750424768514, 'maintain_record', '保养记录', 'maintain_record',
        '/tpm/maintain/record/index',
        'iconfont icon-caidan', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1491959985118347265, 1504060956569051137, 'repair_record', '维修记录', 'repair_record', '/tpm/repair/record/index',
        'iconfont iconicon_compile', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1493780574536388609, 1483604280849457153, 'tpm_notice', '通知待办', 'tpm_notice', '/tpm/notice/index',
        'iconfont iconicon_notice', 9, 1, 0, 1, '', 0, 'CPS', 1),
       (1504030750424768514, 1483604280849457153, 'maintenance', '保养', 'maintenance', '/tpm/maintenance',
        'iconfont iconicon_notice', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1504059536042172417, 1483604280849457153, 'fixed_point_inspect', '点检', 'fixed_point_inspect',
        '/tpm/fixed-point-inspect', 'iconfont iconicon_sms', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1504060956569051137, 1483604280849457153, 'repair', '维修', 'repair', '/tpm/service',
        'iconfont iconicon_setting', 3, 1, 0, 1, '', 0, 'CPS', 1),
       (1519861848982163458, 1483604280849457153, 'tpmMaintenance', '保养、维修待确认', 'card', '',
        'iconfont iconicon_send', 11, 3, 0, 1, '', 0, 'CPS', 1),
       (1519862507798269953, 1483604280849457153, 'tpmTheBeyond', '保养计划超期及预警', 'card', '',
        'iconfont iconicon_send', 12, 3, 0, 1, '', 0, 'CPS', 1),
       (1519862661901193218, 1483604280849457153, 'tpmTodayMaintenance', '今日保养、点检及维修', 'card', '',
        'iconfont iconicon_send', 13, 3, 0, 1, '', 0, 'CPS', 1),
       (1595225500642377729, 0, 'hmi_tpm', '维护保养', 'hmi_tpm', '/tpm', '', 1, 1, 0, 1, '', 0, 'HMI', 1);


