-- 生产计划
CREATE TABLE mes_yield_plan
(
    id                 NUMBER(20, 0)           NOT NULL ENABLE,
    tenant_id          NVARCHAR2(12) DEFAULT '000000',
    create_user        NUMBER(20, 0),
    create_dept        NUMBER(20, 0),
    create_time        DATE          DEFAULT SYSDATE,
    update_user        NUMBER(20, 0),
    update_time        DATE          DEFAULT SYSDATE,
    status             NUMBER(11, 0) DEFAULT 1,
    is_deleted         NUMBER(11, 0) DEFAULT 0,
    yp_code            NVARCHAR2(255)          NOT NULL ENABLE,
    part_code          NVARCHAR2(255)          NOT NULL ENABLE,
    product_type       NVARCHAR2(255),
    part_name          NVARCHAR2(255)          NOT NULL ENABLE,
    plate              NVARCHAR2(255),
    product_ident      NVARCHAR2(255),
    use_dept           NVARCHAR2(255),
    yp_qty             NUMBER                  NOT NULL ENABLE,
    yp_area            NUMBER(20, 10)          NOT NULL ENABLE,
    demand_date        DATE,
    plan_user          NVARCHAR2(255),
    release_date       DATE,
    roam_no            NVARCHAR2(255),
    delivery_qty       NUMBER                  NOT NULL ENABLE,
    already_branch_qty NUMBER                  NOT NULL ENABLE,
    cur_status         NUMBER        DEFAULT 0 NOT NULL ENABLE,
    primary_craft      NVARCHAR2(900),
    sync_time          DATE                    NOT NULL ENABLE,
    dominant_dept      NVARCHAR2(255),
    memo               NVARCHAR2(255),
    route_no           NVARCHAR2(255),
    custodian          NVARCHAR2(255),
    bps_id             NUMBER(18, 0),
    priority           NUMBER        DEFAULT 1,
    plan_type          NUMBER        DEFAULT 1 NOT NULL ENABLE,
    sure_type          NUMBER,
    close_man          NUMBER(18, 0),
    close_time         DATE,
    product_line       NVARCHAR2(255),
    CONSTRAINT mes_yield_plan_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_yield_plan IS '生产计划';
COMMENT ON COLUMN mes_yield_plan.id IS '主键';
COMMENT ON COLUMN mes_yield_plan.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_yield_plan.create_user IS '创建人';
COMMENT ON COLUMN mes_yield_plan.create_dept IS '创建部门';
COMMENT ON COLUMN mes_yield_plan.create_time IS '创建时间';
COMMENT ON COLUMN mes_yield_plan.update_user IS '修改人';
COMMENT ON COLUMN mes_yield_plan.update_time IS '修改时间';
COMMENT ON COLUMN mes_yield_plan.status IS '状态';
COMMENT ON COLUMN mes_yield_plan.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_yield_plan.yp_code IS '订单单号';
COMMENT ON COLUMN mes_yield_plan.part_code IS '零件号';
COMMENT ON COLUMN mes_yield_plan.product_type IS '产品型号';
COMMENT ON COLUMN mes_yield_plan.part_name IS '名称';
COMMENT ON COLUMN mes_yield_plan.plate IS '镀种';
COMMENT ON COLUMN mes_yield_plan.product_ident IS '生产标识';
COMMENT ON COLUMN mes_yield_plan.use_dept IS '使用部门';
COMMENT ON COLUMN mes_yield_plan.yp_qty IS '数量';
COMMENT ON COLUMN mes_yield_plan.yp_area IS '面积（㎡）';
COMMENT ON COLUMN mes_yield_plan.demand_date IS '需求交期';
COMMENT ON COLUMN mes_yield_plan.plan_user IS '计划员';
COMMENT ON COLUMN mes_yield_plan.release_date IS '计划下达时间';
COMMENT ON COLUMN mes_yield_plan.roam_no IS '当前B号';
COMMENT ON COLUMN mes_yield_plan.delivery_qty IS '已交件数量';
COMMENT ON COLUMN mes_yield_plan.already_branch_qty IS '已分批数量';
COMMENT ON COLUMN mes_yield_plan.cur_status IS '状态;1.正常，2.已退回，3.已派工，4，加工中，20已完工，21已作废';
COMMENT ON COLUMN mes_yield_plan.primary_craft IS '一级工艺线路';
COMMENT ON COLUMN mes_yield_plan.sync_time IS '同步日期';
COMMENT ON COLUMN mes_yield_plan.dominant_dept IS '主制部门';
COMMENT ON COLUMN mes_yield_plan.memo IS '备注';
COMMENT ON COLUMN mes_yield_plan.bps_id IS '镀种小类';
COMMENT ON COLUMN mes_yield_plan.priority IS '优先级;1.正常，2.项目要求日期急件，3.合同急件，4.绩效零件，5.调度标注急件';
COMMENT ON COLUMN mes_yield_plan.sure_type IS '是否确认;是否确认(烧结计划专用，默认为空，1是代表确认，烧结计划不显示)';
COMMENT ON COLUMN mes_yield_plan.close_man IS '关闭人';
COMMENT ON COLUMN mes_yield_plan.close_time IS '关闭时间';
COMMENT ON COLUMN mes_yield_plan.product_line IS '产品系列';

-- 生产订单
CREATE TABLE mes_yield_order
(
    id                   NUMBER(20, 0)            NOT NULL ENABLE,
    tenant_id            NVARCHAR2(12) DEFAULT '000000',
    create_user          NUMBER(20, 0),
    create_dept          NUMBER(20, 0),
    create_time          DATE          DEFAULT SYSDATE,
    update_user          NUMBER(20, 0),
    update_time          DATE          DEFAULT SYSDATE,
    status               NUMBER(11, 0) DEFAULT 1,
    is_deleted           NUMBER(11, 0) DEFAULT 0,
    yo_code              NVARCHAR2(255)           NOT NULL ENABLE,
    yp_code              NVARCHAR2(255),
    part_code            NVARCHAR2(255)           NOT NULL ENABLE,
    product_type         NVARCHAR2(255),
    part_name            NVARCHAR2(255),
    plate                NVARCHAR2(255),
    product_ident        NVARCHAR2(255)           NOT NULL ENABLE,
    use_dept             NVARCHAR2(255),
    yp_area              NUMBER(20, 10)           NOT NULL ENABLE,
    demand_date          DATE,
    plan_user            NVARCHAR2(255),
    release_date         DATE,
    memo                 NVARCHAR2(255),
    card_no              NVARCHAR2(255)           NOT NULL ENABLE,
    batch_no             NVARCHAR2(255)           NOT NULL ENABLE,
    site_work            CHAR(1)                  NOT NULL ENABLE,
    yp_qty               NUMBER                   NOT NULL ENABLE,
    sync_time            DATE                     NOT NULL ENABLE,
    cur_status           NUMBER                   NOT NULL ENABLE,
    roam_no              NVARCHAR2(255),
    primary_craft        NVARCHAR2(900),
    next_roam            NVARCHAR2(255),
    pdm_url              NVARCHAR2(255),
    priority             NUMBER,
    custodian            NVARCHAR2(255),
    rework_code          NVARCHAR2(255),
    rework_no            NUMBER,
    entrust_dept         NVARCHAR2(255),
    rework_memo          NVARCHAR2(900),
    failure_memo         NVARCHAR2(900),
    business_type        NUMBER        DEFAULT -1 NOT NULL ENABLE,
    failure_man          NUMBER(18, 0),
    failure_time         DATE,
    recseq_no            NVARCHAR2(255),
    cart_id              NUMBER(18, 0),
    manual_increase      CHAR(1)       DEFAULT 0,
    yield_type           NUMBER        DEFAULT 1  NOT NULL ENABLE,
    father_yo_id         NUMBER(18, 0),
    newlev_flag          NVARCHAR2(255),
    produce_bool         CHAR(1)       DEFAULT 0,
    use_dept_code        NVARCHAR2(255),
    yp_product_line      NVARCHAR2(255),
    yp_memo              NVARCHAR2(255),
    sj_mold_preparation  NUMBER(18, 0),
    sj_kit_preparation   NUMBER(18, 0),
    pk_username          NVARCHAR2(255),
    pk_date              DATE,
    kit_preparation_man  NVARCHAR2(255),
    kit_preparation_time DATE,
    CONSTRAINT mes_yield_order_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_yield_order IS '生产订单';
COMMENT ON COLUMN mes_yield_order.id IS '主键';
COMMENT ON COLUMN mes_yield_order.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_yield_order.create_user IS '创建人';
COMMENT ON COLUMN mes_yield_order.create_dept IS '创建部门';
COMMENT ON COLUMN mes_yield_order.create_time IS '创建时间';
COMMENT ON COLUMN mes_yield_order.update_user IS '修改人';
COMMENT ON COLUMN mes_yield_order.update_time IS '修改时间';
COMMENT ON COLUMN mes_yield_order.status IS '状态';
COMMENT ON COLUMN mes_yield_order.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_yield_order.yo_code IS '生产单号';
COMMENT ON COLUMN mes_yield_order.yp_code IS '计划单号';
COMMENT ON COLUMN mes_yield_order.part_code IS '零件号';
COMMENT ON COLUMN mes_yield_order.product_type IS '产品型号';
COMMENT ON COLUMN mes_yield_order.part_name IS '名称';
COMMENT ON COLUMN mes_yield_order.plate IS '镀种';
COMMENT ON COLUMN mes_yield_order.product_ident IS '生产标识';
COMMENT ON COLUMN mes_yield_order.use_dept IS '使用部门';
COMMENT ON COLUMN mes_yield_order.yp_area IS '面积（㎡）';
COMMENT ON COLUMN mes_yield_order.demand_date IS '需求交期';
COMMENT ON COLUMN mes_yield_order.plan_user IS '计划员';
COMMENT ON COLUMN mes_yield_order.release_date IS '计划下达时间';
COMMENT ON COLUMN mes_yield_order.memo IS '备注';
COMMENT ON COLUMN mes_yield_order.card_no IS '路线卡号';
COMMENT ON COLUMN mes_yield_order.batch_no IS '批次号';
COMMENT ON COLUMN mes_yield_order.site_work IS '场内生产';
COMMENT ON COLUMN mes_yield_order.yp_qty IS '生产数量';
COMMENT ON COLUMN mes_yield_order.sync_time IS '同步日期';
COMMENT ON COLUMN mes_yield_order.cur_status IS '状态';
COMMENT ON COLUMN mes_yield_order.roam_no IS 'B号';
COMMENT ON COLUMN mes_yield_order.primary_craft IS '一级路线';
COMMENT ON COLUMN mes_yield_order.next_roam IS '下级B号';
COMMENT ON COLUMN mes_yield_order.custodian IS '保管员';
COMMENT ON COLUMN mes_yield_order.rework_code IS '返工单号';
COMMENT ON COLUMN mes_yield_order.rework_no IS '返工顺序';
COMMENT ON COLUMN mes_yield_order.rework_memo IS '返工意见';
COMMENT ON COLUMN mes_yield_order.failure_memo IS '失败原因';
COMMENT ON COLUMN mes_yield_order.business_type IS '业务类型';
COMMENT ON COLUMN mes_yield_order.failure_man IS '分派失败人员';
COMMENT ON COLUMN mes_yield_order.failure_time IS '接收时间';
COMMENT ON COLUMN mes_yield_order.manual_increase IS '手动增加';
COMMENT ON COLUMN mes_yield_order.father_yo_id IS '父级订单Id';
COMMENT ON COLUMN mes_yield_order.produce_bool IS '是否可生产;0:否 1：是';
COMMENT ON COLUMN mes_yield_order.use_dept_code IS '使用部门代码';
COMMENT ON COLUMN mes_yield_order.yp_product_line IS '产品系列（mes_yield_plan.PRODUCT_line）';
COMMENT ON COLUMN mes_yield_order.yp_memo IS '工作订单备注（mes_yield_plan.memo）';
COMMENT ON COLUMN mes_yield_order.sj_mold_preparation IS '烧结石墨模准备状态';
COMMENT ON COLUMN mes_yield_order.sj_kit_preparation IS '烧结齐套流转状态';
COMMENT ON COLUMN mes_yield_order.pk_username IS '配套人';
COMMENT ON COLUMN mes_yield_order.pk_date IS '配套时间';
COMMENT ON COLUMN mes_yield_order.kit_preparation_man IS '流转人';
COMMENT ON COLUMN mes_yield_order.kit_preparation_time IS '流转时间';

-- 生产订单工艺
CREATE TABLE mes_yield_order_craft
(
    id          NUMBER(20, 0)  NOT NULL ENABLE,
    tenant_id   NVARCHAR2(12) DEFAULT '000000',
    create_user NUMBER(20, 0),
    create_dept NUMBER(20, 0),
    create_time DATE          DEFAULT SYSDATE,
    update_user NUMBER(20, 0),
    update_time DATE          DEFAULT SYSDATE,
    status      NUMBER(11, 0) DEFAULT 1,
    is_deleted  NUMBER(11, 0) DEFAULT 0,
    yo_id       NVARCHAR2(255) NOT NULL ENABLE,
    craft_no    NVARCHAR2(255),
    process_no  NVARCHAR2(255) NOT NULL ENABLE,
    pps_id      NUMBER(18, 0)  NOT NULL ENABLE,
    make_memo   NVARCHAR2(900),
    hour_quota  NUMBER(18, 12) NOT NULL ENABLE,
    pid         NUMBER(18, 0),
    start_time  DATE,
    end_time    DATE,
    make_team   NUMBER(18, 0),
    oc_id       NUMBER(18, 0),
    ca_id       NUMBER(18, 0),
    rp_id       NUMBER(18, 0),
    CONSTRAINT mes_yield_order_craft_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_yield_order_craft IS '生产订单工艺';
COMMENT ON COLUMN mes_yield_order_craft.id IS '主键';
COMMENT ON COLUMN mes_yield_order_craft.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_yield_order_craft.create_user IS '创建人';
COMMENT ON COLUMN mes_yield_order_craft.create_dept IS '创建部门';
COMMENT ON COLUMN mes_yield_order_craft.create_time IS '创建时间';
COMMENT ON COLUMN mes_yield_order_craft.update_user IS '修改人';
COMMENT ON COLUMN mes_yield_order_craft.update_time IS '修改时间';
COMMENT ON COLUMN mes_yield_order_craft.status IS '状态';
COMMENT ON COLUMN mes_yield_order_craft.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_yield_order_craft.yo_id IS '生产订单';
COMMENT ON COLUMN mes_yield_order_craft.craft_no IS 'C号';
COMMENT ON COLUMN mes_yield_order_craft.process_no IS '序号';
COMMENT ON COLUMN mes_yield_order_craft.pps_id IS '工序';
COMMENT ON COLUMN mes_yield_order_craft.make_memo IS '工艺描述';
COMMENT ON COLUMN mes_yield_order_craft.make_team IS '加工班组';
COMMENT ON COLUMN mes_yield_order_craft.oc_id IS '外协商';
COMMENT ON COLUMN mes_yield_order_craft.ca_id IS '工艺能力;外键（工艺能力）';
COMMENT ON COLUMN mes_yield_order_craft.rp_id IS '返工工序id';

-- 异常订单
CREATE TABLE mes_yield_error
(
    id          NUMBER(20, 0)  NOT NULL ENABLE,
    tenant_id   NVARCHAR2(12) DEFAULT '000000',
    create_user NUMBER(20, 0),
    create_dept NUMBER(20, 0),
    create_time DATE          DEFAULT SYSDATE,
    update_user NUMBER(20, 0),
    update_time DATE          DEFAULT SYSDATE,
    status      NUMBER(11, 0) DEFAULT 1,
    is_deleted  NUMBER(11, 0) DEFAULT 0,
    yp_id       NUMBER(20, 0),
    yo_id       NUMBER(20, 0),
    ex_type     NUMBER(11, 0)  NOT NULL ENABLE,
    ex_memo     NVARCHAR2(255) NOT NULL ENABLE,
    CONSTRAINT mes_yield_error_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_yield_error IS '异常订单';
COMMENT ON COLUMN mes_yield_error.id IS '主键';
COMMENT ON COLUMN mes_yield_error.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_yield_error.create_user IS '创建人';
COMMENT ON COLUMN mes_yield_error.create_dept IS '创建部门';
COMMENT ON COLUMN mes_yield_error.create_time IS '创建时间';
COMMENT ON COLUMN mes_yield_error.update_user IS '修改人';
COMMENT ON COLUMN mes_yield_error.update_time IS '修改时间';
COMMENT ON COLUMN mes_yield_error.status IS '状态';
COMMENT ON COLUMN mes_yield_error.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_yield_error.yp_id IS '生产计划ID';
COMMENT ON COLUMN mes_yield_error.yo_id IS '生产订单ID';
COMMENT ON COLUMN mes_yield_error.ex_type IS '异常类型，1：数据缺失，2：工艺缺失，3：资源缺失，2：交期冲突';
COMMENT ON COLUMN mes_yield_error.ex_memo IS '异常原因';

-- 镀层物料需求申报
CREATE TABLE mes_plate_goods_record
(
    id                       NUMBER(20, 0)            NOT NULL ENABLE,
    tenant_id                NVARCHAR2(12)  DEFAULT '000000',
    create_user              NUMBER(20, 0),
    create_dept              NUMBER(20, 0),
    create_time              DATE           DEFAULT SYSDATE,
    update_user              NUMBER(20, 0),
    update_time              DATE           DEFAULT SYSDATE,
    status                   NUMBER(11, 0)  DEFAULT 1,
    is_deleted               NUMBER(11, 0)  DEFAULT 0,
    wc_id                    NUMBER(18, 0)            NOT NULL ENABLE,
    plate_goods_code         NVARCHAR2(255)           NOT NULL ENABLE,
    goods_demand             NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    silver_potassium         NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    coefficient              NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    approval_man             NUMBER(20, 0),
    approval_time            DATE,
    approval_status          NUMBER(18, 0),
    approval_memo            NVARCHAR2(255),
    declared_quota           NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    declared_silver          NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    declared_status          NUMBER         DEFAULT 0 NOT NULL ENABLE,
    goods_bo_id              NUMBER(18, 0),
    coefficient_bo_id        NUMBER(18, 0),
    pgr_code                 NVARCHAR2(255),
    surplus                  NUMBER(20, 10) DEFAULT 0,
    silver_potassium_residue NUMBER(20, 10) DEFAULT 0,
    CONSTRAINT mes_plate_goods_record_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_plate_goods_record IS '镀层物料额外需求上报';
COMMENT ON COLUMN mes_plate_goods_record.id IS '主键';
COMMENT ON COLUMN mes_plate_goods_record.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_plate_goods_record.create_user IS '创建人';
COMMENT ON COLUMN mes_plate_goods_record.create_dept IS '创建部门';
COMMENT ON COLUMN mes_plate_goods_record.create_time IS '创建时间';
COMMENT ON COLUMN mes_plate_goods_record.update_user IS '修改人';
COMMENT ON COLUMN mes_plate_goods_record.update_time IS '修改时间';
COMMENT ON COLUMN mes_plate_goods_record.status IS '状态';
COMMENT ON COLUMN mes_plate_goods_record.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_plate_goods_record.wc_id IS '作业中心';
COMMENT ON COLUMN mes_plate_goods_record.plate_goods_code IS '镀层物料';
COMMENT ON COLUMN mes_plate_goods_record.goods_demand IS '物料需求定额';
COMMENT ON COLUMN mes_plate_goods_record.silver_potassium IS '上报银钾';
COMMENT ON COLUMN mes_plate_goods_record.coefficient IS '银钾系数';
COMMENT ON COLUMN mes_plate_goods_record.approval_man IS '审批人';
COMMENT ON COLUMN mes_plate_goods_record.approval_time IS '审批时间';
COMMENT ON COLUMN mes_plate_goods_record.approval_status IS '审批状态';
COMMENT ON COLUMN mes_plate_goods_record.approval_memo IS '审批结果';
COMMENT ON COLUMN mes_plate_goods_record.declared_quota IS '已申报定额';
COMMENT ON COLUMN mes_plate_goods_record.declared_silver IS '已申报银钾';
COMMENT ON COLUMN mes_plate_goods_record.declared_status IS '申报状态';
COMMENT ON COLUMN mes_plate_goods_record.goods_bo_id IS '物料采购id';
COMMENT ON COLUMN mes_plate_goods_record.coefficient_bo_id IS '银钾采购id';
COMMENT ON COLUMN mes_plate_goods_record.surplus IS '剩余量';
COMMENT ON COLUMN mes_plate_goods_record.silver_potassium_residue IS '上报银钾剩余量';


-- 镀层物料需求申报明细
CREATE TABLE mes_plate_goods_record_detail
(
    id          NUMBER(20, 0)  NOT NULL ENABLE,
    tenant_id   NVARCHAR2(12) DEFAULT '000000',
    create_user NUMBER(20, 0),
    create_dept NUMBER(20, 0),
    create_time DATE          DEFAULT SYSDATE,
    update_user NUMBER(20, 0),
    update_time DATE          DEFAULT SYSDATE,
    status      NUMBER(11, 0) DEFAULT 1,
    is_deleted  NUMBER(11, 0) DEFAULT 0,
    pgrd_id     NUMBER(18, 0)  NOT NULL ENABLE,
    yo_id       NVARCHAR2(255) NOT NULL ENABLE,
    CONSTRAINT mes_plate_goods_record_detail_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_plate_goods_record_detail IS '镀层物料需求申报明细';
COMMENT ON COLUMN mes_plate_goods_record_detail.id IS '主键';
COMMENT ON COLUMN mes_plate_goods_record_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_plate_goods_record_detail.create_user IS '创建人';
COMMENT ON COLUMN mes_plate_goods_record_detail.create_dept IS '创建部门';
COMMENT ON COLUMN mes_plate_goods_record_detail.create_time IS '创建时间';
COMMENT ON COLUMN mes_plate_goods_record_detail.update_user IS '修改人';
COMMENT ON COLUMN mes_plate_goods_record_detail.update_time IS '修改时间';
COMMENT ON COLUMN mes_plate_goods_record_detail.status IS '状态';
COMMENT ON COLUMN mes_plate_goods_record_detail.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_plate_goods_record_detail.pgrd_id IS '申报ID';
COMMENT ON COLUMN mes_plate_goods_record_detail.yo_id IS '生产订单ID';

-- 镀层物料添加量申报
CREATE TABLE mes_plate_goods_apply
(
    id              NUMBER(20, 0)             NOT NULL ENABLE,
    tenant_id       NVARCHAR2(12)  DEFAULT '000000',
    create_user     NUMBER(20, 0),
    create_dept     NUMBER(20, 0),
    create_time     DATE           DEFAULT SYSDATE,
    update_user     NUMBER(20, 0),
    update_time     DATE           DEFAULT SYSDATE,
    status          NUMBER(11, 0)  DEFAULT 1,
    is_deleted      NUMBER(11, 0)  DEFAULT 0,
    goods_code      NVARCHAR2(255)            NOT NULL ENABLE,
    goods_demand    NUMBER(20, 10) DEFAULT 0  NOT NULL ENABLE,
    approval_status NUMBER         DEFAULT -1 NOT NULL ENABLE,
    bo_id           NUMBER(18, 0),
    br_id           NUMBER(18, 0),
    ac_id           NUMBER(18, 0),
    pgr_id          NUMBER(18, 0),
    wc_id           NUMBER(18, 0),
    involve_code    NVARCHAR2(255),
    code_num        NVARCHAR2(255),
    CONSTRAINT mes_plate_goods_apply_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_plate_goods_apply IS '镀层物料申报添加量';
COMMENT ON COLUMN mes_plate_goods_apply.id IS '主键';
COMMENT ON COLUMN mes_plate_goods_apply.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_plate_goods_apply.create_user IS '创建人';
COMMENT ON COLUMN mes_plate_goods_apply.create_dept IS '创建部门';
COMMENT ON COLUMN mes_plate_goods_apply.create_time IS '创建时间';
COMMENT ON COLUMN mes_plate_goods_apply.update_user IS '修改人';
COMMENT ON COLUMN mes_plate_goods_apply.update_time IS '修改时间';
COMMENT ON COLUMN mes_plate_goods_apply.status IS '状态';
COMMENT ON COLUMN mes_plate_goods_apply.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_plate_goods_apply.goods_code IS '镀层物料号';
COMMENT ON COLUMN mes_plate_goods_apply.goods_demand IS '申报镀层';
COMMENT ON COLUMN mes_plate_goods_apply.approval_status IS '审批状态';
COMMENT ON COLUMN mes_plate_goods_apply.bo_id IS '采购Id';
COMMENT ON COLUMN mes_plate_goods_apply.br_id IS '领料单Id';
COMMENT ON COLUMN mes_plate_goods_apply.involve_code IS '涉及单号';
COMMENT ON COLUMN mes_plate_goods_apply.code_num IS '涉及单号及数量';


-- 镀层物料添加量申报明细
CREATE TABLE mes_plate_goods_apply_detail
(
    id              NUMBER(20, 0)             NOT NULL ENABLE,
    tenant_id       NVARCHAR2(12)  DEFAULT '000000',
    create_user     NUMBER(20, 0),
    create_dept     NUMBER(20, 0),
    create_time     DATE           DEFAULT SYSDATE,
    update_user     NUMBER(20, 0),
    update_time     DATE           DEFAULT SYSDATE,
    status          NUMBER(11, 0)  DEFAULT 1,
    is_deleted      NUMBER(11, 0)  DEFAULT 0,
    goods_code      NVARCHAR2(255)            NOT NULL ENABLE,
    goods_demand    NUMBER(20, 10) DEFAULT 0  NOT NULL ENABLE,
    approval_status NUMBER         DEFAULT -1 NOT NULL ENABLE,
    pgad_id         NUMBER(20, 0),
    involve_code    NVARCHAR2(255),
    CONSTRAINT mes_plate_goods_apply_detail_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_plate_goods_apply_detail IS '镀层物料添加量申报明细';
COMMENT ON COLUMN mes_plate_goods_apply_detail.id IS '主键';
COMMENT ON COLUMN mes_plate_goods_apply_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_plate_goods_apply_detail.create_user IS '创建人';
COMMENT ON COLUMN mes_plate_goods_apply_detail.create_dept IS '创建部门';
COMMENT ON COLUMN mes_plate_goods_apply_detail.create_time IS '创建时间';
COMMENT ON COLUMN mes_plate_goods_apply_detail.update_user IS '修改人';
COMMENT ON COLUMN mes_plate_goods_apply_detail.update_time IS '修改时间';
COMMENT ON COLUMN mes_plate_goods_apply_detail.status IS '状态';
COMMENT ON COLUMN mes_plate_goods_apply_detail.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_plate_goods_apply_detail.pgad_id IS '添加量申报ID';
COMMENT ON COLUMN mes_plate_goods_apply_detail.involve_code IS '涉及单号';

-- 化验含量
CREATE TABLE mes_assay_content
(
    id               NUMBER(20, 0)            NOT NULL ENABLE,
    tenant_id        NVARCHAR2(12)  DEFAULT '000000',
    create_user      NUMBER(20, 0),
    create_dept      NUMBER(20, 0),
    create_time      DATE           DEFAULT SYSDATE,
    update_user      NUMBER(20, 0),
    update_time      DATE           DEFAULT SYSDATE,
    status           NUMBER(11, 0)  DEFAULT 1,
    is_deleted       NUMBER(11, 0)  DEFAULT 0,
    wc_id            NUMBER(18, 0)            NOT NULL ENABLE,
    assay_man        NUMBER(18, 0)            NOT NULL ENABLE,
    assay_time       DATE                     NOT NULL ENABLE,
    apply_status     NUMBER         DEFAULT 0 NOT NULL ENABLE,
    gold_potassium   NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    silver_potassium NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    silver_plate     NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    CONSTRAINT mes_assay_content_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_assay_content IS '化验含量';
COMMENT ON COLUMN mes_assay_content.id IS '主键';
COMMENT ON COLUMN mes_assay_content.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_assay_content.create_user IS '创建人';
COMMENT ON COLUMN mes_assay_content.create_dept IS '创建部门';
COMMENT ON COLUMN mes_assay_content.create_time IS '创建时间';
COMMENT ON COLUMN mes_assay_content.update_user IS '修改人';
COMMENT ON COLUMN mes_assay_content.update_time IS '修改时间';
COMMENT ON COLUMN mes_assay_content.status IS '状态';
COMMENT ON COLUMN mes_assay_content.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_assay_content.wc_id IS '作业中心';
COMMENT ON COLUMN mes_assay_content.assay_man IS '化验人';
COMMENT ON COLUMN mes_assay_content.assay_time IS '化验时间';
COMMENT ON COLUMN mes_assay_content.apply_status IS '申报状态';
COMMENT ON COLUMN mes_assay_content.gold_potassium IS '金钾申报量';
COMMENT ON COLUMN mes_assay_content.silver_potassium IS '银钾申报量';
COMMENT ON COLUMN mes_assay_content.silver_plate IS '银板申报量';

-- 化验含量明细
CREATE TABLE mes_assay_content_detail
(
    id              NUMBER(20, 0)            NOT NULL ENABLE,
    tenant_id       NVARCHAR2(12)  DEFAULT '000000',
    create_user     NUMBER(20, 0),
    create_dept     NUMBER(20, 0),
    create_time     DATE           DEFAULT SYSDATE,
    update_user     NUMBER(20, 0),
    update_time     DATE           DEFAULT SYSDATE,
    status          NUMBER(11, 0)  DEFAULT 1,
    is_deleted      NUMBER(11, 0)  DEFAULT 0,
    ac_id           NUMBER(18, 0)            NOT NULL ENABLE,
    slot            NVARCHAR2(255)           NOT NULL ENABLE,
    test_val        NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    save_gold_val   NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    save_silver_val NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    save_board_val  NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    actual_val      NUMBER(20, 10) DEFAULT 0 NOT NULL ENABLE,
    CONSTRAINT mes_assay_content_detail_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_assay_content_detail IS '化验含量明细';
COMMENT ON COLUMN mes_assay_content_detail.id IS '主键';
COMMENT ON COLUMN mes_assay_content_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_assay_content_detail.create_user IS '创建人';
COMMENT ON COLUMN mes_assay_content_detail.create_dept IS '创建部门';
COMMENT ON COLUMN mes_assay_content_detail.create_time IS '创建时间';
COMMENT ON COLUMN mes_assay_content_detail.update_user IS '修改人';
COMMENT ON COLUMN mes_assay_content_detail.update_time IS '修改时间';
COMMENT ON COLUMN mes_assay_content_detail.status IS '状态';
COMMENT ON COLUMN mes_assay_content_detail.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_assay_content_detail.ac_id IS '化验记录';
COMMENT ON COLUMN mes_assay_content_detail.slot IS '槽号';
COMMENT ON COLUMN mes_assay_content_detail.test_val IS '化验值';
COMMENT ON COLUMN mes_assay_content_detail.save_gold_val IS '申报添加金钾';
COMMENT ON COLUMN mes_assay_content_detail.save_silver_val IS '申报添加银钾';
COMMENT ON COLUMN mes_assay_content_detail.save_board_val IS '申报添加银板';
COMMENT ON COLUMN mes_assay_content_detail.actual_val IS '实际值';

-- 烧结模具计划
CREATE TABLE mes_mold_plan
(
    id             NUMBER(20, 0)            NOT NULL ENABLE,
    tenant_id      NVARCHAR2(12)  DEFAULT '000000',
    create_user    NUMBER(20, 0),
    create_dept    NUMBER(20, 0),
    create_time    DATE           DEFAULT SYSDATE,
    update_user    NUMBER(20, 0),
    update_time    DATE           DEFAULT SYSDATE,
    status         NUMBER(11, 0)  DEFAULT 1,
    is_deleted     NUMBER(11, 0)  DEFAULT 0,
    mo_code        NVARCHAR2(255),
    mo_name        NVARCHAR2(255),
    quantity       NUMBER                   NOT NULL ENABLE,
    erp_id         NUMBER(18, 0),
    yp_id          NUMBER(18, 0),
    erp_wo_code    NVARCHAR2(255),
    maf_status     NUMBER         DEFAULT 1 NOT NULL ENABLE,
    plan_type      NVARCHAR2(255),
    need_date      DATE,
    keeper         NUMBER(18, 0),
    releaser       NUMBER(18, 0),
    qua_level      NVARCHAR2(255),
    plan_type_name NVARCHAR2(255),
    part_code      NVARCHAR2(255),
    part_name      NVARCHAR2(255),
    memo           NVARCHAR2(900),
    maf_type       NUMBER         DEFAULT 1 NOT NULL ENABLE,
    urgent_type    NVARCHAR2(255) DEFAULT 0 NOT NULL ENABLE,
    CONSTRAINT mes_mold_plan_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_mold_plan IS '烧结模具计划';
COMMENT ON COLUMN mes_mold_plan.id IS '主键';
COMMENT ON COLUMN mes_mold_plan.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_mold_plan.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_plan.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_plan.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_plan.update_user IS '修改人';
COMMENT ON COLUMN mes_mold_plan.update_time IS '修改时间';
COMMENT ON COLUMN mes_mold_plan.status IS '状态';
COMMENT ON COLUMN mes_mold_plan.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_mold_plan.mo_code IS '模具编码';
COMMENT ON COLUMN mes_mold_plan.mo_name IS '模具名称';
COMMENT ON COLUMN mes_mold_plan.quantity IS '数量';
COMMENT ON COLUMN mes_mold_plan.erp_id IS 'erpId';
COMMENT ON COLUMN mes_mold_plan.yp_id IS '生产计划id';
COMMENT ON COLUMN mes_mold_plan.maf_status IS '状态;1、新建，2、已下发，3、已完成';
COMMENT ON COLUMN mes_mold_plan.plan_type IS '计划类型名称';
COMMENT ON COLUMN mes_mold_plan.need_date IS '需求日期';
COMMENT ON COLUMN mes_mold_plan.keeper IS '保管员';
COMMENT ON COLUMN mes_mold_plan.releaser IS '下达人';
COMMENT ON COLUMN mes_mold_plan.qua_level IS '生产标识';
COMMENT ON COLUMN mes_mold_plan.part_code IS '零件编码';
COMMENT ON COLUMN mes_mold_plan.part_name IS '零件名称';
COMMENT ON COLUMN mes_mold_plan.memo IS '备注';
COMMENT ON COLUMN mes_mold_plan.maf_type IS '类型;1、热表，烧结，2、仓库';
COMMENT ON COLUMN mes_mold_plan.urgent_type IS '紧急状态';


-- 烧结模具计划-工装关联表
CREATE TABLE mes_mold_plan_tool
(
    id          NUMBER(20, 0) NOT NULL ENABLE,
    tenant_id   NVARCHAR2(12) DEFAULT '000000',
    create_user NUMBER(20, 0),
    create_dept NUMBER(20, 0),
    create_time DATE          DEFAULT SYSDATE,
    update_user NUMBER(20, 0),
    update_time DATE          DEFAULT SYSDATE,
    status      NUMBER(11, 0) DEFAULT 1,
    is_deleted  NUMBER(11, 0) DEFAULT 0,
    mp_id       NUMBER(20, 0),
    tool_id     NUMBER(20, 0),
    CONSTRAINT mes_mold_plan_tool_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_mold_plan_tool IS '烧结模具计划-工装关联表';
COMMENT ON COLUMN mes_mold_plan_tool.id IS '主键';
COMMENT ON COLUMN mes_mold_plan_tool.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_mold_plan_tool.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_plan_tool.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_plan_tool.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_plan_tool.update_user IS '修改人';
COMMENT ON COLUMN mes_mold_plan_tool.update_time IS '修改时间';
COMMENT ON COLUMN mes_mold_plan_tool.status IS '状态';
COMMENT ON COLUMN mes_mold_plan_tool.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_mold_plan_tool.mp_id IS '烧结模具计划ID';
COMMENT ON COLUMN mes_mold_plan_tool.tool_id IS '工装id';

-- 烧结模具计划-订单关联表
CREATE TABLE mes_mold_plan_order
(
    id          NUMBER(20, 0) NOT NULL ENABLE,
    tenant_id   NVARCHAR2(12) DEFAULT '000000',
    create_user NUMBER(20, 0),
    create_dept NUMBER(20, 0),
    create_time DATE          DEFAULT SYSDATE,
    update_user NUMBER(20, 0),
    update_time DATE          DEFAULT SYSDATE,
    status      NUMBER(11, 0) DEFAULT 1,
    is_deleted  NUMBER(11, 0) DEFAULT 0,
    mp_id       NUMBER(20, 0),
    yo_id       NUMBER(20, 0),
    CONSTRAINT mes_mold_plan_order_pk PRIMARY KEY (id)
) TABLESPACE JONHON_MES_DATA;

COMMENT ON TABLE mes_mold_plan_order IS '烧结模具计划-订单关联表';
COMMENT ON COLUMN mes_mold_plan_order.id IS '主键';
COMMENT ON COLUMN mes_mold_plan_order.tenant_id IS '租户ID';
COMMENT ON COLUMN mes_mold_plan_order.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_plan_order.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_plan_order.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_plan_order.update_user IS '修改人';
COMMENT ON COLUMN mes_mold_plan_order.update_time IS '修改时间';
COMMENT ON COLUMN mes_mold_plan_order.status IS '状态';
COMMENT ON COLUMN mes_mold_plan_order.is_deleted IS '是否已删除';
COMMENT ON COLUMN mes_mold_plan_tool.mp_id IS '烧结模具计划ID';
COMMENT ON COLUMN mes_mold_plan_tool.tool_id IS '生产订单id';
