USE teachcloud_db;

CREATE TABLE `sys_tools` (
         `type` VARCHAR(20) NOT NULL COMMENT '类型',
         `path` MEDIUMTEXT NOT NULL COMMENT '文件地址信息',
         `create_id` BIGINT(20) NULL,
         `create_time` BIGINT(20) NULL,
         PRIMARY KEY (`type`))
    COMMENT = '工具管理';

ALTER TABLE `basic_print_config` ADD COLUMN `output_file_type` VARCHAR(100) NULL COMMENT '输出文件类型' AFTER `print_method`;
update basic_print_config set output_file_type = '["PAPER","ALL_CARD","PACKAGE","SIGN","CHECK_IN"]' where output_file_type is null;

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('1151', '导入数据包', 'CardJsonImport', 'BUTTON', '897', '9', 'AUTH', '1152', '1', '0', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1152', '导入数据包', '/api/admin/mark/setting/card_json/import', 'URL', '897', '20', 'AUTH', '1', '1', '1');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1011', '主观题检查-确认任务', '/api/admin/mark/inspected/subjective/confirmTask', 'URL', '946', '14', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '956,957,958,1011' WHERE (`id` = '1176');
UPDATE `sys_privilege` SET `related` = '888,894,956,957,958,1011' WHERE (`id` = '1179');

ALTER TABLE `mark_task` ADD COLUMN `reject_reason` VARCHAR(128) NULL COMMENT '打回原因' AFTER `header_score_list`;
ALTER TABLE `mark_user_group` ADD COLUMN `reject_count` INT NULL COMMENT '打回次数' AFTER `min_score`;
ALTER TABLE `mark_subjective_score` ADD COLUMN `rejected` TINYINT(1) NULL DEFAULT 0 COMMENT '是否打回' AFTER `uncalculate`;
ALTER TABLE `mark_task` ADD COLUMN `basic_student_id` BIGINT(20) NULL COMMENT '考生管理ID' AFTER `student_id`;
update mark_task mt set mt.basic_student_id = (select ms.basic_student_id from mark_student ms where mt.student_id = ms.id) where mt.basic_student_id is null;

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('1184', '打回', 'MarkTaskReject', 'LINK', '917', '10', 'AUTH', '1185', '1', '0', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1183', '任务管理列表查询', '/api/admin/mark/task/list', 'URL', '917', '24', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1185', '打回', '/api/admin/mark/task/reject', 'URL', '917', '25', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1186', '打回历史列表查询', '/api/admin/mark/reject/list', 'URL', '917', '26', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '928,929,932,933,934,935,936,937,938,939,940,941,942,943,964,965,966,967,968,1008,1183,1186' WHERE (`id` = '944');

CREATE TABLE `mark_reject_history`(
          `id` bigint NOT NULL,
          `exam_id` bigint NULL DEFAULT NULL COMMENT '考试ID',
          `paper_number` varchar(45) NULL DEFAULT NULL COMMENT '试卷编号',
          `group_number` int NULL DEFAULT NULL COMMENT '分组号',
          `task_id` bigint NULL DEFAULT NULL COMMENT '任务ID',
          `student_id` bigint NULL DEFAULT NULL COMMENT '考生ID',
          `basic_student_id` bigint NULL DEFAULT NULL COMMENT 'basic_exam_student表id',
          `student_code` varchar(255) NULL DEFAULT NULL COMMENT '学号',
          `secret_number` varchar(255) NULL DEFAULT NULL COMMENT '任务密号',
          `user_id` bigint NULL DEFAULT NULL COMMENT '评卷用户ID',
          `reject_reason` varchar(255) NULL DEFAULT NULL COMMENT '打回原因',
          `reject_score_list` varchar(255) NULL DEFAULT NULL COMMENT '打回后分数列表',
          `marker_score_list` varchar(255) NULL DEFAULT NULL COMMENT '打回前分数列表',
          `marker_score` double NULL DEFAULT NULL COMMENT '总分',
          `marker_time` bigint NULL DEFAULT NULL COMMENT '评卷时间',
          `reject_user_id` bigint NULL DEFAULT NULL COMMENT '打回用户ID',
          `reject_time` bigint NOT NULL COMMENT '打回时间',
          PRIMARY KEY (`id`) USING BTREE,
          INDEX `index2`(`task_id` ASC) USING BTREE,
          INDEX `index1`(`exam_id` ASC, `paper_number` ASC, `group_number` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

ALTER TABLE `exam_task` ADD COLUMN `exam_task_content` MEDIUMTEXT NULL COMMENT '入库申请请求参数' AFTER `source`;

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1187', '打回-查询轨迹图', '/api/admin/mark/task/get_mark_track', 'URL', '917', '27', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '1185,1187' WHERE (`id` = '1184');

UPDATE `sys_privilege` SET `related` = '74,417,420,421,427,441,442,477,417,640,641,642' WHERE (`id` = '292');
UPDATE `sys_privilege` SET `related` = '74,477,417,420,421,427,441,442,640,641,642' WHERE (`id` = '296');
UPDATE `sys_privilege` SET `enable` = '0', `front_display` = '0' WHERE (`id` = '275');

ALTER TABLE `exam_card` ADD COLUMN `page_size` VARCHAR(10) NULL COMMENT '题卡纸张大小（A3，8K）' AFTER `copy_card_id`;
update exam_card set page_size = 'A3' where page_size is null;
ALTER TABLE `scan_answer_card` ADD COLUMN `content` MEDIUMTEXT NULL COMMENT '题卡内容（模式4导入）' AFTER `adapte_uri`;

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3055', '首页-评卷待办数量', '/api/admin/work/mark/task/ready_count', 'URL', '16', '11', 'SYS', '1', '1', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3056', '首页-评卷待办列表', '/api/admin/work/mark/task/ready', 'URL', '16', '12', 'SYS', '1', '1', '1');
INSERT INTO `sys_config` (`id`, `school_id`, `org_id`, `config_key`, `config_name`, `config_value`, `remark`, `enable`, `sort`, `create_id`, `create_time`, `update_id`, `update_time`) VALUES (43, NULL, NULL, 'sys.card.size.list', '全局题卡格式清单', '[A3, 8K]', NULL, 1, 2, 1, NULL, NULL, NULL);
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3057', '总量分析', '/api/admin/mark/archive/score/list/export', 'URL', '487', '3', 'AUTH', '1', '1', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('3058', '总量分析', 'aggregateAnalysis', 'BUTTON', '487', '3', 'AUTH', '3057', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3059', '文档管理-批量下载', '/api/admin/mark/archive/document/download_batch', 'URL', '577', '7', 'AUTH', '1', '1', '1');
UPDATE sys_privilege SET related = '466,467,494,544,585,586,587,588,3059' WHERE (id = '582');

ALTER TABLE obe_culture_program ADD grade varchar(100) NULL COMMENT '年级';
ALTER TABLE obe_culture_program CHANGE grade grade varchar(100) NULL COMMENT '年级' AFTER professional_id;
UPDATE sys_privilege SET name='查看详情', url='View', `type`='LINK', parent_id=2002, `sequence`=1, property='AUTH', related='2026,2027,2028,2031,2110', enable=1, default_auth=0, front_display=1 WHERE id=2025;
INSERT INTO sys_privilege (id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display) VALUES(2110, '导出平时成绩报告', '/api/admin/course/degree/report/usual_score/export', 'URL', 2025, 1, 'AUTH', NULL, 1, 1, 1);
ALTER TABLE t_r_basic_info DROP COLUMN finish_points;
ALTER TABLE t_r_basic_info DROP COLUMN requirement_points;
