-- 化验明细添加槽号对应名称字段
ALTER TABLE mes_assay_content_detail
	ADD slot_name VARCHAR2(100) NULL;
COMMENT ON COLUMN mes_assay_content_detail.slot_name IS '槽名称';

-- 摸具申报添加字段
ALTER TABLE mes_mold_plan
	ADD stock_num NUMBER(8, 0) NULL;
COMMENT ON COLUMN mes_mold_plan.stock_num IS '库存量';
ALTER TABLE mes_mold_plan
	ADD occupy_num NUMBER(8, 0) NULL;
COMMENT ON COLUMN mes_mold_plan.occupy_num IS '占用量';
ALTER TABLE mes_mold_plan
	ADD link_order_ids VARCHAR2(255) NULL;
COMMENT ON COLUMN mes_mold_plan.link_order_ids IS 'LINK_ORDER_IDS';

-- 字段长度修改
ALTER TABLE mes_assay_content
	MODIFY wc_id NUMBER(20, 0);
ALTER TABLE mes_assay_content
	MODIFY assay_man NUMBER(20, 0);
ALTER TABLE mes_assay_content
	MODIFY apply_id NUMBER(20, 0);
ALTER TABLE mes_assay_content
	MODIFY apply_status NUMBER(8, 0) DEFAULT 0;
ALTER TABLE mes_assay_content
	MODIFY is_used NUMBER(8, 0);
ALTER TABLE mes_assay_content_detail
	MODIFY ac_id NUMBER(20, 0);
ALTER TABLE mes_mold_plan
	MODIFY erp_id NUMBER(20, 0);
ALTER TABLE mes_mold_plan
	MODIFY yp_id NUMBER(20, 0);
ALTER TABLE mes_mold_plan
	MODIFY keeper NUMBER(20, 0);
ALTER TABLE mes_mold_plan
	MODIFY releaser NUMBER(20, 0);
ALTER TABLE mes_plate_goods_apply
	MODIFY bo_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_apply
	MODIFY br_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_apply
	MODIFY ac_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_apply
	MODIFY pgr_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_apply
	MODIFY wc_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_record
	MODIFY wc_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_record
	MODIFY approval_status NUMBER(20, 0);
ALTER TABLE mes_plate_goods_record
	MODIFY goods_bo_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_record
	MODIFY coefficient_bo_id NUMBER(20, 0);
ALTER TABLE mes_plate_goods_record_detail
	MODIFY pgrd_id NUMBER(20, 0);

ALTER TABLE mes_plate_goods_record
	ADD involving_record_code VARCHAR2(255) NULL;
COMMENT ON COLUMN mes_plate_goods_record.involving_record_code IS '本次添加涉及单号';
ALTER TABLE mes_plate_goods_record
	ADD detail_order_num NUMBER(8, 0) NULL;
COMMENT ON COLUMN mes_plate_goods_record.detail_order_num IS '本次关联订单数量';

ALTER TABLE mes_assay_content_detail
	ADD add_val NUMBER(20, 10) NULL;
COMMENT ON COLUMN mes_assay_content_detail.add_val IS '添加量值';

ALTER TABLE mes_yield_order
	ADD goods_demand NUMBER(20,10) NULL;
COMMENT ON COLUMN mes_yield_order.goods_demand IS '物料需求数量';

ALTER TABLE mes_yield_order
	ADD tools_demand NUMBER(20,10) NULL;
COMMENT ON COLUMN mes_yield_order.tools_demand IS '工装需求数量';

ALTER TABLE mes_yield_order
	ADD PLATE_GOODS_CODE NVARCHAR2(255) NULL;
COMMENT ON COLUMN mes_yield_order.PLATE_GOODS_CODE IS '需求镀层物料编码';

