DROP TABLE IF EXISTS `art_history_score_control_line`;
CREATE TABLE `art_history_score_control_line` (
  `control_id` bigint NOT NULL AUTO_INCREMENT COMMENT '省控线主键',
  `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
  `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '删除标志（0存在 1删除）',
  `province_code` varchar(6) NOT NULL COMMENT '省份行政区划代码',
  `province_name` varchar(32) NOT NULL COMMENT '省份名称',
  `year` smallint NOT NULL COMMENT '年份',
  `major_category` varchar(25) NOT NULL COMMENT '专业类别',
  `batch_name` varchar(25) NOT NULL COMMENT '批次',
  `subject_type` varchar(16) NOT NULL COMMENT '科类(文/理)',
  `culture_score` decimal(6,2) DEFAULT NULL COMMENT '文化成绩分数',
  `major_score` decimal(6,2) DEFAULT NULL COMMENT '专业成绩分数',
  `culture_score_exam` decimal(6,2) DEFAULT NULL COMMENT '文化成绩校考分数',
  `major_score_exam` decimal(6,2) DEFAULT NULL COMMENT '专业成绩校考分数',
  `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
  `create_by` bigint DEFAULT NULL COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`control_id`),
  UNIQUE KEY `uk_control_province_year`
      (`province_code`,`year`,`subject_type`,`major_category`,`batch_name`),
  KEY `idx_control_year` (`year`),
  KEY `idx_control_tenant` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历
  年省控线表';

DROP TABLE IF EXISTS `art_major`;
CREATE TABLE `art_major` (
 `major_id` bigint NOT NULL AUTO_INCREMENT COMMENT '专业主键ID',
 `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
 `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '删除标志（0存在 1删除）',
 `major_name` varchar(128) NOT NULL COMMENT '专业名称',
 `education_level` varchar(16) NOT NULL COMMENT '学历层次',
 `major_icon` varchar(255) DEFAULT NULL COMMENT '专业图标',
 `schooling_years` tinyint DEFAULT NULL COMMENT '学制(年)',
 `discipline_primary` varchar(64) DEFAULT NULL COMMENT '所属一级学科',
 `discipline_secondary` varchar(64) DEFAULT NULL COMMENT '所属二级学科',
 `degree_awarded` varchar(64) DEFAULT NULL COMMENT '授予学士学位',
 `summary` varchar(1000) DEFAULT NULL COMMENT '专业概括',
 `training_direction` text COMMENT '培养方向',
 `core_courses` text COMMENT '主要课程',
 `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
 `create_by` bigint DEFAULT NULL COMMENT '创建者',
 `create_time` datetime DEFAULT NULL COMMENT '创建时间',
 `update_by` bigint DEFAULT NULL COMMENT '更新者',
 `update_time` datetime DEFAULT NULL COMMENT '更新时间',
 `remark` varchar(500) DEFAULT NULL COMMENT '备注',
 PRIMARY KEY (`major_id`),
 UNIQUE KEY `uk_major_name_level` (`major_name`,`education_level`),
 KEY `idx_major_level` (`education_level`),
 KEY `idx_major_tenant` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='艺
  术专业库';

DROP TABLE IF EXISTS `art_school_recruit_major`;
CREATE TABLE `art_school_recruit_major` (
                                            `recruit_major_id` bigint NOT NULL AUTO_INCREMENT COMMENT '院校招录专业ID',
                                            `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
                                            `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '删除标志（0存在 1删除）',
                                            `school_id` bigint NOT NULL COMMENT '学校ID',
                                            `school_code` varchar(32) NOT NULL COMMENT '学校代码',
                                            `school_name` varchar(128) NOT NULL DEFAULT '' COMMENT '学校名称(冗余)',
                                            `year` smallint NOT NULL COMMENT '年份',
                                            `major_id` bigint DEFAULT NULL COMMENT '专业ID',
                                            `major_code` varchar(32) NOT NULL COMMENT '专业代码',
                                            `major_name` varchar(128) NOT NULL COMMENT '专业名称',
                                            `enroll_code` varchar(64) NOT NULL DEFAULT '' COMMENT '招生代码(为空则存空串)',
                                            `data_status` varchar(16) NOT NULL COMMENT '数据状态(停招/新招/新增)',
                                            `batch_name` varchar(32) DEFAULT NULL COMMENT '批次',
                                            `major_type` varchar(32) DEFAULT NULL COMMENT '专业类型',
                                            `major_type_sub` varchar(32) DEFAULT NULL COMMENT '二级专业类型',
                                            `subject_type` varchar(16) DEFAULT NULL COMMENT '科类(文/理)',
                                            `admission_way_short` varchar(32) DEFAULT NULL COMMENT '录取方式缩写',
                                            `admission_way_external` varchar(64) DEFAULT NULL COMMENT '对外录取方式',
                                            `admission_way_external_op` varchar(8) DEFAULT NULL COMMENT '对外录取方式运算符',
                                            `admission_way_internal` varchar(64) DEFAULT NULL COMMENT '内部录取方式',
                                            `admission_way_internal_op` varchar(8) DEFAULT NULL COMMENT '内部录取方式运算符',
                                            `plan_enroll` int DEFAULT NULL COMMENT '计划招生人数',
                                            `main_exam_subject` varchar(64) DEFAULT NULL COMMENT '主考科目',
                                            `schooling_years` tinyint DEFAULT NULL COMMENT '学制(年)',
                                            `enroll_limit_desc` text COMMENT '院校限制说明',
                                            `tuition_fee` decimal(10,2) DEFAULT NULL COMMENT '学费(元/年)',
                                            `culture_score_limit` decimal(6,2) DEFAULT NULL COMMENT '文化分数限制',
                                            `major_score_limit` decimal(6,2) DEFAULT NULL COMMENT '专业分数限制',
                                            `chinese_score_limit` decimal(6,2) DEFAULT NULL COMMENT '语文成绩限制',
                                            `english_score_limit` decimal(6,2) DEFAULT NULL COMMENT '英语成绩限制',
                                            `remark` varchar(500) DEFAULT NULL COMMENT '备注',
                                            `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
                                            `create_by` bigint DEFAULT NULL COMMENT '创建者',
                                            `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                            `update_by` bigint DEFAULT NULL COMMENT '更新者',
                                            `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                            PRIMARY KEY (`recruit_major_id`),
                                            UNIQUE KEY `uk_recruit_school_year` (`school_id`,`year`,`major_code`,`enroll_code`),
                                            KEY `idx_recruit_school_code` (`school_code`,`year`),
                                            KEY `idx_recruit_major_code` (`major_code`,`year`),
                                            KEY `idx_recruit_tenant` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='院校招录专业';

DROP TABLE IF EXISTS `art_school_recruit_history`;
CREATE TABLE `art_school_recruit_history` (
                                              `history_id` bigint NOT NULL AUTO_INCREMENT COMMENT '历年录取数据ID',
                                              `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
                                              `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '删除标志（0存在 1删除）',
                                              `recruit_major_id` bigint NOT NULL COMMENT '对应招录专业ID',
                                              `school_id` bigint NOT NULL COMMENT '学校ID',
                                              `school_code` varchar(32) NOT NULL COMMENT '学校代码',
                                              `college_code` varchar(32) DEFAULT NULL COMMENT '院校代码',
                                              `school_name` varchar(128) NOT NULL COMMENT '学校名称',
                                              `major_id` bigint DEFAULT NULL COMMENT '专业ID',
                                              `major_code` varchar(32) NOT NULL COMMENT '专业代码',
                                              `major_name` varchar(128) NOT NULL COMMENT '专业名称',
                                              `enroll_code` varchar(64) DEFAULT NULL COMMENT '招生代码',
                                              `major_type` varchar(32) DEFAULT NULL COMMENT '专业类型',
                                              `major_type_sub` varchar(32) DEFAULT NULL COMMENT '专业类别子级',
                                              `main_exam_subject` varchar(64) DEFAULT NULL COMMENT '主考科目',
                                              `year` smallint NOT NULL COMMENT '年份',
                                              `subject_type` varchar(16) DEFAULT NULL COMMENT '科类(文/理)',
                                              `batch_name` varchar(32) DEFAULT NULL COMMENT '批次',
                                              `admission_formula` varchar(64) DEFAULT NULL COMMENT '录取方式(文*x+专*y)',
                                              `probability_operator` varchar(16) DEFAULT NULL COMMENT '录取概率规则运算符',
                                              `control_score` decimal(6,2) DEFAULT NULL COMMENT '省控线',
                                              `admission_score` decimal(6,2) DEFAULT NULL COMMENT '录取线',
                                              `plan_enroll` int DEFAULT NULL COMMENT '招生人数',
                                              `filed_amount` int DEFAULT NULL COMMENT '实际投档人数',
                                              `admit_amount` int DEFAULT NULL COMMENT '录取数',
                                              `first_choice_admit_amount` int DEFAULT NULL COMMENT '一志愿录取数',
                                              `min_score_diff` decimal(6,2) DEFAULT NULL COMMENT '最低分数差',
                                              `tuition_fee` decimal(10,2) DEFAULT NULL COMMENT '学费(元/年)',
                                              `remark` varchar(500) DEFAULT NULL COMMENT '备注',
                                              `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
                                              `create_by` bigint DEFAULT NULL COMMENT '创建者',
                                              `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                              `update_by` bigint DEFAULT NULL COMMENT '更新者',
                                              `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                              PRIMARY KEY (`history_id`),
                                              KEY `idx_history_school_year` (`school_id`,`year`),
                                              KEY `idx_history_recruit_year` (`recruit_major_id`,`year`),
                                              KEY `idx_history_subject_batch` (`subject_type`,`batch_name`),
                                              KEY `idx_history_tenant` (`tenant_id`),
                                              CONSTRAINT `fk_history_recruit` FOREIGN KEY (`recruit_major_id`) REFERENCES `art_school_recruit_major` (`recruit_major_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='院校招录专业历年录取数据';