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 (1584363919958806529, 0, 'FMS', '柔性线生产Fms', 'FMS', '', 'iconfont saber-shikuang', 5, 0, 0, 1, '', 0, 'CPS', 1),
       (1584366536134955010, 1584363919958806529, 'cps_workorder', '工单', 'cps_workorder', '/fms/work-order/index',
        'iconfont saber-gongdan1', 1, 1, 0, 1, '', 0, 'CPS', 1),
       (1584367046896324609, 1584363919958806529, 'fms_live', '调度实况', 'fms_live', '/fms/live/index',
        'iconfont saber-shikuang1', 2, 1, 0, 1, '', 0, 'CPS', 1),
       (1585097946642714625, 1584363919958806529, 'production_statistics', '生产统计', 'production_statistics',
        '/fms/production-statistics/index',
        '', 3, 1, 0, 2, '', 0, 'CPS', 1),
       (1585098719174791169, 1584363919958806529, 'equipment_analysis', '设备分析', 'equipment_analysis',
        '/fms/equipment-analysis/index',
        '', 4, 1, 0, 1, '', 0, 'CPS', 1);

DROP TABLE IF EXISTS "blade_fms_order";
CREATE TABLE "BLADE_FMS_ORDER"
(
    "ID"                 BIGINT NOT NULL,
    "CODE"               VARCHAR(50),
    "ORDER_CODE"         VARCHAR(50),
    "ORDER_TYPE"         INT,
    "ORDER_STATUS"       INT,
    "ASSIGN_NUM"         INT,
    "PLAN_START_TIME"    TIMESTAMP(0),
    "PLAN_END_TIME"      TIMESTAMP(0),
    "START_TIME"         TIMESTAMP(0),
    "END_TIME"           TIMESTAMP(0),
    "PRIORITY"           INT,
    "QUALIFY_NUM"        INT,
    "UNQUALIFY_NUM"      INT,
    "ONLINE_NUMBER"      INT,
    "OFFLINE_NUMBER"     INT,
    "PRODUCT_ID"         BIGINT,
    "PRODUCT_NAME"       VARCHAR(255),
    "CRAFT_ID"           BIGINT,
    "CRAFT_NAME"         VARCHAR(255),
    "CRAFT_VERSION_ID"   BIGINT,
    "CRAFT_VERSION_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"             TINYINT,
    "IS_DELETED"         BIGINT,
    "CREATE_DEPT"        BIGINT,
    "PRODUCT_CODE"       VARCHAR(255),
    "START_UP_TIME"      TIMESTAMP(0),
    NOT CLUSTER PRIMARY KEY ("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ASSIGN_NUM" IS '工单数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CODE" IS '工单编号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CRAFT_ID" IS '工艺路线ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CRAFT_NAME" IS '产品路线名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CRAFT_VERSION_ID" IS '工艺路线版本';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CRAFT_VERSION_NAME" IS '工艺路线名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."END_TIME" IS '实际完成时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."IS_DELETED" IS '删除标识';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."OFFLINE_NUMBER" IS '下线数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ONLINE_NUMBER" IS '上线数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ORDER_CODE" IS '订单编号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ORDER_STATUS" IS '工单状态 待发布 0 待加工 1 加工中 2 暂停中 3 暂停 4 已完成 5';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."ORDER_TYPE" IS '工单类型  1.来料  2.生产';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PLAN_END_TIME" IS '结束时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PLAN_START_TIME" IS '开始时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PRIORITY" IS '优先级（1，2，3，4）';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PRODUCT_CODE" IS '产品编码';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PRODUCT_ID" IS '产品ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."PRODUCT_NAME" IS '产品名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."QUALIFY_NUM" IS '合格数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."REMARK" IS '备注';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."START_TIME" IS '实际开始时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."START_UP_TIME" IS '工单启动时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."STATUS" IS '状态';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."UNQUALIFY_NUM" IS '不合格数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER"."UPDATE_USER" IS '更新人';

CREATE INDEX "PRODUCT_ID" ON "BLADE_FMS_ORDER" ("PRODUCT_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "CRAFT_ID" ON "BLADE_FMS_ORDER" ("CRAFT_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

-- 工单工序表
DROP TABLE IF EXISTS "blade_fms_order_process";
CREATE TABLE "BLADE_FMS_ORDER_PROCESS"
(
    "ID"                BIGINT NOT NULL,
    "ORDER_ID"          BIGINT,
    "PROCESS_NAME"      VARCHAR(50),
    "PROCESS_CODE"      VARCHAR(50),
    "PROCESS_STATUS"    INT,
    "WORK_STATION_ID"   VARCHAR(255),
    "WORK_STATION_NAME" VARCHAR(255),
    "PROCESS_TYPE"      INT,
    "PROCESS_TYPE_NAME" VARCHAR(11),
    "SORT"              INT,
    "PROGRAM_ID"        BIGINT,
    "PROGRAM_NAME"      VARCHAR(255),
    "QUALIFY_NUM"       INT,
    "UNQUALIFY_NUM"     INT,
    "ONLINE_NUMBER"     INT,
    "OFFLINE_NUMBER"    INT,
    "STANDARD_TIME"     INT,
    "PREPARE_TIME"      INT,
    "DISASSEMBLY_TIME"  INT,
    "TRANSPORT_TIME"    INT,
    "TENANT_ID"         VARCHAR(12),
    "CREATE_USER"       BIGINT,
    "CREATE_TIME"       TIMESTAMP(0),
    "UPDATE_USER"       BIGINT,
    "UPDATE_TIME"       TIMESTAMP(0),
    "REMARK"            VARCHAR(255),
    "STATUS"            TINYINT,
    "IS_DELETED"        BIGINT,
    "CREATE_DEPT"       BIGINT,
    "INPUT_NUM"         INT,
    "START_TIME"        TIMESTAMP(0),
    "END_TIME"          TIMESTAMP(0),
    "DISTRIBUTED_NUM"   INT,
    "PART_NUMBER"       VARCHAR(20),
    "CUR_TRAY_CODE"     VARCHAR(20),
    NOT CLUSTER PRIMARY KEY ("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."CUR_TRAY_CODE" IS '当前托盘号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."DISASSEMBLY_TIME" IS '拆卸工时';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."DISTRIBUTED_NUM" IS '待派发数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."END_TIME" IS '实际完成时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."INPUT_NUM" IS '投产数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."IS_DELETED" IS '删除标识';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."OFFLINE_NUMBER" IS '下线数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."ONLINE_NUMBER" IS '上线数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."ORDER_ID" IS '所属工单ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PART_NUMBER" IS '零件号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PREPARE_TIME" IS '准备工时';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROCESS_CODE" IS '工单工序编号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROCESS_NAME" IS '工单工序名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROCESS_STATUS" IS '工单工序状态';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROCESS_TYPE" IS '工序工种';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROCESS_TYPE_NAME" IS '工序工种名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROGRAM_ID" IS '程序ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."PROGRAM_NAME" IS '程序名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."QUALIFY_NUM" IS '合格数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."REMARK" IS '备注';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."SORT" IS '顺序';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."STANDARD_TIME" IS '标准工时';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."START_TIME" IS '实际开始时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."STATUS" IS '状态';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."TRANSPORT_TIME" IS '运输工时';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."UNQUALIFY_NUM" IS '不合格数量';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."WORK_STATION_ID" IS '工单派发工位ID列表';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS"."WORK_STATION_NAME" IS '工单派发工位名字列表';


CREATE INDEX "INDEX65357921835400" ON "BLADE_FMS_ORDER_PROCESS" ("ORDER_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

-- 工单工序夹具表
DROP TABLE IF EXISTS "blade_fms_order_process_fixture";
CREATE TABLE "BLADE_FMS_ORDER_PROCESS_FIXTURE"
(
    "ID"                 BIGINT NOT NULL,
    "ORDER_PROCESS_ID"   BIGINT,
    "FIXTURE_ID"         VARCHAR(255),
    "FIXTURE_CODE"       VARCHAR(255),
    "FIXTURE_NAME"       VARCHAR(255),
    "TRAY_CODE"          VARCHAR(255),
    "FIXTURE_GROUP_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,
    "ORDER_ID"           BIGINT,
    "TRAY_ID"            VARCHAR(255),
    NOT CLUSTER PRIMARY KEY ("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."FIXTURE_CODE" IS '夹具编号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."FIXTURE_GROUP_NAME" IS '夹具组名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."FIXTURE_ID" IS '夹具ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."FIXTURE_NAME" IS '夹具名称';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."IS_DELETED" IS '删除标识';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."ORDER_ID" IS '工单id';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."ORDER_PROCESS_ID" IS '工单工序ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."REMARK" IS '备注';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."STATUS" IS '记录状态';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."TENANT_ID" IS '租户ID';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."TRAY_CODE" IS '托盘号';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."TRAY_ID" IS '托盘id';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_FMS_ORDER_PROCESS_FIXTURE"."UPDATE_USER" 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"         int default 0,
    "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 '更新人';

-- 工单工序开报工表
DROP TABLE IF EXISTS "blade_fms_work_station_record";
CREATE TABLE "BLADE_FMS_WORK_STATION_RECORD"
(
    "ID"                BIGINT NOT NULL,
    "ORDER_ID"          BIGINT,
    "ORDER_PROCESS_ID"  BIGINT,
    "WORK_STATION_ID"   BIGINT,
    "WORK_STATION_NAME" VARCHAR(50),
    "START_TIME"        TIMESTAMP(0),
    "END_TIME"          TIMESTAMP(0),
    "QUALIFY_NUM"       INT,
    "UNQUALIFY_NUM"     INT,
    "WORK_TIME"         INT,
    "TRAY_CODE"         VARCHAR(255),
    "PART_CODE"         VARCHAR(255),
    "CREATE_USER"       BIGINT,
    "CREATE_TIME"       TIMESTAMP(0),
    "UPDATE_USER"       BIGINT,
    "UPDATE_TIME"       TIMESTAMP(0),
    "REMARK"            VARCHAR(255),
    "STATUS"            INT,
    "IS_DELETED"        INT DEFAULT 0,
    "CREATE_DEPT"       BIGINT,
    "RECORD_STATUS"     TINYINT,
    "WORK_BENCH_NUMBER" VARCHAR(255),
    NOT CLUSTER PRIMARY KEY ("ID")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."CREATE_TIME" IS '创建时间';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."CREATE_USER" IS '创建人';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."END_TIME" IS '结束时间';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."ID" IS '主键';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."IS_DELETED" IS '删除标识';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."ORDER_ID" IS '工单ID';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."ORDER_PROCESS_ID" IS '工单工序ID';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."PART_CODE" IS '零件号';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."QUALIFY_NUM" IS '报工合格数量';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."RECORD_STATUS" IS '1-加工中 2-完成';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."REMARK" IS '备注';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."START_TIME" IS '开工时间';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."STATUS" IS '记录状态';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."TRAY_CODE" IS '托盘号';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."UNQUALIFY_NUM" IS '报工不合格数量';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."UPDATE_TIME" IS '更新时间';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."UPDATE_USER" IS '更新人';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."WORK_STATION_NAME" IS '工位名称';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."WORK_TIME" IS '报工工时';
COMMENT
ON COLUMN "BLADE_FMS_WORK_STATION_RECORD"."WORK_BENCH_NUMBER" IS '工作台编号';

CREATE INDEX "ORDER_PROCESS_ID" ON "BLADE_FMS_WORK_STATION_RECORD" ("ORDER_PROCESS_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "WORK_SATION_ID" ON "BLADE_FMS_WORK_STATION_RECORD" ("WORK_STATION_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "ORDER_ID" ON "BLADE_FMS_WORK_STATION_RECORD" ("ORDER_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR);



DROP TABLE IF EXISTS "blade_fms_abnormal";
create table "blade_fms_abnormal"
(
    "id"           bigint identity(969, 1) not null,
    "status"       int,
    "is_deleted"   int default 0,
    "create_user"  bigint,
    "create_dept"  bigint,
    "create_time"  timestamp(0),
    "update_user"  bigint,
    "update_time"  timestamp(0),
    "tenant_id"    varchar(12),
    "report_state" tinyint,
    "content"      text,
    "type"         tinyint,
    not cluster primary key ("id"),
    check ("status" >= 0),
    check ("is_deleted" >= 0)
) storage(on "main", clusterbtr);

comment
on column "blade_fms_abnormal"."content" is '内容';
comment
on column "blade_fms_abnormal"."create_dept" is '创建部门';
comment
on column "blade_fms_abnormal"."create_time" is '创建时间';
comment
on column "blade_fms_abnormal"."create_user" is '创建人';
comment
on column "blade_fms_abnormal"."id" is '主键';
comment
on column "blade_fms_abnormal"."is_deleted" is '删除状态：0-未删除，1-已删除';
comment
on column "blade_fms_abnormal"."report_state" is '提报状态 1-待提报;2-已取消;3-已提报';
comment
on column "blade_fms_abnormal"."status" is '状态';
comment
on column "blade_fms_abnormal"."tenant_id" is '所属租户';
comment
on column "blade_fms_abnormal"."type" is '异常类型';
comment
on column "blade_fms_abnormal"."update_time" is '更新时间';
comment
on column "blade_fms_abnormal"."update_user" is '更新人';

DROP TABLE IF EXISTS "blade_fms_instruction_record";
create table "blade_fms_instruction_record"
(
    "id"              bigint identity(3, 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),
    "order_code"      varchar(64),
    "process_code"    varchar(64),
    "state"           tinyint,
    "start_position"  varchar(64),
    "start_bench"     varchar(64),
    "end_position"    varchar(64),
    "end_bench"       varchar(64),
    "tray_code"       varchar(64),
    "program_no"      varchar(64),
    "program_offset"  varchar(64),
    "signal_state"    tinyint,
    "abnormal_reason" varchar(256),
    "log"             text,
    "last_load"       tinyint,
    "change_model"    tinyint,
    not cluster primary key ("id"),
    check ("status" >= 0),
    check ("is_deleted" >= 0)
) storage(on "main", clusterbtr);

comment
on table "blade_fms_instruction_record" is '指令记录表';
comment
on column "blade_fms_instruction_record"."abnormal_reason" is '异常原因';
comment
on column "blade_fms_instruction_record"."change_model" is '停止标记(0：未停止，1：已停止)';
comment
on column "blade_fms_instruction_record"."create_dept" is '创建部门';
comment
on column "blade_fms_instruction_record"."create_time" is '创建时间';
comment
on column "blade_fms_instruction_record"."create_user" is '创建人';
comment
on column "blade_fms_instruction_record"."end_bench" is '目标工作台编号';
comment
on column "blade_fms_instruction_record"."end_position" is '目标位置 目标设备编号';
comment
on column "blade_fms_instruction_record"."id" is '主键';
comment
on column "blade_fms_instruction_record"."is_deleted" is '删除状态：0-未删除，1-已删除';
comment
on column "blade_fms_instruction_record"."last_load" is '是否装卸站末件';
comment
on column "blade_fms_instruction_record"."log" is '产生日志';
comment
on column "blade_fms_instruction_record"."order_code" is '工单号';
comment
on column "blade_fms_instruction_record"."process_code" is '工序号';
comment
on column "blade_fms_instruction_record"."program_no" is '程序号';
comment
on column "blade_fms_instruction_record"."program_offset" is '程序偏移';
comment
on column "blade_fms_instruction_record"."signal_state" is '信号状态 1-动作执行;2-数据传递';
comment
on column "blade_fms_instruction_record"."start_bench" is '起始工作台编号';
comment
on column "blade_fms_instruction_record"."start_position" is '起始位置 起始设备编号';
comment
on column "blade_fms_instruction_record"."state" is '状态 0-已生成;1-执行中;2-执行完成;3-执行异常';
comment
on column "blade_fms_instruction_record"."status" is '状态';
comment
on column "blade_fms_instruction_record"."tenant_id" is '所属租户';
comment
on column "blade_fms_instruction_record"."tray_code" is '托盘编号';
comment
on column "blade_fms_instruction_record"."update_time" is '更新时间';
comment
on column "blade_fms_instruction_record"."update_user" is '更新人';

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 (1589806703919927297, 1584366536134955010, 'fms_order_process.detail', '工单工序信息详情',
        '/blade-fms/order/process/get/*', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:27:10', 1123598821738675201, '2022-11-08 10:27:10', 1, 0),
       (1589806703928315905, 1584366536134955010, 'fms_order_process.list', '工单工序信息列表', '/blade-fms/order/process/list',
        NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201, '2022-11-08 10:27:10', 1123598821738675201,
        '2022-11-08 10:27:10', 1, 0),
       (1589806703932510210, 1584366536134955010, 'fms_order_process.remove', '工单工序信息删除',
        '/blade-fms/order/process/remove', NULL, NULL, 'DELETE', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:27:10', 1123598821738675201, '2022-11-08 10:27:10', 1, 0),
       (1589806703936704513, 1584366536134955010, 'fms_order_process.update', '工单工序信息修改',
        '/blade-fms/order/process/update', NULL, NULL, 'PUT', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:27:10', 1123598821738675201, '2022-11-08 10:27:10', 1, 0),
       (1589806703940898818, 1584366536134955010, 'fms_order_process.workstation_list', '根据工单ID获取每道工序的工位列表数据',
        '/blade-fms/order/process/workstation-list', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:27:10', 1123598821738675201, '2022-11-08 10:27:10', 1, 0),
       (1589806649947623425, 1584366536134955010, 'fms_order.count', '工单基础状态信息统计值', '/blade-fms/order/count', NULL,
        NULL, 'GET', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649951817729, 1584366536134955010, 'fms_order.detail', '工单基础状态信息详情', '/blade-fms/order/get/*', NULL,
        NULL, 'GET', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649951817730, 1584366536134955010, 'fms_order.get_fms_online', '获取柔性线当前运行状态',
        '/blade-fms/order/fms-running-status', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649951817731, 1584366536134955010, 'fms_order.get_production_craft', '根据产品ID查询工艺路线列表数据',
        '/blade-fms/order/get-production-craft/*', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649951817732, 1584366536134955010, 'fms_order.list_craft', '获取所有的工艺路线列表', '/blade-fms/order/list-craft',
        NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649951817733, 1584366536134955010, 'fms_order.order_statistics', '查看工单统计信息',
        '/blade-fms/order/statistics', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649956012033, 1584366536134955010, 'fms_order.page', '工单基础状态信息分页', '/blade-fms/order/page', NULL, NULL,
        'GET', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649956012034, 1584366536134955010, 'fms_order.pause', '工单暂停', '/blade-fms/order/pause', NULL, NULL,
        'POST', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649956012035, 1584366536134955010, 'fms_order.production_statistics', '查看产量统计信息',
        '/blade-fms/order/production-statistics', NULL, NULL, 'GET', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649956012036, 1584366536134955010, 'fms_order.publish', '工单发布', '/blade-fms/order/publish', NULL, NULL,
        'POST', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649956012037, 1584366536134955010, 'fms_order.remove', '工单基础状态信息删除', '/blade-fms/order/remove', NULL,
        NULL, 'DELETE', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649956012038, 1584366536134955010, 'fms_order.save', '保存工单基础信息', '/blade-fms/order/save', NULL, NULL,
        'POST', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649960206337, 1584366536134955010, 'fms_order.save_workstation', '保存指派工位信息',
        '/blade-fms/order/save-workstation', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649960206338, 1584366536134955010, 'fms_order.shut_down_order', '停止计划工单（产线）',
        '/blade-fms/order/shut-down-order', NULL, NULL, 'PUT', 1123598821738675201, 1123598813738675201,
        '2022-11-08 10:26:57', 1123598821738675201, '2022-11-08 10:26:57', 1, 0),
       (1589806649960206339, 1584366536134955010, 'fms_order.start', '工单启动', '/blade-fms/order/start', NULL, NULL,
        'POST', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0),
       (1589806649960206340, 1584366536134955010, 'fms_order.switch_state', '手自动切换', '/blade-fms/order/switch', NULL,
        NULL, 'POST', 1123598821738675201, 1123598813738675201, '2022-11-08 10:26:57', 1123598821738675201,
        '2022-11-08 10:26:57', 1, 0);
INSERT INTO blade_param (id, param_name, param_key, param_value, remark, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1564441155800182785, '是否自动', 'system.automatic', 'false', NULL, NULL, NULL, '2022-08-30 10:33:32', 1123598821738675201, '2023-01-05 15:31:38', 1, 0);
