----- 2021年3月8号
-- 工作站表
ALTER TABLE "basic_workstation" RENAME  status TO artificial_type ;
-- 人员表
ALTER TABLE "production_product_output_staff" RENAME  status TO artificial_type ;
-- 2021年3月10号
-- 人员表
ALTER TABLE "basic_staff" ADD COLUMN "personnel_factor" numeric(12,3) DEFAULT 0;
-- 2021年3月12号
-- 上班记录表
ALTER TABLE "production_duty_record" ADD COLUMN "now_duty_date" varchar(250) COLLATE "pg_catalog"."default";
-- 2021年3月23号
-- 人员表
ALTER TABLE "production_product_output_staff"  ADD COLUMN "staff_id" int8;
-- 2021年3月25号
-- 工序模板表
CREATE TABLE "public"."technology_operation_template" (
  "id" int8 NOT NULL,
  "operation_template_name" varchar(255) COLLATE "pg_catalog"."default",
  "operation_template_no" varchar(255) COLLATE "pg_catalog"."default",
  "operation_template_type" varchar(255) COLLATE "pg_catalog"."default",
  "remark" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "technology_operation_template_pkey" PRIMARY KEY ("id")
)
;
-- 工序模板与工序参数关联表
CREATE TABLE "public"."technology_operation_join_template" (
  "technology_operation_param_id" int8 NOT NULL,
  "technology_operation_template_id" int8 NOT NULL
);




-- 2021年3月26号
-- 工序与工序模板关联表
ALTER TABLE "technology_join_operation_param" RENAME TO "technology_join_operation_template";
ALTER TABLE "technology_join_operation_template" RENAME  technology_param_id TO technology_template_id ;
-- 2021年3月29号
-- 工序模板与工序参数关联表
ALTER TABLE "technology_join_operation_template"  ADD COLUMN "sort" int8;

-- 2021年4月2号
-- 工序模板
ALTER TABLE "technology_operation_template" RENAME TO "basic_template";
-- 工序参数
ALTER TABLE "technology_param" RENAME TO "basic_param"  ;
-- 工序参数关联工序模板
ALTER TABLE "technology_operation_join_template" RENAME TO "basic_param_join_template";
-- 2021年4月6号
-- 工艺路线复制模板表
ALTER TABLE "technology_operation_template_copy" RENAME TO "technology_routing_operation_template";
-- 模板类型
CREATE SEQUENCE "public"."basic_template_type_relation_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."basic_template_type_relation" (
  "id" int8 NOT NULL DEFAULT nextval('basic_template_type_relation_id_seq'::regclass),
  "template_type_name" varchar(255) COLLATE "pg_catalog"."default",
  "data_type" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "create_user" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "basic_template_type_relation_pkey" PRIMARY KEY ("id"),
  CONSTRAINT "template_type_name_uniq" UNIQUE ("template_type_name")
)
;

ALTER SEQUENCE "public"."basic_template_type_relation_id_seq"
    OWNED BY "public"."basic_template_type_relation"."id";

ALTER SEQUENCE "public"."basic_template_type_relation_id_seq" OWNER TO "postgres";

-- 2021年4月6号
-- 制造订单复制参数表
CREATE SEQUENCE "public"."plan_routing_operation_param_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."plan_routing_operation_param" (
  "id" int8 NOT NULL DEFAULT nextval('plan_routing_operation_param_id_seq'::regclass),
  "routing_id" int8,
  "code" varchar(255) COLLATE "pg_catalog"."default",
  "parameter_item" varchar(255) COLLATE "pg_catalog"."default",
  "type" varchar(255) COLLATE "pg_catalog"."default",
  "unit" varchar(255) COLLATE "pg_catalog"."default",
  "param_value" varchar(255) COLLATE "pg_catalog"."default",
  "operation_id" int8,
  "routing_operation_id" int8,
  "operation_template_id" int8,
 CONSTRAINT "plan_routing_operation_param_pkey" PRIMARY KEY ("id")
)
;

ALTER SEQUENCE "public"."plan_routing_operation_param_id_seq"
    OWNED BY "public"."plan_routing_operation_param"."id";

ALTER SEQUENCE "public"."plan_routing_operation_param_id_seq" OWNER TO "postgres";


-- 制造订单复制模板表
CREATE SEQUENCE "public"."plan_routing_operation_template_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."plan_routing_operation_template" (
  "id" int8 NOT NULL DEFAULT nextval('plan_routing_operation_template_id_seq'::regclass),
  "operation_template_name" varchar(255) COLLATE "pg_catalog"."default",
  "operation_template_no" varchar(255) COLLATE "pg_catalog"."default",
  "operation_template_type" varchar(255) COLLATE "pg_catalog"."default",
  "remark" varchar(2000) COLLATE "pg_catalog"."default",
  "routing_operation_id" int8,
  "data_type" varchar(255) COLLATE "pg_catalog"."default",
  "system_no" varchar(255) COLLATE "pg_catalog"."default",
  "mo_id" int8,
   CONSTRAINT "plan_routing_operation_template_pkey" PRIMARY KEY ("id")
)
;

ALTER SEQUENCE "public"."plan_routing_operation_template_id_seq"
    OWNED BY "public"."plan_routing_operation_template"."id";

ALTER SEQUENCE "public"."plan_routing_operation_template_id_seq" OWNER TO "postgres";

-- 2021年4月6号
-- 工艺路线复制模板表
ALTER TABLE "public"."technology_routing_operation_template" ADD COLUMN "system_no" varchar(250) COLLATE "pg_catalog"."default";
-- 2021年4月7号
-- 工序模板
ALTER TABLE "basic_template" RENAME  operation_template_name TO template_name ;
ALTER TABLE "basic_template" RENAME  operation_template_no TO template_no ;
ALTER TABLE "basic_template" RENAME  operation_template_type TO template_type ;
-- 2021年4月8号
-- 工作台参数
CREATE SEQUENCE "public"."production_operation_task_param_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."production_operation_task_param" (
  "id" int8 NOT NULL DEFAULT nextval('production_operation_task_param_id_seq'::regclass),
  "code" varchar(255) COLLATE "pg_catalog"."default",
  "parameter_item" varchar(255) COLLATE "pg_catalog"."default",
  "type" varchar(255) COLLATE "pg_catalog"."default",
  "unit" varchar(255) COLLATE "pg_catalog"."default",
  "param_value" varchar(255) COLLATE "pg_catalog"."default",
  "operation_template_id" int8,
  "operation_task_id" int8,
  CONSTRAINT "production_operation_task_param_pkey" PRIMARY KEY ("id")
)
;
ALTER SEQUENCE "public"."production_operation_task_param_id_seq"
    OWNED BY "public"."production_operation_task_param"."id";

ALTER SEQUENCE "public"."production_operation_task_param_id_seq" OWNER TO "postgres";
-- 2021年4月9号
-- 工作台产出表
ALTER TABLE "public"."production_product_output" RENAME  out_system_no TO system_no ;
-- 2021年4月13号
-- 工作台投料表
ALTER TABLE "public"."production_product_input" ADD COLUMN "system_no" varchar(2000) COLLATE "pg_catalog"."default";
-- 2021年4月13号
-- 实时库存
ALTER TABLE "public"."warehouse_stock" ADD COLUMN "system_no" varchar(2000) COLLATE "pg_catalog"."default";


-- 2021年4月16号
--客户订单参数
CREATE SEQUENCE "public"."plan_customer_order_param_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."plan_customer_order_param" (
  "id" int8 NOT NULL DEFAULT nextval('plan_customer_order_param_id_seq'::regclass),
  "order_id" int8,
  "field" varchar(255) COLLATE "pg_catalog"."default",
  "value" varchar(255) COLLATE "pg_catalog"."default",
  "order_param_id" int8,
  CONSTRAINT "plan_customer_order_param_pkey" PRIMARY KEY ("id")
)
;
ALTER SEQUENCE "public"."plan_customer_order_param_id_seq"
    OWNED BY "public"."plan_customer_order_param"."id";

ALTER TABLE "public"."plan_customer_order_param"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_customer_order_param"."id" IS 'id';

COMMENT ON COLUMN "public"."plan_customer_order_param"."order_id" IS '订单id';

COMMENT ON COLUMN "public"."plan_customer_order_param"."field" IS '参数对应字段';

COMMENT ON COLUMN "public"."plan_customer_order_param"."value" IS '参数值';

COMMENT ON COLUMN "public"."plan_customer_order_param"."order_param_id" IS '订单参数id';


--订单参数
CREATE SEQUENCE "public"."plan_order_param_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."plan_order_param" (
  "id" int8 NOT NULL DEFAULT nextval('plan_order_param_id_seq'::regclass),
  "code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  "item" varchar(255) COLLATE "pg_catalog"."default",
  "type" varchar(255) COLLATE "pg_catalog"."default",
  "source" varchar(255) COLLATE "pg_catalog"."default",
  "field" varchar(255) COLLATE "pg_catalog"."default",
  "distinguish" varchar(255) COLLATE "pg_catalog"."default",
  "rename_field" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "plan_order_param_pkey" PRIMARY KEY ("id")
)
;

ALTER SEQUENCE "public"."plan_order_param_id_seq"
    OWNED BY "public"."plan_order_param"."id";

ALTER TABLE "public"."plan_order_param"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_order_param"."id" IS 'id';

COMMENT ON COLUMN "public"."plan_order_param"."code" IS '参数编号';

COMMENT ON COLUMN "public"."plan_order_param"."item" IS '参数项';

COMMENT ON COLUMN "public"."plan_order_param"."type" IS '参数类型';

COMMENT ON COLUMN "public"."plan_order_param"."source" IS '参数来源';

COMMENT ON COLUMN "public"."plan_order_param"."field" IS '参数对应字段';

COMMENT ON COLUMN "public"."plan_order_param"."distinguish" IS '参数区分主表还是从表';

COMMENT ON COLUMN "public"."plan_order_param"."rename_field" IS '参数对应字段(重命名)';

COMMENT ON TABLE "public"."plan_order_param" IS '订单参数';

-- 2021年4月19号
--工步
CREATE SEQUENCE "public"."technology_step_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."technology_step" (
  "id" int8 NOT NULL DEFAULT nextval('technology_step_id_seq'::regclass),
  "step_no" varchar(255) COLLATE "pg_catalog"."default",
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "remark" varchar(255) COLLATE "pg_catalog"."default",
  "update_time" timestamp(6),
  CONSTRAINT "technology_step_pkey" PRIMARY KEY ("id")
)
;
ALTER SEQUENCE "public"."technology_step_id_seq"
    OWNED BY "public"."technology_step"."id";

ALTER TABLE "public"."technology_step"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."technology_step"."id" IS 'id';

COMMENT ON COLUMN "public"."technology_step"."step_no" IS '工步编号';

COMMENT ON COLUMN "public"."technology_step"."name" IS '工步名称';

COMMENT ON COLUMN "public"."technology_step"."remark" IS '备注';

COMMENT ON COLUMN "public"."technology_step"."update_time" IS '更新时间';

COMMENT ON TABLE "public"."technology_step" IS '工步';

--工序关联工步
CREATE TABLE "public"."technology_join_operation_step" (
  "technology_operation_id" int8 NOT NULL,
  "technology_step_id" int8 NOT NULL,
  "sort" int8 NOT NULL
)
;

ALTER TABLE "public"."technology_join_operation_step"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."technology_join_operation_step"."technology_operation_id" IS '工序id';

COMMENT ON COLUMN "public"."technology_join_operation_step"."technology_step_id" IS '工步id';

COMMENT ON COLUMN "public"."technology_join_operation_step"."sort" IS '排序';

COMMENT ON TABLE "public"."technology_join_operation_step" IS '工序关联工步';

--工作台关联工步
CREATE SEQUENCE "public"."production_product_step_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."production_product_step" (
  "id" int8 NOT NULL DEFAULT nextval('production_product_step_id_seq'::regclass),
  "operation_task_id" int8,
  "step_id" int8,
  "number" numeric(12,3),
  "create_time" timestamp(6),
  CONSTRAINT "production_product_step_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."production_product_step"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."production_product_step_id_seq"
    OWNED BY "public"."production_product_step"."id";

COMMENT ON COLUMN "public"."production_product_step"."id" IS 'id';

COMMENT ON COLUMN "public"."production_product_step"."operation_task_id" IS '工单id';

COMMENT ON COLUMN "public"."production_product_step"."step_id" IS '工步id';

