ALTER table wms_storage MODIFY column header_no VARCHAR(128) comment '上游单据单号';
ALTER table wms_storage MODIFY column  wh_id BIGINT(20) null comment '仓库 Id,对应 wms_wh 表中的Id';
ALTER table wms_storage_mat MODIFY column  wh_id BIGINT(20) null comment '仓库 Id,对应 wms_wh 表中的Id';
ALTER table wms_storage_mat MODIFY column  rg_id BIGINT(20) null comment '库区 Id,对应 wms_rg 表中的Id';
ALTER table wms_storage_mat MODIFY column  pn_id BIGINT(20) null comment  '库区 Id,对应 wms_rg 表中的Id';

ALTER table wms_storage_log MODIFY column  wh_id BIGINT(20) null comment '仓库 Id,对应 wms_wh 表中的Id';
ALTER table wms_storage_log MODIFY column  rg_id BIGINT(20) null comment '库区 Id,对应 wms_rg 表中的Id';
ALTER table wms_storage_log MODIFY column  pn_id BIGINT(20) null comment  '库区 Id,对应 wms_rg 表中的Id';

UPDATE base_material set virtual_part = 'N';
ALTER TABLE base_material MODIFY COLUMN virtual_part CHAR ( 1 ) NOT NULL DEFAULT 'N' COMMENT '虚拟物料标识,只能填写Y和N,Y表示虚拟物料,N表示反之';

ALTER TABLE project_sale_order ADD COLUMN `project_name` VARCHAR (255) NOT NULL COMMENT '项目名称' after `contract_no`;
UPDATE project_sale_order set project_name = mould_name;
ALTER TABLE project_sale_order DROP COLUMN `mould_name`;

DROP TABLE IF EXISTS `base_equip`;
CREATE TABLE `base_equip` (
                              `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                              `name` varchar(64)  NOT NULL COMMENT '设备名称 唯一',
                              `mould_type_id` bigint(20) NOT NULL COMMENT '模具类型id,对应 base_mould_type 表中的id',
                              `status` tinyint(1) DEFAULT '1' COMMENT '状态,1表示正常,2表示禁用,默认是1',
                              `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                              `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                              `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                              `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                              `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                              `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                              PRIMARY KEY (`id`),
                              UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB  COMMENT='设备信息';


DROP TABLE IF EXISTS `pro_process_design`;
CREATE TABLE `pro_process_design` (
                                      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                      `plan_id` BIGINT(20) NOT NULL COMMENT '生产计划id',
                                      `project_id` BIGINT(20) NOT NULL COMMENT '项目id',
                                      `project_sub_id` BIGINT(20) COMMENT '子项目id',
                                      `process_design_type` varchar(64) not null COMMENT '设计类型 铸造工艺|3D图纸|2D图纸|毛坯图纸 BLUEPRINT_FOUNDRY_TECHNOLOGY|BLUEPRINT_3D|BLUEPRINT_2D|BLUEPRINT_WORKBLANK',
                                      `remark` varchar(255) DEFAULT NULL COMMENT '备注',
                                      `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常,2表示禁用',
                                      `creator` varchar(64) DEFAULT '' COMMENT '创建者',
                                      `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                      `updater` varchar(64) DEFAULT '' COMMENT '更新者',
                                      `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                      `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                      `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                      PRIMARY KEY (`id`) USING BTREE,
                                      INDEX `idx_plan`(`plan_id`) USING BTREE,
                                      INDEX `idx_project`(`project_id`) USING BTREE
) ENGINE=InnoDB COMMENT='工艺设计表';

