-- 入场隔离登记主表 + 分圈明细
CREATE TABLE IF NOT EXISTS `biz_entry_isolation` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `entry_time` datetime NOT NULL COMMENT '进场时间',
  `supplier_id` bigint(20) NOT NULL COMMENT '供应商ID',
  `cert_file_url` varchar(512) DEFAULT NULL COMMENT '检疫证URL',
  `cert_file_path` varchar(512) DEFAULT NULL COMMENT '检疫证路径',
  `cert_no` varchar(50) NOT NULL COMMENT '检疫证号',
  `quantity` int(11) NOT NULL COMMENT '总数量头',
  `ear_tags` text NOT NULL COMMENT '耳标号逗号分隔',
  `isolation_days` int(11) NOT NULL COMMENT '隔离天数',
  `expected_release_date` date NOT NULL COMMENT '预计解除日期',
  `del_flag` char(1) NOT NULL 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 '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  KEY `idx_entry_time` (`entry_time`),
  KEY `idx_cert_no` (`cert_no`),
  KEY `idx_supplier` (`supplier_id`),
  KEY `idx_del_flag` (`del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='入场隔离登记';

CREATE TABLE IF NOT EXISTS `biz_entry_isolation_alloc` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `entry_id` bigint(20) NOT NULL COMMENT '登记主表ID',
  `pen_id` bigint(20) NOT NULL COMMENT '圈位ID',
  `quantity` int(11) NOT NULL COMMENT '本圈数量头',
  `ear_tags` text NOT NULL COMMENT '本圈耳标逗号分隔',
  `sort_order` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
  PRIMARY KEY (`id`),
  KEY `idx_entry_id` (`entry_id`),
  UNIQUE KEY `uk_entry_pen` (`entry_id`,`pen_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='入场隔离分圈明细';
