ALTER TABLE t_b_user ADD pwd_force TINYINT DEFAULT 0
		COMMENT '强制修改密码，0：未修改，1：已修改' NOT NULL after remark;

UPDATE t_b_user
SET org_id=NULL, login_name='sysadmin', name='sysadmin', password='cW10aDIwMjIpKCo=', mobile_number=NULL, enable=1, create_time=1600932652000, update_time=1600932652000, remark='系统管理员', pwd_force=1, create_id=0, update_id=1
WHERE id=1;

INSERT INTO t_b_privilege
(id, name, url, `type`, parent_id, `sequence`, remark, create_time)
VALUES(206, '报表-情况统计导出', '/api/admin/report/exam_view_count/export', 'LINK', 24, 3, NULL, 1600932652000);
INSERT INTO t_b_privilege
(id, name, url, `type`, parent_id, `sequence`, remark, create_time)
VALUES(207, '报表-缺考名单导出', '/api/admin/report/exam_deficiency_list/export', 'LINK', 24, 4, NULL, 1600932652000);
INSERT INTO t_b_privilege
(id, name, url, `type`, parent_id, `sequence`, remark, create_time)
VALUES(208, '报表-违纪名单导出', '/api/admin/report/exam_breach_list/export', 'LINK', 24, 9, NULL, 1600932652000);

INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(256, 'ADMIN', 206);
INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(257, 'ADMIN', 207);
INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(258, 'ADMIN', 208);

ALTER TABLE t_ie_exam_invigilate_call ADD form_user_id BIGINT NULL COMMENT '发起人id';
ALTER TABLE t_ie_exam_invigilate_call ADD receive_user_id BIGINT NULL COMMENT '接收人id';
ALTER TABLE t_ie_exam_invigilate_call_log ADD form_user_id BIGINT NULL COMMENT '发起人id';
ALTER TABLE t_ie_exam_invigilate_call_log ADD receive_user_id BIGINT NULL COMMENT '接收人id';
ALTER TABLE t_ie_exam_invigilate_call_log ADD start_time BIGINT NULL COMMENT '开始通话时间';
ALTER TABLE t_ie_exam_invigilate_call_log ADD end_time BIGINT NULL COMMENT '结束通话时间';
ALTER TABLE t_oe_exam_record ADD warning_unread INTEGER NULL COMMENT '预警记录未读数';
ALTER TABLE t_oe_exam_record ADD warning_multiple_face_count INTEGER NULL COMMENT '陌生人脸预警总数';
ALTER TABLE t_oe_exam_record ADD exception_count INTEGER NULL COMMENT '异常数据总数';

ALTER TABLE t_ie_exam_invigilate_call ADD call_time BIGINT NULL COMMENT '接通时间';
ALTER TABLE t_ie_exam_invigilate_call CHANGE call_time call_time BIGINT NULL COMMENT '接通时间' AFTER start_time;
ALTER TABLE t_ie_exam_invigilate_call_log ADD call_time BIGINT NULL COMMENT '接通时间';
ALTER TABLE t_ie_exam_invigilate_call_log CHANGE call_time call_time BIGINT NULL COMMENT '接通时间' AFTER start_time;