DROP TABLE IF EXISTS `pro_process_design_progress`;
CREATE TABLE `pro_process_design_progress` (
                                               `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                               `process_design_id` BIGINT(20) not null COMMENT '工艺设计id',
                                               `progress` DECIMAL(20,6) not null DEFAULT '0' COMMENT '进度百分比(%)',
                                               `blueprint_link` varchar(255) not null comment '图纸链接',
                                               `remark` varchar(255) DEFAULT NULL COMMENT '备注',
                                               `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常,2表示禁用',
                                               `creator` varchar(64) DEFAULT '' COMMENT '创建者',
                                               `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                               `updater` varchar(64) DEFAULT '' COMMENT '更新者',
                                               `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                               `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                               `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                               PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='工艺设计进度表';

ALTER TABLE project_deliver_order MODIFY COLUMN `deliver_mode` CHAR ( 1 ) COMMENT '发货方式';

ALTER TABLE wms_storage ADD COLUMN `v_mat_name` varchar(128) COMMENT '虚拟物料名称';

DROP TABLE IF EXISTS `project_plan`;
CREATE TABLE `project_plan` (
                                `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                `plan_no` varchar(11)  NOT NULL COMMENT '计划单号',
                                `project_id` bigint(20) NOT NULL COMMENT '项目id',
                                `project_owner` bigint(20)  DEFAULT NULL COMMENT '项目负责人',
                                `has_craft` tinyint(1) DEFAULT NULL COMMENT '是否需要工艺:1表示需要,0表示不需要',
                                `craft_owner` bigint(20)  DEFAULT NULL COMMENT '工艺负责人',
                                `craft_start_date` datetime DEFAULT NULL COMMENT '工艺开始日期',
                                `craft_end_date` datetime DEFAULT NULL COMMENT '工艺结束日期',
                                `craft_content` varchar(1024) DEFAULT NULL COMMENT '工艺流程数组信息[{''id'':1,''sdate'':'''',''edate'':'''',''owner'':'''',''description'':''''}]',
                                `editor` bigint(20)  DEFAULT NULL COMMENT '编制人',
                                `editor_date` datetime DEFAULT NULL COMMENT '编制日期',
                                `auditor` bigint(20)  DEFAULT NULL COMMENT '审核人',
                                `audit_date` datetime DEFAULT NULL COMMENT '审核日期',
                                `approver` bigint(20)  DEFAULT NULL COMMENT '批准人',
                                `approve_date` datetime DEFAULT NULL COMMENT '批准日期',
                                `description` varchar(255)  DEFAULT NULL COMMENT '备注',
                                `status` tinyint(1) DEFAULT '1' COMMENT '状态,1未开始,2生产中,3已完成,4已终止 ,默认是1',
                                `change_num` int(11) DEFAULT NULL COMMENT '项目变更次数',
                                `change_last_date` datetime DEFAULT NULL COMMENT '项目变更日期',
                                `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                                `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                                `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='生产计划表';

DROP TABLE IF EXISTS `project_plan_sub`;
CREATE TABLE `project_plan_sub` (
                                    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                    `project_plan_id` bigint(20) NOT NULL COMMENT '计划id',
                                    `project_id` bigint(20) NOT NULL COMMENT '项目id',
                                    `project_sub_id` bigint(20) DEFAULT NULL COMMENT '子项目id',
                                    `project_sub_short_name` varchar(128)  DEFAULT NULL COMMENT '子项目简称',
                                    `project_sub_code` varchar(128)  DEFAULT NULL COMMENT '子项目编码',
                                    `mould_id` bigint(20) DEFAULT NULL COMMENT '模具类型id',
                                    `equip_id` bigint(20) DEFAULT NULL COMMENT '设备id',
                                    `blank_date` datetime DEFAULT NULL COMMENT '毛坯结束日期',
                                    `blank_owner` bigint(20)  DEFAULT NULL COMMENT '毛坯负责人',
                                    `two_dim_date` datetime DEFAULT NULL COMMENT '2D结束日期',
                                    `two_dim_owner`bigint(20)  DEFAULT NULL COMMENT '2D负责人',
                                    `three_dim_date` datetime DEFAULT NULL COMMENT '3D结束日期',
                                    `three_dim_owner` bigint(20)  DEFAULT NULL COMMENT '3D负责人',
                                    `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                                    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                    `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                    `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                    `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                    PRIMARY KEY (`id`)
) ENGINE=InnoDB  COMMENT='生产计划子项目表';

DROP TABLE IF EXISTS `project_material_plan`;
CREATE TABLE `project_material_plan` (
                                         `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                         `project_material_plan_no` varchar(16)  NOT NULL COMMENT '物料计划单号',
                                         `project_id` bigint(20) DEFAULT NULL COMMENT '订单id',
                                         `project_plan_id` bigint(20) DEFAULT NULL COMMENT '生产计划id',
                                         `submit_user_id` bigint(20) DEFAULT NULL COMMENT '送审人',
                                         `submit_time` datetime DEFAULT NULL COMMENT '送审时间',
                                         `auditor` bigint(20) DEFAULT NULL COMMENT '审核人',
                                         `audit_time` datetime DEFAULT NULL COMMENT '审核时间',
                                         `status` tinyint(1) DEFAULT '1' COMMENT '状态,1已保存,2已送审,3已审核,4已打回 ,默认是1',
                                         `description` varchar(255)  DEFAULT NULL COMMENT '备注',
                                         `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                                         `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                         `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                                         `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                         `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                         `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                         PRIMARY KEY (`id`)
) ENGINE=InnoDB  COMMENT='物料需求计划';

DROP TABLE IF EXISTS `project_material_plan_detail`;
CREATE TABLE `project_material_plan_detail` (
                                                `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                                `project_material_plan_id` bigint(20) NOT NULL COMMENT '物料需求采购计划id',
                                                `material_id` bigint(20) NOT NULL COMMENT '物料id',
                                                `project_sub_id` bigint(20) DEFAULT NULL COMMENT '子项目编号',
                                                `require_amount` decimal(20,2) DEFAULT NULL COMMENT '需求数量',
                                                `require_arrive_time` datetime DEFAULT NULL COMMENT '需求到货日期',
                                                `description` varchar(255)  DEFAULT NULL COMMENT '备注',
                                                `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                                                `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                                                `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                                `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                                `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                                PRIMARY KEY (`id`)
) ENGINE=InnoDB  COMMENT='物料需求计划物料详情表';

CREATE OR REPLACE VIEW v_storage_material_log AS
select 0 AS `deleted`,`lg`.`id` AS `id`,`lg`.`creator` AS `creator`,`lg`.`create_time` AS `create_time`,`lg`.`updater` AS `updater`,`lg`.`update_time` AS `update_time`,
       `lg`.`tenant_id` AS `tenant_id`,`lg`.`status` AS `status`,`mat`.`code` AS `mat_code`,`mat`.`name` AS `mat_name`,
       (select `system_dict_data`.`label` from `system_dict_data` where ((`system_dict_data`.`dict_type` = 'heli_material_type') and (`system_dict_data`.`value` = `mat`.`material_type`))) AS `mat_type`,
       (case when (isnull(`mat`.`short_name`) = TRUE) then '' else `mat`.`short_name` end) AS `short_name`,
       (case when (isnull(`mat`.`spec`) = TRUE) then '' else `mat`.`spec` end) AS `mat_spec`,
       (case when (isnull(`mat`.`brand`) = TRUE) then '' else `mat`.`brand` end) AS `mat_brand`,
       (select `system_dict_data`.`label` from `system_dict_data` where ((`system_dict_data`.`dict_type` = 'heli_material_unit') and (`system_dict_data`.`value` = `mat`.`unit`))) AS `mat_unit`,
       `st`.`stock_no` AS `stock_no`,`st`.`stock_type` AS `stock_type`,
       (case when (`st`.`stock_type` = 1) then (select `system_dict_data`.`label` from `system_dict_data` where ((`system_dict_data`.`dict_type` = 'heli_storage_in_type') and (`system_dict_data`.`value` = `st`.`stock_in_type`))) else (select `system_dict_data`.`label` from `system_dict_data` where ((`system_dict_data`.`dict_type` = 'heli_storage_out_type') and (`system_dict_data`.`value` = `st`.`stock_in_type`))) end) AS `stock_type_name`,
       (case when (isnull(`st`.`header_no`) = TRUE) then '' else `st`.`header_no` end) AS `header_no`,`wh`.`id` AS `wh_id`,`wh`.`wh_name` AS `wh_name`,`rg`.`rg_name` AS `rg_name`,`pn`.`pn_name` AS `pn_name`,
       (case when (isnull(`lg`.`lot_no`) = 1) then '' else `lg`.`lot_no` end) AS `lot_no`,
       (case when ((`st`.`stock_type` = 1) and (`lg`.`status` = 2)) then `lg`.`storage_ok_qty` when ((`st`.`stock_type` = 1) and (`lg`.`status` = 3)) then (-(1) * `lg`.`storage_ok_qty`) when ((`st`.`stock_type` = 2) and (`lg`.`status` = 2)) then (-(1) * `lg`.`storage_ok_qty`) when ((`st`.`stock_type` = 2) and (`lg`.`status` = 3)) then `lg`.`storage_ok_qty` else `lg`.`storage_ok_qty` end) AS `storage_ok_qty`
from (((((`wms_storage_log` `lg` left join `wms_storage` `st` on((`lg`.`stock_id` = `st`.`id`)))
    left join `base_material` `mat` on((`lg`.`mat_id` = `mat`.`id`)))
    left join `wms_wh` `wh` on((`lg`.`wh_id` = `wh`.`id`)))
    left join `wms_rg` `rg` on((`lg`.`rg_id` = `rg`.`id`)))
    left join `wms_pn` `pn` on((`lg`.`pn_id` = `pn`.`id`)))
where ((`st`.`deleted` = 0) and (`mat`.`deleted` = 0) and (`wh`.`deleted` = 0) and (`rg`.`deleted` = 0) and (`pn`.`deleted` = 0));

DROP TABLE IF EXISTS `base_bom`;
DROP TABLE IF EXISTS `pro_plan`;

DROP TABLE IF EXISTS `pro_process_bom`;
CREATE TABLE `pro_process_bom` (
                                   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                   `code` varchar(255) COMMENT '编号,唯一',
                                   `plan_id` BIGINT(20) NOT NULL COMMENT '生产计划id',
                                   `project_id` BIGINT(20) NOT NULL COMMENT '项目id',
                                   `project_sub_id` bigint(20) NOT NULL COMMENT '子项目id',
                                   `version` int(11) not null DEFAULT '0' COMMENT 'bom版本号',
                                   `bom_status` TINYINT(1) not null comment 'bom状态 已保存|已提交 1|2',
                                   `remark` varchar(255) DEFAULT NULL COMMENT '备注',
                                   `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常,2表示禁用',
                                   `creator` varchar(64) DEFAULT '' COMMENT '创建者',
                                   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                   `updater` varchar(64) DEFAULT '' COMMENT '更新者',
                                   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                   `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                   `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                   PRIMARY KEY (`id`) USING BTREE,
                                   INDEX `idx_plan`(`plan_id`) USING BTREE,
                                   INDEX `idx_project`(`project_id`) USING BTREE
) ENGINE=InnoDB COMMENT='工艺bom表';

DROP TABLE IF EXISTS `pro_process_bom_detail`;
CREATE TABLE `pro_process_bom_detail` (
                                          `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                          `bom_id` bigint(20) NOT NULL COMMENT 'bom id',
                                          `type` char(1) not null comment '物料类型 1 标准件|2 其它',
                                          `material_id` BIGINT(20) COMMENT '物料id',
                                          `material_name` varchar(64) NOT NULL COMMENT '物料名称',
                                          `material_code` varchar(64) COMMENT '物料编码',
                                          `composition_id` BIGINT(20) NOT NULL COMMENT '材质id',
                                          `spec` varchar(255) COMMENT '规格',
                                          `unit` char(2) NOT NULL COMMENT '单位',
                                          `blueprint_no` varchar(64) COMMENT '图号',
                                          `amount` int(11) NOT NULL COMMENT '数量',
                                          `remark` varchar(255) DEFAULT NULL COMMENT '备注',
                                          `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1表示正常,2表示禁用',
                                          `creator` varchar(64) DEFAULT '' COMMENT '创建者',
                                          `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                          `updater` varchar(64) DEFAULT '' COMMENT '更新者',
                                          `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                          `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                          `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                          PRIMARY KEY (`id`) USING BTREE,
                                          INDEX `idx_bom`(`bom_id`) USING BTREE
) ENGINE=InnoDB COMMENT='工艺bom明细表';

DROP TABLE IF EXISTS `project_purchase_order`;
CREATE TABLE `project_purchase_order` (
                                          `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                          `purchase_no` varchar(16) NOT NULL COMMENT '采购单号',
                                          `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商id',
                                          `contract_no` varchar(255) DEFAULT NULL COMMENT '采购合同号',
                                          `purchase_type` tinyint(1) DEFAULT NULL COMMENT '采购单类型,1按物料需求计划采购,2备库采购',
                                          `project_material_plan_id` bigint(20) DEFAULT NULL COMMENT '供应商id',
                                          `goods_type` tinyint(1) NOT NULL COMMENT '采购物类型,1物料,2加工件',
                                          `currency_type` tinyint(4) DEFAULT NULL COMMENT '结算币种',
                                          `tax_ratio` int(11) DEFAULT NULL COMMENT '税率',
                                          `estimated_price` decimal(20,6) DEFAULT NULL COMMENT '暂估价金额',
                                          `actual_price` decimal(20,6) DEFAULT NULL COMMENT '实际价金额',
                                          `status` tinyint(1) DEFAULT '1' COMMENT '状态,1已保存,2已送审,3已审核,4已打回 ,默认是1',
                                          `submit_user_id` bigint(20) DEFAULT NULL COMMENT '送审人',
                                          `submit_time` datetime DEFAULT NULL COMMENT '送审时间',
                                          `auditor` bigint(20) DEFAULT NULL COMMENT '审核人',
                                          `audit_time` datetime DEFAULT NULL COMMENT '审核时间',
                                          `description` varchar(255)  DEFAULT NULL COMMENT '备注',
                                          `creator` varchar(64) DEFAULT '' COMMENT '创建者',
                                          `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                          `updater` varchar(64) DEFAULT '' COMMENT '更新者',
                                          `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                          `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                          `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                          PRIMARY KEY (`id`)
) ENGINE=InnoDB  COMMENT='采购订单';

DROP TABLE IF EXISTS `project_purchase_order_material`;
CREATE TABLE `project_purchase_order_material` (
                                                   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
                                                   `purchase_order_id` bigint(20) NOT NULL COMMENT '采购单编号',
                                                   `material_id` bigint(20) DEFAULT NULL COMMENT '物料id',
                                                   `purchase_amount` decimal(20,2) DEFAULT NULL COMMENT '采购数量',
                                                   `estimated_price` decimal(20,2) DEFAULT NULL COMMENT '暂估价金额',
                                                   `actual_price` decimal(20,2) DEFAULT NULL COMMENT '实际价金额',
                                                   `arrive_time` datetime DEFAULT NULL COMMENT '预计到期日期',
                                                   `description` varchar(255)  DEFAULT NULL COMMENT '备注',
                                                   `creator` varchar(64)  DEFAULT '' COMMENT '创建者',
                                                   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                   `updater` varchar(64)  DEFAULT '' COMMENT '更新者',
                                                   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                                   `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                                   `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
                                                   PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='采购单物料表';