USE msjg_db;

-- ----------------------------
-- Table structure for attachment
-- ----------------------------
CREATE TABLE IF NOT EXISTS `attachment`  (
    `id` bigint(64) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `subject` varchar(10) NULL DEFAULT NULL,
    `exam_number` varchar(20) NULL DEFAULT NULL,
    `file_path_local` varchar(512) NOT NULL,
    `file_name` varchar(128) NOT NULL,
    `file_type` varchar(8) NULL DEFAULT NULL,
    `file_ext` varchar(16) NULL DEFAULT NULL,
    `bucket` varchar(64) NOT NULL,
    `object_key` varchar(128) NOT NULL,
    `oss_name` varchar(500) NOT NULL,
    `oss_status` varchar(20) NOT NULL,
    `oss_fail_msg` varchar(500) NULL DEFAULT NULL COMMENT '上传oss失败原因',
    `delete_status` varchar(20) NULL DEFAULT NULL,
    `time` datetime(0) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for change_level
-- ----------------------------
CREATE TABLE IF NOT EXISTS `change_level`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `subject` varchar(50) NULL DEFAULT NULL,
    `paper_id` bigint(20) NULL DEFAULT NULL,
    `original_level` varchar(45) NULL DEFAULT NULL COMMENT '原档位',
    `audit_status` tinyint(1) NULL DEFAULT NULL COMMENT '改档审核：0-申请，1-同意，2-不同意',
    `create_id` bigint(20) NULL DEFAULT NULL COMMENT '申请改档用户id',
    `create_date` datetime(0) NULL DEFAULT NULL COMMENT '申请改档时间',
    `audit_id` bigint(20) NULL DEFAULT NULL COMMENT '审核用户id',
    `audit_date` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
    `suggest_level` varchar(255) NULL DEFAULT NULL,
    `is_curr` tinyint(1) NULL DEFAULT NULL COMMENT '是否最新',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '改档记录表';

-- ----------------------------
-- Table structure for exam_question
-- ----------------------------
CREATE TABLE IF NOT EXISTS `exam_question`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `area_code` varchar(255)  NOT NULL,
    `area_name` varchar(255)  NULL DEFAULT NULL,
    `name` varchar(255)  NOT NULL,
    `subject` varchar(50)  NOT NULL,
    `work_id` bigint(20) NOT NULL,
    `is_test` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否试评,0:不是，1:数据已导入，2:试评中',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for exam_score_prop
-- ----------------------------
CREATE TABLE IF NOT EXISTS `exam_score_prop`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
    `subject` varchar(50) NULL DEFAULT NULL COMMENT '科目',
    `exclude` varchar(100) NULL DEFAULT NULL COMMENT '打分阶段配置过滤档位(可选一个或多个档位，多个档位用\",\"号隔开)',
    `task_sort` varchar(50) NULL DEFAULT NULL COMMENT '打分阶段配置档位排序规则(可选random/paper，为paper时，score.level.exclude置为空)',
    `enable` bit(1) NULL DEFAULT b'0' COMMENT '打分阶段配置是否启用(为false则不启用打分阶段分档)，0：不启用，1：启用',
    `work_id` bigint(20) NULL DEFAULT NULL COMMENT '工作区id',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '考试打分配置';

-- ----------------------------
-- Table structure for inspect_range
-- ----------------------------
CREATE TABLE IF NOT EXISTS `inspect_range`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `condition` int(11) NULL DEFAULT NULL,
    `enabled` bit(1) NULL DEFAULT NULL,
    `student_count` int(11) NULL DEFAULT NULL,
    `type` varchar(255) NULL DEFAULT NULL,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `active` bit(1) NOT NULL,
    `editable` bit(1) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for inspect_student
-- ----------------------------
CREATE TABLE IF NOT EXISTS `inspect_student`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `exam_number` varchar(255) NOT NULL,
    `inspect_range_id` bigint(20) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for inspect_task
-- ----------------------------
CREATE TABLE IF NOT EXISTS `inspect_task`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `created_on` datetime(0) NULL DEFAULT NULL,
    `inspect_range_id` bigint(20) NOT NULL,
    `marker_id` bigint(20) NOT NULL,
    `marker_name` varchar(50) NOT NULL,
    `question_id` bigint(20) NULL DEFAULT NULL,
    `subject` varchar(50) NULL DEFAULT NULL,
    `updated_on` datetime(0) NULL DEFAULT NULL,
    `work_id` bigint(20) NOT NULL,
    `paper_id` bigint(20) NOT NULL,
    `level` varchar(255) NULL DEFAULT NULL,
    `score` int(11) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `FK4e9mfahf522t4ej4y4yd065dh`(`paper_id`) USING BTREE,
    CONSTRAINT `FK4e9mfahf522t4ej4y4yd065dh` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_10` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_11` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_12` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_13` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_14` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_2` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_3` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_4` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_5` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_6` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_7` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_8` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `inspect_task_ibfk_9` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for level
-- ----------------------------
CREATE TABLE IF NOT EXISTS `level`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `code` varchar(50)  NOT NULL,
    `interval_score` int(11) NOT NULL,
    `level_type` int(11) NULL DEFAULT NULL,
    `level_value` int(11) NOT NULL,
    `max_score` int(11) NOT NULL,
    `min_score` int(11) NOT NULL,
    `pt` int(11) NOT NULL,
    `score_list` varchar(255)  NULL DEFAULT NULL,
    `weight` int(11) NOT NULL,
    `kdpt` int(11) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `idx_level_workId_code`(`work_id`, `code`) USING BTREE,
    CONSTRAINT `FK3km0g7jbkt78oj20csqeh26f2` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_1` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_10` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_11` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_12` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_13` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_14` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_2` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_3` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_4` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_5` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_6` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_7` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_8` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `level_ibfk_9` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for mark_log
-- ----------------------------
CREATE TABLE IF NOT EXISTS `mark_log`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
    `create_user_id` bigint(20) NULL DEFAULT NULL COMMENT '操作人id',
    `create_user_name` varchar(100) NULL DEFAULT NULL COMMENT '操作人名字',
    `create_role` varchar(50) NULL DEFAULT NULL COMMENT '操作人角色',
    `subject` varchar(50) NULL DEFAULT NULL COMMENT '科目',
    `exam_number` varchar(50) NULL DEFAULT NULL COMMENT '准考证号',
    `student_name` varchar(100) NULL DEFAULT NULL COMMENT '学生姓名',
    `login_time` datetime(0) NULL DEFAULT NULL COMMENT '登录时间（采集专用）',
    `logout_time` datetime(0) NULL DEFAULT NULL COMMENT '登出时间（采集专用）',
    `oper_type` int(11) NULL DEFAULT NULL COMMENT '操作类型，1：分档，2：打分，3：回评档位，4：回评分数，5：档位打回，6：档位打回回评，7：一键定档，8：标准卷设置',
    `oper_data_before` varchar(255) NULL DEFAULT NULL COMMENT '操作前数据',
    `oper_data_after` varchar(255) NULL DEFAULT NULL COMMENT '操作后数据',
    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
    `work_id` bigint(20) NULL DEFAULT NULL COMMENT '考区id',
    `paper_id` bigint(20) NULL DEFAULT NULL COMMENT '试卷id',
    `remark` varchar(500) NULL DEFAULT NULL COMMENT '备注',
    `stage` bigint(20) NULL DEFAULT NULL COMMENT '试卷阶段，0：初始，1：分档，2：打分',
    `work_name` varchar(255) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `union_001_index`(`create_user_id`, `oper_type`, `subject`, `exam_number`) USING BTREE,
    INDEX `idx_union_2`(`work_id`, `paper_id`, `oper_type`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '操作日志';

-- ----------------------------
-- Table structure for mark_subject
-- ----------------------------
CREATE TABLE IF NOT EXISTS `mark_subject`  (
    `id` varchar(50)  NOT NULL,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `name` varchar(255)  NULL DEFAULT NULL,
    `collect_config` varchar(255)  NULL DEFAULT NULL,
    `stage` int(11) NULL DEFAULT NULL,
    `total_score` int(11) NOT NULL,
    `sample_count` int(11) NOT NULL DEFAULT 100,
    `is_test` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否试评,0:不是，1:数据已导入，2:试评中',
    `is_formal` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否正评，0:不是，1:是',
    `all_level` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否全部根据档位分配完，0:不是，1:是',
    `enable` tinyint(1) NULL DEFAULT 1 COMMENT '是否启用 0：禁用 1：启用',
    `locking` tinyint(1) NULL DEFAULT 0 COMMENT '锁定（禁止评卷） 0：未锁定 1：锁定',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `FK1tvc2mil1ebqgt08912t4hxqw`(`work_id`) USING BTREE,
    CONSTRAINT `FK1tvc2mil1ebqgt08912t4hxqw` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_1` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_10` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_11` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_12` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_13` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_14` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_2` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_3` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_4` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_5` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_6` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_7` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_8` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_subject_ibfk_9` FOREIGN KEY (`work_id`) REFERENCES `work` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE = InnoDB CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for mark_task
-- ----------------------------
CREATE TABLE IF NOT EXISTS `mark_task`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NOT NULL,
    `paper_id` bigint(20) NOT NULL,
    `subject` varchar(50)  NULL DEFAULT NULL,
    `stage` int(11) NOT NULL,
    `is_rejected` bit(1) NOT NULL,
    `level_value` int(11) NULL DEFAULT NULL,
    `marker_id` bigint(20) NOT NULL,
    `marker_name` varchar(50)  NOT NULL,
    `origin_level` varchar(255)  NULL DEFAULT NULL,
    `question_id` bigint(20) NULL DEFAULT NULL,
    `result` varchar(50)  NULL DEFAULT NULL,
    `level` varchar(45) NULL DEFAULT NULL,
    `random_seq` int(11) NULL DEFAULT NULL,
    `secret_number` varchar(255) NULL DEFAULT NULL,
    `random_seq_new` bigint(20) NULL DEFAULT NULL COMMENT '随机号',
    `is_active` bit(1) NULL DEFAULT b'0' COMMENT '是否激活',
    `is_test` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否试评,0:不是，1:数据已导入，2:试评中',
    `batch_no` bigint(45) NULL DEFAULT NULL COMMENT '批次号',
    `is_change_stage` tinyint(1) NULL DEFAULT NULL COMMENT '是否改档',
    `serial_number` varchar(10) NULL DEFAULT NULL COMMENT '叫号序号',
    `display_number` int(11) NULL DEFAULT NULL,
    `manual_score` tinyint(1) NULL DEFAULT NULL COMMENT '是否手工输入打分，1-是、0-否（分档阶段无此值）',
    `is_sample` bit(1) NULL DEFAULT NULL,
    `deviation_direction` varchar(10) NULL DEFAULT NULL COMMENT '偏差方向',
    `is_mark` bit(1) NULL DEFAULT b'0' COMMENT '是否标记',
    `created_on` datetime(0) NULL DEFAULT NULL,
    `updated_on` datetime(0) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_mark_task_paper_id`(`paper_id`) USING BTREE,
    INDEX `question_id`(`question_id`, `marker_id`, `stage`, `result`, `is_rejected`, `random_seq`, `random_seq_new`) USING BTREE,
    INDEX `idx_union_1`(`marker_id`, `stage`, `result`, `random_seq`, `random_seq_new`) USING BTREE,
    CONSTRAINT `FKa6xqlu9ml2e47x1o2u2yec7vm` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_10` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_11` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_12` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_13` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_14` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_2` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_3` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_4` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_5` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_6` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_7` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_8` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_task_ibfk_9` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for mark_task_job
-- ----------------------------
CREATE TABLE IF NOT EXISTS `mark_task_job`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
    `data_object` varchar(4000) NULL DEFAULT NULL COMMENT 'object',
    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
    `status` bit(1) NULL DEFAULT b'0' COMMENT '状态，0：未记录，1：已记录',
    `work_id` bigint(20) NULL DEFAULT NULL COMMENT '工作区id',
    `version` int(11) NULL DEFAULT 0 COMMENT '版本号',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '定时任务调度表';

-- ----------------------------
-- Table structure for mark_user
-- ----------------------------
CREATE TABLE IF NOT EXISTS `mark_user`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NOT NULL,
    `organization_id` bigint(20) NULL DEFAULT NULL COMMENT '机构id',
    `subject` varchar(50)  NOT NULL,
    `name` varchar(255)  NULL DEFAULT NULL,
    `role` varchar(255)  NULL DEFAULT NULL,
    `enabled` bit(1) NOT NULL,
    `last_login_time` datetime(0) NULL DEFAULT NULL,
    `login_name` varchar(50)  NOT NULL,
    `password` varchar(255)  NULL DEFAULT NULL,
    `pw_changed_count` int(11) NOT NULL,
    `session_id` varchar(255)  NULL DEFAULT NULL,
    `group_id` bigint(20) NULL DEFAULT NULL,
    `mark_right` int(11) NULL DEFAULT NULL,
    `inspect_sc` bit(1) NULL DEFAULT NULL,
    `inspect_sm` bit(1) NULL DEFAULT NULL,
    `inspect_sx` bit(1) NULL DEFAULT NULL,
    `weight` double NULL DEFAULT NULL,
    `one_click_level` bit(1) NULL DEFAULT b'0' COMMENT '科组长是否开启一键定档',
    `standard_volume` bit(1) NOT NULL,
    `level_callback` bit(1) NOT NULL,
    `leader_confirm` bit(1) NULL DEFAULT b'0' COMMENT '科组长打回、定档是否要确认',
    `display_count` int(1) NULL DEFAULT NULL COMMENT '显示数量：4-4张显示，6-6张显示，8-8张显示',
    `default_account` tinyint(1) NULL DEFAULT NULL COMMENT '是否默认账号（采集账号）',
    `user_type` varchar(1) NULL DEFAULT NULL COMMENT '机构管理员类型，1-机构，2-项目经理',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `UK_cyf7k1neuij8lma85x19omo07`(`login_name`) USING BTREE,
    INDEX `FKinr4i9gbxj9njwo82s7cc89q5`(`group_id`) USING BTREE,
    CONSTRAINT `FKinr4i9gbxj9njwo82s7cc89q5` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_10` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_11` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_12` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_13` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_14` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_3` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_4` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_5` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_6` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_7` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_8` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
    CONSTRAINT `mark_user_ibfk_9` FOREIGN KEY (`group_id`) REFERENCES `marker_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for marker_group
-- ----------------------------
CREATE TABLE IF NOT EXISTS `marker_group`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NOT NULL,
    `subject` varchar(50)  NOT NULL,
    `name` varchar(255)  NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for organization
-- ----------------------------
CREATE TABLE IF NOT EXISTS `organization`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `name` varchar(255) NULL DEFAULT NULL COMMENT '机构名称',
    `abbreviation` varchar(45) NULL DEFAULT NULL COMMENT '机构id',
    `enabled` bit(1) NULL DEFAULT NULL COMMENT '是否启用',
    `created_on` date NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '机构管理';

-- ----------------------------
-- Table structure for paper
-- ----------------------------
CREATE TABLE IF NOT EXISTS `paper`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NOT NULL,
    `subject` varchar(50)  NOT NULL,
    `exam_number` varchar(50)  NOT NULL,
    `student_name` varchar(50)  NOT NULL,
    `area_code` varchar(50)  NOT NULL,
    `idx` bigint(20) NULL DEFAULT NULL,
    `is_arbitrated` bit(1) NOT NULL,
    `is_manual` bit(1) NOT NULL,
    `is_rejected` bit(1) NOT NULL,
    `is_tagged` bit(1) NOT NULL,
    `level` varchar(255)  NULL DEFAULT NULL,
    `redo_level` varchar(255)  NULL DEFAULT NULL,
    `score` double NULL DEFAULT NULL,
    `mark_by_leader` bit(1) NOT NULL,
    `marked_logic` bit(1) NOT NULL,
    `question_id` bigint(20) NOT NULL,
    `question_name` varchar(255)  NOT NULL,
    `secret_number` varchar(255)  NULL DEFAULT NULL,
    `uploaded_count` int(11) NOT NULL,
    `uploaded_on` datetime(0) NULL DEFAULT NULL,
    `inspect_range` bigint(20) NULL DEFAULT NULL,
    `inspect_score` double NULL DEFAULT NULL,
    `source_name` varchar(255) NULL DEFAULT NULL,
    `inspect_level` varchar(255) NULL DEFAULT NULL,
    `inspector` bigint(20) NULL DEFAULT NULL,
    `is_sample` bit(1) NOT NULL,
    `sheet_md5` varchar(255) NULL DEFAULT NULL,
    `slice_md5` varchar(255) NULL DEFAULT NULL,
    `random_seq` bigint(20) NULL DEFAULT NULL COMMENT '随机号',
    `is_missing` bit(1) NOT NULL,
    `exam_room` varchar(255) NULL DEFAULT NULL,
    `is_test` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否试评,0:不是，1:数据已导入，2:试评中',
    `is_active` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否激活',
    `batch_no` bigint(45) NULL DEFAULT NULL COMMENT '批次号',
    `score_batch_no` bigint(45) NULL DEFAULT NULL COMMENT '打分任务发布批次号',
    `is_shift` bit(1) NULL DEFAULT b'0' COMMENT '是否改档',
    `is_shift_score` bit(1) NULL DEFAULT b'0' COMMENT '是否改档打分',
    `is_one_click` bit(1) NULL DEFAULT b'0' COMMENT '是否一键定档',
    `is_rejected_by_leader` bit(1) NULL DEFAULT b'0' COMMENT '是否科组长打回',
    `is_relate` bit(1) NULL DEFAULT b'0' COMMENT '是否关联试卷',
    `sort_num` int(11) NULL DEFAULT NULL,
    `scan_user_id` bigint(20) NULL DEFAULT NULL COMMENT '采集员ID',
    `is_mark` bit(1) NULL DEFAULT b'0' COMMENT '是否标记',
    `updated_on` datetime(0) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_paper_exam_number`(`exam_number`) USING BTREE,
    INDEX `idx_union_1`(`batch_no`) USING BTREE,
    INDEX `idx_union_2`(`question_id`, `level`) USING BTREE,
    INDEX `idx_union_3`(`work_id`, `subject`, `batch_no`) USING BTREE,
    INDEX `idx_union_4`(`is_shift`, `is_shift_score`) USING BTREE,
    INDEX `idx_union_5`(`work_id`, `subject`, `score_batch_no`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for param_setting
-- ----------------------------
CREATE TABLE IF NOT EXISTS `param_setting`  (
    `id` bigint(10) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(10) NULL DEFAULT NULL COMMENT '工作id',
    `package_scan` tinyint(1) NULL DEFAULT NULL COMMENT '[采集参数]是否整包扫描1：是 0：否',
    `image_encrypt` tinyint(1) NULL DEFAULT NULL COMMENT '[采集参数]是否加密1：是 0：否',
    `name_rule` tinyint(1) NULL DEFAULT NULL COMMENT '[采集参数]图片命名规则（1：考号命名、0：随机码命名）',
    `paper_stage` tinyint(1) NULL DEFAULT NULL COMMENT '[采集参数]试卷档位状态（1：已知、0：未知）',
    `deviation` int(2) NULL DEFAULT NULL COMMENT '[分档参数]仲裁档位差',
    `auto_callback` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]是否自动打回（1：是、0：否）',
    `cumulative_error` int(3) NULL DEFAULT NULL COMMENT '[分档参数]打回累计误差',
    `auto_callback_show_deviation` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]自动打回时显示偏差',
    `majority` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]是否过半定档（1：是、0：否）',
    `take_best` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]取优原则（1：是、0：否）',
    `level_show_all_paper` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]分档阶段阅卷员是否显示所有试卷（1：是、0：否）',
    `show_paper_count` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]打分界面评卷数量是否显示（1：是、0：否）',
    `prop_denominator` int(2) NULL DEFAULT NULL COMMENT '[分档参数]档位百分比分母（1: \"全部考生数\", 2: \"去掉缺考考生数\"）',
    `show_sample` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]是否显示标准卷',
    `allow_task_overlay` tinyint(1) NULL DEFAULT NULL COMMENT '[分档参数]是否允许任务数累加 默认0',
    `round_up` tinyint(1) NULL DEFAULT NULL COMMENT '[打分参数]分数处理方式（1：四舍五入、0：非零进一）',
    `change_stage` tinyint(1) NULL DEFAULT NULL COMMENT '[打分参数]改档及改档打分（1：显示、0：不显示）',
    `score_show_all_paper` tinyint(1) NULL DEFAULT NULL COMMENT '[打分参数]打分阶段阅卷员是否显示所有试卷（1：是、0：否）',
    `is_level_to_score` tinyint(1) NULL DEFAULT NULL COMMENT '[打分参数]是否谁分档谁打分',
    `direct_score` tinyint(1) NULL DEFAULT NULL COMMENT '[打分参数]是否启用直接输分功能',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '参数设置';

