CREATE TABLE IF NOT EXISTS `blade_waybill_import_batch` (
  `id` bigint NOT NULL,
  `tenant_id` varchar(12) NOT NULL DEFAULT '000000',
  `batch_no` varchar(64) NOT NULL COMMENT '运单批次号',
  `project_id` bigint DEFAULT NULL,
  `project_name` varchar(200) DEFAULT NULL,
  `customer_name` varchar(200) DEFAULT NULL,
  `contract_id` bigint DEFAULT NULL,
  `contract_name` varchar(200) DEFAULT NULL,
  `carrier_type` varchar(32) DEFAULT NULL,
  `carrier_ids` varchar(1000) DEFAULT NULL,
  `carrier_name` varchar(500) DEFAULT NULL,
  `import_type` varchar(32) NOT NULL COMMENT 'waybill/settlement',
  `import_status` varchar(32) NOT NULL COMMENT 'draft/processing/completed',
  `plan_id` bigint DEFAULT NULL,
  `plan_name` varchar(200) DEFAULT NULL,
  `waybill_count` int NOT NULL DEFAULT 0,
  `remark` varchar(500) DEFAULT NULL,
  `create_user` bigint DEFAULT NULL,
  `create_dept` bigint DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_user` bigint DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `status` tinyint NOT NULL DEFAULT 1,
  `is_deleted` tinyint NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_waybill_import_batch_no` (`tenant_id`,`batch_no`),
  KEY `idx_waybill_import_batch_project` (`project_id`),
  KEY `idx_waybill_import_batch_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运单批量导入批次记录';

ALTER TABLE `blade_waybill` ADD COLUMN `import_batch_id` bigint DEFAULT NULL COMMENT '运单导入批次ID';
ALTER TABLE `blade_waybill` ADD KEY `idx_waybill_import_batch_id` (`import_batch_id`);