CREATE TABLE mes_mold_apply
(
	id             NUMBER(20, 0)   NOT NULL ENABLE,
	tenant_id      NVARCHAR2(12),
	create_user    NUMBER(20, 0),
	create_time    DATE,
	create_dept    NUMBER(20, 0),
	update_user    NUMBER(20, 0),
	update_time    DATE,
	status         NUMBER(11, 0)   NOT NULL ENABLE,
	is_deleted     NUMBER(11, 0),
	part_code      VARCHAR2(255)   NULL,
	part_name      VARCHAR2(255)   NULL,
	tool_code      VARCHAR2(255)   NULL,
	tool_name      VARCHAR2(255)   NULL,
	apply_num      NUMBER(20,10) NULL,
	plan_type_code VARCHAR2(255)   NULL,
	plan_type_name VARCHAR2(255)   NULL,
	need_date      DATE            NULL,
	qua_level      VARCHAR2(255)   NULL,
	maf_type       DECIMAL(10, 0)  NULL,
	keeper         DECIMAL(20, 0)  NULL,
	releaser       VARCHAR2(255)   NULL,
	memo           VARCHAR2(255)   NULL
) TABLESPACE jonhon_mes_data;
COMMENT ON TABLE mes_mold_apply IS '烧结模具计划-申报';
COMMENT ON COLUMN mes_mold_apply.id IS '主键';
COMMENT ON COLUMN mes_mold_apply.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_apply.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_apply.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_apply.update_user IS '更新人';
COMMENT ON COLUMN mes_mold_apply.update_time IS '更新时间';
COMMENT ON COLUMN mes_mold_apply.status IS '状态';
COMMENT ON COLUMN mes_mold_apply.is_deleted IS '删除标记';
COMMENT ON COLUMN mes_mold_apply.part_code IS '零件编码';
COMMENT ON COLUMN mes_mold_apply.part_name IS '零件名称';
COMMENT ON COLUMN mes_mold_apply.tool_code IS '工装编码';
COMMENT ON COLUMN mes_mold_apply.tool_name IS '工装名称';
COMMENT ON COLUMN mes_mold_apply.apply_num IS '申报数量';
COMMENT ON COLUMN mes_mold_apply.plan_type_code IS '计划类型; 13001:Z:制造(工装不为空且工装名称为压饼模),13002:D:夹具(工装不为空且工装名称为石墨模)';
COMMENT ON COLUMN mes_mold_apply.plan_type_name IS '计划类型; 13001:Z:制造(工装不为空且工装名称为压饼模),13002:D:夹具(工装不为空且工装名称为石墨模)';
COMMENT ON COLUMN mes_mold_apply.need_date IS '需求日期';
COMMENT ON COLUMN mes_mold_apply.qua_level IS '生产标识';
COMMENT ON COLUMN mes_mold_apply.maf_type IS '类型; 12001、热表，烧结，12002、仓库';
COMMENT ON COLUMN mes_mold_apply.keeper IS '保管员';
COMMENT ON COLUMN mes_mold_apply.releaser IS '下达人';
COMMENT ON COLUMN mes_mold_apply.memo IS '备注';


CREATE TABLE mes_mold_demand
(
	id             NUMBER(20, 0)   NOT NULL ENABLE,
	tenant_id      NVARCHAR2(12),
	create_user    NUMBER(20, 0),
	create_time    DATE,
	create_dept    NUMBER(20, 0),
	update_user    NUMBER(20, 0),
	update_time    DATE,
	status         NUMBER(11, 0)   NOT NULL ENABLE,
	is_deleted     NUMBER(11, 0),
	md_code        VARCHAR2(255)   NULL,
	part_code      VARCHAR2(255)   NULL,
	part_name      VARCHAR2(255)   NULL,
	tool_code      VARCHAR2(255)   NULL,
	tool_name      VARCHAR2(255)   NULL,
	demand_num     NUMBER(20,10) NULL,
	plan_type_code VARCHAR2(255)   NULL,
	plan_type_name VARCHAR2(255)   NULL,
	need_date      DATE            NULL,
	qua_level      VARCHAR2(255)   NULL,
	maf_type       DECIMAL(10, 0)  NULL,
	keeper         DECIMAL(20, 0)  NULL,
	releaser       VARCHAR2(255)   NULL,
	memo           VARCHAR2(255)   NULL,
	"SOURCE"       DECIMAL(8, 0)   NULL,
	stock_num      NUMBER(20,10) NULL,
	occupy_num     NUMBER(20,10) NULL,
	link_order_ids VARCHAR2(255)   NULL,
	mo_code        VARCHAR2(100)   NULL,
	mo_name        VARCHAR2(100)   NULL,
	quantity       NUMBER(20,10) NULL,
	yp_id          DECIMAL(20, 0)  NULL,
	erp_id         DECIMAL(20, 0)  NULL,
	erp_wo_code    VARCHAR2(100)   NULL,
	maf_status     DECIMAL(8, 0)   NULL,
	urgent_type    VARCHAR2(100)   NULL
) TABLESPACE jonhon_mes_data;
COMMENT ON TABLE mes_mold_demand IS '烧结模具计划-需求';
COMMENT ON COLUMN mes_mold_demand.id IS '主键';
COMMENT ON COLUMN mes_mold_demand.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_demand.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_demand.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_demand.update_user IS '更新人';
COMMENT ON COLUMN mes_mold_demand.update_time IS '更新时间';
COMMENT ON COLUMN mes_mold_demand.status IS '状态';
COMMENT ON COLUMN mes_mold_demand.is_deleted IS '删除标记';
COMMENT ON COLUMN mes_mold_demand.md_code IS '需求单号';
COMMENT ON COLUMN mes_mold_demand.part_code IS '零件编码';
COMMENT ON COLUMN mes_mold_demand.part_name IS '零件名称';
COMMENT ON COLUMN mes_mold_demand.tool_code IS '工装编码';
COMMENT ON COLUMN mes_mold_demand.tool_name IS '工装名称';
COMMENT ON COLUMN mes_mold_demand.demand_num IS '需求数量';
COMMENT ON COLUMN mes_mold_demand.plan_type_code IS '计划类型; 13001:Z:制造(工装不为空且工装名称为压饼模),13002:D:夹具(工装不为空且工装名称为石墨模)';
COMMENT ON COLUMN mes_mold_demand.plan_type_name IS '计划类型; 13001:Z:制造(工装不为空且工装名称为压饼模),13002:D:夹具(工装不为空且工装名称为石墨模)';
COMMENT ON COLUMN mes_mold_demand.need_date IS '需求日期';
COMMENT ON COLUMN mes_mold_demand.qua_level IS '生产标识';
COMMENT ON COLUMN mes_mold_demand.maf_type IS '类型; 12001、热表，烧结，12002、仓库';
COMMENT ON COLUMN mes_mold_demand.keeper IS '保管员';
COMMENT ON COLUMN mes_mold_demand.releaser IS '下达人';
COMMENT ON COLUMN mes_mold_demand.memo IS '备注';
COMMENT ON COLUMN mes_mold_demand."SOURCE" IS '计划来源;15001:自动生成，15002：人工添加';
COMMENT ON COLUMN mes_mold_demand.stock_num IS '库存量';
COMMENT ON COLUMN mes_mold_demand.occupy_num IS '占用量';
COMMENT ON COLUMN mes_mold_demand.link_order_ids IS '关联生产订单, 多个订单以'',''分割';
COMMENT ON COLUMN mes_mold_demand.mo_code IS '模具编码';
COMMENT ON COLUMN mes_mold_demand.mo_name IS '模具名称';
COMMENT ON COLUMN mes_mold_demand.quantity IS '数量';
COMMENT ON COLUMN mes_mold_demand.yp_id IS '生产计划id';
COMMENT ON COLUMN mes_mold_demand.erp_id IS 'erpId';
COMMENT ON COLUMN mes_mold_demand.erp_wo_code IS 'erpCode';
COMMENT ON COLUMN mes_mold_demand.maf_status IS '状态; 11001、新建，11002:已下发，11003、已完成';
COMMENT ON COLUMN mes_mold_demand.urgent_type IS '紧急状态';