-- ----------------------------
-- Table structure for student
-- ----------------------------
CREATE TABLE IF NOT EXISTS `student`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `exam_number` varchar(50)  NULL DEFAULT NULL,
    `name` varchar(50)  NULL DEFAULT NULL,
    `area_code` varchar(255)  NULL DEFAULT NULL,
    `area_name` varchar(255)  NULL DEFAULT NULL,
    `exam_room` varchar(255)  NULL DEFAULT NULL,
    `school` varchar(255) NULL DEFAULT NULL COMMENT '学校',
    `is_absent` bit(1) NOT NULL,
    `upload_status` varchar(255)  NULL DEFAULT NULL,
    `source_name` varchar(255) NULL DEFAULT NULL,
    `is_test` varchar(50) NOT NULL DEFAULT '0' COMMENT '是否试评,0:不是，1:数据已导入，2:试评中',
    `relate_exam_number` varchar(50) NULL DEFAULT NULL COMMENT '关联考号',
    `sc_missing` bit(1) NULL DEFAULT b'0' COMMENT '色彩缺考',
    `sx_missing` bit(1) NULL DEFAULT b'0' COMMENT '速写缺考',
    `sm_missing` bit(1) NULL DEFAULT b'0' COMMENT '素描缺考',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `exam_number`(`exam_number`, `work_id`, `is_test`) USING BTREE,
    INDEX `idx_student_name`(`name`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

-- ----------------------------
-- Table structure for task_publish_setting
-- ----------------------------
CREATE TABLE IF NOT EXISTS `task_publish_setting`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `work_id` bigint(20) NULL DEFAULT NULL,
    `question_id` bigint(45) NULL DEFAULT NULL COMMENT '考区',
    `subject` varchar(50) NULL DEFAULT NULL,
    `code` varchar(45) NULL DEFAULT NULL COMMENT '档位',
    `total_count` int(11) NULL DEFAULT NULL COMMENT '总数量',
    `success_count` int(11) NULL DEFAULT NULL COMMENT '已评数量',
    `wait_count` varchar(45) NULL DEFAULT NULL COMMENT '待评数量',
    `sort_rule` tinyint(1) NULL DEFAULT NULL COMMENT '排序规则：0-乱序，1-定序',
    `display_number` tinyint(1) NULL DEFAULT NULL COMMENT '是否显示序号：0-否，1-是',
    `task_count` int(11) NULL DEFAULT NULL COMMENT '本次任务数',
    `batch_no` bigint(45) NULL DEFAULT NULL,
    `publish_count` int(3) NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '发布打分任务';

-- ----------------------------
-- Table structure for work
-- ----------------------------
CREATE TABLE IF NOT EXISTS `work`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `name` varchar(255)  NULL DEFAULT NULL,
    `organization_id` bigint(20) NULL DEFAULT NULL COMMENT '机构id',
    `active` bit(1) NOT NULL,
    `created_on` date NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4;