COMMENT ON COLUMN "public"."production_product_step"."number" IS '数量';

COMMENT ON COLUMN "public"."production_product_step"."create_time" IS '创建时间';

COMMENT ON TABLE "public"."production_product_step" IS '工单工步表';

--工单工步人员表
CREATE SEQUENCE "public"."production_product_step_staff_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."production_product_step_staff" (
  "id" int8 NOT NULL DEFAULT nextval('production_product_step_staff_id_seq'::regclass),
  "product_step_id" int8,
  "staff_id" int8,
  "number" numeric(12,3),
  CONSTRAINT "production_product_step_staff_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."production_product_step_staff"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."production_product_step_staff_id_seq"
    OWNED BY "public"."production_product_step_staff"."id";

COMMENT ON COLUMN "public"."production_product_step_staff"."id" IS 'id';

COMMENT ON COLUMN "public"."production_product_step_staff"."product_step_id" IS '工单工步id';

COMMENT ON COLUMN "public"."production_product_step_staff"."staff_id" IS '人员id';

COMMENT ON COLUMN "public"."production_product_step_staff"."number" IS '数量';

COMMENT ON TABLE "public"."production_product_step_staff" IS '工单工步人员表';




--工作台生产记录的记录表
CREATE SEQUENCE "public"."production_operation_task_record_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."production_operation_task_record" (
  "id" int8 NOT NULL DEFAULT nextval('production_operation_task_record_id_seq'::regclass),
  "name" varchar(255) COLLATE "pg_catalog"."default",
  "operation_task_id" int8,
  "operation_template_id" int8,
  "duty_record_id" int8,
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "create_user" varchar(255) COLLATE "pg_catalog"."default",
  "update_user" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "production_operation_task_record_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."production_operation_task_record"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."production_operation_task_record_id_seq"
    OWNED BY "public"."production_operation_task_record"."id";
COMMENT ON COLUMN "public"."production_operation_task_record"."id" IS 'id';

COMMENT ON COLUMN "public"."production_operation_task_record"."name" IS '名称';

COMMENT ON COLUMN "public"."production_operation_task_record"."operation_task_id" IS '工单id';

COMMENT ON COLUMN "public"."production_operation_task_record"."operation_template_id" IS '工序模板id';

COMMENT ON COLUMN "public"."production_operation_task_record"."duty_record_id" IS '班次id';

COMMENT ON COLUMN "public"."production_operation_task_record"."create_time" IS '创建时间';

COMMENT ON COLUMN "public"."production_operation_task_record"."update_time" IS '更新时间';

COMMENT ON COLUMN "public"."production_operation_task_record"."create_user" IS '创建人';

COMMENT ON COLUMN "public"."production_operation_task_record"."update_user" IS '更新人';

COMMENT ON TABLE "public"."production_operation_task_record" IS '生产记录模板记录';

--工作台生产记录的参数表
ALTER TABLE "production_operation_task_param"  ADD COLUMN "operation_task_record_id" int8;



--2021-05-05 by zhangxy
--保存完整的bom树
CREATE TABLE "public"."technology_bom" (
                       "id" serial8,
                       "number" varchar(255) COLLATE "pg_catalog"."default",
                       "state" varchar(255) COLLATE "pg_catalog"."default" NOT NULL DEFAULT '01draft'::character varying,
                       "part_id" int8,
                       "remark" varchar(255) COLLATE "pg_catalog"."default",
                       "create_time" timestamp(6),
                       "update_time" timestamp(6),
                       "create_user" varchar(255) COLLATE "pg_catalog"."default",
                       "update_user" varchar(255) COLLATE "pg_catalog"."default",
                       CONSTRAINT "technology_bom_pkey" PRIMARY KEY ("id"),
                       CONSTRAINT "uniq_bom_number" UNIQUE ("number")
)
;

ALTER TABLE "public"."technology_bom"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."technology_bom"."id" IS 'id';

COMMENT ON COLUMN "public"."technology_bom"."number" IS '编号';

COMMENT ON COLUMN "public"."technology_bom"."state" IS '状态';

COMMENT ON COLUMN "public"."technology_bom"."part_id" IS '零件id';

COMMENT ON COLUMN "public"."technology_bom"."remark" IS '备注';

COMMENT ON TABLE "public"."technology_bom" IS '完整bom';