CREATE TABLE mes_mold_demand_detail
(
	id          NUMBER(20, 0) NOT NULL ENABLE,
	tenant_id   NVARCHAR2(12),
	create_user NUMBER(20, 0),
	create_time DATE,
	create_dept NUMBER(20, 0),
	update_user NUMBER(20, 0),
	update_time DATE,
	status      NUMBER(11, 0) NOT NULL ENABLE,
	is_deleted  NUMBER(11, 0),
	md_id       NUMBER(20, 0) NULL,
	order_id    NUMBER(20, 0) NULL
) TABLESPACE jonhon_mes_data;
COMMENT ON TABLE mes_mold_demand_detail IS '烧结模具计划-订单关联表';
COMMENT ON COLUMN mes_mold_demand_detail.id IS '主键';
COMMENT ON COLUMN mes_mold_demand_detail.create_user IS '创建人';
COMMENT ON COLUMN mes_mold_demand_detail.create_time IS '创建时间';
COMMENT ON COLUMN mes_mold_demand_detail.create_dept IS '创建部门';
COMMENT ON COLUMN mes_mold_demand_detail.update_user IS '更新人';
COMMENT ON COLUMN mes_mold_demand_detail.update_time IS '更新时间';
COMMENT ON COLUMN mes_mold_demand_detail.status IS '状态';
COMMENT ON COLUMN mes_mold_demand_detail.is_deleted IS '删除标记';
COMMENT ON COLUMN mes_mold_demand_detail.md_id IS '烧结模具计划需求ID';
COMMENT ON COLUMN mes_mold_demand_detail.order_id IS '生产订单id';

ALTER TABLE mes_yield_plan
	ADD generate_glass_cake SMALLINT DEFAULT 0 NULL;
COMMENT ON COLUMN mes_yield_plan.generate_glass_cake IS '是否生成玻璃饼订单, 0:否，1：是';

ALTER TABLE mes_yield_plan
	ADD check_close_time DATE NULL;
COMMENT ON COLUMN mes_yield_plan.check_close_time IS '验证关闭时间';
ALTER TABLE mes_yield_plan
	ADD check_totqty_time DATE NULL;
COMMENT ON COLUMN mes_yield_plan.check_totqty_time IS '验证完工数时间';

ALTER TABLE MES_RECORDER
    MODIFY (RECORDER NVARCHAR2(255));
--varchar不允许修改为clob类型，所以先删除再添加
ALTER TABLE MES_RECORDER DROP COLUMN MEMO;
ALTER TABLE MES_RECORDER ADD (MEMO CLOB);
