USE stmms_ms;

ALTER TABLE `paper`
    ADD COLUMN `rough_mark_leader_id` BIGINT(10) NULL COMMENT '粗分档阶段科组长操作ID' AFTER `size_abnormal`,
ADD COLUMN `mark_leader_id` BIGINT(10) NULL COMMENT '细分档阶段科组长操作ID' AFTER `rough_mark_leader_id`;


CREATE TABLE `change_level_task` (
        `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
        `work_id` BIGINT(20) NOT NULL COMMENT '工作ID',
        `change_level_id` BIGINT(20) NULL COMMENT '改档数据ID',
        `question_id` BIGINT(20) NOT NULL COMMENT '考区ID',
        `paper_id` BIGINT(20) NOT NULL COMMENT '试卷ID',
        `subject` VARCHAR(45) NOT NULL COMMENT '科目',
        `stage` INT NOT NULL COMMENT '阶段',
        `marker_id` BIGINT(20) NULL COMMENT '评卷员ID',
        `marker_name` VARCHAR(45) NULL COMMENT '评卷员姓名',
        `secret_number` VARCHAR(45) NULL COMMENT '密号',
        `result` VARCHAR(3) NULL COMMENT '改档档位（纪检员同意后）',
        `is_mark` TINYINT(1) NULL DEFAULT 0 COMMENT '是否标记',
        `confirm_change_stage` TINYINT(1) NULL COMMENT '是否确认改档',
        `confirm_on` DATETIME NULL COMMENT '确认时间',
        `created_on` DATETIME NULL COMMENT '创建时间',
        PRIMARY KEY (`id`))
    COMMENT = '改档评卷员确认任务表';

ALTER TABLE `change_level` ADD COLUMN `role` VARCHAR(45) NULL DEFAULT 'MARK_LEADER' COMMENT '操作员角色，MARK_LEADER-科组长，INSPECTION-纪检' AFTER `audit_id`;
ALTER TABLE `change_level` ADD COLUMN `paper_check_id` BIGINT(20) NULL COMMENT '试卷抽查任务ID（role=‘MARK_LEADER’时，默认为’-1’）' AFTER `audit_status`;

CREATE TABLE `paper_check` (
          `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
          `work_id` BIGINT(20) NOT NULL COMMENT '工作ID',
          `subject` VARCHAR(45) NOT NULL COMMENT '科目',
          `stage` INT NOT NULL COMMENT '阶段',
          `name` VARCHAR(45) NOT NULL COMMENT '任务名称',
          `remark` VARCHAR(100) NULL COMMENT '备注',
          `student_count` INT NULL DEFAULT 0 COMMENT '学生数量',
          `start_deal` TINYINT(1) NULL DEFAULT 0 COMMENT '是否开始批量处理',
          `select_info` VARCHAR(150) NULL COMMENT '最后一次操作的试卷信息',
          `created_id` BIGINT(20) NULL COMMENT '创建人',
          `created_on` DATETIME NULL COMMENT '创建时间',
          PRIMARY KEY (`id`))
    COMMENT = '试卷抽查任务表';

CREATE TABLE `paper_check_student` (
          `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
          `work_id` BIGINT(20) NULL COMMENT '工作ID',
          `paper_check_id` BIGINT(20) NULL COMMENT '试卷抽查任务ID',
          `subject` VARCHAR(45) NULL COMMENT '科目',
          `stage` INT NULL COMMENT '阶段',
          `paper_id` BIGINT(20) NULL COMMENT '试卷ID',
          `secret_number` VARCHAR(45) NULL COMMENT '试卷密号',
          PRIMARY KEY (`id`))
    COMMENT = '试卷抽查考生表';
