-- �˵����������ű��������ṹ��

CREATE TABLE IF NOT EXISTS `transport_waybill` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '����',
  `org_id` varchar(64) DEFAULT NULL COMMENT '��֯ID',
  `waybill_no` varchar(64) NOT NULL COMMENT '���˵���',
  `transport_type` varchar(32) DEFAULT NULL COMMENT '��������',
  `document_date` date DEFAULT NULL COMMENT '��������',
  `plan_depart_time` datetime DEFAULT NULL COMMENT 'Ԥ�Ʒ���ʱ��',
  `plan_arrive_time` datetime DEFAULT NULL COMMENT 'Ԥ�Ƶ���ʱ��',
  `remark` varchar(500) DEFAULT NULL COMMENT '��ע',
  `sender_company` varchar(128) DEFAULT NULL COMMENT '������ҵ',
  `sender_province` varchar(64) DEFAULT NULL COMMENT '����ʡ',
  `sender_city` varchar(64) DEFAULT NULL COMMENT '������',
  `sender_district` varchar(64) DEFAULT NULL COMMENT '������',
  `sender_address_detail` varchar(255) DEFAULT NULL COMMENT '������ϸ��ַ',
  `sender_contact` varchar(64) DEFAULT NULL COMMENT '������ϵ��',
  `sender_phone` varchar(32) DEFAULT NULL COMMENT '������ϵ�绰',
  `load_time_require` varchar(128) DEFAULT NULL COMMENT 'װ��ʱ��Ҫ��',
  `receiver_company` varchar(128) DEFAULT NULL COMMENT '�ջ���ҵ',
  `receiver_province` varchar(64) DEFAULT NULL COMMENT '�ջ�ʡ',
  `receiver_city` varchar(64) DEFAULT NULL COMMENT '�ջ���',
  `receiver_district` varchar(64) DEFAULT NULL COMMENT '�ջ���',
  `receiver_address_detail` varchar(255) DEFAULT NULL COMMENT '�ջ���ϸ��ַ',
  `receiver_contact` varchar(64) DEFAULT NULL COMMENT '�ջ���ϵ��',
  `receiver_phone` varchar(32) DEFAULT NULL COMMENT '�ջ���ϵ�绰',
  `plan_sign_time` datetime DEFAULT NULL COMMENT 'Ԥ��ǩ��ʱ��',
  `temp_max` decimal(10,2) DEFAULT NULL COMMENT '�¶�����(��)',
  `temp_min` decimal(10,2) DEFAULT NULL COMMENT '�¶�����(��)',
  `humidity_require` varchar(64) DEFAULT NULL COMMENT 'ʪ��Ҫ��(%)',
  `transport_special_note` varchar(500) DEFAULT NULL COMMENT '��������˵��',
  `label_temp_record` tinyint(1) DEFAULT 0 COMMENT '���¶ȼ�¼��(0��1��)',
  `label_fragile` tinyint(1) DEFAULT 0 COMMENT '����Ʒ(0��1��)',
  `label_shockproof` tinyint(1) DEFAULT 0 COMMENT '����(0��1��)',
  `label_moistureproof` tinyint(1) DEFAULT 0 COMMENT '����(0��1��)',
  `line_num` varchar(64) DEFAULT NULL COMMENT '�����߱��',
  `line_name` varchar(128) DEFAULT NULL COMMENT '����������',
  `car_num` varchar(32) DEFAULT NULL COMMENT '���ƺ�',
  `car_model` varchar(64) DEFAULT NULL COMMENT '����',
  `driver_name` varchar(64) DEFAULT NULL COMMENT '��ʻԱ',
  `driver_phone` varchar(32) DEFAULT NULL COMMENT '��ʻԱ�绰',
  `estimate_distance` decimal(10,2) DEFAULT NULL COMMENT 'Ԥ�����(km)',
  `total_quantity` decimal(18,4) DEFAULT NULL COMMENT '�ϼ�����',
  `total_weight` decimal(18,4) DEFAULT NULL COMMENT '�ϼ�����(kg)',
  `total_volume` decimal(18,4) DEFAULT NULL COMMENT '�ϼ����(m?)',
  `total_value` decimal(18,2) DEFAULT NULL COMMENT '�ϼƻ�ֵ(Ԫ)',
  `audit_status` tinyint(1) DEFAULT 0 COMMENT '���״̬(0�ݸ�1�����2��ͨ��)',
  `del_flag` char(1) DEFAULT '0' COMMENT 'ɾ����־��0�������� 2����ɾ����',
  `create_by` varchar(64) DEFAULT '' COMMENT '������',
  `create_time` datetime DEFAULT NULL COMMENT '����ʱ��',
  `update_by` varchar(64) DEFAULT '' COMMENT '������',
  `update_time` datetime DEFAULT NULL COMMENT '����ʱ��',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_waybill_no_del` (`waybill_no`, `del_flag`),
  KEY `idx_org_document_date` (`org_id`, `document_date`),
  KEY `idx_audit_status` (`audit_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='�˵�����';

CREATE TABLE IF NOT EXISTS `transport_waybill_cargo` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '����',
  `org_id` varchar(64) DEFAULT NULL COMMENT '��֯ID',
  `waybill_no` varchar(64) NOT NULL COMMENT '���˵���',
  `cargo_name` varchar(128) NOT NULL COMMENT '��������',
  `spec_model` varchar(256) DEFAULT NULL COMMENT '����ͺ�',
  `unit` varchar(32) DEFAULT NULL COMMENT '��λ',
  `quantity` decimal(18,4) DEFAULT NULL COMMENT '����',
  `weight_kg` decimal(18,4) DEFAULT NULL COMMENT '����(kg)',
  `volume_m3` decimal(18,4) DEFAULT NULL COMMENT '���(m?)',
  `cargo_value` decimal(18,2) DEFAULT NULL COMMENT '��ֵ(Ԫ)',
  `sort_order` int(11) DEFAULT 0 COMMENT '����',
  `del_flag` char(1) DEFAULT '0' COMMENT 'ɾ����־��0�������� 2����ɾ����',
  `create_by` varchar(64) DEFAULT '' COMMENT '������',
  `create_time` datetime DEFAULT NULL COMMENT '����ʱ��',
  `update_by` varchar(64) DEFAULT '' COMMENT '������',
  `update_time` datetime DEFAULT NULL COMMENT '����ʱ��',
  PRIMARY KEY (`id`),
  KEY `idx_waybill_no` (`waybill_no`),
  KEY `idx_waybill_del` (`waybill_no`, `del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='�˵�������ϸ';
