DROP TABLE IF EXISTS "blade_device_type";
CREATE TABLE "blade_device_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_device_type" IS '机器类型';
COMMENT
ON COLUMN "blade_device_type"."code" IS '类型编码（唯一）';
COMMENT
ON COLUMN "blade_device_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_device_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_device_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_device_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_device_type"."name" IS '类型名称';
COMMENT
ON COLUMN "blade_device_type"."remark" IS '备注';
COMMENT
ON COLUMN "blade_device_type"."status" IS '状态';
COMMENT
ON COLUMN "blade_device_type"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_device_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_device_type"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_employee";
CREATE TABLE "blade_employee"
(
    "id"              BIGINT NOT NULL,
    "tenant_id"       VARCHAR(12) DEFAULT '000000',
    "code"            VARCHAR(128),
    "name"            VARCHAR(32),
    "email"           VARCHAR(45),
    "tel"             VARCHAR(32),
    "hire_date"       TIMESTAMP(0),
    "job_number"      VARCHAR(32),
    "pin_code"        VARCHAR(128),
    "organization_id" VARCHAR(1000),
    "dept_id"         VARCHAR(1000),
    "post_id"         VARCHAR(1000),
    "user_id"         VARCHAR(32),
    "role_id"         VARCHAR(1000),
    "create_user"     BIGINT,
    "create_dept"     BIGINT,
    "create_time"     TIMESTAMP(0),
    "update_user"     BIGINT,
    "update_time"     TIMESTAMP(0),
    "status"          INT,
    "is_deleted"      INT,
    "avatar"          VARCHAR(1000),
    NOT               CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_employee" IS '员工';
COMMENT
ON COLUMN "blade_employee"."code" IS '员工编号';
COMMENT
ON COLUMN "blade_employee"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_employee"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_employee"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_employee"."dept_id" IS '数据权限';
COMMENT
ON COLUMN "blade_employee"."email" IS '邮箱';
COMMENT
ON COLUMN "blade_employee"."hire_date" IS '入职日期';
COMMENT
ON COLUMN "blade_employee"."job_number" IS '工卡号';
COMMENT
ON COLUMN "blade_employee"."name" IS '姓名';
COMMENT
ON COLUMN "blade_employee"."organization_id" IS '组织ID';
COMMENT
ON COLUMN "blade_employee"."pin_code" IS 'PIN码';
COMMENT
ON COLUMN "blade_employee"."post_id" IS '岗位ID';
COMMENT
ON COLUMN "blade_employee"."role_id" IS '角色ID';
COMMENT
ON COLUMN "blade_employee"."status" IS '数据状态';
COMMENT
ON COLUMN "blade_employee"."tel" IS '电话';
COMMENT
ON COLUMN "blade_employee"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_employee"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_employee"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_employee"."user_id" IS '账号ID';
COMMENT
ON COLUMN "blade_employee"."avatar" IS '员工头像';


DROP TABLE IF EXISTS "blade_employee_post";
CREATE TABLE "blade_employee_post"
(
    "id"          BIGINT NOT NULL,
    "employee_id" BIGINT DEFAULT 0,
    "post_id"     BIGINT DEFAULT 0,
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_employee_post" IS '员工岗位表';
COMMENT
ON COLUMN "blade_employee_post"."employee_id" IS '员工ID';
COMMENT
ON COLUMN "blade_employee_post"."id" IS '主键';
COMMENT
ON COLUMN "blade_employee_post"."post_id" IS '岗位ID';


DROP TABLE IF EXISTS "blade_maintain_item";
CREATE TABLE "blade_maintain_item"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "requirement" VARCHAR(350),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_maintain_item" IS '保养项信息';
COMMENT
ON COLUMN "blade_maintain_item"."code" IS '保养编码';
COMMENT
ON COLUMN "blade_maintain_item"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_maintain_item"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_maintain_item"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_maintain_item"."id" IS '主键';
COMMENT
ON COLUMN "blade_maintain_item"."name" IS '保养项';
COMMENT
ON COLUMN "blade_maintain_item"."remark" IS '备注';
COMMENT
ON COLUMN "blade_maintain_item"."requirement" IS '保养要求';
COMMENT
ON COLUMN "blade_maintain_item"."status" IS '状态';
COMMENT
ON COLUMN "blade_maintain_item"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_maintain_item"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_maintain_item"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_maintain_project";
CREATE TABLE "blade_maintain_project"
(
    "id"               BIGINT NOT NULL,
    "status"           INT,
    "is_deleted"       INT,
    "create_user"      BIGINT,
    "create_dept"      BIGINT,
    "create_time"      TIMESTAMP(0),
    "update_user"      BIGINT,
    "update_time"      TIMESTAMP(0),
    "tenant_id"        VARCHAR(12),
    "device_type_id"   BIGINT,
    "device_type_name" VARCHAR(64),
    "code"             VARCHAR(128),
    "name"             VARCHAR(64),
    "interval_time"    INT,
    "pre_warning_days" INT,
    "remark"           VARCHAR(255),
    NOT                CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_maintain_project" IS '保养项目';
COMMENT
ON COLUMN "blade_maintain_project"."code" IS '保养项目编码';
COMMENT
ON COLUMN "blade_maintain_project"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_maintain_project"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_maintain_project"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_maintain_project"."device_type_id" IS '机器类型Id';
COMMENT
ON COLUMN "blade_maintain_project"."device_type_name" IS '机器类型名称';
COMMENT
ON COLUMN "blade_maintain_project"."id" IS '主键';
COMMENT
ON COLUMN "blade_maintain_project"."interval_time" IS '周期（天）';
COMMENT
ON COLUMN "blade_maintain_project"."name" IS '保养项目名称';
COMMENT
ON COLUMN "blade_maintain_project"."pre_warning_days" IS '保养预警提示（天）';
COMMENT
ON COLUMN "blade_maintain_project"."remark" IS '备注';
COMMENT
ON COLUMN "blade_maintain_project"."status" IS '状态';
COMMENT
ON COLUMN "blade_maintain_project"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_maintain_project"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_maintain_project"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_maintain_project_item";
CREATE TABLE "blade_maintain_project_item"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "project_id"  BIGINT,
    "item_id"     BIGINT,
    NOT           CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_maintain_project_item" IS '保养项目保养项';
COMMENT
ON COLUMN "blade_maintain_project_item"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_maintain_project_item"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_maintain_project_item"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_maintain_project_item"."id" IS '主键';
COMMENT
ON COLUMN "blade_maintain_project_item"."item_id" IS '保养项Id';
COMMENT
ON COLUMN "blade_maintain_project_item"."project_id" IS '保养项目Id';
COMMENT
ON COLUMN "blade_maintain_project_item"."status" IS '状态';
COMMENT
ON COLUMN "blade_maintain_project_item"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_maintain_project_item"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_maintain_project_item"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_malfunction_type";
CREATE TABLE "blade_malfunction_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_malfunction_type" IS '故障类型信息';
COMMENT
ON COLUMN "blade_malfunction_type"."code" IS '故障类型编号';
COMMENT
ON COLUMN "blade_malfunction_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_malfunction_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_malfunction_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_malfunction_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_malfunction_type"."name" IS '故障类型';
COMMENT
ON COLUMN "blade_malfunction_type"."remark" IS '备注';
COMMENT
ON COLUMN "blade_malfunction_type"."status" IS '状态';
COMMENT
ON COLUMN "blade_malfunction_type"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_malfunction_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_malfunction_type"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_material";
CREATE TABLE "blade_material"
(
    "id"             BIGINT NOT NULL,
    "status"         INT,
    "is_deleted"     INT,
    "create_user"    BIGINT,
    "create_dept"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "tenant_id"      VARCHAR(12),
    "code"           VARCHAR(128),
    "bar_code"       VARCHAR(128),
    "name"           VARCHAR(64),
    "type_id"        BIGINT,
    "unit"           VARCHAR(48),
    "stuff"          VARCHAR(48),
    "standard_model" VARCHAR(48),
    "remark"         VARCHAR(255),
    "lower_limit"    decimal(20, 2),
    "upper_limit"    decimal(20, 2),
    "is_must_check"  INT,
    "property"       INT,
    NOT              CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_material" IS '物料';
COMMENT
ON COLUMN "blade_material"."bar_code" IS '物料条码';
COMMENT
ON COLUMN "blade_material"."code" IS '物料编码';
COMMENT
ON COLUMN "blade_material"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_material"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_material"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_material"."id" IS '主键';
COMMENT
ON COLUMN "blade_material"."is_must_check" IS '是否必检：0-非必检，1-必检';
COMMENT
ON COLUMN "blade_material"."lower_limit" IS '额定库存';
COMMENT
ON COLUMN "blade_material"."name" IS '物料名称';
COMMENT
ON COLUMN "blade_material"."property" IS '物料性质：1-原材料、2-半成品、3-成品、4-备品备件、5-辅助用品、9-其它';
COMMENT
ON COLUMN "blade_material"."remark" IS '备注';
COMMENT
ON COLUMN "blade_material"."standard_model" IS '规格';
COMMENT
ON COLUMN "blade_material"."status" IS '状态';
COMMENT
ON COLUMN "blade_material"."stuff" IS '材质';
COMMENT
ON COLUMN "blade_material"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_material"."type_id" IS '物料类型id';
COMMENT
ON COLUMN "blade_material"."unit" IS '计量单位';
COMMENT
ON COLUMN "blade_material"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_material"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_material"."upper_limit" IS '安全库存';


DROP TABLE IF EXISTS "blade_material_type";
CREATE TABLE "blade_material_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_material_type" IS '物料类型';
COMMENT
ON COLUMN "blade_material_type"."code" IS '物料类型编码';
COMMENT
ON COLUMN "blade_material_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_material_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_material_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_material_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_material_type"."name" IS '物料类型名称';
COMMENT
ON COLUMN "blade_material_type"."remark" IS '备注';
COMMENT
ON COLUMN "blade_material_type"."status" IS '状态';
COMMENT
ON COLUMN "blade_material_type"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_material_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_material_type"."update_user" IS '更新人';

DROP TABLE IF EXISTS "blade_code";
CREATE TABLE "blade_code"
(
    "id"            BIGINT NOT NULL,
    "title"         VARCHAR(255),
    "datasource_id" BIGINT,
    "service_name"  VARCHAR(64),
    "code_name"     VARCHAR(64),
    "table_name"    VARCHAR(64),
    "table_prefix"  VARCHAR(64),
    "pk_name"       VARCHAR(32),
    "package_name"  VARCHAR(500),
    "base_mode"     INT,
    "wrap_mode"     INT,
    "api_path"      VARCHAR(2000),
    "web_path"      VARCHAR(2000),
    "is_deleted"    INT,
    NOT             CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_code" IS '代码生成表';
COMMENT
ON COLUMN "blade_code"."api_path" IS '后端路径';
COMMENT
ON COLUMN "blade_code"."base_mode" IS '基础业务模式';
COMMENT
ON COLUMN "blade_code"."code_name" IS '模块名称';
COMMENT
ON COLUMN "blade_code"."datasource_id" IS '数据源主键';
COMMENT
ON COLUMN "blade_code"."id" IS '主键';
COMMENT
ON COLUMN "blade_code"."package_name" IS '后端包名';
COMMENT
ON COLUMN "blade_code"."pk_name" IS '主键名';
COMMENT
ON COLUMN "blade_code"."service_name" IS '服务名称';
COMMENT
ON COLUMN "blade_code"."table_name" IS '表名';
COMMENT
ON COLUMN "blade_code"."table_prefix" IS '表前缀';
COMMENT
ON COLUMN "blade_code"."web_path" IS '前端路径';
COMMENT
ON COLUMN "blade_code"."wrap_mode" IS '包装器模式';



DROP TABLE IF EXISTS "blade_notice";
CREATE TABLE "blade_notice"
(
    "id"           BIGINT NOT NULL,
    "tenant_id"    VARCHAR(12) DEFAULT '000000',
    "title"        VARCHAR(255),
    "category"     INT,
    "release_time" TIMESTAMP(0),
    "content"      VARCHAR(2000),
    "create_user"  BIGINT,
    "create_dept"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "status"       INT,
    "is_deleted"   INT,
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_notice" IS '通知公告表';
COMMENT
ON COLUMN "blade_notice"."category" IS '类型';
COMMENT
ON COLUMN "blade_notice"."content" IS '内容';
COMMENT
ON COLUMN "blade_notice"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_notice"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_notice"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_notice"."id" IS '主键';
COMMENT
ON COLUMN "blade_notice"."release_time" IS '发布时间';
COMMENT
ON COLUMN "blade_notice"."status" IS '状态';
COMMENT
ON COLUMN "blade_notice"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_notice"."title" IS '标题';
COMMENT
ON COLUMN "blade_notice"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_notice"."update_user" IS '修改人';


DROP TABLE IF EXISTS "blade_notify_history";
CREATE TABLE "blade_notify_history"
(
    "id"           VARCHAR(64)  NOT NULL,
    "state"        VARCHAR(255) NOT NULL,
    "notify_type"  VARCHAR(32)  NOT NULL,
    "notifier_id"  VARCHAR(32)  NOT NULL,
    "notify_time"  TIMESTAMP(0),
    "provider"     VARCHAR(32)  NOT NULL,
    "template_id"  VARCHAR(32),
    "template"     CLOB,
    "retry_times"  INT,
    "error_type"   VARCHAR(1024),
    "context_data" TEXT,
    "error_stack"  TEXT,
    "create_user"  BIGINT,
    "create_dept"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "status"       INT,
    "is_deleted"   INT,
    "trance_id"    VARCHAR(32),
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_notify_history"."context_data" IS '通知数据';
COMMENT
ON COLUMN "blade_notify_history"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_notify_history"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_notify_history"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_notify_history"."error_stack" IS '错误栈';
COMMENT
ON COLUMN "blade_notify_history"."error_type" IS '错误类型';
COMMENT
ON COLUMN "blade_notify_history"."notifier_id" IS '通知ID';
COMMENT
ON COLUMN "blade_notify_history"."notify_time" IS '通知时间';
COMMENT
ON COLUMN "blade_notify_history"."notify_type" IS '通知类型';
COMMENT
ON COLUMN "blade_notify_history"."provider" IS '提供商';
COMMENT
ON COLUMN "blade_notify_history"."retry_times" IS '重试次数';
COMMENT
ON COLUMN "blade_notify_history"."state" IS '通知状态';
COMMENT
ON COLUMN "blade_notify_history"."status" IS '状态';
COMMENT
ON COLUMN "blade_notify_history"."template" IS '模板内容';
COMMENT
ON COLUMN "blade_notify_history"."template_id" IS '模板id';
COMMENT
ON COLUMN "blade_notify_history"."trance_id" IS '追溯ID';
COMMENT
ON COLUMN "blade_notify_history"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_notify_history"."update_user" IS '修改人';


CREATE
    INDEX "idx_nt_his_notifier_id" ON "blade_notify_history" ("notifier_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_notify_notifications";
CREATE TABLE "blade_notify_notifications"
(
    "id"           VARCHAR(64) NOT NULL,
    "subscribe_id" VARCHAR(64) NOT NULL,
    "subscriber"   VARCHAR(64) NOT NULL,
    "businessKey"  VARCHAR(32) NOT NULL,
    "businessName" VARCHAR(64),
    "message"      TEXT,
    "notify_time"  BIGINT      NOT NULL,
    "state"        VARCHAR(32),
    "description"  VARCHAR(1024),
    "create_user"  BIGINT,
    "create_dept"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "status"       INT,
    "is_deleted"   INT,
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_notify_notifications"."businessKey" IS '主题标识,如:device_alarm';
COMMENT
ON COLUMN "blade_notify_notifications"."businessName" IS '主题名称';
COMMENT
ON COLUMN "blade_notify_notifications"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_notify_notifications"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_notify_notifications"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_notify_notifications"."message" IS '通知消息内容';
COMMENT
ON COLUMN "blade_notify_notifications"."notify_time" IS '通知时间';
COMMENT
ON COLUMN "blade_notify_notifications"."state" IS '通知状态';
COMMENT
ON COLUMN "blade_notify_notifications"."status" IS '状态';
COMMENT
ON COLUMN "blade_notify_notifications"."subscribe_id" IS '订阅追溯Id';
COMMENT
ON COLUMN "blade_notify_notifications"."subscriber" IS '订阅得用户ID';
COMMENT
ON COLUMN "blade_notify_notifications"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_notify_notifications"."update_user" IS '修改人';


CREATE
    INDEX "idx_ntfc_subscribe" ON "blade_notify_notifications" ("subscriber" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_notify_subscribers";
CREATE TABLE "blade_notify_subscribers"
(
    "id"            VARCHAR(64) NOT NULL,
    "tenant_id"     VARCHAR(12) DEFAULT '000000',
    "subscriber"    VARCHAR(32) NOT NULL,
    "business_key"  VARCHAR(32) NOT NULL,
    "business_name" VARCHAR(64),
    "notify_type"   VARCHAR(255),
    "description"   VARCHAR(255),
    "create_user"   BIGINT,
    "create_dept"   BIGINT,
    "create_time"   TIMESTAMP(0),
    "update_user"   BIGINT,
    "update_time"   TIMESTAMP(0),
    "status"        INT,
    "is_deleted"    INT,
    NOT             CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_notify_subscribers"."business_key" IS '业务主题,如:device_alarm';
COMMENT
ON COLUMN "blade_notify_subscribers"."business_name" IS '主题名称,如:设备告警';
COMMENT
ON COLUMN "blade_notify_subscribers"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_notify_subscribers"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_notify_subscribers"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_notify_subscribers"."description" IS '描述';
COMMENT
ON COLUMN "blade_notify_subscribers"."notify_type" IS '订阅通知类型';
COMMENT
ON COLUMN "blade_notify_subscribers"."status" IS '状态';
COMMENT
ON COLUMN "blade_notify_subscribers"."subscriber" IS '订阅者ID';
COMMENT
ON COLUMN "blade_notify_subscribers"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_notify_subscribers"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_notify_subscribers"."update_user" IS '修改人';


CREATE
    INDEX "idx_nfy_subs_subscriber" ON "blade_notify_subscribers" ("subscriber" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_process";
CREATE TABLE "blade_process"
(
    "id"          BIGINT NOT NULL,
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(32),
    "type"        INT,
    "description" VARCHAR(255),
    "is_import"   TINYINT,
    "is_deleted"  INT,
    "create_time" TIMESTAMP(0),
    "create_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "create_dept" BIGINT,
    "status"      INT,
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_process" IS '生产工序信息；';
COMMENT
ON COLUMN "blade_process"."code" IS '工序编号';
COMMENT
ON COLUMN "blade_process"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_process"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_process"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_process"."description" IS '工序描述';
COMMENT
ON COLUMN "blade_process"."is_import" IS '是否导入';
COMMENT
ON COLUMN "blade_process"."name" IS '工序名称';
COMMENT
ON COLUMN "blade_process"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_process"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_process"."type" IS '工序类型';
COMMENT
ON COLUMN "blade_process"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_process"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_process_association";
CREATE TABLE "blade_process_association"
(
    "id"         BIGINT NOT NULL,
    "type"       TINYINT,
    "biz_id"     BIGINT,
    "process_id" BIGINT,
    NOT          CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_process_association" IS '工序关系表';
COMMENT
ON COLUMN "blade_process_association"."biz_id" IS '业务id';
COMMENT
ON COLUMN "blade_process_association"."id" IS '主键id';
COMMENT
ON COLUMN "blade_process_association"."process_id" IS '工序id';
COMMENT
ON COLUMN "blade_process_association"."type" IS '业务类型：1、工位，2、库区，3、供应商';


DROP TABLE IF EXISTS "blade_product";
CREATE TABLE "blade_product"
(
    "id"             BIGINT       NOT NULL,
    "tenant_id"      VARCHAR(12) DEFAULT '000000',
    "code"           VARCHAR(128) NOT NULL,
    "name"           VARCHAR(255),
    "parent_id"      BIGINT,
    "type_id"        BIGINT       NOT NULL,
    "unit"           VARCHAR(10),
    "standard_model" VARCHAR(255),
    "description"    VARCHAR(255),
    "documents"      TEXT,
    "extend_field"   CLOB,
    "create_user"    BIGINT,
    "create_dept"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "status"         INT,
    "is_deleted"     INT,
    NOT              CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_product" IS '产品信息';
COMMENT
ON COLUMN "blade_product"."code" IS '产品编号';
COMMENT
ON COLUMN "blade_product"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_product"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_product"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_product"."description" IS '产品描述';
COMMENT
ON COLUMN "blade_product"."documents" IS '产品文档';
COMMENT
ON COLUMN "blade_product"."id" IS '产品ID';
COMMENT
ON COLUMN "blade_product"."name" IS '产品名称';
COMMENT
ON COLUMN "blade_product"."parent_id" IS '上级产品ID';
COMMENT
ON COLUMN "blade_product"."standard_model" IS '规格型号';
COMMENT
ON COLUMN "blade_product"."status" IS '状态：1启用 0停用';
COMMENT
ON COLUMN "blade_product"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_product"."type_id" IS '产品类型';
COMMENT
ON COLUMN "blade_product"."unit" IS '计量单位';
COMMENT
ON COLUMN "blade_product"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_product"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_product"."extend_field" IS '扩展字段';

CREATE
    INDEX "INDEX544681361209200" ON "blade_product" ("type_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_product_type";
CREATE TABLE "blade_product_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT DEFAULT 1,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "unique_name_index" UNIQUE ("name", "is_deleted")
)STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_product_type" IS '产品类型';
COMMENT
ON COLUMN "blade_product_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_product_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_product_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_product_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_product_type"."name" iS '名称';
COMMENT
ON COLUMN "blade_product_type"."remark" IS '备注/说明';
COMMENT
ON COLUMN "blade_product_type"."status" IS '状态: 1为启动，0为停用';
COMMENT
ON COLUMN "blade_product_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_product_type"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_production_calendar";
CREATE TABLE "blade_production_calendar"
(
    "id"          BIGINT NOT NULL,
    "code"        VARCHAR(128),
    "name"        VARCHAR(50),
    "year"        INT,
    "tenant_id"   VARCHAR(12),
    "is_deleted"  INT,
    "create_dept" BIGINT,
    "status"      TINYINT,
    "create_user" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_calendar" IS '生产日历';
COMMENT
ON COLUMN "blade_production_calendar"."code" IS '日历编号';
COMMENT
ON COLUMN "blade_production_calendar"."create_dept" IS '部门';
COMMENT
ON COLUMN "blade_production_calendar"."create_time" IS '创建日期';
COMMENT
ON COLUMN "blade_production_calendar"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_production_calendar"."name" IS '日历名称';
COMMENT
ON COLUMN "blade_production_calendar"."status" IS '启用禁用(0:禁用，1:启用)';
COMMENT
ON COLUMN "blade_production_calendar"."tenant_id" IS '租户id';
COMMENT
ON COLUMN "blade_production_calendar"."update_time" IS '更新日期';
COMMENT
ON COLUMN "blade_production_calendar"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_production_calendar"."year" IS '应用年份';
CREATE INDEX "INDEX1657856130001" ON "blade_production_calendar" ("code" ASC) STORAGE(ON "MAIN", CLUSTERBTR);


DROP TABLE IF EXISTS "blade_production_calendar_day";
CREATE TABLE "blade_production_calendar_day"
(
    "id"               BIGINT NOT NULL,
    "calendar_id"      BIGINT,
    "calendar_date"    DATE,
    "start_time"       TIMESTAMP(0),
    "end_time"         TIMESTAMP(0),
    "week"             INT,
    "month"            INT,
    "year"             INT,
    "model_id"         BIGINT,
    "is_deleted"       INT,
    "is_high_priority" TINYINT,
    "is_off_day"       TINYINT,
    "off_id"           BIGINT,
    NOT                CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_calendar_day" IS '生产日历日信息';
COMMENT
ON COLUMN "blade_production_calendar_day"."calendar_date" IS '生产日历日期';
COMMENT
ON COLUMN "blade_production_calendar_day"."calendar_id" IS '生产日历id';
COMMENT
ON COLUMN "blade_production_calendar_day"."end_time" IS '班次日结束时间';
COMMENT
ON COLUMN "blade_production_calendar_day"."is_high_priority" IS '是否高优先级(0:否,1:是)';
COMMENT
ON COLUMN "blade_production_calendar_day"."model_id" IS '班次模型id';
COMMENT
ON COLUMN "blade_production_calendar_day"."month" IS '属于当年的第几月';
COMMENT
ON COLUMN "blade_production_calendar_day"."start_time" IS '班次日开始时间';
COMMENT
ON COLUMN "blade_production_calendar_day"."week" IS '属于当年的第几周';
COMMENT
ON COLUMN "blade_production_calendar_day"."year" IS '属于哪一年';
COMMENT
ON COLUMN "blade_production_calendar_day"."is_off_day" IS '是否是休息日(0:否,1:是)';
COMMENT
ON COLUMN "blade_production_calendar_day"."off_id" IS '休息日id';


CREATE INDEX "INDEX26621424248600" ON "blade_production_calendar_day" ("calendar_date" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "INDEX26621429809100" ON "blade_production_calendar_day" ("calendar_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "INDEX1657856130002" ON "blade_production_calendar_day" ("model_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_production_calendar_daytime";
CREATE TABLE "blade_production_calendar_daytime"
(
    "id"               BIGINT NOT NULL,
    "calendar_id"      BIGINT,
    "calendar_day_id"  BIGINT,
    "calendar_date"    DATE,
    "start_time"       TIMESTAMP(0),
    "end_time"         TIMESTAMP(0),
    "shift_index"      TINYINT,
    "shift_type"       TINYINT,
    "week"             INT,
    "month"            INT,
    "year"             INT,
    "create_time"      TIMESTAMP(0),
    "create_user"      BIGINT,
    "is_high_priority" TINYINT,
    "is_undefined"     TINYINT,
    NOT                CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_calendar_daytime" IS '生产日历日时间段定义';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."calendar_date" IS '生产日历日期';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."calendar_day_id" IS '生产日历具体id';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."calendar_id" IS '生产日历id';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."create_time" IS '本条记录创建时间';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."end_time" IS '班次结束时间';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."is_high_priority" IS '是否高优先级(0:否,1:是)';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."is_undefined" IS '是否未定义工厂日(0:否,1:是)';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."month" IS '属于当年第几月';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."shift_index" IS '班次序号';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."shift_type" IS '班次类型(1-工作时段,2-休息时段,0-工厂日内未定义时段,3-工厂日外未定义时段)';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."start_time" IS '班次开始时间';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."week" IS '属于当年的第几周';
COMMENT
ON COLUMN "blade_production_calendar_daytime"."year" IS '年';


CREATE
    INDEX "shift_time_index" ON "blade_production_calendar_daytime" ("calendar_id" ASC, "start_time" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE
    INDEX "calendarDateIndex" ON "blade_production_calendar_daytime" ("calendar_date" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE
    INDEX "calendarIdIndex" ON "blade_production_calendar_daytime" ("calendar_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_production_capacity_group";
CREATE TABLE "blade_production_capacity_group"
(
    "id"            BIGINT NOT NULL,
    "tenant_id"     VARCHAR(12) DEFAULT '000000',
    "name"          VARCHAR(45),
    "full_name"     VARCHAR(45),
    "sort"          INT,
    "remark"        VARCHAR(255),
    "calendar_code" VARCHAR(128),
    "is_deleted"    INT,
    NOT             CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_capacity_group" IS '组';
COMMENT
ON COLUMN "blade_production_capacity_group"."full_name" IS '组完整名称';
COMMENT
ON COLUMN "blade_production_capacity_group"."id" IS '主键';
COMMENT
ON COLUMN "blade_production_capacity_group"."name" IS '组名';
COMMENT
ON COLUMN "blade_production_capacity_group"."remark" IS '备注';
COMMENT
ON COLUMN "blade_production_capacity_group"."sort" IS '排序';
COMMENT
ON COLUMN "blade_production_capacity_group"."tenant_id" IS '租户ID';


DROP TABLE IF EXISTS "blade_region";
CREATE TABLE "blade_region"
(
    "code"          VARCHAR(12) NOT NULL,
    "parent_code"   VARCHAR(12),
    "ancestors"     VARCHAR(255),
    "name"          VARCHAR(32),
    "province_code" VARCHAR(12),
    "province_name" VARCHAR(32),
    "city_code"     VARCHAR(12),
    "city_name"     VARCHAR(32),
    "district_code" VARCHAR(12),
    "district_name" VARCHAR(32),
    "town_code"     VARCHAR(12),
    "town_name"     VARCHAR(32),
    "village_code"  VARCHAR(12),
    "village_name"  VARCHAR(32),
    "region_level"  INT,
    "sort"          INT,
    "remark"        VARCHAR(255),
    NOT             CLUSTER PRIMARY KEY("code")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_region" IS '行政区划表';
COMMENT
ON COLUMN "blade_region"."ancestors" IS '祖区划编号';
COMMENT
ON COLUMN "blade_region"."city_code" IS '市级区划编号';
COMMENT
ON COLUMN "blade_region"."city_name" IS '市级名称';
COMMENT
ON COLUMN "blade_region"."code" IS '区划编号';
COMMENT
ON COLUMN "blade_region"."district_code" IS '区级区划编号';
COMMENT
ON COLUMN "blade_region"."district_name" IS '区级名称';
COMMENT
ON COLUMN "blade_region"."name" IS '区划名称';
COMMENT
ON COLUMN "blade_region"."parent_code" IS '父区划编号';
COMMENT
ON COLUMN "blade_region"."province_code" IS '省级区划编号';
COMMENT
ON COLUMN "blade_region"."province_name" IS '省级名称';
COMMENT
ON COLUMN "blade_region"."region_level" IS '层级';
COMMENT
ON COLUMN "blade_region"."remark" IS '备注';
COMMENT
ON COLUMN "blade_region"."sort" IS '排序';
COMMENT
ON COLUMN "blade_region"."town_code" IS '镇级区划编号';
COMMENT
ON COLUMN "blade_region"."town_name" IS '镇级名称';
COMMENT
ON COLUMN "blade_region"."village_code" IS '村级区划编号';
COMMENT
ON COLUMN "blade_region"."village_name" IS '村级名称';


CREATE
    UNIQUE INDEX "INDEX26621245466500" ON "blade_region" ("code" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_shift_detail";
CREATE TABLE "blade_shift_detail"
(
    "id"               BIGINT NOT NULL,
    "model_id"         BIGINT,
    "shift_index"      TINYINT,
    "shift_start_time" INT,
    "shift_end_time"   INT,
    "rest_number"      TINYINT,
    "index_name"       VARCHAR(50),
    NOT                CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_shift_detail"."index_name" IS '下标名称';
COMMENT
ON COLUMN "blade_shift_detail"."model_id" IS '班次模型id';
COMMENT
ON COLUMN "blade_shift_detail"."rest_number" IS '班次休息时段数量';
COMMENT
ON COLUMN "blade_shift_detail"."shift_end_time" IS '班次开始时间的偏移量(以当日0点为基准的偏移量的分钟数）';
COMMENT
ON COLUMN "blade_shift_detail"."shift_index" IS '班次序号';
COMMENT
ON COLUMN "blade_shift_detail"."shift_start_time" IS '班次开始时间的偏移量(以当日0点为基准的偏移量的分钟数）';
CREATE INDEX "INDEX1657856130003" ON "blade_shift_detail" ("model_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_shift_model";
CREATE TABLE "blade_shift_model"
(
    "id"           BIGINT NOT NULL,
    "code"         VARCHAR(128),
    "name"         VARCHAR(50),
    "shift_number" TINYINT,
    "colour"       VARCHAR(30),
    "start_time"   INT,
    "end_time"     INT,
    "tenant_id"    VARCHAR(12),
    "is_deleted"   INT,
    "is_default"   TINYINT,
    "create_user"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "create_dept"  BIGINT,
    "status"       INT,
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_shift_model"."code" IS '班次编号';
COMMENT
ON COLUMN "blade_shift_model"."colour" IS '班次颜色';
COMMENT
ON COLUMN "blade_shift_model"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_shift_model"."create_time" IS '创建日期';
COMMENT
ON COLUMN "blade_shift_model"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_shift_model"."end_time" IS '班次日结束时间的偏移量(以当日0点为基准的偏移量的分钟数）';
COMMENT
ON COLUMN "blade_shift_model"."is_default" IS '是否是默认班次(0-默认,1-非默认)默认班次不可编辑,不可删除';
COMMENT
ON COLUMN "blade_shift_model"."is_deleted" IS '是否删除(0-未删除,1-已删除)';
COMMENT
ON COLUMN "blade_shift_model"."name" IS '班次名称';
COMMENT
ON COLUMN "blade_shift_model"."shift_number" IS '班次数量';
COMMENT
ON COLUMN "blade_shift_model"."start_time" IS '班次日开始时间的偏移量(以当日0点为基准的偏移量的分钟数）';
COMMENT
ON COLUMN "blade_shift_model"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_shift_model"."tenant_id" IS '租户id';
COMMENT
ON COLUMN "blade_shift_model"."update_time" IS '更新日期';
COMMENT
ON COLUMN "blade_shift_model"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_shift_rest_time";
CREATE TABLE "blade_shift_rest_time"
(
    "id"              BIGINT NOT NULL,
    "model_id"        BIGINT,
    "rest_index"      INT,
    "shift_id"        BIGINT,
    "rest_start_time" INT,
    "rest_end_time"   INT,
    NOT               CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_shift_rest_time"."model_id" IS '模型Id';
COMMENT
ON COLUMN "blade_shift_rest_time"."rest_end_time" IS '休息时段结束时间的偏移量(以当日0点为基准的偏移量的分钟数）';
COMMENT
ON COLUMN "blade_shift_rest_time"."rest_index" IS '休息时段序号';
COMMENT
ON COLUMN "blade_shift_rest_time"."rest_start_time" IS '休息时段开始时间的偏移量(以当日0点为基准的偏移量的分钟数）';
COMMENT
ON COLUMN "blade_shift_rest_time"."shift_id" IS '班次Id';


DROP TABLE IF EXISTS "blade_stock_in_type";
CREATE TABLE "blade_stock_in_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_stock_in_type" IS '入库类型';
COMMENT
ON COLUMN "blade_stock_in_type"."code" IS '入库类型编码';
COMMENT
ON COLUMN "blade_stock_in_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_stock_in_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_stock_in_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_stock_in_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_stock_in_type"."name" IS '入库类型名称';
COMMENT
ON COLUMN "blade_stock_in_type"."remark" IS '备注';
COMMENT
ON COLUMN "blade_stock_in_type"."status" IS '状态';
COMMENT
ON COLUMN "blade_stock_in_type"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_stock_in_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_stock_in_type"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_stock_out_type";
CREATE TABLE "blade_stock_out_type"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_stock_out_type" IS '出库类型';
COMMENT
ON COLUMN "blade_stock_out_type"."code" IS '出库类型编码';
COMMENT
ON COLUMN "blade_stock_out_type"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_stock_out_type"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_stock_out_type"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_stock_out_type"."id" IS '主键';
COMMENT
ON COLUMN "blade_stock_out_type"."name" IS '出库类型名称';
COMMENT
ON COLUMN "blade_stock_out_type"."remark" IS '备注';
COMMENT
ON COLUMN "blade_stock_out_type"."status" IS '状态';
COMMENT
ON COLUMN "blade_stock_out_type"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_stock_out_type"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_stock_out_type"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_supplier";
CREATE TABLE "blade_supplier"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "address"     VARCHAR(128),
    "tel"         VARCHAR(64),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_supplier" IS '供应商';
COMMENT
ON COLUMN "blade_supplier"."address" IS '供应商地址';
COMMENT
ON COLUMN "blade_supplier"."code" IS '供应商编码';
COMMENT
ON COLUMN "blade_supplier"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_supplier"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_supplier"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_supplier"."id" IS '主键';
COMMENT
ON COLUMN "blade_supplier"."name" IS '供应商名称';
COMMENT
ON COLUMN "blade_supplier"."status" IS '状态';
COMMENT
ON COLUMN "blade_supplier"."tel" IS '联系方式';
COMMENT
ON COLUMN "blade_supplier"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_supplier"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_supplier"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_tool";
CREATE TABLE "blade_tool"
(
    "id"                BIGINT NOT NULL,
    "status"            INT,
    "is_deleted"        BIGINT      DEFAULT 0,
    "create_user"       BIGINT,
    "create_dept"       BIGINT,
    "create_time"       TIMESTAMP(0),
    "update_user"       BIGINT,
    "update_time"       TIMESTAMP(0),
    "tenant_id"         VARCHAR(12) DEFAULT '000000',
    "tool_category_id"  BIGINT,
    "tool_model_id"     BIGINT,
    "tool_prefix_code"  VARCHAR(45),
    "life_count_method" INT,
    "initial_life"      INT,
    "used_life"         INT,
    "remain_life"       INT,
    "warning_value"     INT,
    "life_state"        INT,
    "use_state"         INT,
    "workstation_id"    BIGINT,
    "workstation_code"  VARCHAR(45),
    "workstation_name"  VARCHAR(45),
    "tool_position"     INT,
    "parameter1"        VARCHAR(45),
    "parameter2"        VARCHAR(45),
    "parameter3"        VARCHAR(45),
    "parameter4"        VARCHAR(45),
    "parameter5"        VARCHAR(45),
    "parameter6"        VARCHAR(45),
    "parameter7"        VARCHAR(45),
    "parameter8"        VARCHAR(45),
    "parameter9"        VARCHAR(45),
    "parameter10"       VARCHAR(45),
    "code"              VARCHAR(255),
    NOT                 CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_tool" IS '刀具管理';
COMMENT
ON COLUMN "blade_tool"."code" IS '刀具编号';
COMMENT
ON COLUMN "blade_tool"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_tool"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tool"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tool"."id" IS '主键';
COMMENT
ON COLUMN "blade_tool"."initial_life" IS '初始寿命';
COMMENT
ON COLUMN "blade_tool"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_tool"."life_count_method" IS '寿命计数方式(1.按次数 2.按时间)';
COMMENT
ON COLUMN "blade_tool"."life_state" IS '寿命状态(1.正常 2.警告 3.报警)';
COMMENT
ON COLUMN "blade_tool"."parameter1" IS '参数1';
COMMENT
ON COLUMN "blade_tool"."parameter10" IS '参数10';
COMMENT
ON COLUMN "blade_tool"."parameter2" IS '参数2';
COMMENT
ON COLUMN "blade_tool"."parameter3" IS '参数3';
COMMENT
ON COLUMN "blade_tool"."parameter4" IS '参数4';
COMMENT
ON COLUMN "blade_tool"."parameter5" IS '参数5';
COMMENT
ON COLUMN "blade_tool"."parameter6" IS '参数6';
COMMENT
ON COLUMN "blade_tool"."parameter7" IS '参数7';
COMMENT
ON COLUMN "blade_tool"."parameter8" IS '参数8';
COMMENT
ON COLUMN "blade_tool"."parameter9" IS '参数9';
COMMENT
ON COLUMN "blade_tool"."remain_life" IS '剩余寿命';
COMMENT
ON COLUMN "blade_tool"."status" IS '状态';
COMMENT
ON COLUMN "blade_tool"."tenant_id" IS '租户id';
COMMENT
ON COLUMN "blade_tool"."tool_category_id" IS '刀具类型id';
COMMENT
ON COLUMN "blade_tool"."tool_model_id" IS '刀具型号id';
COMMENT
ON COLUMN "blade_tool"."tool_position" IS '机床刀位';
COMMENT
ON COLUMN "blade_tool"."tool_prefix_code" IS '刀具前缀编号';
COMMENT
ON COLUMN "blade_tool"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_tool"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_tool"."use_state" IS '使用状态(2.新增 1.已装刀 0.已卸刀)';
COMMENT
ON COLUMN "blade_tool"."used_life" IS '已用寿命';
COMMENT
ON COLUMN "blade_tool"."warning_value" IS '预警值';
COMMENT
ON COLUMN "blade_tool"."workstation_code" IS '工位编号';
COMMENT
ON COLUMN "blade_tool"."workstation_id" IS '工位id';
COMMENT
ON COLUMN "blade_tool"."workstation_name" IS '工位名称';

DROP TABLE IF EXISTS "blade_workstation";
CREATE TABLE "blade_workstation"
(
    "id"                        BIGINT                           NOT NULL,
    "tenant_id"                 VARCHAR(6),
    "code"                      VARCHAR(128)                     NOT NULL,
    "name"                      VARCHAR(32)                      NOT NULL,
    "avatar"                    VARCHAR(1000),
    "type"                      INT          DEFAULT 1           NOT NULL,
    "calendar_code"             VARCHAR(128) DEFAULT '#default#' NOT NULL,
    "standard_efficiency"       DEC(5, 2),
    "production_capacity_group" BIGINT,
    "calendar_code_waiting"     VARCHAR(32),
    "status"                    INT,
    "create_dept"               BIGINT,
    "is_deleted"                INT,
    "create_time"               TIMESTAMP(0),
    "create_user"               BIGINT,
    "update_time"               TIMESTAMP(0),
    "update_user"               BIGINT,
    "support_cnc_rw"            TINYINT,
    "device_type"               int,
    "properties"                int,
    "transmission_method"       int          DEFAULT 1,
    NOT                         CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "uniqueCodeIndex" UNIQUE ("code", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_workstation" IS '工位';
COMMENT
ON COLUMN "blade_workstation"."avatar" IS '头像';
COMMENT
ON COLUMN "blade_workstation"."calendar_code" IS '生产日历';
COMMENT
ON COLUMN "blade_workstation"."calendar_code_waiting" IS '生产日历等待更新';
COMMENT
ON COLUMN "blade_workstation"."code" IS '工位编号';
COMMENT
ON COLUMN "blade_workstation"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_workstation"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_workstation"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_workstation"."name" IS '工位名称';
COMMENT
ON COLUMN "blade_workstation"."production_capacity_group" IS '产能组';
COMMENT
ON COLUMN "blade_workstation"."standard_efficiency" IS '标准效率';
COMMENT
ON COLUMN "blade_workstation"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_workstation"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_workstation"."type" IS '工位类型：机器、人, 来自字典 workstation_type';
COMMENT
ON COLUMN "blade_workstation"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_workstation"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_workstation"."support_cnc_rw" IS '是否支持文件写入(1 支持 0 不支持)';
COMMENT
ON COLUMN "blade_workstation"."device_type" IS '加工设备类型';
COMMENT
ON COLUMN "blade_workstation"."properties" IS '加工属性';
COMMENT
ON COLUMN "blade_workstation"."transmission_method" IS '程序传输方式：1 FTP 2 串口';
CREATE INDEX "INDEX1657856130000" ON "blade_workstation" ("calendar_code" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_workstation_of_machine";
CREATE TABLE "blade_workstation_of_machine"
(
    "id"             BIGINT NOT NULL,
    "workstation_id" BIGINT NOT NULL,
    "machine_id"     BIGINT NOT NULL,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_workstation_of_machine" IS '机器工位';


DROP TABLE IF EXISTS "blade_workstation_of_workstation_group";
CREATE TABLE "blade_workstation_of_workstation_group"
(
    "id"                   BIGINT NOT NULL,
    "workstation_id"       BIGINT NOT NULL,
    "workstation_group_id" BIGINT NOT NULL,
    NOT                    CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_workstation_of_workstation_group" IS '工位-工位组对应表';


DROP TABLE IF EXISTS "blade_workstation_wcs";
CREATE TABLE "blade_workstation_wcs"
(
    "id"                   BIGINT            NOT NULL,
    "tenant_id"            VARCHAR(12),
    "workstation_id"       BIGINT,
    "data_item"            VARCHAR(255),
    "data_type"            INT,
    "dmp_variables_id"     BIGINT,
    "status"               INT,
    "collect_item"         VARCHAR(255),
    "create_dept"          BIGINT,
    "create_time"          TIMESTAMP(0),
    "create_user"          BIGINT,
    "update_time"          TIMESTAMP(0),
    "update_user"          BIGINT,
    "is_deleted"           INT,
    "data_item_crc"        VARCHAR(8),
    "collect_setting_item" VARCHAR(255),
    "big_screen"           TINYINT DEFAULT 1 NOT NULL,
    "real_time_data"       TINYINT DEFAULT 1 NOT NULL,
    "process_parameter"    TINYINT DEFAULT 1 NOT NULL,
    NOT                    CLUSTER PRIMARY KEY ("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_workstation_wcs" IS '工况参数';
COMMENT
ON COLUMN "blade_workstation_wcs"."dmp_variables_id" IS '采集项';
COMMENT
ON COLUMN "blade_workstation_wcs"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_workstation_wcs"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_workstation_wcs"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_workstation_wcs"."data_item" IS '工位数据项';
COMMENT
ON COLUMN "blade_workstation_wcs"."data_type" IS '数据类型 0-状态 1-产量 2-其他';
COMMENT
ON COLUMN "blade_workstation_wcs"."id" IS '主键id';
COMMENT
ON COLUMN "blade_workstation_wcs"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_workstation_wcs"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_workstation_wcs"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_workstation_wcs"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_workstation_wcs"."workstation_id" IS '工位id';
COMMENT
ON COLUMN "blade_workstation_wcs"."collect_setting_item" IS '采集项';
COMMENT
ON COLUMN "blade_workstation_wcs"."data_item_crc" IS '校验值';
COMMENT
ON COLUMN "blade_workstation_wcs"."big_screen" IS '大屏';
COMMENT
ON COLUMN "blade_workstation_wcs"."real_time_data" IS '实时数据';
COMMENT
ON COLUMN "blade_workstation_wcs"."process_parameter" IS '过程参数';


DROP TABLE IF EXISTS "blade_gallery";
CREATE TABLE "blade_gallery"
(
    "id"          BIGINT NOT NULL,
    "name"        VARCHAR(64),
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    NOT           CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_gallery" IS '图库';
COMMENT
ON COLUMN "blade_gallery"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_gallery"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_gallery"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_gallery"."id" IS '主键';
COMMENT
ON COLUMN "blade_gallery"."name" IS '图库名称';
COMMENT
ON COLUMN "blade_gallery"."status" IS '状态';
COMMENT
ON COLUMN "blade_gallery"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_gallery"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_gallery_item";
CREATE TABLE "blade_gallery_item"
(
    "id"            BIGINT NOT NULL,
    "gallery_id"    BIGINT,
    "name"          VARCHAR(64),
    "original_name" VARCHAR(500),
    "thumbnail"     TEXT,
    "link"          VARCHAR(1000),
    "extension"     VARCHAR(12),
    "status"        INT,
    "is_deleted"    INT,
    "create_user"   BIGINT,
    "create_dept"   BIGINT,
    "create_time"   TIMESTAMP(0),
    "update_user"   BIGINT,
    "update_time"   TIMESTAMP(0),
    NOT             CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_gallery_item" IS '图库';
COMMENT
ON COLUMN "blade_gallery_item"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_gallery_item"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_gallery_item"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_gallery_item"."extension" IS '附件拓展名';
COMMENT
ON COLUMN "blade_gallery_item"."id" IS '主键';
COMMENT
ON COLUMN "blade_gallery_item"."link" IS '文件地址';
COMMENT
ON COLUMN "blade_gallery_item"."name" IS '名称';
COMMENT
ON COLUMN "blade_gallery_item"."original_name" IS '文件原名';
COMMENT
ON COLUMN "blade_gallery_item"."status" IS '数据状态，1启用/0停用';
COMMENT
ON COLUMN "blade_gallery_item"."thumbnail" IS '缩略图，base64存储';
COMMENT
ON COLUMN "blade_gallery_item"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_gallery_item"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_gallery_item"."gallery_id" IS '图库类别ID';


DROP TABLE IF EXISTS "blade_check_item";
CREATE TABLE "blade_check_item"
(
    "id"               BIGINT NOT NULL,
    "status"           INT,
    "is_deleted"       INT,
    "create_user"      BIGINT,
    "create_dept"      BIGINT,
    "create_time"      TIMESTAMP(0),
    "update_user"      BIGINT,
    "update_time"      TIMESTAMP(0),
    "tenant_id"        VARCHAR(12),
    "check_project_id" BIGINT,
    "name"             VARCHAR(64),
    "value_type"       VARCHAR(64),
    "requirement"      VARCHAR(255),
    "standard_value"   VARCHAR(64),
    NOT                CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_check_item" IS '点检项';
COMMENT
ON COLUMN "blade_check_item"."check_project_id" IS '点检项目Id';
COMMENT
ON COLUMN "blade_check_item"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_check_item"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_check_item"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_check_item"."id" IS '主键';
COMMENT
ON COLUMN "blade_check_item"."name" IS '点检项';
COMMENT
ON COLUMN "blade_check_item"."requirement" IS '点检要求';
COMMENT
ON COLUMN "blade_check_item"."standard_value" IS '标准数值';
COMMENT
ON COLUMN "blade_check_item"."status" IS '状态';
COMMENT
ON COLUMN "blade_check_item"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_check_item"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_check_item"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_check_item"."value_type" IS '数值类型';


DROP TABLE IF EXISTS "blade_check_project";
CREATE TABLE "blade_check_project"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(128),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_check_project" IS '点检项目信息';
COMMENT
ON COLUMN "blade_check_project"."code" IS '点检项目编码';
COMMENT
ON COLUMN "blade_check_project"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_check_project"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_check_project"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_check_project"."id" IS '主键';
COMMENT
ON COLUMN "blade_check_project"."name" IS '点检项目名称';
COMMENT
ON COLUMN "blade_check_project"."remark" IS '备注';
COMMENT
ON COLUMN "blade_check_project"."status" IS '状态';
COMMENT
ON COLUMN "blade_check_project"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_check_project"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_check_project"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_machine";
CREATE TABLE "blade_machine"
(
    "id"                        BIGINT            NOT NULL,
    "tenant_id"                 VARCHAR(12),
    "extend_id"                 VARCHAR(36),
    "machine_code"              VARCHAR(64)       NOT NULL,
    "machine_name"              VARCHAR(64)       NOT NULL,
    "collect_switch"            TINYINT DEFAULT 0 NOT NULL,
    "collect_driver"            VARCHAR(64),
    "type_name"                 VARCHAR(64),
    "machine_type"              VARCHAR(64),
    "machine_model"             VARCHAR(64),
    "machine_life_status"       TINYINT,
    "machine_use_status"        TINYINT,
    "factory_no"                VARCHAR(64),
    "assets_code"               VARCHAR(64),
    "brand"                     VARCHAR(64),
    "nameplate"                 VARCHAR(64),
    "avatar"                    VARCHAR(1000),
    "serial_no"                 VARCHAR(32),
    "factory_file"              VARCHAR(64),
    "manufacturer"              VARCHAR(64),
    "country_of_manufacture"    VARCHAR(64),
    "system_name"               VARCHAR(32),
    "software_version"          VARCHAR(32),
    "net_weight"                DEC(19, 2),
    "power"                     DEC(19, 2),
    "voltage"                   DEC(19, 2),
    "dimensions"                VARCHAR(64),
    "production_time"           TIMESTAMP(0),
    "delivery_time"             TIMESTAMP(0),
    "depreciation_year"         INT,
    "turn_to_fixed_assets_time" TIMESTAMP(0),
    "invoice_value"             DEC(19, 2),
    "ovfa"                      DEC(19, 2),
    "net_asset_value"           DEC(19, 2),
    "organization"              BIGINT,
    "custodian"                 BIGINT,
    "management_class"          TINYINT,
    "elaborate_equipment"       INT,
    "create_user"               BIGINT,
    "create_dept"               BIGINT,
    "create_time"               TIMESTAMP(0),
    "update_user"               BIGINT,
    "update_time"               TIMESTAMP(0),
    "status"                    INT,
    "is_deleted"                INT,
    "pin_code"                  VARCHAR(6),
    "short_code"                VARCHAR(12),
    "last_repair_time"          TIMESTAMP(0),
    "employee_id"               BIGINT,
    "production_line"           VARCHAR(255),
    "organization_id"           BIGINT,
    "remark"                    VARCHAR(255),
    "machine_type_id"           BIGINT,
    "group_id"                  BIGINT,
    "last_maintain_time"        TIMESTAMP(0),
    "next_maintain_time"        TIMESTAMP(0),
    "last_check_time"           TIMESTAMP(0),
    "installation_location"     VARCHAR(64),
    "maintenance_time"          TIMESTAMP(0),
    "repair_status"             TINYINT,
    "maintenance_status"        TINYINT,
    "external_key"              VARCHAR(128),
    NOT                         CLUSTER PRIMARY KEY("id"),
    CHECK ("elaborate_equipment" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_machine" IS '机器';
COMMENT
ON COLUMN "blade_machine"."assets_code" IS '资产编号';
COMMENT
ON COLUMN "blade_machine"."avatar" IS '头像';
COMMENT
ON COLUMN "blade_machine"."brand" IS '品牌';
COMMENT
ON COLUMN "blade_machine"."collect_driver" IS '采集驱动';
COMMENT
ON COLUMN "blade_machine"."collect_switch" IS '采集开关：0关/1开';
COMMENT
ON COLUMN "blade_machine"."country_of_manufacture" IS '产地国别';
COMMENT
ON COLUMN "blade_machine"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_machine"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_machine"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_machine"."custodian" IS '保管人';
COMMENT
ON COLUMN "blade_machine"."delivery_time" IS '交付日期';
COMMENT
ON COLUMN "blade_machine"."depreciation_year" IS '折旧年限';
COMMENT
ON COLUMN "blade_machine"."dimensions" IS '轮廓尺寸(CM)';
COMMENT
ON COLUMN "blade_machine"."elaborate_equipment" IS '是否是特种设备，1是/0否';
COMMENT
ON COLUMN "blade_machine"."employee_id" IS '责任人';
COMMENT
ON COLUMN "blade_machine"."extend_id" IS '扩展id';
COMMENT
ON COLUMN "blade_machine"."external_key" IS '设备外部标识（用户可更改，用于标识该设备,唯一标识，可使用该Key进行检索设备）';
COMMENT
ON COLUMN "blade_machine"."factory_file" IS '出厂档案';
COMMENT
ON COLUMN "blade_machine"."factory_no" IS '出厂编号';
COMMENT
ON COLUMN "blade_machine"."group_id" IS '所属机器组id';
COMMENT
ON COLUMN "blade_machine"."installation_location" IS '安装位置';
COMMENT
ON COLUMN "blade_machine"."invoice_value" IS '发票金额';
COMMENT
ON COLUMN "blade_machine"."last_check_time" IS '最后点检时间';
COMMENT
ON COLUMN "blade_machine"."last_maintain_time" IS '最后保养时间';
COMMENT
ON COLUMN "blade_machine"."last_repair_time" IS '维修日期';
COMMENT
ON COLUMN "blade_machine"."machine_code" IS '机器编号';
COMMENT
ON COLUMN "blade_machine"."machine_life_status" IS '生命状态 字典 machine_life_status';
COMMENT
ON COLUMN "blade_machine"."machine_model" IS '机器规格';
COMMENT
ON COLUMN "blade_machine"."machine_name" IS '机器名称';
COMMENT
ON COLUMN "blade_machine"."machine_type" IS '设备类型';
COMMENT
ON COLUMN "blade_machine"."machine_type_id" IS '机器类型id';
COMMENT
ON COLUMN "blade_machine"."machine_use_status" IS '使用状态 字典 machine_use_status';
COMMENT
ON COLUMN "blade_machine"."maintenance_status" IS '保养状态';
COMMENT
ON COLUMN "blade_machine"."maintenance_time" IS '保养日期';
COMMENT
ON COLUMN "blade_machine"."management_class" IS '管理等级，字典 machine_management_class';
COMMENT
ON COLUMN "blade_machine"."manufacturer" IS '制造厂商';
COMMENT
ON COLUMN "blade_machine"."nameplate" IS '铭牌';
COMMENT
ON COLUMN "blade_machine"."net_asset_value" IS '资产净值';
COMMENT
ON COLUMN "blade_machine"."net_weight" IS '净重kg';
COMMENT
ON COLUMN "blade_machine"."next_maintain_time" IS '下次保养时间';
COMMENT
ON COLUMN "blade_machine"."organization" IS '使用部门';
COMMENT
ON COLUMN "blade_machine"."organization_id" IS '使用部门';
COMMENT
ON COLUMN "blade_machine"."ovfa" IS '资产原值';
COMMENT
ON COLUMN "blade_machine"."pin_code" IS 'PIN码';
COMMENT
ON COLUMN "blade_machine"."power" IS '功率kw';
COMMENT
ON COLUMN "blade_machine"."production_line" IS '生产线';
COMMENT
ON COLUMN "blade_machine"."production_time" IS '生产日期';
COMMENT
ON COLUMN "blade_machine"."remark" IS '备注';
COMMENT
ON COLUMN "blade_machine"."repair_status" IS '维修状态';
COMMENT
ON COLUMN "blade_machine"."serial_no" IS '序列号';
COMMENT
ON COLUMN "blade_machine"."short_code" IS '短编码';
COMMENT
ON COLUMN "blade_machine"."software_version" IS '软件版本';
COMMENT
ON COLUMN "blade_machine"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_machine"."system_name" IS '系统名称';
COMMENT
ON COLUMN "blade_machine"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_machine"."turn_to_fixed_assets_time" IS '转固日期';
COMMENT
ON COLUMN "blade_machine"."type_name" IS '设备类型';
COMMENT
ON COLUMN "blade_machine"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_machine"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_machine"."voltage" IS '电压v';
comment
on column "blade_machine"."external_key" is '设备外部标识（用户可更改，用于标识该设备,唯一标识，可使用该Key进行检索设备）';



CREATE INDEX "employee_id_2" ON "blade_machine" ("employee_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "blade_shift_off_day";
CREATE TABLE "blade_shift_off_day"
(
    "ID"            BIGINT NOT NULL,
    "STATUS"        INT,
    "IS_DELETED"    BIGINT DEFAULT 0,
    "CREATE_USER"   BIGINT,
    "CREATE_DEPT"   BIGINT,
    "CREATE_TIME"   TIMESTAMP(0),
    "UPDATE_USER"   BIGINT,
    "UPDATE_TIME"   TIMESTAMP(0),
    "START_OFF_DAY" DATE,
    "END_OFF_DAY"   DATE,
    "REMARK"        VARCHAR(255),
    "YEAR"          BIGINT,
    NOT             CLUSTER PRIMARY KEY("ID"),
    CHECK ("STATUS" >= 0),
    CHECK ("IS_DELETED" >= 0),
    CHECK ("YEAR" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_shift_off_day" IS '班次休息日';
COMMENT
ON COLUMN "blade_shift_off_day"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "blade_shift_off_day"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "blade_shift_off_day"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "blade_shift_off_day"."END_OFF_DAY" IS '休息日-结束';
COMMENT
ON COLUMN "blade_shift_off_day"."ID" IS '主键';
COMMENT
ON COLUMN "blade_shift_off_day"."IS_DELETED" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_shift_off_day"."REMARK" IS '备注/说明';
COMMENT
ON COLUMN "blade_shift_off_day"."START_OFF_DAY" IS '休息日-开始';
COMMENT
ON COLUMN "blade_shift_off_day"."STATUS" IS '状态';
COMMENT
ON COLUMN "blade_shift_off_day"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "blade_shift_off_day"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "blade_shift_off_day"."YEAR" IS '年份';


DROP TABLE IF EXISTS "blade_fixture";
CREATE TABLE "blade_fixture"
(
    "id"             BIGINT       NOT NULL,
    "tenant_id"      VARCHAR(6),
    "code"           VARCHAR(128) NOT NULL,
    "name"           VARCHAR(32)  NOT NULL,
    "fixture_status" INT,
    "description"    VARCHAR(255),
    "avatar"         VARCHAR(255),
    "in_use"         TINYINT DEFAULT 0,
    "status"         INT,
    "create_dept"    BIGINT,
    "is_deleted"     INT,
    "create_time"    TIMESTAMP(0),
    "create_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "remark"         VARCHAR(255),
    NOT              CLUSTER PRIMARY KEY("ID"),
    UNIQUE ("CODE", "IS_DELETED")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_fixture" IS '工装夹具';
COMMENT
ON COLUMN "blade_fixture"."avatar" IS '图像';
COMMENT
ON COLUMN "blade_fixture"."code" IS '夹具编号';
COMMENT
ON COLUMN "blade_fixture"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_fixture"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_fixture"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_fixture"."description" IS '描述';
COMMENT
ON COLUMN "blade_fixture"."fixture_status" IS '夹具状态';
COMMENT
ON COLUMN "blade_fixture"."in_use" IS '是否在使用';
COMMENT
ON COLUMN "blade_fixture"."name" IS '夹具名称';
COMMENT
ON COLUMN "blade_fixture"."remark" IS '备注';
COMMENT
ON COLUMN "blade_fixture"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_fixture"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_fixture"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_fixture"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_warehouse_area";
CREATE TABLE "blade_warehouse_area"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "parent_id"   BIGINT NOT NULL,
    "is_deleted"  INT,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "code"        VARCHAR(32),
    "name"        VARCHAR(64),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    UNIQUE ("code", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_warehouse_area" IS '库区';
COMMENT
ON COLUMN "blade_warehouse_area"."code" IS '库区编码';
COMMENT
ON COLUMN "blade_warehouse_area"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_warehouse_area"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_warehouse_area"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_warehouse_area"."id" IS '主键';
COMMENT
ON COLUMN "blade_warehouse_area"."name" IS '库区名称';
COMMENT
ON COLUMN "blade_warehouse_area"."parent_id" IS '父级id';
COMMENT
ON COLUMN "blade_warehouse_area"."remark" IS '备注';
COMMENT
ON COLUMN "blade_warehouse_area"."status" IS '状态';
COMMENT
ON COLUMN "blade_warehouse_area"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_warehouse_area"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_warehouse_area"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_warehouse_area_of_material_type";
CREATE TABLE "blade_warehouse_area_of_material_type"
(
    "ID"                BIGINT NOT NULL,
    "WAREHOUSE_AREA_ID" BIGINT,
    "MATERIAL_TYPE_ID"  BIGINT,
    NOT                 CLUSTER PRIMARY KEY("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_warehouse_area_of_material_type" IS '库区物料类型连接表';
COMMENT
ON COLUMN "blade_warehouse_area_of_material_type"."ID" IS '主键';
COMMENT
ON COLUMN "blade_warehouse_area_of_material_type"."MATERIAL_TYPE_ID" IS '物料类型id';
COMMENT
ON COLUMN "blade_warehouse_area_of_material_type"."WAREHOUSE_AREA_ID" IS '库区id';



DROP TABLE IF EXISTS "blade_device_type_check_project";
CREATE TABLE "blade_device_type_check_project"
(
    "id"               BIGINT NOT NULL,
    "status"           INT,
    "is_deleted"       INT,
    "create_user"      BIGINT,
    "create_dept"      BIGINT,
    "create_time"      TIMESTAMP(0),
    "update_user"      BIGINT,
    "update_time"      TIMESTAMP(0),
    "tenant_id"        VARCHAR(12),
    "device_type_id"   BIGINT,
    "check_project_id" BIGINT,
    "interval_time"    INT,
    NOT                CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_device_type_check_project" IS '设备类型点检记录';
COMMENT
ON COLUMN "blade_device_type_check_project"."check_project_id" IS '点检项目id';
COMMENT
ON COLUMN "blade_device_type_check_project"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_device_type_check_project"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_device_type_check_project"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_device_type_check_project"."device_type_id" IS '设备类型id';
COMMENT
ON COLUMN "blade_device_type_check_project"."id" IS '主键';
COMMENT
ON COLUMN "blade_device_type_check_project"."interval_time" IS '点检周期';
COMMENT
ON COLUMN "blade_device_type_check_project"."status" IS '状态';
COMMENT
ON COLUMN "blade_device_type_check_project"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_device_type_check_project"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_device_type_check_project"."update_user" IS '更新人';

DROP TABLE IF EXISTS "blade_warehouse_grid";
CREATE TABLE "blade_warehouse_grid"
(
    "id"          BIGINT NOT NULL,
    "tenant_id"   VARCHAR(6),
    "station_id"  BIGINT NOT NULL,
    "code"        VARCHAR(32),
    "name"        VARCHAR(32),
    "status"      INT,
    "create_dept" BIGINT,
    "is_deleted"  INT,
    "create_time" TIMESTAMP(0),
    "create_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "unique_code_index" UNIQUE ("code", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_warehouse_grid" IS '库区货格';
COMMENT
ON COLUMN "blade_warehouse_grid"."code" IS '货格编号';
COMMENT
ON COLUMN "blade_warehouse_grid"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_warehouse_grid"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_warehouse_grid"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_warehouse_grid"."id" IS 'id';
COMMENT
ON COLUMN "blade_warehouse_grid"."name" IS '货格名称';
COMMENT
ON COLUMN "blade_warehouse_grid"."remark" IS '备注';
COMMENT
ON COLUMN "blade_warehouse_grid"."station_id" IS '库位id';
COMMENT
ON COLUMN "blade_warehouse_grid"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_warehouse_grid"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_warehouse_grid"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_warehouse_grid"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_warehouse_station";
CREATE TABLE "BLADE_WAREHOUSE_STATION"
(
    "ID"             BIGINT NOT NULL,
    "TENANT_ID"      VARCHAR(6),
    "AREA_ID"        BIGINT NOT NULL,
    "WAREHOUSE_CODE" VARCHAR(32),
    "WAREHOUSE_NAME" VARCHAR(32),
    "STATUS"         INT,
    "CREATE_DEPT"    BIGINT,
    "IS_DELETED"     INT,
    "CREATE_TIME"    TIMESTAMP(0),
    "CREATE_USER"    BIGINT,
    "UPDATE_TIME"    TIMESTAMP(0),
    "UPDATE_USER"    BIGINT,
    "REMARK"         VARCHAR(255),
    "AVATAR"         VARCHAR(1000),
    NOT              CLUSTER PRIMARY KEY("ID"),
    UNIQUE ("AREA_ID", "WAREHOUSE_CODE", "IS_DELETED"),
    CONSTRAINT "UNIQUENAMEINDEX" UNIQUE ("AREA_ID", "WAREHOUSE_NAME", "IS_DELETED")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_WAREHOUSE_STATION" IS '库区库位';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."AREA_ID" IS '库区id';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."AVATAR" IS '头像';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."CREATE_DEPT" IS '创建单位';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."ID" IS 'id';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."REMARK" IS '备注';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."STATUS" IS '业务状态';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."TENANT_ID" IS '所属租户';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."WAREHOUSE_CODE" IS '库位编号';
COMMENT
ON COLUMN "BLADE_WAREHOUSE_STATION"."WAREHOUSE_NAME" IS '库位名称';

DROP TABLE IF EXISTS "blade_tray";
CREATE TABLE "blade_tray"
(
    "id"             bigint NOT NULL,
    "code"           varchar(255),
    "name"           varchar(255),
    "picture"        varchar(255),
    "tray_status"    tinyint DEFAULT 1,
    "description"    varchar(255),
    "in_use"         TINYINT DEFAULT 0,
    "category"       TINYINT,
    "standard_model" varchar(255),
    "availability"   TINYINT,
    "remark"         varchar(255),
    "status"         TINYINT DEFAULT 1,
    "is_deleted"     bigint,
    "create_user"    bigint,
    "create_dept"    bigint,
    "create_time"    datetime,
    "update_user"    bigint,
    "update_time"    TIMESTAMP(0),
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_tray" IS '托盘';
COMMENT
ON COLUMN "blade_tray"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_tray"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tray"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tray"."id" IS 'id';
COMMENT
ON COLUMN "blade_tray"."status" IS '业务状态 1激活 0 冻结';
COMMENT
ON COLUMN "blade_tray"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_tray"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_tray"."code" IS '编码';
COMMENT
ON COLUMN "blade_tray"."name" IS '名称';
COMMENT
ON COLUMN "blade_tray"."picture" IS '图片';
COMMENT
ON COLUMN "blade_tray"."tray_status" IS '托盘状态 1 - 空载 0 - 负载';
COMMENT
ON COLUMN "blade_tray"."description" IS '托盘描述';
COMMENT
ON COLUMN "blade_tray"."category" IS '托盘类别';
COMMENT
ON COLUMN "blade_tray"."standard_model" IS '规格';
COMMENT
ON COLUMN "blade_tray"."availability" IS '可用状态 1-激活 0-冻结';
COMMENT
ON COLUMN "blade_tray"."remark" IS '备注';

DROP TABLE IF EXISTS "blade_tray_surface";
CREATE TABLE "blade_tray_surface"
(
    "id"           bigint NOT NULL,
    "tray_id"      bigint,
    "name"         varchar(255),
    "code"         varchar(255),
    "program_code" varchar(255),
    "in_use"       tinyint DEFAULT 0,
    "status"       tinyint DEFAULT 1,
    "is_deleted"   bigint,
    "create_user"  bigint,
    "create_dept"  bigint,
    "create_time"  TIMESTAMP(0),
    "update_user"  bigint,
    "update_time"  TIMESTAMP(0),
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);
COMMENT
ON TABLE "blade_tray_surface" IS '托盘面-托盘';
COMMENT
ON COLUMN "blade_tray_surface"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_tray_surface"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tray_surface"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tray_surface"."id" IS 'id';
COMMENT
ON COLUMN "blade_tray_surface"."status" IS '业务状态 1激活 0 冻结';
COMMENT
ON COLUMN "blade_tray_surface"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_tray_surface"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_tray_surface"."code" IS '托盘面编号';
COMMENT
ON COLUMN "blade_tray_surface"."name" IS '托盘面名称';
COMMENT
ON COLUMN "blade_tray_surface"."tray_id" IS '托盘id';
COMMENT
ON COLUMN "blade_tray_surface"."program_code" IS '偏移程序编号';
COMMENT
ON COLUMN "blade_tray_surface"."in_use" IS '是否使用 默认为1';

DROP TABLE IF EXISTS "blade_tray_fixture";
CREATE TABLE "blade_tray_fixture"
(
    "id"          bigint NOT NULL,
    "tray_id"     bigint,
    "face_id"     bigint,
    "fix_id"      bigint,
    "status"      tinyint DEFAULT 1,
    "is_deleted"  bigint,
    "create_user" bigint,
    "create_dept" bigint,
    "create_time" TIMESTAMP(0),
    "update_user" bigint,
    "update_time" TIMESTAMP(0),
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_tray_fixture" IS '托盘面-夹具';
COMMENT
ON COLUMN "blade_tray_fixture"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_tray_fixture"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tray_fixture"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tray_fixture"."id" IS 'id';
COMMENT
ON COLUMN "blade_tray_fixture"."status" IS '业务状态 1激活 0 冻结';
COMMENT
ON COLUMN "blade_tray_fixture"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_tray_fixture"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_tray_fixture"."tray_id" IS '托盘id';
COMMENT
ON COLUMN "blade_tray_fixture"."face_id" IS '托盘面id';
COMMENT
ON COLUMN "blade_tray_fixture"."fix_id" IS '夹具id';

DROP TABLE IF EXISTS "blade_workstation_workbench";
CREATE TABLE "blade_workstation_workbench"
(
    "id"                BIGINT NOT NULL,
    "status"            tinyint,
    "is_deleted"        int,
    "create_user"       varchar(255),
    "create_dept"       bigint,
    "create_time"       TIMESTAMP(0),
    "update_user"       bigint,
    "update_time"       TIMESTAMP(0),
    "tenant_id"         varchar(12),
    "workstation_id"    bigint,
    "sort"              int,
    "name"              varchar(128),
    "workbench_default" int,
    NOT                 CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_workstation_workbench" IS '工位工作台';
COMMENT
ON COLUMN "blade_workstation_workbench"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_workstation_workbench"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_workstation_workbench"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_workstation_workbench"."id" IS '主键';
COMMENT
ON COLUMN "blade_workstation_workbench"."is_deleted" IS '删除';
COMMENT
ON COLUMN "blade_workstation_workbench"."name" IS '工作台名称';
COMMENT
ON COLUMN "blade_workstation_workbench"."sort" IS '排序';
COMMENT
ON COLUMN "blade_workstation_workbench"."status" IS '状态';
COMMENT
ON COLUMN "blade_workstation_workbench"."tenant_id" IS '租户';
COMMENT
ON COLUMN "blade_workstation_workbench"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_workstation_workbench"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_workstation_workbench"."workstation_id" IS '工位ID';
COMMENT
ON COLUMN "blade_workstation_workbench"."workbench_default" IS '是否为默认工作台';

-- 工装附件
DROP TABLE IF EXISTS "blade_tool_appendix";
CREATE TABLE "blade_tool_appendix"
(
    "id"           BIGINT NOT NULL,
    "tenant_id"    VARCHAR(6),
    "parent_id"    BIGINT,
    "file_length"  BIGINT,
    "file_name"    VARCHAR(255),
    "object_key"   VARCHAR(255),
    "file_link"    VARCHAR(255),
    "content_type" VARCHAR(255),
    "status"       INT,
    "create_dept"  BIGINT,
    "is_deleted"   INT,
    "create_time"  TIMESTAMP(0),
    "create_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "remark"       VARCHAR(255),
    NOT            CLUSTER PRIMARY KEY("id"),
    UNIQUE ("id", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_tool_appendix" IS '附件文件';
COMMENT
ON COLUMN "blade_tool_appendix"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_tool_appendix"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tool_appendix"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tool_appendix"."file_length" IS '文件大小';
COMMENT
ON COLUMN "blade_tool_appendix"."file_link" IS '文件链接';
COMMENT
ON COLUMN "blade_tool_appendix"."content_type" IS '文件mini类型';
COMMENT
ON COLUMN "blade_tool_appendix"."file_name" IS '文件名称';
COMMENT
ON COLUMN "blade_tool_appendix"."object_key" IS '文件key';
COMMENT
ON COLUMN "blade_tool_appendix"."parent_id" IS '父id';
COMMENT
ON COLUMN "blade_tool_appendix"."remark" IS '备注';
COMMENT
ON COLUMN "blade_tool_appendix"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_tool_appendix"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_tool_appendix"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_tool_appendix"."update_user" IS '更新人';

DROP TABLE IF EXISTS "blade_tray_storage";
CREATE TABLE "blade_tray_storage"
(
    "id"                   bigint NOT NULL,
    "tray_id"              bigint,
    "warehouse_station_id" bigint,
    "status"               tinyint DEFAULT 1,
    "is_deleted"           bigint,
    "create_user"          bigint,
    "create_dept"          bigint,
    "create_time"          datetime,
    "update_user"          bigint,
    "update_time"          TIMESTAMP(0),
    NOT                    CLUSTER PRIMARY KEY ("id")
) STORAGE(ON "MAIN", CLUSTERBTR);
COMMENT
ON TABLE "blade_tray_storage" IS '托盘存放';
COMMENT
ON COLUMN "blade_tray_storage"."id" IS '主键';
COMMENT
ON COLUMN "blade_tray_storage"."tray_id" IS '托盘id';
COMMENT
ON COLUMN "blade_tray_storage"."warehouse_station_id" IS '库位id';
COMMENT
ON COLUMN "blade_tray_storage"."status" IS '状态';
COMMENT
ON COLUMN "blade_tray_storage"."is_deleted" IS '删除';
COMMENT
ON COLUMN "blade_tray_storage"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tray_storage"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_tray_storage"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tray_storage"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_tray_storage"."update_time" IS '更新时间';

DROP TABLE IF EXISTS "blade_production_craft_process";
CREATE TABLE "blade_production_craft_process"
(
    "id"                BIGINT NOT NULL,
    "tenant_id"         VARCHAR(6),
    "version_id"        BIGINT,
    "process_id"        BIGINT,
    "sort"              INT,
    "program_name"      VARCHAR(255),
    "standard_time"     INT,
    "prepare_time"      INT DEFAULT 0,
    "disassembly_time"  INT DEFAULT 0,
    "transport_time"    INT DEFAULT 0,
    "source_id"         VARCHAR(50),
    "target_id"         VARCHAR(255),
    "x_coordinate"      VARCHAR(10),
    "y_coordinate"      VARCHAR(10),
    "is_deleted"        DECIMAL(20, 0),
    "create_time"       TIMESTAMP(0),
    "create_user"       BIGINT,
    "update_time"       TIMESTAMP(0),
    "update_user"       BIGINT,
    "create_dept"       BIGINT,
    "status"            INT,
    "process_name"      varchar(32),
    "process_code"      varchar(128),
    "process_desc"      varchar(255),
    "process_type"      int,
    "process_type_name" varchar(32),
    "program_id"        BIGINT,
    "mea_method"        varchar(20),
    "mea_method_value"  int,
    "handler_method"    int,
    "main_sequence_id"  BIGINT,
    "whether_test"      int,
    "whether_parallel"  int,
    "bag_id"            BIGINT,
    "bag_name"          varchar(64),
    "height"            INT,
    NOT                 CLUSTER PRIMARY KEY("id"),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_process" IS '工艺版本的工序流程';
COMMENT
ON COLUMN "blade_production_craft_process"."version_id" IS '所属工艺';
COMMENT
ON COLUMN "blade_production_craft_process"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_production_craft_process"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_production_craft_process"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_production_craft_process"."disassembly_time" IS '拆卸工时';
COMMENT
ON COLUMN "blade_production_craft_process"."id" IS '主键';
COMMENT
ON COLUMN "blade_production_craft_process"."is_deleted" IS '删除标记：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_production_craft_process"."prepare_time" IS '准备工时';
COMMENT
ON COLUMN "blade_production_craft_process"."process_id" IS '所属生产工序';
COMMENT
ON COLUMN "blade_production_craft_process"."program_name" IS '程序名称';
COMMENT
ON COLUMN "blade_production_craft_process"."sort" IS '工序顺序';
COMMENT
ON COLUMN "blade_production_craft_process"."source_id" IS '资源ID';
COMMENT
ON COLUMN "blade_production_craft_process"."standard_time" IS '标准工时（秒）';
COMMENT
ON COLUMN "blade_production_craft_process"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_production_craft_process"."target_id" IS '目标ID';
COMMENT
ON COLUMN "blade_production_craft_process"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_production_craft_process"."transport_time" IS '运输工时';
COMMENT
ON COLUMN "blade_production_craft_process"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_production_craft_process"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_production_craft_process"."x_coordinate" IS 'x坐标';
COMMENT
ON COLUMN "blade_production_craft_process"."y_coordinate" IS 'y坐标';
COMMENT
ON COLUMN "blade_production_craft_process"."process_name" IS '工序名称';
COMMENT
ON COLUMN "blade_production_craft_process"."process_code" IS '工序编号';
COMMENT
ON COLUMN "blade_production_craft_process"."process_name" IS '工序描述';
COMMENT
ON COLUMN "blade_production_craft_process"."process_type" IS '工种';
COMMENT
ON COLUMN "blade_production_craft_process"."process_type_name" IS '工种名称';
COMMENT
ON COLUMN "blade_production_craft_process"."program_id" IS '程序id';
COMMENT
ON COLUMN "blade_production_craft_process"."mea_method" IS '测量方式';
COMMENT
ON COLUMN "blade_production_craft_process"."mea_method_value" IS '测量方式维护的值';
COMMENT
ON COLUMN "blade_production_craft_process"."handler_method" IS '不合格品处理方式';
COMMENT
ON COLUMN "blade_production_craft_process"."main_sequence_id" IS '主序id（当主序id不为空时，代表工序是子序）';
COMMENT
ON COLUMN "blade_production_craft_process"."whether_test" IS '是否质检：默认 0 否 1 是';
COMMENT
ON COLUMN "blade_production_craft_process"."whether_parallel" IS '是否并行：默认 0 否 1 是';
COMMENT
ON COLUMN "blade_production_craft_process"."bag_id" IS '工艺包id';
COMMENT
ON COLUMN "blade_production_craft_process"."bag_name" IS '工艺包名称';
COMMENT
ON COLUMN "blade_production_craft_process"."height" IS '主序的高度';

DROP TABLE IF EXISTS "blade_production_craft_process_file";
CREATE TABLE "blade_production_craft_process_file"
(
    "id"                 BIGINT NOT NULL,
    "version_process_id" BIGINT,
    "file_name"          VARCHAR(100),
    "object_key"         VARCHAR(100),
    "content_type"       VARCHAR(100),
    "link"               VARCHAR(100),
    "file_size"          VARCHAR(100),
    "upload_time"        TIMESTAMP(0),
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_process_file" IS '产品工艺工序文件';
COMMENT
ON COLUMN "blade_production_craft_process_file"."content_type" IS '文件mini类型';
COMMENT
ON COLUMN "blade_production_craft_process_file"."file_name" IS '文件名称';
COMMENT
ON COLUMN "blade_production_craft_process_file"."file_size" IS '文件大小';
COMMENT
ON COLUMN "blade_production_craft_process_file"."link" IS '文件外链';
COMMENT
ON COLUMN "blade_production_craft_process_file"."object_key" IS '文件key';
COMMENT
ON COLUMN "blade_production_craft_process_file"."version_process_id" IS '产品工艺工序ID';
COMMENT
ON COLUMN "blade_production_craft_process_file"."upload_time" IS '上传时间';

DROP TABLE IF EXISTS "blade_production_craft_process_related_fixture";
CREATE TABLE "blade_production_craft_process_related_fixture"
(
    "id"                 BIGINT NOT NULL,
    "fixture_id"         BIGINT,
    "version_process_id" BIGINT,
    "fixture_group_name" varchar(45),
    "fixture_code"       varchar(128),
    "fixture_name"       varchar(32),
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_process_related_fixture" IS '产品工艺工序关联夹具';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."fixture_id" IS '夹具ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."id" IS '主键';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."version_process_id" IS '产品工艺工序ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."fixture_group_name" IS '夹具组名称';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."fixture_code" IS '夹具编号';
COMMENT
ON COLUMN "blade_production_craft_process_related_fixture"."fixture_name" IS '夹具名称';

DROP TABLE IF EXISTS "blade_production_craft_process_related_tool";
CREATE TABLE "blade_production_craft_process_related_tool"
(
    "id"                 BIGINT NOT NULL,
    "tool_id"            BIGINT,
    "version_process_id" BIGINT,
    tool_code            varchar(128),
    tool_name            varchar(64),
    tool_group_name      varchar(45),
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_process_related_tool" IS '产品工艺工序关联刀具';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."id" IS '主键';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."version_process_id" IS '产品工艺工序ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_id" IS '刀具ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_code" IS '刀具编号';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_name" IS '刀具名称';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_group_name" IS '刀具组名称';

DROP TABLE IF EXISTS "blade_production_craft_version";
CREATE TABLE "blade_production_craft_version"
(
    "id"             BIGINT      NOT NULL,
    "tenant_id"      VARCHAR(6),
    "name"           VARCHAR(32) NOT NULL,
    "description"    VARCHAR(255),
    "craft_id"       BIGINT,
    "edition_status" INT DEFAULT 0,
    "status"         INT,
    "create_dept"    BIGINT,
    "is_deleted"     BIGINT,
    "create_time"    TIMESTAMP(0),
    "create_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_version" IS '产品工艺版本';
COMMENT
ON COLUMN "blade_production_craft_version"."create_dept" IS '创建单位';
COMMENT
ON COLUMN "blade_production_craft_version"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_production_craft_version"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_production_craft_version"."description" IS '版本描述';
COMMENT
ON COLUMN "blade_production_craft_version"."edition_status" IS '是否定版(0:否 1:是)';
COMMENT
ON COLUMN "blade_production_craft_version"."name" IS '版本名称';
COMMENT
ON COLUMN "blade_production_craft_version"."craft_id" IS '产品ID';
COMMENT
ON COLUMN "blade_production_craft_version"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_production_craft_version"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_production_craft_version"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_production_craft_version"."update_user" IS '更新人';

-- 物料存放
DROP TABLE IF EXISTS "blade_material_storage";
CREATE TABLE "blade_material_storage"
(
    "id"                   BIGINT NOT NULL,
    "material_id"          BIGINT,
    "warehouse_station_id" BIGINT,
    "status"               TINYINT DEFAULT 1,
    "is_deleted"           DECIMAL(20, 0),
    "create_user"          BIGINT,
    "create_dept"          BIGINT,
    "create_time"          TIMESTAMP(0),
    "update_user"          BIGINT,
    "update_time"          TIMESTAMP(0),
    NOT                    CLUSTER PRIMARY KEY ("ID"),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_material_storage" IS '物料存放';
COMMENT
ON COLUMN "blade_material_storage"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_material_storage"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_material_storage"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_material_storage"."is_deleted" IS '删除标记：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_material_storage"."material_id" IS '物料id';
COMMENT
ON COLUMN "blade_material_storage"."status" IS '业务状态 1激活 0 冻结';
COMMENT
ON COLUMN "blade_material_storage"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_material_storage"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_material_storage"."warehouse_station_id" IS '库位id';

DROP TABLE IF EXISTS "blade_bom_material";
CREATE TABLE "blade_bom_material"
(
    "id"          BIGINT NOT NULL,
    "status"      INT,
    "is_deleted"  DECIMAL(20, 0) DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "tenant_id"   VARCHAR(12),
    "version_id"  BIGINT,
    "material_id" BIGINT,
    "parent_id"   BIGINT,
    "all_path"    VARCHAR(255),
    "remark"      VARCHAR(255),
    NOT           CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_bom_material" IS 'bom物料';
COMMENT
ON COLUMN "blade_bom_material"."all_path" IS 'allPath';
COMMENT
ON COLUMN "blade_bom_material"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_bom_material"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_bom_material"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_bom_material"."id" IS '主键';
COMMENT
ON COLUMN "blade_bom_material"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_bom_material"."material_id" IS '物料id';
COMMENT
ON COLUMN "blade_bom_material"."parent_id" IS '父级Id';
COMMENT
ON COLUMN "blade_bom_material"."remark" IS '备注';
COMMENT
ON COLUMN "blade_bom_material"."status" IS '状态';
COMMENT
ON COLUMN "blade_bom_material"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_bom_material"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_bom_material"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_bom_material"."version_id" IS 'bom版本id';

DROP TABLE IF EXISTS "blade_bom_process";
CREATE TABLE "blade_bom_process"
(
    "id"              BIGINT NOT NULL,
    "status"          INT,
    "is_deleted"      DECIMAL(20, 0) DEFAULT 0,
    "create_user"     BIGINT,
    "create_dept"     BIGINT,
    "create_time"     TIMESTAMP(0),
    "update_user"     BIGINT,
    "update_time"     TIMESTAMP(0),
    "tenant_id"       VARCHAR(12),
    "bom_material_id" BIGINT,
    "molecule"        INT,
    "denominator"     INT,
    "process_id"      BIGINT,
    "loss"            DEC(10, 2),
    NOT               CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_bom_process" IS 'bom物料工序';
COMMENT
ON COLUMN "blade_bom_process"."bom_material_id" IS 'bom物料Id';
COMMENT
ON COLUMN "blade_bom_process"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_bom_process"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_bom_process"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_bom_process"."denominator" IS '用量分母';
COMMENT
ON COLUMN "blade_bom_process"."id" IS '主键';
COMMENT
ON COLUMN "blade_bom_process"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_bom_process"."loss" IS '固定损耗';
COMMENT
ON COLUMN "blade_bom_process"."molecule" IS '用量分子';
COMMENT
ON COLUMN "blade_bom_process"."process_id" IS '用料工序id';
COMMENT
ON COLUMN "blade_bom_process"."status" IS '状态';
COMMENT
ON COLUMN "blade_bom_process"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_bom_process"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_bom_process"."update_user" IS '更新人';

DROP TABLE IF EXISTS "blade_bom_version";
CREATE TABLE "blade_bom_version"
(
    "id"             BIGINT NOT NULL,
    "status"         INT,
    "is_deleted"     DECIMAL(20, 0) DEFAULT 0,
    "create_user"    BIGINT,
    "create_dept"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "tenant_id"      VARCHAR(12),
    "product_id"     BIGINT,
    "version"        VARCHAR(32),
    "version_status" INT            DEFAULT 0,
    "craft_id"       BIGINT,
    "craft_version"  VARCHAR(32),
    "remark"         VARCHAR(255),
    "description"    VARCHAR(255),
    NOT              CLUSTER PRIMARY KEY("id"),
    CHECK ("status" >= 0),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_bom_version" IS 'bom版本';
COMMENT
ON COLUMN "blade_bom_version"."craft_id" IS '工艺版本id';
COMMENT
ON COLUMN "blade_bom_version"."craft_version" IS '工艺版本';
COMMENT
ON COLUMN "blade_bom_version"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_bom_version"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_bom_version"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_bom_version"."description" IS '版本描述';
COMMENT
ON COLUMN "blade_bom_version"."id" IS '主键';
COMMENT
ON COLUMN "blade_bom_version"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_bom_version"."product_id" IS '产品id';
COMMENT
ON COLUMN "blade_bom_version"."remark" IS '备注';
COMMENT
ON COLUMN "blade_bom_version"."status" IS '状态';
COMMENT
ON COLUMN "blade_bom_version"."tenant_id" IS '所属租户';
COMMENT
ON COLUMN "blade_bom_version"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_bom_version"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_bom_version"."version" IS '版本';
COMMENT
ON COLUMN "blade_bom_version"."version_status" IS '版本状态(0：未定版，1：已定版)';

-- 工艺路线
DROP TABLE IF EXISTS "BLADE_CRAFT_ROUTING";
CREATE TABLE "BLADE_CRAFT_ROUTING"
(
    "ID"          BIGINT NOT NULL,
    "STATUS"      INT DEFAULT 1,
    "IS_DELETED"  INT,
    "CREATE_USER" BIGINT,
    "CREATE_DEPT" BIGINT,
    "CREATE_TIME" TIMESTAMP(0),
    "UPDATE_USER" BIGINT,
    "UPDATE_TIME" TIMESTAMP(0),
    "TENANT_ID"   VARCHAR(64),
    "NAME"        VARCHAR(64),
    "DESCRIPTION" VARCHAR(255),
    "PRODUCT_ID"  BIGINT,
    NOT           CLUSTER PRIMARY KEY ("ID"),
    CONSTRAINT "uniqueCraftIndex" UNIQUE ("NAME", "IS_DELETED")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_CRAFT_ROUTING" IS '工艺路线';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."STATUS" IS '状态: 1为启动，0为停用';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."NAME" IS '名称';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."DESCRIPTION" IS '描述';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."TENANT_ID" IS '所属租户';
COMMENT
ON COLUMN "BLADE_CRAFT_ROUTING"."PRODUCT_ID" IS '产品id';

-- 工艺路线版本产线表
DROP TABLE IF EXISTS "BLADE_CRAFT_VERSION_LINE";
CREATE TABLE "BLADE_CRAFT_VERSION_LINE"
(
    "ID"          BIGINT NOT NULL,
    "STATUS"      INT DEFAULT 1,
    "IS_DELETED"  INT,
    "CREATE_USER" BIGINT,
    "CREATE_DEPT" BIGINT,
    "CREATE_TIME" TIMESTAMP(0),
    "UPDATE_USER" BIGINT,
    "UPDATE_TIME" TIMESTAMP(0),
    "TENANT_ID"   VARCHAR(64),
    "CRAFT_ID"    BIGINT,
    "VERSION_ID"  BIGINT,
    "GROUP_ID"    BIGINT,
    NOT           CLUSTER PRIMARY KEY ("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);
COMMENT
ON TABLE "BLADE_CRAFT_VERSION_LINE" IS '工艺路线版本产线表';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."STATUS" IS '状态: 1为启动，0为停用';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."CRAFT_ID" IS '工艺路线id';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."VERSION_ID" IS '工艺路线版本id';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."TENANT_ID" IS '所属租户';
COMMENT
ON COLUMN "BLADE_CRAFT_VERSION_LINE"."GROUP_ID" IS '产线id';



-- 菜单脚本
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_TOOL_CATEGORY";
CREATE TABLE "BLADE_TOOL_CATEGORY"
(
    "ID"               BIGINT NOT NULL,
    "STATUS"           INT,
    "IS_DELETED"       BIGINT      DEFAULT 0,
    "CREATE_USER"      BIGINT,
    "CREATE_DEPT"      BIGINT,
    "CREATE_TIME"      TIMESTAMP(0),
    "UPDATE_USER"      BIGINT,
    "UPDATE_TIME"      TIMESTAMP(0),
    "TENANT_ID"        VARCHAR(12) DEFAULT '000000',
    "PARENT_ID"        BIGINT      DEFAULT 0,
    "NAME"             VARCHAR(45),
    "SORT"             INT,
    "TOOL_PREFIX_CODE" VARCHAR(45),
    "CODE_LENGTH"      VARCHAR(45),
    NOT                CLUSTER PRIMARY KEY("ID"),
    CHECK ("STATUS" >= 0),
    CHECK ("IS_DELETED" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_TOOL_CATEGORY" IS '刀具类型';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."CODE_LENGTH" IS '编码长度';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."IS_DELETED" IS '删除状态：0-未删除';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."NAME" IS '组名';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."PARENT_ID" IS '父主键';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."SORT" IS '顺序';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."STATUS" IS '状态';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."TOOL_PREFIX_CODE" IS '编码规则前缀';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_TOOL_CATEGORY"."UPDATE_USER" IS '更新人';

DROP TABLE IF EXISTS "BLADE_TOOL_MODEL";
CREATE TABLE "BLADE_TOOL_MODEL"
(
    "ID"                BIGINT NOT NULL,
    "STATUS"            INT,
    "IS_DELETED"        BIGINT      DEFAULT 0,
    "CREATE_USER"       BIGINT,
    "CREATE_DEPT"       BIGINT,
    "CREATE_TIME"       TIMESTAMP(0),
    "UPDATE_USER"       BIGINT,
    "UPDATE_TIME"       TIMESTAMP(0),
    "TENANT_ID"         VARCHAR(12) DEFAULT '000000',
    "TOOL_CATEGORY_ID"  BIGINT,
    "TOOL_CATEGORY"     VARCHAR(45),
    "TOOL_PREFIX_CODE"  VARCHAR(45),
    "LIFE_COUNT_METHOD" INT,
    "INITIAL_LIFE"      INT,
    "WARNING_VALUE"     INT,
    "PARAMETER1"        VARCHAR(255),
    "PARAMETER2"        VARCHAR(255),
    "PARAMETER3"        VARCHAR(255),
    "PARAMETER4"        VARCHAR(255),
    "PARAMETER5"        VARCHAR(255),
    "PARAMETER6"        VARCHAR(255),
    "PARAMETER7"        VARCHAR(255),
    "PARAMETER8"        VARCHAR(255),
    "PARAMETER9"        VARCHAR(255),
    "PARAMETER10"       VARCHAR(255),
    "MODEL"             VARCHAR(255),
    NOT                 CLUSTER PRIMARY KEY("ID"),
    CHECK ("STATUS" >= 0),
    CHECK ("IS_DELETED" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_TOOL_MODEL" IS '刀具型号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."INITIAL_LIFE" IS '初始寿命';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."IS_DELETED" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."LIFE_COUNT_METHOD" IS '寿命计数方式(1.按次数 2.按时间)';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."MODEL" IS '刀具型号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER1" IS '参数1';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER10" IS '参数10';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER2" IS '参数2';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER3" IS '参数3';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER4" IS '参数4';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER5" IS '参数5';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER6" IS '参数6';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER7" IS '参数7';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER8" IS '参数8';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER9" IS '参数9';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."STATUS" IS '状态';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TOOL_CATEGORY" IS '刀具类型';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TOOL_CATEGORY_ID" IS '刀具类型id';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TOOL_PREFIX_CODE" IS '刀具前缀编号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."WARNING_VALUE" IS '预警值';

DROP TABLE IF EXISTS "blade_production_craft_process_related_tool";
CREATE TABLE "blade_production_craft_process_related_tool"
(
    "id"                 BIGINT NOT NULL,
    "tool_id"            BIGINT,
    "version_process_id" BIGINT,
    "tool_code"          varchar(128),
    "tool_model_name"    varchar(64),
    "tool_category_name" varchar(45),
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_production_craft_process_related_tool" IS '产品工艺工序关联刀具';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."id" IS '主键';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."version_process_id" IS '产品工艺工序ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_id" IS '刀具ID';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_code" IS '刀具编号';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_model_name" IS '刀具型号名称';
COMMENT
ON COLUMN "blade_production_craft_process_related_tool"."tool_category_name" IS '刀具类型名称';

DROP TABLE IF EXISTS "blade_fms_order_process_tool";
create table "blade_fms_order_process_tool"
(
    "id"                 bigint not null,
    "order_process_id"   bigint,
    "tool_id"            varchar(255),
    "tool_code"          varchar(255),
    "tool_model_name"    varchar(255),
    "tool_category_name" varchar(255),
    "tenant_id"          varchar(12),
    "create_user"        bigint,
    "create_time"        timestamp(0),
    "update_user"        bigint,
    "update_time"        timestamp(0),
    "remark"             varchar(255),
    "status"             int,
    "is_deleted"         bigint,
    "create_dept"        bigint,
    not                  cluster primary key("id")
) storage(on "main", clusterbtr);

comment
on column "blade_fms_order_process_tool"."create_time" is '创建时间';
comment
on column "blade_fms_order_process_tool"."create_user" is '创建人';
comment
on column "blade_fms_order_process_tool"."id" is '主键';
comment
on column "blade_fms_order_process_tool"."is_deleted" is '1	删除标识';
comment
on column "blade_fms_order_process_tool"."order_process_id" is '工单工序id';
comment
on column "blade_fms_order_process_tool"."remark" is '备注';
comment
on column "blade_fms_order_process_tool"."status" is '记录状态';
comment
on column "blade_fms_order_process_tool"."tenant_id" is '租户id';
comment
on column "blade_fms_order_process_tool"."tool_code" is '刀具编号';
comment
on column "blade_fms_order_process_tool"."tool_category_name" is '刀具类型名称';
comment
on column "blade_fms_order_process_tool"."tool_id" is '刀具id';
comment
on column "blade_fms_order_process_tool"."tool_model_name" is '刀具型号名称';
comment
on column "blade_fms_order_process_tool"."update_time" is '更新时间';
comment
on column "blade_fms_order_process_tool"."update_user" is '更新人';

CREATE TABLE "BLADE_TOOL_MODEL"
(
    "ID"                BIGINT IDENTITY(1568168501910892547, 1) NOT NULL,
    "STATUS"            INT,
    "IS_DELETED"        BIGINT      DEFAULT 0,
    "CREATE_USER"       BIGINT,
    "CREATE_DEPT"       BIGINT,
    "CREATE_TIME"       TIMESTAMP(0),
    "UPDATE_USER"       BIGINT,
    "UPDATE_TIME"       TIMESTAMP(0),
    "TENANT_ID"         VARCHAR(12) DEFAULT '000000',
    "TOOL_CATEGORY_ID"  BIGINT,
    "TOOL_PREFIX_CODE"  VARCHAR(45),
    "LIFE_COUNT_METHOD" INT,
    "INITIAL_LIFE"      INT,
    "WARNING_VALUE"     INT,
    "PARAMETER1"        VARCHAR(255),
    "PARAMETER2"        VARCHAR(255),
    "PARAMETER3"        VARCHAR(255),
    "PARAMETER4"        VARCHAR(255),
    "PARAMETER5"        VARCHAR(255),
    "PARAMETER6"        VARCHAR(255),
    "PARAMETER7"        VARCHAR(255),
    "PARAMETER8"        VARCHAR(255),
    "PARAMETER9"        VARCHAR(255),
    "PARAMETER10"       VARCHAR(255),
    "MODEL"             VARCHAR(255),
    NOT                 CLUSTER PRIMARY KEY("ID"),
    CHECK ("STATUS" >= 0),
    CHECK ("IS_DELETED" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_TOOL_MODEL" IS '刀具型号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."INITIAL_LIFE" IS '初始寿命';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."IS_DELETED" IS '删除状态：0-未删除，1-已删除';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."LIFE_COUNT_METHOD" IS '寿命计数方式(1.按次数 2.按时间)';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."MODEL" IS '刀具型号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER1" IS '参数1';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER10" IS '参数10';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER2" IS '参数2';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER3" IS '参数3';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER4" IS '参数4';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER5" IS '参数5';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER6" IS '参数6';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER7" IS '参数7';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER8" IS '参数8';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."PARAMETER9" IS '参数9';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."STATUS" IS '状态';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TOOL_CATEGORY_ID" IS '刀具类型id';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."TOOL_PREFIX_CODE" IS '刀具前缀编号';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_TOOL_MODEL"."WARNING_VALUE" IS '预警值';

DROP TABLE IF EXISTS "blade_dnc_art_bag";
CREATE TABLE "blade_dnc_art_bag"
(
    "id"           BIGINT NOT NULL,
    "remark"       VARCHAR(255),
    "create_user"  BIGINT,
    "create_dept"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "status"       INT,
    "is_deleted"   INT,
    "tenant_id"    VARCHAR(10) DEFAULT '000000',
    "name"         VARCHAR(64),
    "code"         VARCHAR(64),
    "catalogue_id" BIGINT,
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_dnc_art_bag"."catalogue_id" IS '工艺目录id';
COMMENT
ON COLUMN "blade_dnc_art_bag"."code" IS '工艺包编码';
COMMENT
ON COLUMN "blade_dnc_art_bag"."name" IS '工艺包名称';
COMMENT
ON COLUMN "blade_dnc_art_bag"."remark" IS '备注';

DROP TABLE IF EXISTS "blade_dnc_art_file";
CREATE TABLE "blade_dnc_art_file"
(
    "id"                 BIGINT NOT NULL,
    "remark"             VARCHAR(255),
    "create_user"        BIGINT,
    "create_dept"        BIGINT,
    "create_time"        TIMESTAMP(0),
    "update_user"        BIGINT,
    "update_time"        TIMESTAMP(0),
    "status"             INT,
    "is_deleted"         INT,
    "tenant_id"          VARCHAR(10) DEFAULT '000000',
    "file_id"            BIGINT,
    "art_bag_id"         BIGINT,
    "source_type"        INT,
    "file_type"          INT,
    "original_filename"  VARCHAR(100),
    "filename"           VARCHAR(100),
    "content_length"     BIGINT,
    "content_md5"        VARCHAR(100),
    "content_type"       VARCHAR(100),
    "object_key"         VARCHAR(100),
    "suffix"             VARCHAR(50),
    "document_ownership" INT,
    "is_current"         INT,
    "link"               VARCHAR(500),
    "storage_space"      INT,
    "version"            INT,
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_art_file" IS '工艺包文件';
COMMENT
ON COLUMN "blade_dnc_art_file"."art_bag_id" IS '工艺包id';
COMMENT
ON COLUMN "blade_dnc_art_file"."content_md5" IS '文件md5值';
COMMENT
ON COLUMN "blade_dnc_art_file"."content_type" IS '文件类型';
COMMENT
ON COLUMN "blade_dnc_art_file"."document_ownership" IS '文件归属：1 工位  2 工厂';
COMMENT
ON COLUMN "blade_dnc_art_file"."file_id" IS '文件id';
COMMENT
ON COLUMN "blade_dnc_art_file"."file_type" IS '文件类别(1:程序,2 文档)';
COMMENT
ON COLUMN "blade_dnc_art_file"."filename" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_art_file"."is_current" IS '是否为当前版本,1是0否';
COMMENT
ON COLUMN "blade_dnc_art_file"."link" IS '文件链接';
COMMENT
ON COLUMN "blade_dnc_art_file"."object_key" IS '文件的objectKey';
COMMENT
ON COLUMN "blade_dnc_art_file"."original_filename" IS '原始文件名称';
COMMENT
ON COLUMN "blade_dnc_art_file"."remark" IS '备注';
COMMENT
ON COLUMN "blade_dnc_art_file"."source_type" IS '文件来源 1 我的文档  2 工位文件 3 本地上传 4 归档文件';
COMMENT
ON COLUMN "blade_dnc_art_file"."storage_space" IS '存储位置：1 常规空间  2 固定空间';
COMMENT
ON COLUMN "blade_dnc_art_file"."suffix" IS '文件后缀';
COMMENT
ON COLUMN "blade_dnc_art_file"."version" IS '文件版本';

CREATE TABLE "BLADE_EMPLOYEE_ON_OFF_WORK"
(
    "ID"                  BIGINT NOT NULL,
    "ONLINE_TIME"         TIMESTAMP(0),
    "ON_EMPLOYEE_ID"      BIGINT,
    "ON_EMPLOYEE_CODE"    VARCHAR(128),
    "ON_EMPLOYEE_NAME"    VARCHAR(32),
    "ON_EMPLOYEE_AVATAR"  VARCHAR(1000),
    "WORKSTATION_ID"      BIGINT,
    "WORKSTATION_CODE"    VARCHAR(128),
    "WORKSTATION_NAME"    VARCHAR(32),
    "WORKSTATION_AVATAR"  VARCHAR(1000),
    "OFFLINE_TIME"        TIMESTAMP(0),
    "OFF_EMPLOYEE_ID"     BIGINT,
    "OFF_EMPLOYEE_CODE"   VARCHAR(128),
    "OFF_EMPLOYEE_NAME"   VARCHAR(32),
    "OFF_EMPLOYEE_AVATAR" VARCHAR(1000),
    "ONLINE_TYPE"         TINYINT DEFAULT 0,
    "TIME_TYPE"           TINYINT DEFAULT 0,
    "STATUS"              TINYINT DEFAULT 1,
    "IS_DELETED"          DECIMAL(20, 0),
    "CREATE_USER"         BIGINT,
    "CREATE_DEPT"         BIGINT,
    "CREATE_TIME"         TIMESTAMP(0),
    "UPDATE_USER"         BIGINT,
    "UPDATE_TIME"         TIMESTAMP(0),
    NOT                   CLUSTER PRIMARY KEY("ID"),
    CHECK ("IS_DELETED" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "BLADE_EMPLOYEE_ON_OFF_WORK" IS '员工上下线表';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."CREATE_DEPT" IS '创建部门';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."IS_DELETED" IS '删除标记：0-未删除，1-已删除';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."OFF_EMPLOYEE_AVATAR" IS '下线员工头像';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."OFF_EMPLOYEE_CODE" IS '下线员工编号';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."OFF_EMPLOYEE_ID" IS '下线员工id';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."OFF_EMPLOYEE_NAME" IS '下线员工名称';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."OFFLINE_TIME" IS '下线时间';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ON_EMPLOYEE_AVATAR" IS '上线员工头像';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ON_EMPLOYEE_CODE" IS '上线员工编号';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ON_EMPLOYEE_ID" IS '上线员工id';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ON_EMPLOYEE_NAME" IS '上线员工名称';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ONLINE_TIME" IS '上线时间';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."ONLINE_TYPE" IS '上下线类型 0-上线 1-下线';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."STATUS" IS '业务状态 1激活 0 冻结';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."TIME_TYPE" IS '按时间/班次上下线 0-时间 1-班次';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."WORKSTATION_AVATAR" IS '工位名称头像';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."WORKSTATION_CODE" IS '工位编号';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."WORKSTATION_ID" IS '工位id';
COMMENT
ON COLUMN "BLADE_EMPLOYEE_ON_OFF_WORK"."WORKSTATION_NAME" IS '工位名称';


DROP TABLE IF EXISTS "blade_dnc_process_catalogue";
CREATE TABLE "blade_dnc_process_catalogue"
(
    "id"          BIGINT NOT NULL,
    "tenant_id"   VARCHAR(12) DEFAULT '000000',
    "parent_id"   BIGINT      DEFAULT 0,
    "name"        VARCHAR(64),
    "all_path"    VARCHAR(500),
    "is_deleted"  INT,
    "status"      INT,
    "create_time" TIMESTAMP(0),
    "create_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "create_dept" BIGINT,
    "dept_id"     BIGINT,
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_process_catalogue" IS '工艺目录表';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."all_path" IS '全路径(包含自身)';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."dept_id" IS '职权域id';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."id" IS '主键';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."name" IS '工艺目录名称';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."status" IS '状态';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_process_catalogue"."update_user" IS '更新人';


-- 数据标签关系表
ALTER TABLE blade_workstation_wcs
    ADD COLUMN usage_id bigint;
comment
on column blade_workstation_wcs.usage_id is '数据标签ID';
-- 增加数据标签关系表
CREATE TABLE "blade_workstation_wcs_usage"
(
    "id"           BIGINT NOT NULL,
    "collect_type" tinyint,
    "usage_name"   varchar(255),
    "usage_code"   varchar(50),
    "parameter"    varchar(255),
    "create_time"  timestamp,
    "create_user"  bigint,
    "update_time"  timestamp,
    "update_user"  bigint,
    CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_workstation_wcs_usage"."id" IS '主键';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."collect_type" IS '计算方法';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."usage_name" IS '数据标签名称';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."usage_code" IS '数据标签编号';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."parameter" IS '执行参数';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_workstation_wcs_usage"."update_user" IS '更新人';

-- 增加数据标签初始化数据
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 not null,
    "tenant_id"               varchar(6),
    "tray_code"               varchar(128),
    "fixture_id"              bigint,
    "current_position"        varchar(128),
    "current_station"         varchar(128),
    "current_type"            int,
    "target_position"         varchar(128),
    "target_station"          varchar(128),
    "tray_state"              int,
    "sche_state"              int,
    "arrive_time"             timestamp(0),
    "status"                  int,
    "order_id"                bigint,
    "order_code"              varchar(128),
    "order_process_id"        bigint,
    "process_code"            varchar(128),
    "program_no"              varchar(128),
    "program_offset"          varchar(128),
    "will_order_id"           bigint,
    "will_order_code"         varchar(128),
    "will_order_process_id"   bigint,
    "will_process_code"       varchar(128),
    "will_program_no"         varchar(128),
    "will_program_offset"     varchar(128),
    "part_type"               tinyint,
    "part_type_time"          timestamp(0),
    "components_number"       bigint,
    "last_load_complete_time" timestamp(0),
    "last_cnc_complete_time"  timestamp(0),
    "is_deleted"              bigint,
    "create_time"             timestamp(0),
    "create_user"             bigint,
    "update_time"             timestamp(0),
    "update_user"             bigint,
    "create_dept"             bigint,
    "is_first_empty_return"   int,
    not cluster primary key ("id"),
    check ("is_deleted" >= 0)
) storage(on "main", clusterbtr);

comment
on table "blade_fms_real_time_tray" is '托盘实时数据';
comment
on column "blade_fms_real_time_tray"."arrive_time" is '到达时间 异常不更新';
comment
on column "blade_fms_real_time_tray"."components_number" is '当前工件号';
comment
on column "blade_fms_real_time_tray"."create_dept" is '创建部门';
comment
on column "blade_fms_real_time_tray"."create_time" is '创建时间';
comment
on column "blade_fms_real_time_tray"."create_user" is '创建人';
comment
on column "blade_fms_real_time_tray"."current_position" is '当前位置';
comment
on column "blade_fms_real_time_tray"."current_station" is '当前工作台 1,2';
comment
on column "blade_fms_real_time_tray"."current_type" is '当前位置类型 1-库位 2-设备';
comment
on column "blade_fms_real_time_tray"."fixture_id" is '夹具id';
comment
on column "blade_fms_real_time_tray"."is_deleted" is '删除标记：0-未删除，1-已删除';
comment
on column "blade_fms_real_time_tray"."last_cnc_complete_time" is '上一次加工完成时间';
comment
on column "blade_fms_real_time_tray"."last_load_complete_time" is '上一次装料完成时间';
comment
on column "blade_fms_real_time_tray"."order_code" is '工单号';
comment
on column "blade_fms_real_time_tray"."order_id" is '工单id';
comment
on column "blade_fms_real_time_tray"."order_process_id" is '工单工序id';
comment
on column "blade_fms_real_time_tray"."part_type" is '产品状态 1-待加工,2-加工中,3-加工完成,4-半成品,5-不合格品';
comment
on column "blade_fms_real_time_tray"."part_type_time" is '状态改变时间';
comment
on column "blade_fms_real_time_tray"."process_code" is '工序号';
comment
on column "blade_fms_real_time_tray"."program_no" is '程序号';
comment
on column "blade_fms_real_time_tray"."program_offset" is '程序偏移';
comment
on column "blade_fms_real_time_tray"."sche_state" is '调度状态 1-将要去;2-到达';
comment
on column "blade_fms_real_time_tray"."status" is '业务状态';
comment
on column "blade_fms_real_time_tray"."target_position" is '目标位置';
comment
on column "blade_fms_real_time_tray"."target_station" is '目标工作台 1,2';
comment
on column "blade_fms_real_time_tray"."tenant_id" is '所属租户';
comment
on column "blade_fms_real_time_tray"."tray_code" is '托盘号';
comment
on column "blade_fms_real_time_tray"."tray_state" is '1-满托;2-空托';
comment
on column "blade_fms_real_time_tray"."update_time" is '更新时间';
comment
on column "blade_fms_real_time_tray"."update_user" is '更新人';
comment
on column "blade_fms_real_time_tray"."will_order_code" is '将要去的工单';
comment
on column "blade_fms_real_time_tray"."will_order_id" is '将要去的工单id';
comment
on column "blade_fms_real_time_tray"."will_order_process_id" is '将要去的工单工序id';
comment
on column "blade_fms_real_time_tray"."will_process_code" is '将要去的工序';
comment
on column "blade_fms_real_time_tray"."will_program_no" is '将要去的程序号';
comment
on column "blade_fms_real_time_tray"."will_program_offset" is '将要去的程序偏移';
comment
on column "blade_fms_real_time_tray"."is_first_empty_return" is '是否首序空托返回';

CREATE TABLE "blade_andon_record"
(
    "id" BIGINT NOT NULL,
    "status" TINYINT,
    "is_deleted" INT DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "type_id" BIGINT,
    "type_code" VARCHAR(64),
    "type_name" VARCHAR(64),
    "reason_id" BIGINT,
    "reason_code" VARCHAR(64),
    "reason_name" VARCHAR(64),
    "workstation_id" BIGINT,
    "workstation_name" VARCHAR(64),
    "workstation_code" VARCHAR(64),
    "call_emp_id" BIGINT,
    "call_emp_code" VARCHAR(64),
    "call_emp_name" VARCHAR(64),
    "hand_emp_id" BIGINT,
    "hand_emp_code" VARCHAR(64),
    "hand_emp_name" VARCHAR(64),
    "complete_emp_id" BIGINT,
    "complete_emp_code" VARCHAR(64),
    "complete_emp_name" VARCHAR(64),
    "call_time" TIMESTAMP(0),
    "response_time" TIMESTAMP(0),
    "end_time" TIMESTAMP(0),
    "remark" VARCHAR(140),
    "cur_status" TINYINT DEFAULT 0,
    "shift_index" INT,
    "index_name" VARCHAR(32),
    NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "blade_andon_record" IS '安灯原因表';
COMMENT ON COLUMN "blade_andon_record"."call_emp_code" IS '呼叫人员编号';
COMMENT ON COLUMN "blade_andon_record"."call_emp_id" IS '呼叫人员id';
COMMENT ON COLUMN "blade_andon_record"."call_emp_name" IS '呼叫人员名称';
COMMENT ON COLUMN "blade_andon_record"."call_time" IS '呼叫时间(开始时间)';
COMMENT ON COLUMN "blade_andon_record"."complete_emp_code" IS '完成人员编号';
COMMENT ON COLUMN "blade_andon_record"."complete_emp_id" IS '完成人员id';
COMMENT ON COLUMN "blade_andon_record"."complete_emp_name" IS '完成人员名称';
COMMENT ON COLUMN "blade_andon_record"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_andon_record"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_andon_record"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_andon_record"."cur_status" IS '当前状态 0-当前无状态 1-已发起，待接收 2-已接收，待完成 3-完成';
COMMENT ON COLUMN "blade_andon_record"."end_time" IS '结束时间';
COMMENT ON COLUMN "blade_andon_record"."hand_emp_code" IS '处理人员编号';
COMMENT ON COLUMN "blade_andon_record"."hand_emp_id" IS '处理人员id';
COMMENT ON COLUMN "blade_andon_record"."hand_emp_name" IS '处理人员名称';
COMMENT ON COLUMN "blade_andon_record"."id" IS '主键';
COMMENT ON COLUMN "blade_andon_record"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT ON COLUMN "blade_andon_record"."reason_code" IS '安灯原因编号';
COMMENT ON COLUMN "blade_andon_record"."reason_id" IS '安灯原因id';
COMMENT ON COLUMN "blade_andon_record"."reason_name" IS '安灯原因名称';
COMMENT ON COLUMN "blade_andon_record"."remark" IS '备注';
COMMENT ON COLUMN "blade_andon_record"."response_time" IS '响应时间';
COMMENT ON COLUMN "blade_andon_record"."status" IS '状态';
COMMENT ON COLUMN "blade_andon_record"."type_code" IS '安灯类型编号';
COMMENT ON COLUMN "blade_andon_record"."type_id" IS '安灯类型id';
COMMENT ON COLUMN "blade_andon_record"."type_name" IS '安灯类型名称';
COMMENT ON COLUMN "blade_andon_record"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_andon_record"."update_user" IS '更新人';
COMMENT ON COLUMN "blade_andon_record"."workstation_code" IS '工位编号';
COMMENT ON COLUMN "blade_andon_record"."workstation_id" IS '工位id';
COMMENT ON COLUMN "blade_andon_record"."workstation_name" IS '工位名称';
COMMENT ON COLUMN "blade_andon_record"."shift_index" IS '所在班次';
COMMENT ON COLUMN "blade_andon_record"."index_name" IS '班次名称';


CREATE UNIQUE  INDEX "INDEX1444295229700" ON "blade_andon_record"("id" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

CREATE TABLE "blade_device_andon_type"
(
    "id" BIGINT NOT NULL,
    "status" TINYINT,
    "is_deleted" INT DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "andon_type_id" BIGINT,
    "device_type_id" BIGINT,
    NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "blade_device_andon_type" IS '机器类型安灯类型关联表';
COMMENT ON COLUMN "blade_device_andon_type"."andon_type_id" IS '安灯类型id';
COMMENT ON COLUMN "blade_device_andon_type"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_device_andon_type"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_device_andon_type"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_device_andon_type"."device_type_id" IS '机器类型id';
COMMENT ON COLUMN "blade_device_andon_type"."id" IS '主键';
COMMENT ON COLUMN "blade_device_andon_type"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT ON COLUMN "blade_device_andon_type"."status" IS '状态';
COMMENT ON COLUMN "blade_device_andon_type"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_device_andon_type"."update_user" IS '更新人';


CREATE UNIQUE  INDEX "INDEX1444232099900" ON "blade_device_andon_type"("id" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;
