DROP TABLE IF EXISTS "blade_dnc_archive_directory";
CREATE TABLE "blade_dnc_archive_directory"
(
    "id"          BIGINT NOT NULL,
    "tenant_id"   VARCHAR(12) DEFAULT '000000',
    "parent_id"   BIGINT      DEFAULT 0,
    "name"        VARCHAR(45),
    "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_archive_directory" IS 'dnc 归档目录';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."all_path" IS '全路径(包含自身)';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."dept_id" IS '职权域id';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."id" IS '主键';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."name" IS '工艺目录名称';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."status" IS '状态';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_archive_directory"."update_user" IS '更新人';


DROP TABLE IF EXISTS "blade_dnc_archive_directory_file";
CREATE TABLE "blade_dnc_archive_directory_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',
    "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),
    "is_current"              INT,
    "link"                    VARCHAR(500),
    "business_identification" VARCHAR(50),
    "workstation_file_id"     BIGINT,
    "workstation_id"          BIGINT,
    "archive_directory_id"    BIGINT,
    "version"                 INT,
    NOT                       CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_archive_directory_file" IS '归档目录文件';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."archive_directory_id" IS '归档目录id';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."business_identification" IS '业务标识';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."content_md5" IS '文件md5值';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."content_type" IS '文件类型';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."filename" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."is_current" IS '是否为当前版本,1是0否';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."link" IS '文件链接';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."object_key" IS '文件的objectKey';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."original_filename" IS '原始文件名称';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."remark" IS '备注';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."suffix" IS '文件后缀';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."workstation_file_id" IS '工位文件id';
COMMENT
ON COLUMN "blade_dnc_archive_directory_file"."workstation_id" IS '工位id';


DROP TABLE IF EXISTS "blade_dnc_art_bag_log";
CREATE TABLE "blade_dnc_art_bag_log"
(
    "id"             BIGINT NOT NULL,
    "file_id"        BIGINT,
    "file_name"      VARCHAR(255),
    "object_key"     VARCHAR(255),
    "suffix"         VARCHAR(100),
    "operator_id"    BIGINT,
    "operator_name"  VARCHAR(255),
    "operation_time" TIMESTAMP(0),
    "source_type"    INT,
    "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',
    "link"           VARCHAR(200),
    "art_bag_id"     BIGINT,
    "art_file_id"    BIGINT,
    "operation_type" INT,
    "file_type"      BIGINT,
    "file_belong"    BIGINT,
    "storage"        INT,
    "version"        INT,
    NOT              CLUSTER PRIMARY KEY("id"),
    CHECK ("file_type" >= 0),
    CHECK ("file_belong" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_art_bag_log" IS '工艺包操作历史';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."art_bag_id" IS '工艺包id';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."art_file_id" IS '工位报文件id';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."file_belong" IS '文件归属  工厂1 工位2';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."file_id" IS '文件id';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."file_name" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."file_type" IS '属性 程序1  文档2';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."link" IS '文件链接';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."object_key" IS '文件存储的key';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."operation_time" IS '操作时间';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."operation_type" IS '操作类型：添加1 覆盖2 删除3';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."operator_id" IS '操作人员id';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."operator_name" IS '操作人员姓名';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."remark" IS '备注';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."source_type" IS '源类型：本地文件0 我的文档1 加工程序2 通用文件3  回传文件 4 非通用文件 5   产品 6';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."storage" IS '存储空间 固定空间1 常规空间2';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."suffix" IS '文件后缀';
COMMENT
ON COLUMN "blade_dnc_art_bag_log"."version" IS '版本';



DROP TABLE IF EXISTS "blade_dnc_art_product";
CREATE TABLE "blade_dnc_art_product"
(
    "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',
    "product_id"        BIGINT,
    "art_bag_id"        BIGINT,
    "product_type_id"   BIGINT,
    "product_type_name" VARCHAR(50),
    "product_name"      VARCHAR(50),
    "product_code"      VARCHAR(50),
    NOT                 CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_art_product" IS '工艺包关联产品';
COMMENT
ON COLUMN "blade_dnc_art_product"."art_bag_id" IS '工艺包id';
COMMENT
ON COLUMN "blade_dnc_art_product"."product_code" IS '产品编码';
COMMENT
ON COLUMN "blade_dnc_art_product"."product_id" IS '产品id';
COMMENT
ON COLUMN "blade_dnc_art_product"."product_name" IS '产品名称';
COMMENT
ON COLUMN "blade_dnc_art_product"."product_type_id" IS '产品类型id';
COMMENT
ON COLUMN "blade_dnc_art_product"."product_type_name" IS '产品类型名称';
COMMENT
ON COLUMN "blade_dnc_art_product"."remark" IS '备注';


DROP TABLE IF EXISTS "blade_dnc_craft_file";
CREATE TABLE "blade_dnc_craft_file"
(
    "id"             BIGINT                NOT NULL,
    "tenant_id"      VARCHAR(12) DEFAULT '000000',
    "display_name"   VARCHAR(100),
    "pid"            BIGINT,
    "all_path"       VARCHAR(500),
    "content_length" BIGINT,
    "content_type"   VARCHAR(100),
    "suffix"         VARCHAR(10),
    "file_type"      INT,
    "object_key"     VARCHAR(100),
    "content_md5"    VARCHAR(100),
    "is_locked"      TINYINT,
    "owner"          BIGINT,
    "create_user"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "is_deleted"     INT,
    "create_dept"    BIGINT,
    "status"         INT,
    "link"           VARCHAR(255),
    "is_current"     TINYINT     DEFAULT 0 NOT NULL,
    "cover_time"     TIMESTAMP(0),
    "version"        INT,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_dnc_craft_file"."all_path" IS '全路径';
COMMENT
ON COLUMN "blade_dnc_craft_file"."content_md5" IS '文件md5';
COMMENT
ON COLUMN "blade_dnc_craft_file"."content_type" IS '文件mini类型';
COMMENT
ON COLUMN "blade_dnc_craft_file"."cover_time" IS '覆盖时间';
COMMENT
ON COLUMN "blade_dnc_craft_file"."create_dept" IS '部门';
COMMENT
ON COLUMN "blade_dnc_craft_file"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_craft_file"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_craft_file"."display_name" IS '文件显示名称';
COMMENT
ON COLUMN "blade_dnc_craft_file"."file_type" IS '文件类型，1 文件夹 2 文件 3 资源文件';
COMMENT
ON COLUMN "blade_dnc_craft_file"."is_current" IS '是否为当前版本,1是0否';
COMMENT
ON COLUMN "blade_dnc_craft_file"."is_locked" IS '是否上锁';
COMMENT
ON COLUMN "blade_dnc_craft_file"."link" IS '文件外连接';
COMMENT
ON COLUMN "blade_dnc_craft_file"."object_key" IS '文件key';
COMMENT
ON COLUMN "blade_dnc_craft_file"."owner" IS '拥有者';
COMMENT
ON COLUMN "blade_dnc_craft_file"."pid" IS '上级id';
COMMENT
ON COLUMN "blade_dnc_craft_file"."status" IS '状态';
COMMENT
ON COLUMN "blade_dnc_craft_file"."suffix" IS '后缀名';
COMMENT
ON COLUMN "blade_dnc_craft_file"."tenant_id" IS '租户id';
COMMENT
ON COLUMN "blade_dnc_craft_file"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_craft_file"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_craft_file"."version" IS '版本';


DROP TABLE IF EXISTS "blade_dnc_factory_file";
CREATE TABLE "blade_dnc_factory_file"
(
    "id"                BIGINT NOT NULL,
    "original_filename" VARCHAR(100),
    "filename"          VARCHAR(100),
    "content_length"    BIGINT,
    "content_md5"       VARCHAR(100),
    "last_modified"     TIMESTAMP(0),
    "content_type"      VARCHAR(100),
    "object_key"        VARCHAR(100),
    "suffix"            VARCHAR(50),
    "create_user"       BIGINT,
    "create_time"       TIMESTAMP(0),
    "update_user"       BIGINT,
    "update_time"       TIMESTAMP(0),
    "is_deleted"        INT,
    "create_dept"       BIGINT,
    "status"            INT,
    "link"              VARCHAR(255),
    "is_current"        INT,
    "version"           INT,
    "whether_archive"   INT DEFAULT 1,
    NOT                 CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_dnc_factory_file"."content_md5" IS '文件md5值';
COMMENT
ON COLUMN "blade_dnc_factory_file"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_factory_file"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_factory_file"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_factory_file"."filename" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_factory_file"."is_current" IS '是否为当前版本,1是0否';
COMMENT
ON COLUMN "blade_dnc_factory_file"."last_modified" IS '最后修改时间';
COMMENT
ON COLUMN "blade_dnc_factory_file"."link" IS '文件地址';
COMMENT
ON COLUMN "blade_dnc_factory_file"."object_key" IS '文件的objectKey';
COMMENT
ON COLUMN "blade_dnc_factory_file"."original_filename" IS '原始文件名称';
COMMENT
ON COLUMN "blade_dnc_factory_file"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_dnc_factory_file"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_factory_file"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_factory_file"."version" IS '文件版本';
COMMENT
ON COLUMN "blade_dnc_factory_file"."whether_archive" IS '文件是否归档：1 未归档  2 已归档';


DROP TABLE IF EXISTS "blade_dnc_operation_log";
CREATE TABLE "blade_dnc_operation_log"
(
    "id"                 BIGINT NOT NULL,
    "file_id"            BIGINT,
    "file_name"          VARCHAR(255),
    "object_key"         VARCHAR(255),
    "suffix"             VARCHAR(100),
    "operator_id"        BIGINT,
    "operator_name"      VARCHAR(255),
    "operation_type"     INT,
    "operation_response" INT,
    "operation_time"     TIMESTAMP(0),
    "source_type"        INT,
    "source_path_id"     VARCHAR(255),
    "source_path_name"   VARCHAR(255),
    "target_type"        INT,
    "target_path_id"     VARCHAR(255),
    "target_path_name"   VARCHAR(255),
    "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',
    "link"               VARCHAR(200),
    "workstation_id"     BIGINT,
    "file_type"          INT         DEFAULT 0,
    "version"            INT,
    "storage_space"      INT,
    "file_location"      VARCHAR(255),
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_dnc_operation_log"."file_id" IS '文件id';
COMMENT
ON COLUMN "blade_dnc_operation_log"."file_location" IS '文件位置：1 内部存储 2 以太网';
COMMENT
ON COLUMN "blade_dnc_operation_log"."file_name" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_operation_log"."file_type" IS '文件类型 1:代表文件夹  0:代表文件';
COMMENT
ON COLUMN "blade_dnc_operation_log"."link" IS '文件链接';
COMMENT
ON COLUMN "blade_dnc_operation_log"."object_key" IS '文件存储的key';
COMMENT
ON COLUMN "blade_dnc_operation_log"."operation_response" IS '操作结果';
COMMENT
ON COLUMN "blade_dnc_operation_log"."operation_time" IS '操作时间';
COMMENT
ON COLUMN "blade_dnc_operation_log"."operation_type" IS '操作类型：上传1 下载2 删除3 更新4 5移动 6复制';
COMMENT
ON COLUMN "blade_dnc_operation_log"."operator_id" IS '操作人员id';
COMMENT
ON COLUMN "blade_dnc_operation_log"."operator_name" IS '操作人员姓名';
COMMENT
ON COLUMN "blade_dnc_operation_log"."remark" IS '备注';
COMMENT
ON COLUMN "blade_dnc_operation_log"."source_path_id" IS '源全路径id';
COMMENT
ON COLUMN "blade_dnc_operation_log"."source_path_name" IS '源全路径名称';
COMMENT
ON COLUMN "blade_dnc_operation_log"."source_type" IS '源类型：本地文件0 我的文档1 工位文件-加工程序2 工位文件-工位文件3  FTP 4';
COMMENT
ON COLUMN "blade_dnc_operation_log"."storage_space" IS '存储位置：1 常规空间  2 固定空间';
COMMENT
ON COLUMN "blade_dnc_operation_log"."suffix" IS '文件后缀';
COMMENT
ON COLUMN "blade_dnc_operation_log"."target_path_id" IS '目标全路径id：格式，/1/123/456';
COMMENT
ON COLUMN "blade_dnc_operation_log"."target_path_name" IS '目标全路径名称:格式，/我的文档/文件夹1/文件夹2';
COMMENT
ON COLUMN "blade_dnc_operation_log"."target_type" IS '源类型：本地文件0 我的文档1 工位文件-加工程序2 工位文件-工位文件3  FTP 4';
COMMENT
ON COLUMN "blade_dnc_operation_log"."version" IS '版本';
COMMENT
ON COLUMN "blade_dnc_operation_log"."workstation_id" IS '工位id';



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

COMMENT
ON TABLE "blade_dnc_transfer_directory" IS '工位目录表';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."dept_id" IS '职权域id';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."group_all_path" IS '工位文件组的all_path';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."group_id" IS '工位文件分组Id';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."name" IS '工位文件名称';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."resource_id" IS '资源id';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory"."workstation_id" IS '工位id';


DROP TABLE IF EXISTS "blade_dnc_transfer_directory_file";
CREATE TABLE "blade_dnc_transfer_directory_file"
(
    "id"                    BIGINT NOT NULL,
    "transfer_directory_id" BIGINT NOT NULL,
    "file_source"           TINYINT,
    "file_type"             INT,
    "original_filename"     VARCHAR(100),
    "filename"              VARCHAR(100),
    "content_length"        BIGINT,
    "content_md5"           VARCHAR(100),
    "last_modified"         TIMESTAMP(0),
    "content_type"          VARCHAR(100),
    "object_key"            VARCHAR(100),
    "suffix"                VARCHAR(50),
    "create_user"           BIGINT,
    "create_time"           TIMESTAMP(0),
    "update_user"           BIGINT,
    "update_time"           TIMESTAMP(0),
    "is_deleted"            INT,
    "create_dept"           BIGINT,
    "status"                INT,
    "link"                  VARCHAR(255),
    "is_current"            INT,
    "workstation_id"        BIGINT NOT NULL,
    "cover_time"            TIMESTAMP(0),
    "craft_file_id"         BIGINT,
    "tenant_id"             VARCHAR(12) DEFAULT '000000',
    "version"               INT,
    "storage_space"         INT,
    "whether_archive"       INT,
    "storage_space_id"      BIGINT,
    NOT                     CLUSTER PRIMARY KEY ("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_transfer_directory_file" IS '工位目录文件表';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."content_md5" IS '文件md5值';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."cover_time" IS '文件时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."craft_file_id" IS '文档文件id';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."file_source" IS '文件来源 1 我的文档  2 本地文件 3 工艺管理';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."file_type" IS '文件类别(1:加工文件,2:工艺文件)';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."filename" IS '文件名称';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."is_current" IS '是否为当前版本,1是0否';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."last_modified" IS '最后修改时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."link" IS '文件地址';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."object_key" IS '文件的objectKey';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."original_filename" IS '原始文件名称';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."storage_space" IS '存储位置：1 常规空间  2 固定空间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."transfer_directory_id" IS '工位目录Id';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."version" IS '版本号';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."whether_archive" IS '文件是否归档：1 未归档  2 已归档';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_file"."workstation_id" IS '工位Id';
comment
on column "blade_dnc_transfer_directory_file"."storage_space_id" is '固定空间目录id';

DROP TABLE IF EXISTS "blade_dnc_transfer_directory_group";
CREATE TABLE "blade_dnc_transfer_directory_group"
(
    "id"                   BIGINT NOT NULL,
    "tenant_id"            VARCHAR(12) DEFAULT '000000',
    "parent_id"            BIGINT      DEFAULT 0,
    "name"                 VARCHAR(45),
    "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,
    "workstation_group_id" BIGINT,
    NOT                    CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_transfer_directory_group" IS '工位组目录表';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."all_path" IS '全路径(包含自身)';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."id" IS '主键';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."name" IS '工位文件组名';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."status" IS '状态';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_transfer_directory_group"."workstation_group_id" IS '工位组id';

DROP TABLE IF EXISTS "blade_dnc_ws_relation_td";
CREATE TABLE "blade_dnc_ws_relation_td"
(
    "id"                   BIGINT NOT NULL,
    "tenant_id"            VARCHAR(12) DEFAULT '000000',
    "create_user"          BIGINT,
    "create_time"          TIMESTAMP(0),
    "update_user"          BIGINT,
    "update_time"          TIMESTAMP(0),
    "is_deleted"           INT,
    "create_dept"          BIGINT,
    "status"               INT,
    "transfer_director_id" BIGINT,
    "workstation_id"       BIGINT,
    NOT                    CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "workstation_id" UNIQUE ("workstation_id", "is_deleted")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE  "blade_dnc_ws_relation_td" IS 'FTP目录与工位关系表';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."transfer_director_id" IS 'FTP目录id';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_dnc_ws_relation_td"."workstation_id" IS '工位id';

DROP TABLE IF EXISTS "blade_dnc_fixed_space";
CREATE TABLE "blade_dnc_fixed_space"
(
    "id"             BIGINT NOT NULL,
    "tenant_id"      VARCHAR(12) DEFAULT '000000',
    "parent_id"      BIGINT      DEFAULT 0,
    "name"           VARCHAR(45),
    "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,
    "td_id"          BIGINT,
    "space_location" INT,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dnc_fixed_space" IS '工位目录关联固定空间表';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."all_path" IS '全路径(包含自身)';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."id" IS '主键';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."name" IS '固定空间目录名称';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."space_location" IS '目录属性: 1 常规（根节点）2 固定';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."status" IS '状态';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."td_id" IS '工位目录id';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_dnc_fixed_space"."update_user" IS '更新人';



-- 初始化菜单脚本
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 (1481428245788037121, 0, 'dnc', '生产工艺', 'dnc', '/dnc', 'iconfont saber-shengchangongyi', 5, 0, 0, 1, '', 0,
        'CPS', 1);
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 (1481428568128688130, 1481428245788037121, 'transfer', '文件传输', 'transfer', '/dnc/transport/index',
        'iconfont iconicon_exchange', 3, 1, 0, 1, '', 0, 'CPS', 1);
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 (1481429369576296449, 1481428245788037121, 'station_file', '工位文件', 'station_file', '/dnc/station-file/index',
        'iconfont iconicon_doc', 2, 1, 0, 1, '', 0, 'CPS', 1);
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 (1481429815657304065, 1481428245788037121, 'my_documents', '我的文档', 'my_documents', '/dnc/document/index',
        'iconfont iconicon_subordinate', 1, 1, 0, 1, '', 0, 'CPS', 1);
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 (1495960929735061505, 1481428245788037121, 'operation_log', '操作日志', 'operation_log', '/dnc/log/index',
        'iconfont icon-biaodan', 7, 1, 0, 1, '', 0, 'CPS', 1);
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 (1496427333921992705, 1498201919430000641, 'technology_files', '工艺文件', 'technology_files',
        '/dnc/craft/document/index', 'iconfont iconicon_dispose', 1, 1, 0, 1, '', 0, 'CPS', 1);
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 (1497029135171686401, 1481428245788037121, 'factory_file', '工厂文件', 'factory_file', '/dnc/factory-file/index',
        'iconfont iconicon_doc', 6, 1, 0, 1, '', 0, 'CPS', 1);
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 (1497030448508932097, 1481428245788037121, 'archive', '文件归档', 'archive', '/dnc/archive',
        'iconfont iconicon_coinpurse_line', 5, 1, 0, 1, '', 0, 'CPS', 1);
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 (1497129165478219777, 1497030448508932097, 'archived_files', '归档管理', 'archived_files', '/dnc/file/admin/index',
        'iconfont iconicon_dispose', 2, 1, 0, 1, '', 0, 'CPS', 1);
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 (1497132713708535809, 1497030448508932097, 'archive_catalog', '归档目录', 'archive_catalog',
        '/dnc/file/catalog/index', 'iconfont iconicon_addresslist', 1, 1, 0, 1, '', 0, 'CPS', 1);
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 (1498201919430000641, 1481428245788037121, 'technology_file', '工艺管理', 'technology_file', '/dnc/process',
        'iconfont iconicon_coinpurse_line', 4, 1, 0, 1, '', 0, 'CPS', 1);
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 (1498202645019426818, 1498201919430000641, 'technology_catalog', '工艺目录', 'technology_catalog',
        '/dnc/craft/catalog/index', 'iconfont iconicon_addresslist', 2, 1, 0, 1, '', 0, 'CPS', 1);
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 (1551739877858926594, 1481428245788037121, 'dnc_app_setting', 'dnc应用设置', 'dnc_app_setting', '/dnc/setting/index',
        '', 8, 1, 0, 1, '', 0, 'cps', 1);
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 (1552474588642234369, 1551739877858926594, 'ftp_directory_root_add', '创建FTP目录', 'ftp_directory_root_add', '', '',
        1, 2, 0, 1, '', 0, 'cps', 1);
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 (1552475927401156610, 1551739877858926594, 'bind_workstation', '关联工位', 'bind_workstation', '', '', 2, 2, 0, 1,
        '', 0, 'cps', 1);
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 (1552476695336300545, 1551739877858926594, 'ftp_directory_add', '新增', 'ftp_directory_add', '', '', 4, 2, 0, 1,
        '', 0, 'cps', 1);
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 (1552476901159186434, 1551739877858926594, 'ftp_directory_rename', '重命名', 'ftp_directory_rename', '', '', 5, 2,
        0, 1, '', 0, 'cps', 1);
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 (1552477030549270530, 1551739877858926594, 'ftp_directory_delete', '删除子目录', 'ftp_directory_delete', '', '', 6, 2,
        0, 1, '', 0, 'cps', 1);
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 (1552477343062667265, 1551739877858926594, 'ftp_directory_root_delete', '删除根目录', 'ftp_directory_root_delete', '',
        '', 3, 2, 0, 1, '', 0, 'cps', 1);
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 (1585554742799319042, 0, 'hmi_dnc', '文件传输', 'hmi_dnc', '/dnc', '', 2, 1, 0, 1, '', 0, 'HMI', 1);
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 (1592786664948154369, 1551739877858926594, 'dnc_filedriectory_save', '文件配置设置', 'dnc_filedriectory_save', '', '',
        10, 2, 0, 1, '', 0, 'CPS', 1);
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 (1592786889846734850, 1551739877858926594, 'dnc_filedriectory_switch', '文件配置开关', 'dnc_filedriectory_switch', '',
        '', 11, 2, 0, 1, '', 0, 'CPS', 1);


-- 初始化脚本
INSERT INTO blade_dnc_archive_directory(id, tenant_id, parent_id, name, all_path,
                                        is_deleted, status, create_time, create_user, update_time,
                                        update_user, create_dept,
                                        dept_id)
VALUES (0, '000000', -1, '默认目录', '0', 0, NULL, NOW(), NULL, NOW(), NULL, NULL, NULL);
INSERT INTO blade_dnc_process_catalogue(id, tenant_id, parent_id, name, all_path,
                                        is_deleted, status, create_time, create_user, update_time,
                                        update_user, create_dept,
                                        dept_id)
VALUES (0, '000000', -1, '默认目录', '0', 0, 1, NOW(), NULL, NOW(), NULL, NULL, NULL);

INSERT INTO blade_dnc_craft_file(id, tenant_id, display_name, pid, all_path, content_length,
                                 content_type, suffix, file_type, object_key, content_md5, is_locked,
                                 owner, create_user, create_time, update_user, update_time, is_deleted,
                                 create_dept, status, link, is_current, cover_time, version)
VALUES (0, '000000', '我的文档', -1, '0', 0, NULL, NULL, 1, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 1, NULL,
        1, NULL, 1);

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 (1592793061815402498, 1592786664948154369, 'dnc_directory_settings.update_file_setting_data', '更新文件目录设置',
        '/blade-dnc/dnc-directory-settings/update-setting', NULL, NULL, 'POST', 1123598821738675201,
        1123598813738675201,
        '2022-11-16 16:13:53', 1123598821738675201, '2022-11-16 16:13:53', 1, 0),
       (1592793108263124993, 1592786889846734850, 'dnc_directory_settings.switch_state', '文件设置：开启、关闭',
        '/blade-dnc/dnc-directory-settings/change', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201,
        '2022-11-16 16:14:04', 1123598821738675201, '2022-11-16 16:14:04', 1, 0);
