-- ----------------------------
-- 1、协议模板表
-- ----------------------------
drop table if exists dhc_agreement_template;
create table dhc_agreement_template (
     agreement_template_id           bigint(20)      not null auto_increment    comment '协议模板id',
     production_mothod         char(1)     default '0'                 comment '生产方式(0.自制 1.ODM)',
     product_line        varchar(32)     default ''                 comment '产品线编码',
     product_category_large       varchar(32)     default ''                 comment '产品大类编码',
     product_category_middle       varchar(32)     default ''                 comment '产品中类编码',
     product_category_small       varchar(32)     default ''                 comment '产品小类编码',
     attribute_quantity         int      default 0                  comment '属性数量',
     version         varchar(32)     default ''                  comment '版本号',
     del_flag          char(1)         default '0'                comment '删除标志(0代表存在 1代表删除)',
     create_by         varchar(64)     default ''                 comment '创建者',
     create_time 	    datetime                                   comment '创建时间',
     update_by         varchar(64)     default ''                 comment '更新者',
     update_time       datetime                                   comment '更新时间',
     primary key (agreement_id)
) engine=innodb auto_increment=1 comment = '协议模板表';
-- ----------------------------
-- 2、协议属性组表
-- ----------------------------
drop table if exists dhc_agreement_attribute_group;
create table dhc_agreement_attribute_group (
      attribute_group_id           bigint(20)      not null auto_increment    comment '协议属性组id',
      agreement_template_id           bigint(20)      not null     comment '协议模板id',
      group_code        varchar(64)     default ''                 comment '协议属性组编码',
      group_name         varchar(32)     default ''                 comment '协议属性组名称',
      version         varchar(32)     default ''                  comment '版本号',
      del_flag          char(1)         default '0'                comment '删除标志(0代表存在 1代表删除)',
      create_by         varchar(64)     default ''                 comment '创建者',
      create_time 	    datetime                                   comment '创建时间',
      update_by         varchar(64)     default ''                 comment '更新者',
      update_time       datetime                                   comment '更新时间',
      primary key (attribute_group_id)
) engine=innodb auto_increment=1 comment = '协议属性组表';
-- ----------------------------
-- 3、协议属性表
-- ----------------------------
drop table if exists dhc_agreement_attribute;
create table dhc_agreement_attribute (
     attribute_id           bigint(20)      not null auto_increment    comment '协议属性id',
     agreement_template_id           bigint(20)      not null     comment '协议模板id',
     attribute_group_id           bigint(20)      not null    comment '协议属性组id',
     attribute_code         varchar(32)     default ''                 comment '字段名称',
     attribute_name         varchar(64)     default ''                 comment '属性名称',
     attribute_type       varchar(32)    default ''                 comment '属性类型',
     assembly_type        varchar(64)     default ''                 comment '组件类型',
     format_requirement         varchar(32)     default ''                 comment '格式要求',
     relation_dict        varchar(64)     default ''                 comment '关联数据字典',
     init_data_source       char(1)    default '0'                 comment '初始化数据来源(0滚动计划 1产品信息)',
     is_allow_edit        char(1)     default '0'                 comment '是否可修改',
     is_required        char(1)     default '0'                 comment '是否必填',
     serial_num         int     default 0                 comment '排序',
     version         varchar(32)     default ''                  comment '版本号',
     del_flag          char(1)         default '0'                comment '删除标志(0代表存在 1代表删除)',
     create_by         varchar(64)     default ''                 comment '创建者',
     create_time 	    datetime                                   comment '创建时间',
     update_by         varchar(64)     default ''                 comment '更新者',
     update_time       datetime                                   comment '更新时间',
     primary key (attribute_id)
) engine=innodb auto_increment=1 comment = '协议属性表';

-- ----------------------------
-- 4、协议表
-- ----------------------------
drop table if exists dhc_agreement;
create table dhc_agreement (
    agreement_id           bigint(20)      not null auto_increment    comment '协议模板id',
    roll_plan_id           bigint(20)      not null comment '滚动计划id',
    roll_plan_num         varchar(64)      default ''                  comment '滚动计划号',
    status       char(1)     default '0'                 comment '协议状态',
    del_flag          char(1)         default '0'                comment '删除标志(0代表存在 1代表删除)',
    create_by         varchar(64)     default ''                 comment '创建者',
    create_time 	    datetime                                   comment '创建时间',
    update_by         varchar(64)     default ''                 comment '更新者',
    update_time       datetime                                   comment '更新时间',
    primary key (agreement_id)
) engine=innodb auto_increment=1 comment = '协议表';
-- ----------------------------
-- 4、协议属性值表
-- ----------------------------
drop table if exists dhc_agreement_attribute_value;
create table dhc_agreement_attribute_value (
   agreement_value_id           bigint(20)      not null auto_increment    comment '协议属性值id',
   agreement_template_id           bigint(20)      not null     comment '协议模板id',
   attribute_group_id           bigint(20)      not null    comment '协议属性组id',
   attribute_id           bigint(20)      not null    comment '协议属性id',
   attribute_value         varchar(32)      default '' comment '协议属性执行',
   del_flag          char(1)         default '0'                comment '删除标志(0代表存在 1代表删除)',
   create_by         varchar(64)     default ''                 comment '创建者',
   create_time 	    datetime                                   comment '创建时间',
   update_by         varchar(64)     default ''                 comment '更新者',
   update_time       datetime                                   comment '更新时间',
   primary key (agreement_value_id)
) engine=innodb auto_increment=1 comment = '协议属性值表';