CREATE TABLE "public"."technology_bom_component" (
                         "id" serial8,
                         "qpa" numeric(12,2),
                         "parent" int8,
                         "part_id" int8,
                         "unit" varchar COLLATE "pg_catalog"."default",
                         "bom_id" int8,
                         CONSTRAINT "_bom_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."technology_bom_component"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."technology_bom_component"."id" IS 'id';

COMMENT ON COLUMN "public"."technology_bom_component"."qpa" IS '单位产出';

COMMENT ON COLUMN "public"."technology_bom_component"."parent" IS '状态';

COMMENT ON COLUMN "public"."technology_bom_component"."part_id" IS '零件id';

COMMENT ON COLUMN "public"."technology_bom_component"."unit" IS '单位';

COMMENT ON COLUMN "public"."technology_bom_component"."bom_id" IS 'bom主表id';

COMMENT ON TABLE "public"."technology_bom_component" IS '完整工艺树';

--检测申请材料表
ALTER TABLE "quality_apply_part"  ADD COLUMN "part_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "part_desc" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "order_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "line_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "release_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "receipt_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "supplier_id" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "supplier_name" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "waiv_dev_rej_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "location_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "lot_batch_no" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "quality_apply_part"  ADD COLUMN "qty_arrived" varchar(255) COLLATE "pg_catalog"."default";

CREATE TABLE "public"."production_operation_task_attachment" (
   "id" serial8,
  "operation_task_id" int8,
  "file_name" varchar(255) COLLATE "pg_catalog"."default",
  "url" varchar(255) COLLATE "pg_catalog"."default",
  "original" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "production_operation_task_attachment_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."production_operation_task_attachment"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."production_operation_task_attachment"."id" IS 'id';

COMMENT ON COLUMN "public"."production_operation_task_attachment"."file_name" IS 'oss文件名';

COMMENT ON COLUMN "public"."production_operation_task_attachment"."url" IS '路径';

COMMENT ON COLUMN "public"."production_operation_task_attachment"."original" IS '原文件名';

COMMENT ON TABLE "public"."production_operation_task_attachment" IS '工单的附件表';



--制造订单产品结构
ALTER TABLE "public"."plan_mo_structure_component"  ADD COLUMN "parent" int8;
COMMENT ON COLUMN "public"."plan_mo_structure_component"."parent" IS '父id';


ALTER TABLE "public"."plan_manufacturing_order" ADD COLUMN "bom_id" int8;
COMMENT ON COLUMN "public"."plan_manufacturing_order"."bom_id" IS 'bomid';


--制造订单，允许暂存
ALTER TABLE "public"."plan_manufacturing_order"
    ALTER COLUMN "technology_routing_id" DROP NOT NULL,
    ALTER COLUMN "_id" DROP NOT NULL;

-- 产品结构去掉多余字段
ALTER TABLE "public".""
    DROP COLUMN "routing_id",
    DROP COLUMN "state";
ALTER TABLE "public"."_component"
    DROP COLUMN "routing_operation_id";

--添加库存调整的系统号
ALTER TABLE "warehouse_adjust_detail"  ADD COLUMN "system_no" varchar(255);
COMMENT ON COLUMN "public"."warehouse_adjust_detail"."system_no" IS '系统编号';

--添加库存盘点的系统号
ALTER TABLE "warehouse_check_detail"  ADD COLUMN "system_no" varchar(255);
COMMENT ON COLUMN "public"."warehouse_check_detail"."system_no" IS '系统编号';

--添加仓库备料的系统号
ALTER TABLE "warehouse_prepare_detail"  ADD COLUMN "system_no" varchar(255);
COMMENT ON COLUMN "public"."warehouse_prepare_detail"."system_no" IS '系统编号';

--添加仓库报废的系统号
ALTER TABLE "warehouse_scrap_detail"  ADD COLUMN "system_no" varchar(255);
COMMENT ON COLUMN "public"."warehouse_scrap_detail"."system_no" IS '系统编号';

--添加检测申请的要检验的采购数量
ALTER TABLE "quality_apply_part"  ADD COLUMN "qty_to_inspect" varchar(255);
COMMENT ON COLUMN "public"."quality_apply_part"."qty_to_inspect" IS '要检验的采购数量';
--添加检测申请的检验后移库的字段
ALTER TABLE "quality_apply_part"  ADD COLUMN "serial_no" varchar(255);
COMMENT ON COLUMN "public"."quality_apply_part"."serial_no" IS '序列号';
ALTER TABLE "quality_apply_part"  ADD COLUMN "eng_chg_level" varchar(255);
ALTER TABLE "quality_apply_part"  ADD COLUMN "activity_seq" varchar(255);

--零件族添加检测规则字段
ALTER TABLE "basic_part_family"  ADD COLUMN "test_rule_id" int8;
COMMENT ON COLUMN "public"."basic_part_family"."test_rule_id" IS '检测规则id';
--BOM精度改为小数点后8位
ALTER TABLE "public"."technology_bom_component"    ALTER COLUMN "qpa" TYPE numeric(16,8);
ALTER TABLE "public"."technology_structure_component"    ALTER COLUMN "qpa" TYPE numeric(16,8);
ALTER TABLE "public"."production_operation_task_material"
    ALTER COLUMN "qpa" TYPE numeric(16,8),
    ALTER COLUMN "quantity_required" TYPE numeric(16,8),
    ALTER COLUMN "quantity_issued" TYPE numeric(16,8);

--包装主表
CREATE TABLE "public"."warehouse_packaging" (
  "id" serial8,
  "no" varchar COLLATE "pg_catalog"."default",
  "netweight" numeric(18,6),
  "grossweight" numeric(18,6),
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "create_user" varchar(255) COLLATE "pg_catalog"."default",
  "update_user" varchar(255) COLLATE "pg_catalog"."default",
  "number" numeric(18,6),
  CONSTRAINT "warehouse_package_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."warehouse_packaging"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."warehouse_packaging"."id" IS 'id';

COMMENT ON COLUMN "public"."warehouse_packaging"."no" IS '编号';

COMMENT ON COLUMN "public"."warehouse_packaging"."netweight" IS '净重';

COMMENT ON COLUMN "public"."warehouse_packaging"."grossweight" IS '毛重';

COMMENT ON COLUMN "public"."warehouse_packaging"."create_time" IS '创建日期';

COMMENT ON COLUMN "public"."warehouse_packaging"."update_time" IS '更新日期';

COMMENT ON COLUMN "public"."warehouse_packaging"."create_user" IS '创建人';

COMMENT ON COLUMN "public"."warehouse_packaging"."update_user" IS '更新人';

COMMENT ON COLUMN "public"."warehouse_packaging"."number" IS '数量';

COMMENT ON TABLE "public"."warehouse_packaging" IS '包装主表';

--包装明细表
CREATE TABLE "public"."warehouse_packaging_item" (
  "id" serial8,
  "part_id" int8,
  "out_batch_no" varchar COLLATE "pg_catalog"."default",
  "system_no" varchar COLLATE "pg_catalog"."default",
  "package_qty" numeric,
  "create_time" timestamp(6),
  "specs" varchar(255) COLLATE "pg_catalog"."default",
  "packaging_id" int8,
  CONSTRAINT "warehouse_package_item_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."warehouse_packaging_item"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."warehouse_packaging_item"."id" IS 'id';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."part_id" IS '零件id';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."out_batch_no" IS '批次号';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."system_no" IS '系统号';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."package_qty" IS '包装数量';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."create_time" IS '创建时间';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."specs" IS '规格';

COMMENT ON COLUMN "public"."warehouse_packaging_item"."packaging_id" IS '包装主表id';

COMMENT ON TABLE "public"."warehouse_packaging_item" IS '包装明细表';



-- 打印模板
CREATE TABLE "public"."report_template" (
            "id" serial8,
            "module" varchar(255) COLLATE "pg_catalog"."default",
            "template_name" varchar(255) COLLATE "pg_catalog"."default",
            "description" varchar(255) COLLATE "pg_catalog"."default",
            "sort" int4 DEFAULT 0,
            CONSTRAINT "report_template_pkey" PRIMARY KEY ("id"),
            CONSTRAINT "uniq_temp_name" UNIQUE ("template_name")
)
;

ALTER TABLE "public"."report_template"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."report_template"."module" IS '模块';

COMMENT ON COLUMN "public"."report_template"."template_name" IS '模板名称';

COMMENT ON COLUMN "public"."report_template"."description" IS '描述';

COMMENT ON COLUMN "public"."report_template"."sort" IS '排序';

COMMENT ON TABLE "public"."report_template" IS 'jasper报表模板';

--添加零件的单位重量
ALTER TABLE "basic_part"  ADD COLUMN "weight" numeric(12,3) DEFAULT 1;
COMMENT ON COLUMN "public"."basic_part"."weight" IS '重量';

--添加包装明细表的实时库存id
ALTER TABLE "warehouse_packaging_item"  ADD COLUMN "stock_id" int8;
COMMENT ON COLUMN "public"."warehouse_packaging_item"."stock_id" IS '实时库存id';

--添加包装主表的差异数量和实际数量
ALTER TABLE "warehouse_packaging"  ADD COLUMN "difference_weight" numeric(18,6);
COMMENT ON COLUMN "public"."warehouse_packaging"."difference_weight" IS '差异重量';

ALTER TABLE "warehouse_packaging"  ADD COLUMN "real_weight" numeric(18,6);
COMMENT ON COLUMN "public"."warehouse_packaging"."real_weight" IS '实际重量';



--2021-6-10   模板与客户订单的关系表
CREATE TABLE "public"."plan_join_model_customer" (
  "customer_order_id" int8 NOT NULL,
  "model_id" int8 NOT NULL,
  "model" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
  CONSTRAINT "plan_join_model_customer_pkey" PRIMARY KEY ("customer_order_id", "model_id")
)
;

ALTER TABLE "public"."plan_join_model_customer"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_join_model_customer"."customer_order_id" IS '客户订单id';

COMMENT ON COLUMN "public"."plan_join_model_customer"."model_id" IS '模块的id';

COMMENT ON COLUMN "public"."plan_join_model_customer"."model" IS '模块';

COMMENT ON TABLE "public"."plan_join_model_customer" IS '模块与客户订单的关联表';

--检测规则的检测参数新增参数项的检测类型
ALTER TABLE "quality_test_standard_param"  ADD COLUMN "param_type" varchar(255);
COMMENT ON COLUMN "public"."quality_test_standard_param"."param_type" IS '参数项的检测类型';

--制造订单的检测参数复制表新增参数项的检测类型
ALTER TABLE "plan_mo_test_standard_param"  ADD COLUMN "param_type" varchar(255);
COMMENT ON COLUMN "public"."plan_mo_test_standard_param"."param_type" IS '参数项的检测类型';

CREATE TABLE "public"."quality_exception" (
  "id" serial8,
  "code" varchar(255) COLLATE "pg_catalog"."default",
  "workstation_id" int8,
  "productout_id" int8,
  "exception_type" varchar(255) COLLATE "pg_catalog"."default",
  "exception_description" varchar(255) COLLATE "pg_catalog"."default",
  "handle_way" varchar(255) COLLATE "pg_catalog"."default",
  "create_user" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "remark" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "quality_exception_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."quality_exception"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."quality_exception"."id" IS 'id';

COMMENT ON COLUMN "public"."quality_exception"."code" IS '编号';

COMMENT ON COLUMN "public"."quality_exception"."workstation_id" IS '工作站id';

COMMENT ON COLUMN "public"."quality_exception"."productout_id" IS '产出id';

COMMENT ON COLUMN "public"."quality_exception"."exception_type" IS '异常类型';

COMMENT ON COLUMN "public"."quality_exception"."exception_description" IS '异常描述';

COMMENT ON COLUMN "public"."quality_exception"."handle_way" IS '处理方案';

COMMENT ON COLUMN "public"."quality_exception"."create_user" IS '处理人';

COMMENT ON COLUMN "public"."quality_exception"."create_time" IS '创建时间';

COMMENT ON COLUMN "public"."quality_exception"."remark" IS '备注';

COMMENT ON TABLE "public"."quality_exception" IS '生产异常处理';

CREATE TABLE "public"."quality_exception_attachment" (
  "id" serial8,
  "exception_id" int8,
  "file_name" varchar(255) COLLATE "pg_catalog"."default",
  "url" varchar(255) COLLATE "pg_catalog"."default",
  "original" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "quality_exception_attachment_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."quality_exception_attachment"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."quality_exception_attachment"."id" IS 'id';

COMMENT ON COLUMN "public"."quality_exception_attachment"."exception_id" IS '生产异常记录id';

COMMENT ON COLUMN "public"."quality_exception_attachment"."file_name" IS 'oss文件名';

COMMENT ON COLUMN "public"."quality_exception_attachment"."url" IS '路径';

COMMENT ON COLUMN "public"."quality_exception_attachment"."original" IS '原文件名';

COMMENT ON TABLE "public"."quality_exception_attachment" IS '生产异常记录附件';



--master新增客户订单主表
CREATE TABLE "public"."plan_customer" (
  "id" serial8,
  "contract_no" varchar COLLATE "pg_catalog"."default",
  "customer_contract_no" varchar COLLATE "pg_catalog"."default",
  "customer_name" varchar(255) COLLATE "pg_catalog"."default",
  "entity_name" varchar(255) COLLATE "pg_catalog"."default",
  "delivery_date" timestamp(6),
  "sales_department" varchar(255) COLLATE "pg_catalog"."default",
  "province" varchar(255) COLLATE "pg_catalog"."default",
  "sales_man" varchar(255) COLLATE "pg_catalog"."default",
  "saler_work_code" varchar(255) COLLATE "pg_catalog"."default",
  "original_contract_status" varchar(255) COLLATE "pg_catalog"."default",
  "is_cp" varchar(255) COLLATE "pg_catalog"."default",
  "customer_no" varchar COLLATE "pg_catalog"."default",
  "return_status" varchar(255) COLLATE "pg_catalog"."default",
  "place_order_date" timestamp(6),
  "verify_date" timestamp(6),
  "factory_place_order_date" timestamp(6),
  CONSTRAINT "plan_customer_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."plan_customer"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_customer"."id" IS 'id';

COMMENT ON COLUMN "public"."plan_customer"."contract_no" IS '合同号';

COMMENT ON COLUMN "public"."plan_customer"."customer_contract_no" IS '客户合同号';

COMMENT ON COLUMN "public"."plan_customer"."customer_name" IS '客户名称';

COMMENT ON COLUMN "public"."plan_customer"."entity_name" IS '工程名称';

COMMENT ON COLUMN "public"."plan_customer"."delivery_date" IS '交货日期';

COMMENT ON COLUMN "public"."plan_customer"."sales_department" IS '事业部';

COMMENT ON COLUMN "public"."plan_customer"."province" IS '省份';

COMMENT ON COLUMN "public"."plan_customer"."sales_man" IS '业务员';

COMMENT ON COLUMN "public"."plan_customer"."saler_work_code" IS '业务员编号';

COMMENT ON COLUMN "public"."plan_customer"."original_contract_status" IS '正本状态';

COMMENT ON COLUMN "public"."plan_customer"."is_cp" IS '项目性质';

COMMENT ON COLUMN "public"."plan_customer"."customer_no" IS '客户编码';

COMMENT ON COLUMN "public"."plan_customer"."return_status" IS '合同正本状态';

COMMENT ON COLUMN "public"."plan_customer"."place_order_date" IS '下单日期';

COMMENT ON COLUMN "public"."plan_customer"."verify_date" IS '审核日期';

COMMENT ON COLUMN "public"."plan_customer"."factory_place_order_date" IS '工厂下单日期';

COMMENT ON TABLE "public"."plan_customer" IS '客户订单主表';

--客户订单
ALTER TABLE "plan_customer_order"  ADD COLUMN "customer_id" int8;
COMMENT ON COLUMN "public"."plan_customer_order"."customer_id" IS '客户订单主表的id(plan_customer)';

--检测申请增加创建人、创建时间、更新人和更新时间
ALTER TABLE "quality_apply"  ADD COLUMN "create_time" timestamp(6);
COMMENT ON COLUMN "public"."quality_apply"."create_time" IS '创建时间';
ALTER TABLE "quality_apply"  ADD COLUMN "create_user" varchar(255);
COMMENT ON COLUMN "public"."quality_apply"."create_user" IS '创建人';
ALTER TABLE "quality_apply"  ADD COLUMN "update_time" timestamp(6);
COMMENT ON COLUMN "public"."quality_apply"."update_time" IS '更新时间';
ALTER TABLE "quality_apply"  ADD COLUMN "update_user"  varchar(255);
COMMENT ON COLUMN "public"."quality_apply"."update_user" IS '更新人';

--0830 start  cxf   质量检测自动判断公式
ALTER TABLE "quality_report_sample_item"  ADD COLUMN "item_code" varchar(50);
COMMENT ON COLUMN "public"."quality_report_sample_item"."item_code" IS '检测项目编号';
ALTER TABLE "quality_report_sample_item"  ADD COLUMN "item_type" varchar(50);
COMMENT ON COLUMN "public"."quality_report_sample_item"."item_type" IS '检测项目类型';
ALTER TABLE "quality_report_sample_item"  ADD COLUMN "value_formula" varchar(255);
COMMENT ON COLUMN "public"."quality_report_sample_item"."value_formula" IS '值公式（针对计算出来的值）';
ALTER TABLE "quality_report_sample_item"  ADD COLUMN "judge_formula" varchar(255);
COMMENT ON COLUMN "public"."quality_report_sample_item"."judge_formula" IS '判断公式（是否合格）';

ALTER TABLE "public"."quality_report_sample" RENAME  mo_test_standard_id TO test_standard_id;
ALTER TABLE "quality_report_sample"  ADD COLUMN "is_mo_test_standard" bool;
COMMENT ON COLUMN "public"."quality_report_sample"."is_mo_test_standard" IS '是否来自客户订单的检测标准';

ALTER TABLE "quality_test_standard_param"  ADD COLUMN "value_formula" varchar(255);
COMMENT ON COLUMN "public"."quality_test_standard_param"."value_formula" IS '值公式（针对计算出来的值）';
ALTER TABLE "quality_test_standard_param"  ADD COLUMN "judge_formula" varchar(255);
COMMENT ON COLUMN "public"."quality_test_standard_param"."judge_formula" IS '判断公式（是否合格）';
ALTER TABLE "quality_test_standard"  ADD COLUMN "judge_formula" varchar(255);
COMMENT ON COLUMN "public"."quality_test_standard"."judge_formula" IS '判断公式（是否合格）';

ALTER TABLE "plan_mo_test_standard_param"  ADD COLUMN "value_formula" varchar(255);
COMMENT ON COLUMN "public"."plan_mo_test_standard_param"."value_formula" IS '值公式（针对计算出来的值）';
ALTER TABLE "plan_mo_test_standard_param"  ADD COLUMN "judge_formula" varchar(255);
COMMENT ON COLUMN "public"."plan_mo_test_standard_param"."judge_formula" IS '判断公式（是否合格）';
ALTER TABLE "plan_mo_test_standard"  ADD COLUMN "judge_formula" varchar(255);
COMMENT ON COLUMN "public"."plan_mo_test_standard"."judge_formula" IS '判断公式（是否合格）';
--0830 end


--检测申请增加创建人、创建时间、更新人和更新时间
ALTER TABLE "warehouse_join_stock_order"  ADD COLUMN "operation_task_id" int8;
COMMENT ON COLUMN "public"."warehouse_join_stock_order"."operation_task_id" IS '工单的id';
ALTER TABLE "warehouse_join_stock_order"  ADD COLUMN "type" varchar(255);
COMMENT ON COLUMN "public"."warehouse_join_stock_order"."type" IS '类型';

--工单增加已预留数量
ALTER TABLE "production_operation_task"  ADD COLUMN "reserved_quantity" numeric(12,6) DEFAULT 0;
COMMENT ON COLUMN "public"."production_operation_task"."reserved_quantity" IS '预留数量';
--工单所需物料增加预留数量
ALTER TABLE "production_operation_task_material"  ADD COLUMN "reserved_quantity" numeric(12,6) DEFAULT 0;
COMMENT ON COLUMN "public"."production_operation_task_material"."reserved_quantity" IS '预留数量';
--0831 end
--工艺增加字段是否预留
ALTER TABLE "technology_routing_operation"  ADD COLUMN "reserved"  bool;
COMMENT ON COLUMN "public"."technology_routing_operation"."reserved" IS '是否预留';
--0831 end

--0906  start
--报工产出新增状态
ALTER TABLE "production_product_output"  ADD COLUMN "state" varchar(255) COLLATE "pg_catalog"."default" DEFAULT '01draft'::character varying;
COMMENT ON COLUMN "public"."production_product_output"."state" IS '状态';
--0906  end

--0910 start
--退货
CREATE TABLE "public"."warehouse_send_back" (
  "id" serial8,
  "escort_detail_id" int8,
  "part_no" varchar(100) COLLATE "pg_catalog"."default",
  "part_name" varchar(100) COLLATE "pg_catalog"."default",
  "part_batch_no" varchar(100) COLLATE "pg_catalog"."default",
  "system_no" varchar(100) COLLATE "pg_catalog"."default",
  "send_back_quantity" numeric(18,6) DEFAULT 0,
  "part_unit" varchar(100) COLLATE "pg_catalog"."default",
  "send_back_date" timestamp(6),
  "is_company" bool,
  "send_back_company_date" timestamp(6),
  "send_back_reason" varchar(255) COLLATE "pg_catalog"."default",
  "send_back_location_id" int8,
  "status" varchar(255) COLLATE "pg_catalog"."default",
  CONSTRAINT "warehouse_send_back_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."warehouse_send_back"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."warehouse_send_back"."id" IS 'id';

COMMENT ON COLUMN "public"."warehouse_send_back"."escort_detail_id" IS '发货明细id';

COMMENT ON COLUMN "public"."warehouse_send_back"."part_no" IS '零件编号';

COMMENT ON COLUMN "public"."warehouse_send_back"."part_name" IS '零件名称';

COMMENT ON COLUMN "public"."warehouse_send_back"."part_batch_no" IS '零件批号';

COMMENT ON COLUMN "public"."warehouse_send_back"."system_no" IS '零件系统号';

COMMENT ON COLUMN "public"."warehouse_send_back"."send_back_quantity" IS '退货数量';

COMMENT ON COLUMN "public"."warehouse_send_back"."part_unit" IS '零件单位';

COMMENT ON COLUMN "public"."warehouse_send_back"."send_back_date" IS '退货日期';

COMMENT ON COLUMN "public"."warehouse_send_back"."is_company" IS '是否退回公司';

COMMENT ON COLUMN "public"."warehouse_send_back"."send_back_company_date" IS '退回公司日期';

COMMENT ON COLUMN "public"."warehouse_send_back"."send_back_reason" IS '退货原因';

COMMENT ON COLUMN "public"."warehouse_send_back"."send_back_location_id" IS '退回库位id';

COMMENT ON COLUMN "public"."warehouse_send_back"."status" IS '状态';

COMMENT ON TABLE "public"."warehouse_send_back" IS '退货表';
--0910  end

--0908  start    cxf
ALTER TABLE "public"."quality_report_sample"
  ADD COLUMN "is_qualified" bool;
COMMENT ON COLUMN "public"."quality_report_sample"."is_qualified" IS '是否合格';
--0908  end    cxf
--1023  start    cxf
  CREATE TABLE "public"."plan_outsourcing_order" (
  "id" int8 NOT NULL DEFAULT nextval('plan_outsourcing_order_id_seq'::regclass),
  "outsourcing_order_no" varchar(50) COLLATE "pg_catalog"."default",
  "part_id" int8 NOT NULL,
  "qty_required" numeric(18,6) NOT NULL,
  "qty_finished" numeric(18,6) NOT NULL DEFAULT 0,
  "required_date" timestamp(6),
  "state" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "remark" varchar(255) COLLATE "pg_catalog"."default",
  "oa_id" int8,
  "oa_state" varchar(50) COLLATE "pg_catalog"."default",
  "erp_id" int8,
  "erp_state" varchar(50) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default",
  "mps_id" int8,
  CONSTRAINT "plan_outsourcing_order_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."plan_outsourcing_order"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_outsourcing_order"."id" IS 'id';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."outsourcing_order_no" IS '委外订单号';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."part_id" IS '零件id';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."qty_required" IS '需求数量';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."qty_finished" IS '完成数量';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."required_date" IS '需求日期';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."state" IS '状态';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."remark" IS '备注';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."oa_id" IS 'oa_id';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."oa_state" IS 'oa状态';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."erp_id" IS 'erp_id';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."erp_state" IS 'erp状态';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."create_time" IS '创建时间';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."update_time" IS '更新时间';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."create_user" IS '创建人';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."update_user" IS '更新人';

COMMENT ON COLUMN "public"."plan_outsourcing_order"."mps_id" IS '主生产计划id';

COMMENT ON TABLE "public"."plan_outsourcing_order" IS '委外订单表';

CREATE TABLE "public"."plan_outsourcing_order_stock" (
  "id" int8 NOT NULL DEFAULT nextval('plan_outsourcing_order_stock_id_seq'::regclass),
  "outsourcing_order_id" int8,
  "part_id" int8,
  "part_batch_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "receive_quantity" numeric(18,6) NOT NULL,
  "location_id" int8,
  "stock_id" int8,
  CONSTRAINT "plan_outsourcing_order_stock_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."plan_outsourcing_order_stock"
  OWNER TO "postgres";

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."id" IS 'id';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."outsourcing_order_id" IS '委外订单id';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."part_id" IS '零件id';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."part_batch_no" IS '零件批号';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."receive_quantity" IS '接受数量';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."location_id" IS '库位';

COMMENT ON COLUMN "public"."plan_outsourcing_order_stock"."stock_id" IS '库存id';

COMMENT ON TABLE "public"."plan_outsourcing_order_stock" IS '委外订单库存接收表';

--客户订单增加合同的id
  ALTER TABLE "plan_customer_order" ADD COLUMN    "auto_id" int8,
  COMMENT ON COLUMN "public"."plan_customer_order"."auto_id" IS 'GSM合同产品的id';
--发货增加GSM的押运单的id
ALTER TABLE "warehouse_escort" ADD COLUMN    "escort_auto_id" int8,
  COMMENT ON COLUMN "public"."warehouse_escort"."escort_auto_id" IS 'GSM的押运单的id';
--发货明细增加GSM的押运单的id
ALTER TABLE "warehouse_escort_detail" ADD COLUMN    "escort_in_auto_id" int8,
  COMMENT ON COLUMN "public"."warehouse_escort_detail"."escort_in_auto_id" IS 'GSM的押运单明细表的入库id';
ALTER TABLE "warehouse_escort_detail" ADD COLUMN    "escort_out_auto_id" int8,
  COMMENT ON COLUMN "public"."warehouse_escort_detail"."escort_out_auto_id" IS 'GSM的押运单明细表的发货id';
--1023  end    cxf

-- 2022.09.06
create table public.plan_order_process_config_file
(
    id                       bigserial
        primary key,
    order_number  varchar(50),
    file_name     varchar,
    bucket_name   varchar(255),
    original_file_name varchar(100),
    create_user   varchar(20),
    create_time   timestamp(6),
    update_user   varchar(20),
    update_time   timestamp(6),
    line_number   varchar(10),
    effective_range         varchar(1)
);

comment on column public.plan_order_process_config_file.order_number is '销售订单号';

comment on column public.plan_order_process_config_file.file_name is '文件名';

comment on column public.plan_order_process_config_file.original_file_name is '原始文件名';

comment on column public.plan_order_process_config_file.create_user is '创建人';

comment on column public.plan_order_process_config_file.create_time is '创建时间';

comment on column public.plan_order_process_config_file.update_user is '更新人';

comment on column public.plan_order_process_config_file.update_time is '更新时间';

comment on column public.plan_order_process_config_file.line_number is '行号';

comment on column public.plan_order_process_config_file.effective_range is '文件适用范围：1:销售订单；2：销售订单行';

-- 2022.09.19 生产退料申请表
CREATE SEQUENCE "public"."warehouse_reverse_stock_apply_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."warehouse_reverse_stock_apply"
(
    "id"                    int8 NOT NULL DEFAULT nextval('warehouse_reverse_stock_apply_id_seq'::regclass),
    "apply_serial_no"                  varchar(20) COLLATE "pg_catalog"."default",
    "state"        varchar(20) COLLATE "pg_catalog"."default",
    "create_user"                  varchar(100) COLLATE "pg_catalog"."default",
    "create_time"                  timestamp(6),
    "update_user"           varchar(100) COLLATE "pg_catalog"."default",
    "update_time"          timestamp(6),
    CONSTRAINT "warehouse_reverse_stock_apply_pkey" PRIMARY KEY ("id")
);
comment on column public.warehouse_reverse_stock_apply.apply_serial_no is '退料申请流水号';
comment on column public.warehouse_reverse_stock_apply.state is '状态：draft-草稿;processing-进行中;processed-已执行';
comment on column public.warehouse_reverse_stock_apply.create_user is '创建人';
comment on column public.warehouse_reverse_stock_apply.create_time is '创建时间';
comment on column public.warehouse_reverse_stock_apply.update_user is '更新人';
comment on column public.warehouse_reverse_stock_apply.update_time is '更新时间';

ALTER SEQUENCE "public"."warehouse_reverse_stock_apply_id_seq"
    OWNED BY "public"."warehouse_reverse_stock_apply"."id";

ALTER TABLE "public"."warehouse_reverse_stock_apply" OWNER TO "postgres";
ALTER SEQUENCE "public"."warehouse_reverse_stock_apply_id_seq" OWNER TO "postgres";

-- 生产退料申请详情表
CREATE SEQUENCE "public"."warehouse_reverse_stock_apply_detail_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."warehouse_reverse_stock_apply_detail"
(
    "id"                    int8 NOT NULL DEFAULT nextval('warehouse_reverse_stock_apply_detail_id_seq'::regclass),
    "reverse_apply_id" bigint not null,
    "stock_id" bigint not null,
    "part_no"                  varchar(50) COLLATE "pg_catalog"."default",
    "part_name"        varchar(255) COLLATE "pg_catalog"."default",
    "ifs_batch_no"                  varchar(100) COLLATE "pg_catalog"."default",
    "sn"                  varchar(200) COLLATE "pg_catalog"."default",
    "reverse_quantity" numeric(18,6),
    "unit" varchar(50) COLLATE "pg_catalog"."default",
    "ifs_from_location_no" varchar(255) COLLATE "pg_catalog"."default",
    "ifs_from_location_name" varchar(255) COLLATE "pg_catalog"."default",
    "ifs_to_location_no" varchar(255) COLLATE "pg_catalog"."default",
    "ifs_to_location_name" varchar(255) COLLATE "pg_catalog"."default",
    "state" varchar(20) COLLATE "pg_catalog"."default",
    "create_user"                  varchar(100) COLLATE "pg_catalog"."default",
    "create_time"                  timestamp(6),
    "update_user"           varchar(100) COLLATE "pg_catalog"."default",
    "update_time"          timestamp(6),
    CONSTRAINT "warehouse_reverse_stock_apply_detail_pkey" PRIMARY KEY ("id")
);

comment on column public.warehouse_reverse_stock_apply_detail.reverse_apply_id is '退料申请主表id';
comment on column public.warehouse_reverse_stock_apply_detail.stock_id is '库存id';
comment on column public.warehouse_reverse_stock_apply_detail.part_no is '零件编号';
comment on column public.warehouse_reverse_stock_apply_detail.part_name is '零件名称';
comment on column public.warehouse_reverse_stock_apply_detail.ifs_batch_no is 'IFS批次号';
comment on column public.warehouse_reverse_stock_apply_detail.sn is 'SN号';
comment on column public.warehouse_reverse_stock_apply_detail.reverse_quantity is '退料数量';
comment on column public.warehouse_reverse_stock_apply_detail.unit is '单位';
comment on column public.warehouse_reverse_stock_apply_detail.ifs_from_location_no is 'IFS从库位编号';
comment on column public.warehouse_reverse_stock_apply_detail.ifs_from_location_name is 'IFS从库位名称';
comment on column public.warehouse_reverse_stock_apply_detail.ifs_to_location_no is 'IFS至库位编号';
comment on column public.warehouse_reverse_stock_apply_detail.ifs_to_location_name is 'IFS至库位名称';
comment on column public.warehouse_reverse_stock_apply_detail.state is '状态:new-新建;processed-已执行';
comment on column public.warehouse_reverse_stock_apply_detail.create_user is '创建人';
comment on column public.warehouse_reverse_stock_apply_detail.create_time is '创建时间';
comment on column public.warehouse_reverse_stock_apply_detail.update_user is '更新人';
comment on column public.warehouse_reverse_stock_apply_detail.update_time is '更新时间';

ALTER SEQUENCE "public"."warehouse_reverse_stock_apply_detail_id_seq"
    OWNED BY "public"."warehouse_reverse_stock_apply_detail"."id";

ALTER TABLE "public"."warehouse_reverse_stock_apply_detail" OWNER TO "postgres";
ALTER SEQUENCE "public"."warehouse_reverse_stock_apply_detail_id_seq" OWNER TO "postgres";

-- 工艺配置单销售订单关系表
CREATE SEQUENCE "public"."plan_process_config_file_order_mapping_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."plan_process_config_file_order_mapping"
(
    "id"                    int8 NOT NULL DEFAULT nextval('plan_process_config_file_order_mapping_id_seq'::regclass),
    "config_file_id" bigint not null,
    "order_number"                  varchar(150) COLLATE "pg_catalog"."default",
    "line_number"        varchar(50) COLLATE "pg_catalog"."default",
    "create_user"                  varchar(100) COLLATE "pg_catalog"."default",
    "create_time"                  timestamp(6),
    "update_user"           varchar(100) COLLATE "pg_catalog"."default",
    "update_time"          timestamp(6),
    CONSTRAINT "plan_process_config_file_order_mapping_pkey" PRIMARY KEY ("id")
);

comment on column public.plan_process_config_file_order_mapping.config_file_id is '工艺配置单文件表id';
comment on column public.plan_process_config_file_order_mapping.order_number is '订单号';
comment on column public.plan_process_config_file_order_mapping.line_number is '行号';
comment on column public.plan_process_config_file_order_mapping.create_user is '创建人';
comment on column public.plan_process_config_file_order_mapping.create_time is '创建时间';
comment on column public.plan_process_config_file_order_mapping.update_user is '更新人';
comment on column public.plan_process_config_file_order_mapping.update_time is '更新时间';

ALTER SEQUENCE "public"."plan_process_config_file_order_mapping_id_seq"
    OWNED BY "public"."plan_process_config_file_order_mapping"."id";

ALTER TABLE "public"."plan_process_config_file_order_mapping" OWNER TO "postgres";
ALTER SEQUENCE "public"."plan_process_config_file_order_mapping_id_seq" OWNER TO "postgres";

-- 外协成品报检表
CREATE SEQUENCE "public"."outsource_inspection_declaration_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."outsource_inspection_declaration"
(
    "id"                    int8 NOT NULL DEFAULT nextval('outsource_inspection_declaration_id_seq'::regclass),
    "inspection_serial_no"                  varchar(20) COLLATE "pg_catalog"."default",
    "inspection_quantity" numeric(18,6),
    "stock_quantity" numeric(18,6),
    "difference_quantity" numeric(18,6),
    "create_user"                  varchar(100) COLLATE "pg_catalog"."default",
    "create_time"                  timestamp(6),
    "update_user"           varchar(100) COLLATE "pg_catalog"."default",
    "update_time"          timestamp(6),
    CONSTRAINT "outsource_inspection_declaration_pkey" PRIMARY KEY ("id")
);

comment on column public.outsource_inspection_declaration.inspection_serial_no is '报检流水号';
comment on column public.outsource_inspection_declaration.inspection_quantity is '报检数量';
comment on column public.outsource_inspection_declaration.stock_quantity is '入库数量';
comment on column public.outsource_inspection_declaration.difference_quantity is '差额';
comment on column public.outsource_inspection_declaration.create_user is '创建人';
comment on column public.outsource_inspection_declaration.create_time is '创建时间';
comment on column public.outsource_inspection_declaration.update_user is '更新人';
comment on column public.outsource_inspection_declaration.update_time is '更新时间';

ALTER SEQUENCE "public"."outsource_inspection_declaration_id_seq"
    OWNED BY "public"."outsource_inspection_declaration"."id";

ALTER TABLE "public"."outsource_inspection_declaration" OWNER TO "postgres";
ALTER SEQUENCE "public"."outsource_inspection_declaration_id_seq" OWNER TO "postgres";

-- 外协成品报检明细表
CREATE SEQUENCE "public"."outsource_inspection_declaration_detail_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."outsource_inspection_declaration_detail"
(
    "id"                    int8 NOT NULL DEFAULT nextval('outsource_inspection_declaration_detail_id_seq'::regclass),
    "inspection_serial_no"                  varchar(20) COLLATE "pg_catalog"."default",
    "certificate_number"                  varchar(100) COLLATE "pg_catalog"."default",
    "inspection_quantity" numeric(18,6),
    "sampling_state" varchar(2) COLLATE "pg_catalog"."default",
    "packaging_state" varchar(2) COLLATE "pg_catalog"."default",
    "stock_state" varchar(2) COLLATE "pg_catalog"."default",
    "packaging_operator" varchar(100) COLLATE "pg_catalog"."default",
    "stock_operator" varchar(100) COLLATE "pg_catalog"."default",
    "state" varchar(20) COLLATE "pg_catalog"."default",
    "insp_state" varchar(20) COLLATE "pg_catalog"."default",
    "create_user"                  varchar(100) COLLATE "pg_catalog"."default",
    "create_time"                  timestamp(6),
    "update_user"           varchar(100) COLLATE "pg_catalog"."default",
    "update_time"          timestamp(6),
    CONSTRAINT "outsource_inspection_declaration_detail_pkey" PRIMARY KEY ("id")
);

comment on column public.outsource_inspection_declaration_detail.inspection_serial_no is '报检流水号';
comment on column public.outsource_inspection_declaration_detail.certificate_number is '合格证号';
comment on column public.outsource_inspection_declaration_detail.inspection_quantity is '报检数量';
comment on column public.outsource_inspection_declaration_detail.sampling_state is '是否抽检';
comment on column public.outsource_inspection_declaration_detail.packaging_state is '是否包装';
comment on column public.outsource_inspection_declaration_detail.stock_state is '是否入库';
comment on column public.outsource_inspection_declaration_detail.packaging_operator is '包装人员';
comment on column public.outsource_inspection_declaration_detail.stock_operator is '入库人员';
comment on column public.outsource_inspection_declaration_detail.state is '状态';
comment on column public.outsource_inspection_declaration_detail.insp_state is '检测状态';
comment on column public.outsource_inspection_declaration_detail.create_user is '创建人';
comment on column public.outsource_inspection_declaration_detail.create_time is '创建时间';
comment on column public.outsource_inspection_declaration_detail.update_user is '更新人';
comment on column public.outsource_inspection_declaration_detail.update_time is '更新时间';

ALTER SEQUENCE "public"."outsource_inspection_declaration_detail_id_seq"
    OWNED BY "public"."outsource_inspection_declaration_detail"."id";

ALTER TABLE "public"."outsource_inspection_declaration_detail" OWNER TO "postgres";
ALTER SEQUENCE "public"."outsource_inspection_declaration_detail_id_seq" OWNER TO "postgres";

---- 2022年10月20号
-- 新盘点主表
CREATE SEQUENCE "public"."warehouse_inventory_main_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."warehouse_inventory_main" (
  "id" int8 NOT NULL DEFAULT nextval('warehouse_inventory_main_id_seq'::regclass),
  "iny_no" varchar(50) COLLATE "pg_catalog"."default",
  "iny_desc" varchar(255) COLLATE "pg_catalog"."default",
  "iny_status" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default"
)
;

COMMENT ON COLUMN "public"."warehouse_inventory_main"."id" IS 'id';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."iny_no" IS '盘点编号';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."iny_desc" IS '盘点描述';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."iny_status" IS '状态（草稿，盘点中，已完成）';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."warehouse_inventory_main"."update_user" IS '更新人';

ALTER TABLE "public"."warehouse_inventory_main"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."warehouse_inventory_main_id_seq"
    OWNED BY "public"."warehouse_inventory_main"."id";


---- 2022年10月20号
-- 新盘点明细表
CREATE SEQUENCE "public"."warehouse_inventory_detail_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;
CREATE TABLE "public"."warehouse_inventory_detail" (
  "id" int8 NOT NULL DEFAULT nextval('warehouse_inventory_detail_id_seq'::regclass),
  "inventory_main_id" int8,
  "part_no" varchar(100) COLLATE "pg_catalog"."default",
  "part_name" varchar(225) COLLATE "pg_catalog"."default",
  "planning_method" varchar(50) COLLATE "pg_catalog"."default",
  "sn" varchar(255) COLLATE "pg_catalog"."default",
  "ifs_batch_no" varchar(255) COLLATE "pg_catalog"."default",
  "warehouse_name" varchar(255) COLLATE "pg_catalog"."default",
  "loc_no" varchar(50) COLLATE "pg_catalog"."default",
  "stock_quantity" numeric(18,6),
  "unit" varchar(20) COLLATE "pg_catalog"."default",
  "iny_qty" numeric(18,6),
  "iny_diff_qty" numeric(18,6),
  "commit_num" int4,
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "iny_no" varchar(50) COLLATE "pg_catalog"."default",
  "warehouse_id" int8
)
;


COMMENT ON COLUMN "public"."warehouse_inventory_detail"."id" IS 'id';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."inventory_main_id" IS '盘点主表id';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."part_name" IS '零件名称';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."planning_method" IS '计划方法（只能传A、K、P）';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."sn" IS 'sn号';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."ifs_batch_no" IS 'ifs批次号';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."warehouse_name" IS '仓库';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."loc_no" IS '库位编号';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."stock_quantity" IS '库存数量';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."unit" IS '单位';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."iny_qty" IS '盘点数量';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."iny_diff_qty" IS '盘点差异数量';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."commit_num" IS '扫码提交次数';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."iny_no" IS '盘点编号';
COMMENT ON COLUMN "public"."warehouse_inventory_detail"."warehouse_id" IS '仓库id';

ALTER TABLE "public"."warehouse_inventory_detail"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."warehouse_inventory_detail_id_seq"
    OWNED BY "public"."warehouse_inventory_detail"."id";


-- 2022年10月26号
-- 新工艺配置单
CREATE SEQUENCE "public"."plan_process_config_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."plan_process_config" (
  "id" int8 NOT NULL DEFAULT nextval('plan_process_config_id_seq'::regclass),
  "model_type" varchar(50) COLLATE "pg_catalog"."default",
  "pro_no" varchar(50) COLLATE "pg_catalog"."default",
  "pro_name" varchar(100) COLLATE "pg_catalog"."default",
  "print_req" varchar(255) COLLATE "pg_catalog"."default",
  "remark1" varchar(1000) COLLATE "pg_catalog"."default",
  "remark2" varchar(1000) COLLATE "pg_catalog"."default",
  "remark3" varchar(1000) COLLATE "pg_catalog"."default",
  "remark4" varchar(1000) COLLATE "pg_catalog"."default",
  "real_print_req" varchar(255) COLLATE "pg_catalog"."default",
  "cable_core" varchar(50) COLLATE "pg_catalog"."default",
  "model_core" varchar(50) COLLATE "pg_catalog"."default",
  "model_sleeve" varchar(50) COLLATE "pg_catalog"."default",
  "sizing_model" varchar(50) COLLATE "pg_catalog"."default",
  "strand_model" varchar(50) COLLATE "pg_catalog"."default",
  "work_frequency" varchar(255) COLLATE "pg_catalog"."default",
  "frequency_range" varchar(255) COLLATE "pg_catalog"."default",
  "resistance" varchar(255) COLLATE "pg_catalog"."default",
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "order_number" varchar(50) COLLATE "pg_catalog"."default",
  "order_id" int8
)
;
COMMENT ON COLUMN "public"."plan_process_config"."id" IS 'id';
COMMENT ON COLUMN "public"."plan_process_config"."model_type" IS '模板类型';
COMMENT ON COLUMN "public"."plan_process_config"."pro_no" IS '项目编号';
COMMENT ON COLUMN "public"."plan_process_config"."pro_name" IS '项目名称';
COMMENT ON COLUMN "public"."plan_process_config"."print_req" IS '印字要求';
COMMENT ON COLUMN "public"."plan_process_config"."remark1" IS '备注1';
COMMENT ON COLUMN "public"."plan_process_config"."remark2" IS '备注2';
COMMENT ON COLUMN "public"."plan_process_config"."remark3" IS '备注3';
COMMENT ON COLUMN "public"."plan_process_config"."remark4" IS '备注4';
COMMENT ON COLUMN "public"."plan_process_config"."real_print_req" IS '实际印字要求';
COMMENT ON COLUMN "public"."plan_process_config"."cable_core" IS '发泡缆芯';
COMMENT ON COLUMN "public"."plan_process_config"."model_core" IS '模芯';
COMMENT ON COLUMN "public"."plan_process_config"."model_sleeve" IS '模套';
COMMENT ON COLUMN "public"."plan_process_config"."sizing_model" IS '定径模';
COMMENT ON COLUMN "public"."plan_process_config"."strand_model" IS '绞合模';
COMMENT ON COLUMN "public"."plan_process_config"."work_frequency" IS '工作频带内驻波比';
COMMENT ON COLUMN "public"."plan_process_config"."frequency_range" IS '频率范围';
COMMENT ON COLUMN "public"."plan_process_config"."resistance" IS '直流电阻';
COMMENT ON COLUMN "public"."plan_process_config"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."plan_process_config"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."plan_process_config"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."plan_process_config"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."plan_process_config"."order_number" IS '订单号';
COMMENT ON COLUMN "public"."plan_process_config"."order_id" IS '订单id';


ALTER TABLE "public"."plan_process_config" OWNER TO "postgres";
ALTER SEQUENCE "public"."plan_process_config_id_seq"
    OWNED BY "public"."plan_process_config"."id";





-- 2022年10月26号
-- 新工艺配置单产品性能要求表
CREATE SEQUENCE "public"."plan_process_config_data_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."plan_process_config_data" (
  "id" int8 NOT NULL DEFAULT nextval('plan_process_config_data_id_seq'::regclass),
  "frequency" varchar(50) COLLATE "pg_catalog"."default",
  "delivery_reduce" varchar(50) COLLATE "pg_catalog"."default",
  "coupling_loss" varchar(50) COLLATE "pg_catalog"."default",
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "config_id" int8
)
;
COMMENT ON COLUMN "public"."plan_process_config_data"."id" IS 'id';
COMMENT ON COLUMN "public"."plan_process_config_data"."frequency" IS '频率';
COMMENT ON COLUMN "public"."plan_process_config_data"."delivery_reduce" IS '最大传送衰减';
COMMENT ON COLUMN "public"."plan_process_config_data"."coupling_loss" IS '耦合损耗';
COMMENT ON COLUMN "public"."plan_process_config_data"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."plan_process_config_data"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."plan_process_config_data"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."plan_process_config_data"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."plan_process_config_data"."config_id" IS '工艺配置单id';

ALTER TABLE "public"."plan_process_config_data" OWNER TO "postgres";
ALTER SEQUENCE "public"."plan_process_config_data_id_seq"
    OWNED BY "public"."plan_process_config_data"."id";





---- 2022年10月20号
-- 新盘点pda表
CREATE SEQUENCE "public"."warehouse_inventory_pda_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."warehouse_inventory_pda" (
  "id" int8 NOT NULL DEFAULT nextval('warehouse_inventory_pda_id_seq'::regclass),
  "part_no" varchar(100) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
  "sn" varchar(255) COLLATE "pg_catalog"."default",
  "ifs_batch_no" varchar(255) COLLATE "pg_catalog"."default",
  "loc_no" varchar(50) COLLATE "pg_catalog"."default",
  "iny_qty" numeric(18,6),
  "create_user" varchar(50) COLLATE "pg_catalog"."default",
  "update_user" varchar(50) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "inventory_detail_id" int8
)
;
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."id" IS 'id';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."sn" IS 'sn号';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."ifs_batch_no" IS 'ifs批次号';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."loc_no" IS '库位编号';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."iny_qty" IS '盘点数量';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."warehouse_inventory_pda"."inventory_detail_id" IS '盘点明细id';

ALTER TABLE "public"."warehouse_inventory_pda"
  OWNER TO "postgres";

  ALTER SEQUENCE "public"."warehouse_inventory_pda_id_seq"
    OWNED BY "public"."warehouse_inventory_pda"."id";

-- 2022-11-02 库存事务表新增IFS批次号字段
alter table warehouse_transaction
    add column ifs_batch_no varchar(100);

-- 2022-11-07 对接ifs日志表新增字段
ALTER TABLE "ifs_log"  ADD COLUMN "active" BOOLEAN  DEFAULT TRUE;

-- 2022年11月7号
-- 货盘运输任务主表
ALTER TABLE "warehouse_pallet_transports" ADD COLUMN "state" varchar(20) COLLATE "pg_catalog"."default";

-- 2022年11月8号
-- 货盘运输任务主表状态加默认值
ALTER TABLE "warehouse_pallet_transports" ALTER COLUMN "state" set DEFAULT 'draft' ;


-- 2022年11月7号
--退料申请详情表
ALTER TABLE "warehouse_reverse_stock_apply_detail" ADD COLUMN "executor" varchar(100) COLLATE "pg_catalog"."default";
ALTER TABLE "warehouse_reverse_stock_apply_detail" ADD COLUMN "execute_time" timestamp(6);

-- 2022年11月16号
--工艺文件结构图表
CREATE SEQUENCE "public"."technology_document_jgt_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;


CREATE TABLE "public"."technology_document_jgt" (
    "id" int8 NOT NULL DEFAULT nextval('technology_document_jgt_id_seq'::regclass),
    "file_name" varchar(500) COLLATE "pg_catalog"."default",
    "document_id" int8,
    "create_time" timestamp(6),
    "update_time" timestamp(6),
    "create_user" varchar(50) COLLATE "pg_catalog"."default",
    "update_user" varchar(50) COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."technology_document_jgt"."id" IS 'id';
COMMENT ON COLUMN "public"."technology_document_jgt"."file_name" IS '结构图文件名';
COMMENT ON COLUMN "public"."technology_document_jgt"."document_id" IS '工艺文件id';

ALTER SEQUENCE "public"."technology_document_jgt_id_seq"
    OWNED BY "public"."technology_document_jgt"."id";

ALTER SEQUENCE "public"."technology_document_jgt_id_seq" OWNER TO "postgres";

ALTER table "public"."technology_document" drop COLUMN "jgt";




-- 2022年11月7号
--工厂信息表
ALTER TABLE "equipment_equipment" ADD COLUMN "workshop" varchar(50) COLLATE "pg_catalog"."default";

-- 2022年11月17号
--工艺文件表
ALTER TABLE "technology_document" ADD COLUMN "test_standard" BOOLEAN COLLATE "pg_catalog"."default";
--零件表
ALTER TABLE "basic_part" ADD COLUMN "examiner" varchar(50) COLLATE "pg_catalog"."default";

--馈线合格证表
CREATE SEQUENCE "public"."production_feeder_certificate_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;


CREATE TABLE "public"."production_feeder_certificate" (
  "id" int8 NOT NULL,
  "sn" varchar(255) COLLATE "pg_catalog"."default",
  "part_no" varchar(255) COLLATE "pg_catalog"."default",
  "part_name" varchar(255) COLLATE "pg_catalog"."default",
  "specs" varchar(100) COLLATE "pg_catalog"."default",
  "stock_quantity" numeric(18,6),
  "date" varchar(50) COLLATE "pg_catalog"."default",
  "examiner" varchar(255) COLLATE "pg_catalog"."default",
  "ifs_batch_no" varchar(255) COLLATE "pg_catalog"."default",
  "create_time" timestamp(6),
  "update_time" timestamp(6),
  "create_user" varchar(255) COLLATE "pg_catalog"."default",
  "update_user" varchar(255) COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."production_feeder_certificate"."id" IS 'id';
COMMENT ON COLUMN "public"."production_feeder_certificate"."sn" IS 'sn号';
COMMENT ON COLUMN "public"."production_feeder_certificate"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."production_feeder_certificate"."part_name" IS '零件名称';
COMMENT ON COLUMN "public"."production_feeder_certificate"."specs" IS '规格';
COMMENT ON COLUMN "public"."production_feeder_certificate"."stock_quantity" IS '长度';
COMMENT ON COLUMN "public"."production_feeder_certificate"."date" IS '日期';
COMMENT ON COLUMN "public"."production_feeder_certificate"."examiner" IS '检验员';
COMMENT ON COLUMN "public"."production_feeder_certificate"."ifs_batch_no" IS 'ifs批次号';

ALTER TABLE "public"."production_feeder_certificate"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."production_feeder_certificate_id_seq"
    OWNED BY "public"."production_feeder_certificate"."id";



-- 2022年11月22号
--检验员配置表
CREATE SEQUENCE "public"."production_examiner_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."production_examiner" (
 "id" int8 NOT NULL DEFAULT nextval('production_examiner_id_seq'::regclass),
 "part_no" varchar(100) COLLATE "pg_catalog"."default",
 "examiner" varchar(50) COLLATE "pg_catalog"."default",
 "examiner_after" varchar(50) COLLATE "pg_catalog"."default",
 "part_no_after" varchar(100) COLLATE "pg_catalog"."default",
 "create_time" timestamp(6),
 "create_user" varchar(50) COLLATE "pg_catalog"."default",
 "update_time" timestamp(6),
 "update_user" varchar(50) COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."production_examiner"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."production_examiner"."examiner" IS '默认检验员';
COMMENT ON COLUMN "public"."production_examiner"."examiner_after" IS '改后检验员';
COMMENT ON COLUMN "public"."production_examiner"."part_no_after" IS '改后零件号';


ALTER TABLE "public"."production_examiner"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."production_examiner_id_seq"
    OWNED BY "public"."production_examiner"."id";



-- v1.31.0 检测项继承
-- 工艺文件标准参数
alter table public.technology_document_standard_param
    add extends_part_no varchar(50);

comment on column public.technology_document_standard_param.extends_part_no is '继承检测零件号';

alter table public.technology_document_standard_param
    add extends_routing_id bigint;

comment on column public.technology_document_standard_param.extends_routing_id is '继承检测工艺路线id';

alter table public.technology_document_standard_param
    add extends_routing_no varchar(50);

comment on column public.technology_document_standard_param.extends_routing_no is '继承检测工艺路线编号';

alter table public.technology_document_standard_param
    add extends_operation_id bigint;

comment on column public.technology_document_standard_param.extends_operation_id is '继承检测工序id';

alter table public.technology_document_standard_param
    add extends_operation_no varchar(50);

comment on column public.technology_document_standard_param.extends_operation_no is '继承检测工序编号';

alter table public.technology_document_standard_param
    add extends_test_standard_id bigint;

comment on column public.technology_document_standard_param.extends_test_standard_id is '继承检测标准id';

alter table public.technology_document_standard_param
    add extends_test_standard_no varchar(50);

comment on column public.technology_document_standard_param.extends_test_standard_no is '继承检测标准编号';

alter table public.technology_document_standard_param
    add extends_test_standard_param_id bigint;

comment on column public.technology_document_standard_param.extends_test_standard_param_id is '继承检测标准参数id';

alter table public.technology_document_standard_param
    add extends_test_standard_param_no varchar(50);

comment on column public.technology_document_standard_param.extends_test_standard_param_no is '继承检测标准参数编号';


alter table public.technology_document_standard_param
    add bom_routing_id bigint;

alter table public.technology_document_standard_param
    add routing_operation_id bigint;

-- 制造订单-检测标准参数
alter table public.plan_mo_test_standard_param
    add extends_part_no varchar(50);

comment on column public.plan_mo_test_standard_param.extends_part_no is '继承检测零件号';

alter table public.plan_mo_test_standard_param
    add extends_routing_id bigint;

comment on column public.plan_mo_test_standard_param.extends_routing_id is '继承检测工艺路线id';

alter table public.plan_mo_test_standard_param
    add extends_routing_no varchar(50);

comment on column public.plan_mo_test_standard_param.extends_routing_no is '继承检测工艺路线编号';

alter table public.plan_mo_test_standard_param
    add extends_operation_id bigint;

comment on column public.plan_mo_test_standard_param.extends_operation_id is '继承检测工序id';

alter table public.plan_mo_test_standard_param
    add extends_operation_no varchar(50);

comment on column public.plan_mo_test_standard_param.extends_operation_no is '继承检测工序编号';

alter table public.plan_mo_test_standard_param
    add extends_test_standard_id bigint;

comment on column public.plan_mo_test_standard_param.extends_test_standard_id is '继承检测标准id';

alter table public.plan_mo_test_standard_param
    add extends_test_standard_no varchar(50);

comment on column public.plan_mo_test_standard_param.extends_test_standard_no is '继承检测标准编号';

alter table public.plan_mo_test_standard_param
    add extends_test_standard_param_id bigint;

comment on column public.plan_mo_test_standard_param.extends_test_standard_param_id is '继承检测标准参数id';

alter table public.plan_mo_test_standard_param
    add extends_test_standard_param_no varchar(50);

comment on column public.plan_mo_test_standard_param.extends_test_standard_param_no is '继承检测标准参数编号';


alter table public.plan_mo_test_standard_param
    add technology_document_standard_param_id bigint;

comment on column public.plan_mo_test_standard_param.technology_document_standard_param_id is '工艺文件检测标准参数明细表id';

-- 检测汇报项目表
alter table public.quality_report_sample_item
    add extends_part_no varchar(50);

comment on column public.quality_report_sample_item.extends_part_no is '继承检测零件号';

alter table public.quality_report_sample_item
    add extends_routing_id bigint;

comment on column public.quality_report_sample_item.extends_routing_id is '继承检测工艺路线id';

alter table public.quality_report_sample_item
    add extends_routing_no varchar(50);

comment on column public.quality_report_sample_item.extends_routing_no is '继承检测工艺路线编号';

alter table public.quality_report_sample_item
    add extends_operation_id bigint;

comment on column public.quality_report_sample_item.extends_operation_id is '继承检测工序id';

alter table public.quality_report_sample_item
    add extends_operation_no varchar(50);

comment on column public.quality_report_sample_item.extends_operation_no is '继承检测工序编号';

alter table public.quality_report_sample_item
    add extends_test_standard_id bigint;

comment on column public.quality_report_sample_item.extends_test_standard_id is '继承检测标准id';

alter table public.quality_report_sample_item
    add extends_test_standard_no varchar(50);

comment on column public.quality_report_sample_item.extends_test_standard_no is '继承检测标准编号';

alter table public.quality_report_sample_item
    add extends_test_standard_param_id bigint;

comment on column public.quality_report_sample_item.extends_test_standard_param_id is '继承检测标准参数id';

alter table public.quality_report_sample_item
    add extends_test_standard_param_no varchar(50);

comment on column public.quality_report_sample_item.extends_test_standard_param_no is '继承检测标准参数编号';


alter table public.quality_report_sample_item
    add technology_document_standard_param_id bigint;

comment on column public.quality_report_sample_item.technology_document_standard_param_id is '工艺文件检测标准参数明细表id';



-- 2022年11月21号
--工艺文件主表
ALTER TABLE "technology_document" ADD COLUMN "update_user" varchar(50) COLLATE "pg_catalog"."default";
ALTER TABLE "technology_document" ADD COLUMN "update_time" timestamp(6);

alter table quality_report_sample_item add column extends_result_flag bool;

-- v1.33.0
alter table public.production_mould_register
    add operation_task_id bigint;

comment on column public.production_mould_register.operation_task_id is '工单id';

alter table public.production_mould_register
    add part_no varchar(100);

comment on column public.production_mould_register.part_no is '零件号';

alter table quality_zx_label_bind_relation
    add column packaging_code varchar(100);




-- 2022年12月02号
--单位工时系数表
CREATE SEQUENCE "public"."production_unit_work_id_seq"
    INCREMENT 1
    MINVALUE  1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;


CREATE TABLE "public"."production_unit_work" (
"id" int8 NOT NULL DEFAULT nextval('production_unit_work_id_seq'::regclass),
"operation_id" int8,
"workstation_id" int8,
"part_id" int8,
"unit_work_factor" numeric(12,6),
"quota" numeric(12,6),
"update_user" varchar(255) COLLATE "pg_catalog"."default",
"create_time" timestamp(6),
"update_time" timestamp(6),
"create_user" varchar(255) COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."production_unit_work"."id" IS 'id';
COMMENT ON COLUMN "public"."production_unit_work"."operation_id" IS '工序id';
COMMENT ON COLUMN "public"."production_unit_work"."workstation_id" IS '机台id';
COMMENT ON COLUMN "public"."production_unit_work"."part_id" IS '零件id';
COMMENT ON COLUMN "public"."production_unit_work"."unit_work_factor" IS '单位工时系数';
COMMENT ON COLUMN "public"."production_unit_work"."quota" IS '定额';



-- 2022年12月06号
-- 报工产出表
ALTER TABLE "production_product_output" ADD COLUMN "orig_part_id" int8;
COMMENT ON COLUMN "public"."production_product_output"."orig_part_id" IS '原始零件id';

-- 2022年12月06号
-- 馈线合格证表
ALTER TABLE "production_feeder_certificate" DROP COLUMN "examiner_before";
ALTER TABLE "production_feeder_certificate" DROP COLUMN "part_no_before";
ALTER TABLE "production_feeder_certificate" ADD COLUMN "examiner_after" varchar(255) COLLATE "pg_catalog"."default";
ALTER TABLE "production_feeder_certificate" ADD COLUMN "part_no_after" varchar(255) COLLATE "pg_catalog"."default";
COMMENT ON COLUMN "public"."production_feeder_certificate"."examiner_after" IS '改后检验员';
COMMENT ON COLUMN "public"."production_feeder_certificate"."part_no_after" IS '改后零件号';

-- 2022年12月12号
-- 馈线合格证表
ALTER TABLE "production_feeder_certificate" ADD COLUMN "stock_quantity_after" numeric(18,6) DEFAULT 0;
COMMENT ON COLUMN "public"."production_feeder_certificate"."stock_quantity_after" IS '入库长度';


-- 2022年12月09号
-- 客户订单主表
ALTER TABLE "plan_customer" ADD COLUMN "comment" varchar(255);
COMMENT ON COLUMN "public"."plan_customer"."comment" IS '备注';

-- 2022年12月09号
-- 客户订单主表（股份公司）
ALTER TABLE "plan_customer_joint_stock_company" ADD COLUMN "comment" varchar(255);
COMMENT ON COLUMN "public"."plan_customer_joint_stock_company"."comment" IS '备注';


-- 2022-12-14
-- 工艺文件表
ALTER TABLE "technology_document" ALTER COLUMN "test_standard" SET  DEFAULT false;

-- 2022-12-19 箱码，销售订单关系表
CREATE SEQUENCE "public"."plan_package_code_customer_order_relation_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."plan_package_code_customer_order_relation"
(
    "id"                  int8 NOT NULL                               DEFAULT nextval('plan_package_code_customer_order_relation_id_seq'::regclass),
    "customer_order_id"                 bigint,
    "customer_order_no"        varchar(255) COLLATE "pg_catalog"."default",
    "otc_line_no"              varchar(50) COLLATE "pg_catalog"."default",
    "package_code"             varchar(50) COLLATE "pg_catalog"."default",
    "create_user"         varchar(50) COLLATE "pg_catalog"."default",
    "update_user"         varchar(50) COLLATE "pg_catalog"."default",
    "create_time"         timestamp(6),
    "update_time"         timestamp(6)
)
;
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."id" IS 'id';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."customer_order_id" IS '销售订单id';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."customer_order_no" IS '销售订单号';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."otc_line_no" IS '行号';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."package_code" IS '箱码';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."plan_package_code_customer_order_relation"."update_time" IS '更新时间';

ALTER TABLE "public"."plan_package_code_customer_order_relation"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."plan_package_code_customer_order_relation_id_seq"
    OWNED BY "public"."plan_package_code_customer_order_relation"."id";

-- 2022.12.21
alter table public.plan_manufacturing_order
    add ori_ifs_order_no varchar(32);

comment on column public.plan_manufacturing_order.ori_ifs_order_no is '原ifs车间订单号';

-- 2022年12月20号
-- 工艺文件主表
ALTER TABLE "technology_document" ADD COLUMN "update_real_user" varchar(50) COLLATE "pg_catalog"."default";
ALTER TABLE "technology_document" ADD COLUMN "update_real_time" timestamp(6);

-- 2022-12-28
alter table public.ifs_log
    add interrupt_flag boolean;

comment on column public.ifs_log.interrupt_flag is '定时器执行ifs日志中断标记';
-- 2023年1月4号
-- 客户订单表
ALTER TABLE "plan_customer_order" ADD COLUMN "is_send" BOOLEAN DEFAULT false;


-- 2023年1月6号
-- 报工产出表
ALTER TABLE "production_product_output" ADD COLUMN "print_num" int8;
COMMENT ON COLUMN "public"."production_product_output"."print_num" IS '成品标签1打印次数';

-- 2023年1月12号
-- 馈线合格证
ALTER TABLE "production_feeder_certificate" ADD COLUMN "print_num" int8;
COMMENT ON COLUMN "public"."production_feeder_certificate"."print_num" IS '打印次数';

-- 2023年2月14号
--馈线合格证
ALTER TABLE "production_feeder_certificate" ADD COLUMN "prod_name" varchar(255) COLLATE "pg_catalog"."default";

-- 2023年2月17号
--19码防呆校验
ALTER TABLE "quality_hw_19_verify" ADD unique("bar_code");

-- 2023年3月10号
--检测汇报项目表增加单位
ALTER TABLE "quality_report_sample_item" ADD COLUMN "unit" varchar(50);
COMMENT ON COLUMN "public"."quality_report_sample_item"."unit" IS '单位';

-- 2023年3月20号
--包装表增加 包装称重是否接收异常
ALTER TABLE "warehouse_packaging" ADD COLUMN "is_rec_exception" BOOLEAN ;
COMMENT ON COLUMN "public"."warehouse_packaging"."is_rec_exception" IS '包装称重是否接收异常';

-- 2023年3月23号
--19表增加SN,长度,客户物料编码
ALTER TABLE "quality_hw_19_verify" ADD COLUMN "sn" varchar(64);
COMMENT ON COLUMN "public"."quality_hw_19_verify"."sn" IS 'SN';
ALTER TABLE "quality_hw_19_verify" ADD COLUMN "cus_material_code" varchar(64);
COMMENT ON COLUMN "public"."quality_hw_19_verify"."cus_material_code" IS '客户物料编码';
ALTER TABLE "quality_hw_19_verify" ADD COLUMN "qty" numeric(18,6) DEFAULT 0;
COMMENT ON COLUMN "public"."quality_hw_19_verify"."qty" IS '长度';

-- 2023年3月24号
--检测汇报项目表增加 计算值和采集值
ALTER TABLE "quality_report_sample_item" ADD COLUMN "cal_item_value" varchar(100);
COMMENT ON COLUMN "public"."quality_report_sample_item"."cal_item_value" IS '计算值';
ALTER TABLE "quality_report_sample_item" ADD COLUMN "acq_item_value" varchar(100);
COMMENT ON COLUMN "public"."quality_report_sample_item"."acq_item_value" IS '采集值';

-- 2023年3月27号
--工单生产记录表增加 分割任务产出id
ALTER TABLE "production_operation_task_record" ADD COLUMN "segmentation_id" int8;
COMMENT ON COLUMN "public"."production_operation_task_record"."segmentation_id" IS '分割任务产出id';


-- 2023年4月7号
--产出表表增加 盘具尺寸
ALTER TABLE "production_product_output" ADD COLUMN "disc_tool_measurement" varchar(100);
COMMENT ON COLUMN "public"."production_product_output"."disc_tool_measurement" IS '盘具尺寸';


-- 2023年4月10号
--馈线合格证表增加 零件族群编号
ALTER TABLE "production_feeder_certificate" ADD COLUMN "part_family_no" varchar(100);
COMMENT ON COLUMN "public"."production_feeder_certificate"."part_family_no" IS '零件族编号';

-- 2023年3月30号
--不合格处理基础信息配置表

CREATE SEQUENCE "public"."quality_unqualified_configuration_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;


CREATE TABLE "public"."quality_unqualified_configuration"
(
    "id"     int8 NOT NULL      DEFAULT nextval('quality_unqualified_configuration_id_seq'::regclass),
    "work_shop"                varchar(50) COLLATE "pg_catalog"."default",
    "type"                     varchar(50) COLLATE "pg_catalog"."default",
    "process_mode"              varchar(50) COLLATE "pg_catalog"."default",
    "originator"         varchar(255) COLLATE "pg_catalog"."default",
    "examiner"           varchar(255) COLLATE "pg_catalog"."default",
    "handler"            varchar(255) COLLATE "pg_catalog"."default",
    "create_user"        varchar(50) COLLATE "pg_catalog"."default",
    "update_user"        varchar(50) COLLATE "pg_catalog"."default",
    "create_time"        timestamp(6),
    "update_time"        timestamp(6)
)
;
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."work_shop" IS '车间';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."type" IS '产品类型';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."process_mode" IS '处理方式';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."originator" IS '发起人';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."examiner" IS '审核人';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."handler" IS '处理人';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."update_user" IS '更新人';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_unqualified_configuration"."update_time" IS '更新时间';

ALTER TABLE "public"."quality_unqualified_configuration"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_unqualified_configuration_id_seq"
    OWNED BY "public"."quality_unqualified_configuration"."id";


-- 2023年4月4号
--不合格处理新增字段
ALTER TABLE "quality_unqualified_process" ADD COLUMN "examiner" varchar(255);
COMMENT ON COLUMN "public"."quality_unqualified_process"."examiner" IS '审批人';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "examine_time" timestamp(6);
COMMENT ON COLUMN "public"."quality_unqualified_process"."examine_time" IS '审批时间';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "handler" varchar(255);
COMMENT ON COLUMN "public"."quality_unqualified_process"."handler" IS '执行人';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "handle_time" timestamp(6);
COMMENT ON COLUMN "public"."quality_unqualified_process"."handle_time" IS '执行时间';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "execute_sn" varchar(100);
COMMENT ON COLUMN "public"."quality_unqualified_process"."execute_sn" IS '处理后SN号';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "degrade_part_id" int8;
COMMENT ON COLUMN "public"."quality_unqualified_process"."degrade_part_id" IS '降级后零件id';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "examine_idea" varchar(500);
COMMENT ON COLUMN "public"."quality_unqualified_process"."examine_idea" IS '评审意见';
ALTER TABLE "quality_unqualified_process" ADD COLUMN "loss_registration" numeric(18,6) DEFAULT 0;
COMMENT ON COLUMN "public"."quality_unqualified_process"."loss_registration" IS '损失登记';

-- 2023年4月12号
--工单表表增加 批量提交状态
ALTER TABLE "production_operation_task" ADD COLUMN "is_submit" BOOLEAN default false ;
COMMENT ON COLUMN "public"."production_operation_task"."is_submit" IS '批量提交状态';


-- 2023年4月12号
--检测标准子表  新增是否抽检
ALTER TABLE "quality_test_standard_param" ADD COLUMN "is_check" BOOLEAN default false;
COMMENT ON COLUMN "public"."quality_test_standard_param"."is_check" IS '是否抽检';

-- 2023年4月12号
--检测汇报项目表  新增是否抽检
ALTER TABLE "quality_report_sample_item" ADD COLUMN "is_check" BOOLEAN default false;
COMMENT ON COLUMN "public"."quality_report_sample_item"."is_check" IS '是否抽检';




-- 2023年4月11号
--新建标签元素表
CREATE SEQUENCE "public"."quality_label_element_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."quality_label_element"
(
    "id"                  int8 NOT NULL     DEFAULT nextval('quality_label_element_id_seq'::regclass),
    "item_code"        varchar(255) COLLATE "pg_catalog"."default",
    "item_desc"        varchar(255) COLLATE "pg_catalog"."default",
    "create_time"             timestamp(6),
    "update_time"             timestamp(6),
    "create_user"         varchar(255) COLLATE "pg_catalog"."default",
    "update_user"         varchar(255) COLLATE "pg_catalog"."default"

)
;
COMMENT ON COLUMN "public"."quality_label_element"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_label_element"."item_code" IS '标签元素码';
COMMENT ON COLUMN "public"."quality_label_element"."item_desc" IS '标签元素描述';
COMMENT ON COLUMN "public"."quality_label_element"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_label_element"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."quality_label_element"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_label_element"."update_user" IS '更新人';

ALTER TABLE "public"."quality_label_element"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_label_element_id_seq"
    OWNED BY "public"."quality_label_element"."id";

--新建标签信息配置表
CREATE SEQUENCE "public"."quality_label_print_config_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."quality_label_print_config"
(
    "id"                  int8 NOT NULL     DEFAULT nextval('quality_label_print_config_id_seq'::regclass),
    "label_unique_code"        varchar(255) COLLATE "pg_catalog"."default",
    "label_type_code"        varchar(255) COLLATE "pg_catalog"."default",
    "label_type_desc"        varchar(255) COLLATE "pg_catalog"."default",
    "label_desc"        varchar(255) COLLATE "pg_catalog"."default",
    "label_size"        varchar(255) COLLATE "pg_catalog"."default",
    "file_name"         varchar(255) COLLATE "pg_catalog"."default",
    "create_time"             timestamp(6),
    "update_time"             timestamp(6),
    "create_user"         varchar(255) COLLATE "pg_catalog"."default",
    "update_user"         varchar(255) COLLATE "pg_catalog"."default"

)
;
COMMENT ON COLUMN "public"."quality_label_print_config"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_label_print_config"."label_unique_code" IS '标签身份码';
COMMENT ON COLUMN "public"."quality_label_print_config"."label_type_code" IS '标签类别码';
COMMENT ON COLUMN "public"."quality_label_print_config"."label_type_desc" IS '标签类别描述';
COMMENT ON COLUMN "public"."quality_label_print_config"."label_desc" IS '标签描述';
COMMENT ON COLUMN "public"."quality_label_print_config"."label_size" IS '标签尺寸';
COMMENT ON COLUMN "public"."quality_label_print_config"."file_name" IS '附件';
COMMENT ON COLUMN "public"."quality_label_print_config"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_label_print_config"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."quality_label_print_config"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_label_print_config"."update_user" IS '更新人';

ALTER TABLE "public"."quality_label_print_config"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_label_print_config_id_seq"
    OWNED BY "public"."quality_label_print_config"."id";

--新建标签信息配置明细表
CREATE SEQUENCE "public"."quality_label_print_config_detail_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."quality_label_print_config_detail"
(
    "id"                  int8 NOT NULL     DEFAULT nextval('quality_label_print_config_detail_id_seq'::regclass),
    "mid"                 int8,
    "is_active"           BOOLEAN  DEFAULT FALSE,
    "is_config_data_source"        BOOLEAN  DEFAULT FALSE,
    "item_code"        varchar(255) COLLATE "pg_catalog"."default",
    "caption"        varchar(255) COLLATE "pg_catalog"."default",
    "default_value"        varchar(255) COLLATE "pg_catalog"."default",
    "qry_sql"        varchar(2000) COLLATE "pg_catalog"."default",
    "create_time"             timestamp(6),
    "update_time"             timestamp(6),
    "create_user"         varchar(255) COLLATE "pg_catalog"."default",
    "update_user"         varchar(255) COLLATE "pg_catalog"."default"

)
;
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."mid" IS '标签打印配置表记录行id';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."is_active" IS '是否启用';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."is_config_data_source" IS '是否配置数据源';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."item_code" IS '标签元素码';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."caption" IS '标题';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."default_value" IS '默认值';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."qry_sql" IS '查询SQL，传参统一为SN，输出字段统一为value';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_label_print_config_detail"."update_user" IS '更新人';

ALTER TABLE "public"."quality_label_print_config_detail"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_label_print_config_detail_id_seq"
    OWNED BY "public"."quality_label_print_config_detail"."id";


--新建标签表
CREATE SEQUENCE "public"."quality_label_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."quality_label"
(
    "id"                  int8 NOT NULL     DEFAULT nextval('quality_label_id_seq'::regclass),
    "label_unique_code"        varchar(255) COLLATE "pg_catalog"."default",
    "label_type_code"        varchar(255) COLLATE "pg_catalog"."default",
    "label_type_desc"        varchar(255) COLLATE "pg_catalog"."default",
    "label_desc"        varchar(255) COLLATE "pg_catalog"."default",
    "label_size"        varchar(255) COLLATE "pg_catalog"."default",
    "part_batch_no"        varchar(255) COLLATE "pg_catalog"."default",
    "ifs_batch_no"        varchar(255) COLLATE "pg_catalog"."default",
    "wdr"               varchar(255) COLLATE "pg_catalog"."default",
    "part_no"        varchar(255) COLLATE "pg_catalog"."default",
    "qty"            numeric(18,6) DEFAULT 0,
    "label_info"        varchar(4000) COLLATE "pg_catalog"."default",
    "print_count"        int8 default 0,
    "active"            BOOLEAN  DEFAULT TRUE,
    "create_time"             timestamp(6),
    "update_time"             timestamp(6),
    "create_user"         varchar(255) COLLATE "pg_catalog"."default",
    "update_user"         varchar(255) COLLATE "pg_catalog"."default"

)
;
COMMENT ON COLUMN "public"."quality_label"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_label"."label_unique_code" IS '标签身份码';
COMMENT ON COLUMN "public"."quality_label"."label_type_code" IS '标签类别码';
COMMENT ON COLUMN "public"."quality_label"."label_type_desc" IS '标签类别描述';
COMMENT ON COLUMN "public"."quality_label"."label_desc" IS '标签描述';
COMMENT ON COLUMN "public"."quality_label"."label_size" IS '标签尺寸';
COMMENT ON COLUMN "public"."quality_label"."part_batch_no" IS 'SN号';
COMMENT ON COLUMN "public"."quality_label"."ifs_batch_no" IS 'ifs批次号';
COMMENT ON COLUMN "public"."quality_label"."wdr" IS 'wdr';
COMMENT ON COLUMN "public"."quality_label"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."quality_label"."qty" IS '数量';
COMMENT ON COLUMN "public"."quality_label"."label_info" IS 'JSON格式的标签信息';
COMMENT ON COLUMN "public"."quality_label"."print_count" IS '打印次数';
COMMENT ON COLUMN "public"."quality_label"."active" IS '软删除';
COMMENT ON COLUMN "public"."quality_label"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_label"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."quality_label"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_label"."update_user" IS '更新人';

ALTER TABLE "public"."quality_label"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_label_id_seq"
    OWNED BY "public"."quality_label"."id";


--新建标签打印日志表
CREATE SEQUENCE "public"."quality_label_print_log_id_seq"
    INCREMENT 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    START 1
    CACHE 1;

CREATE TABLE "public"."quality_label_print_log"
(
    "id"                  int8 NOT NULL     DEFAULT nextval('quality_label_print_log_id_seq'::regclass),
    "mid"                 int8,
    "part_batch_no"        varchar(255) COLLATE "pg_catalog"."default",
    "ifs_batch_no"        varchar(255) COLLATE "pg_catalog"."default",
    "wdr"        varchar(255) COLLATE "pg_catalog"."default",
    "part_no"        varchar(255) COLLATE "pg_catalog"."default",
    "qty"            numeric(18,6) DEFAULT 0,
    "label_info"        varchar(4000) COLLATE "pg_catalog"."default",
    "create_time"             timestamp(6),
    "update_time"             timestamp(6),
    "create_user"         varchar(255) COLLATE "pg_catalog"."default",
    "update_user"         varchar(255) COLLATE "pg_catalog"."default"

)
;
COMMENT ON COLUMN "public"."quality_label_print_log"."id" IS 'id';
COMMENT ON COLUMN "public"."quality_label_print_log"."mid" IS '标签表记录行id';
COMMENT ON COLUMN "public"."quality_label_print_log"."part_batch_no" IS 'SN号';
COMMENT ON COLUMN "public"."quality_label_print_log"."ifs_batch_no" IS 'ifs批次号';
COMMENT ON COLUMN "public"."quality_label_print_log"."wdr" IS 'wdr';
COMMENT ON COLUMN "public"."quality_label_print_log"."part_no" IS '零件号';
COMMENT ON COLUMN "public"."quality_label_print_log"."qty" IS '数量';
COMMENT ON COLUMN "public"."quality_label_print_log"."label_info" IS 'JSON格式的合格证信息';
COMMENT ON COLUMN "public"."quality_label_print_log"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."quality_label_print_log"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."quality_label_print_log"."create_user" IS '创建人';
COMMENT ON COLUMN "public"."quality_label_print_log"."update_user" IS '更新人';

ALTER TABLE "public"."quality_label_print_log"
    OWNER TO "postgres";

ALTER SEQUENCE "public"."quality_label_print_log_id_seq"
    OWNED BY "public"."quality_label_print_log"."id";


-- 2023年4月25号
--制造订单-检测标准参数  新增是否抽检
ALTER TABLE "plan_mo_test_standard_param" ADD COLUMN "is_check" BOOLEAN default false;
COMMENT ON COLUMN "public"."plan_mo_test_standard_param"."is_check" IS '是否抽检';

-- 2023年4月25号
--工艺文件检测参数明细表 新增是否抽检
ALTER TABLE "technology_document_standard_param" ADD COLUMN "is_check" BOOLEAN default false;
COMMENT ON COLUMN "public"."technology_document_standard_param"."is_check" IS '是否抽检';