DROP TABLE IF EXISTS `t_ie_exam_media_log`;
CREATE TABLE `t_ie_exam_media_log` (
  `id` bigint NOT NULL COMMENT '主键',
  `exam_id` bigint NOT NULL COMMENT '考试id',
  `exam_activity_id` bigint NOT NULL COMMENT '场次id',
  `exam_student_id` bigint NOT NULL COMMENT '考生id',
  `exam_record_id` bigint NOT NULL COMMENT '考试记录id',
  `source` varchar(30) DEFAULT NULL COMMENT '状态',
  `create_time` bigint DEFAULT NULL COMMENT '创建时间',
  `type` varchar(20) DEFAULT NULL COMMENT '类型',
  `content` varchar(500) DEFAULT NULL COMMENT '内容',
  `start_time` bigint DEFAULT NULL COMMENT '开始通话时间',
  `call_time` bigint DEFAULT NULL COMMENT '接通时间',
  `end_time` bigint DEFAULT NULL COMMENT '结束通话时间',
  `form_user_id` bigint DEFAULT NULL COMMENT '发起人id',
  `receive_user_id` bigint DEFAULT NULL COMMENT '接收人id',
  PRIMARY KEY (`id`),
  UNIQUE KEY `t_ie_exam_media_log_UN_content` (`exam_record_id`,`source`,`content`,`start_time`,`end_time`),
  KEY `t_ie_exam_media_log_exam_record_id_IDX` (`exam_record_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='多媒体日志表';

DROP TABLE IF EXISTS `t_e_exam_summary`;
CREATE TABLE `t_e_exam_summary` (
  `id` bigint NOT NULL COMMENT '主键',
  `exam_id` bigint NOT NULL COMMENT '考试批次id',
  `exam_activity_id` bigint NOT NULL COMMENT '考试场次id',
  `room_code` varchar(50) NOT NULL COMMENT '考场编码',
  `total_count` int DEFAULT NULL COMMENT '考生总数',
  `prepare_count` int DEFAULT NULL COMMENT '候考人数',
  `exam_count` int DEFAULT NULL COMMENT '正在考试人数',
  `finish_count` int DEFAULT NULL COMMENT '考试完成人数',
  `absent_count` int DEFAULT NULL COMMENT '缺考人数',
  `online_count` int DEFAULT NULL COMMENT '在线人数',
  `offline_count` int DEFAULT NULL COMMENT '离线人数',
  `monitor_stop_count` int DEFAULT NULL COMMENT '监控停止人数',
  `warning_count` int DEFAULT NULL COMMENT '预警总数',
  `warning_unread` int DEFAULT NULL COMMENT '预警未读数',
  `warning_student_unread` int DEFAULT NULL COMMENT '预警考生未读数（去重）',
  `warning_multiple_face_count` int DEFAULT NULL COMMENT '陌生人脸预警总数',
  `exception_count` int DEFAULT NULL COMMENT '异常数据总数',
  PRIMARY KEY (`id`),
  UNIQUE KEY `t_e_exam_summary_UN` (`exam_id`,`exam_activity_id`,`room_code`),
  KEY `t_e_exam_summary_exam_id_IDX` (`exam_id`,`exam_activity_id`,`room_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='考试信息统计表';

DROP TABLE IF EXISTS `t_e_org_summary`;
CREATE TABLE `t_e_org_summary` (
  `org_id` bigint NOT NULL DEFAULT '0' COMMENT '机构ID，全局为0',
  `online_count` int DEFAULT NULL COMMENT '在线人数',
  `exam_count` int DEFAULT NULL COMMENT '考试人数',
  `finish_count` int DEFAULT NULL COMMENT '完成考试次数',
  `finish_student_count` int DEFAULT NULL COMMENT '完成考试人数',
  PRIMARY KEY (`org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='超管统计表';

DROP TABLE IF EXISTS `t_e_region_summary`;
CREATE TABLE `t_e_region_summary` (
  `id` bigint NOT NULL COMMENT '主键',
  `country` varchar(30) NOT NULL COMMENT '国家',
  `province` varchar(30) NOT NULL COMMENT '省份',
  `online_count` int DEFAULT NULL COMMENT '在线人数',
  PRIMARY KEY (`id`),
  UNIQUE KEY `t_e_region_summary_UN` (`country`,`province`),
  KEY `t_e_region_summary_country_IDX` (`country`,`province`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='地区统计表';

ALTER TABLE t_e_exam_student DROP INDEX roomcode_examid;
ALTER TABLE t_e_exam_student DROP INDEX student_id;

CREATE INDEX t_e_exam_student_exam_id_IDX USING BTREE ON t_e_exam_student (exam_id,exam_activity_id,room_code);
CREATE INDEX t_e_exam_student_student_id_IDX USING BTREE ON t_e_exam_student (student_id,exam_activity_id,enable);

INSERT INTO sys_config
(id, org_id, config_key, config_name, config_value, enable, create_id, create_time, update_id, update_time, remark, sort, editor)
VALUES(32, NULL, 'client.db.upload.location', '客户端上传db地址', '/oe-client/exception', 1, 1, NULL, NULL, NULL, NULL, 1, 0);

UPDATE sys_config
SET org_id=NULL, config_key='exam.no.auth.urls', config_name='exam无需鉴权的url', config_value='/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/oe/student/login,/api/oe/sys/env,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/oe/exam/short_code,/api/mobile/authorization,/api/oe/black/list/select,/api/oe/sys/school/list,/api/oe/sys/upload/package/callback,/api/oe/sys/file/upload', enable=1, create_id=1, create_time=NULL, update_id=NULL, update_time=NULL, remark=NULL, sort=1, editor=0
WHERE id=17;

INSERT INTO sys_config
(id, org_id, config_key, config_name, config_value, enable, create_id, create_time, update_id, update_time, remark, sort, editor)
VALUES(33, NULL, 'waiting.exam.day', '待考列表天数', '3', 1, 1, NULL, NULL, NULL, NULL, 1, 0);

INSERT INTO t_b_privilege
(id, name, url, `type`, parent_id, `sequence`, remark, create_time)
VALUES(209, '监考编辑接口', '/api/admin/invigilateUser/edit', 'LINK', 9, 2, NULL, 1600932652000);

INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(259, 'ADMIN', 209);

/*删除进度查询菜单*/
INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(149, 'INVIGILATE', 19);
INSERT INTO t_b_role_privilege
(id, role_code, privilege_id)
VALUES(153, 'ADMIN', 19);

delete t from t_b_role_privilege t
where t.id in (149,153);