|
@@ -23,9 +23,11 @@ public class FixExamStudentId {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ private static int errRecord = 0;
|
|
|
+
|
|
|
public void start() {
|
|
|
- final Long examId = 2843L;
|
|
|
- final Long courseId = 11231L;
|
|
|
+ final Long examId = 427L;
|
|
|
+ final Long courseId = 1865L;
|
|
|
|
|
|
// 查询网考端考生表记录
|
|
|
StringBuilder querySql = new StringBuilder()
|
|
@@ -33,11 +35,11 @@ public class FixExamStudentId {
|
|
|
.append("where id > %s and exam_id = %s and course_id = %s ")
|
|
|
.append("order by id asc limit 0,10");
|
|
|
|
|
|
- int total = 0, err = 0;
|
|
|
+ int total = 0;
|
|
|
Long nextMinId = 0L;
|
|
|
while (true) {
|
|
|
System.out.println();
|
|
|
- log.info("query nextMinId:" + nextMinId + ", total " + total + ", err " + err);
|
|
|
+ log.info("query nextMinId:" + nextMinId + ", total " + total + ", errRecord " + errRecord);
|
|
|
|
|
|
List<ExamStudentVO> list = jdbcTemplate.query(
|
|
|
String.format(querySql.toString(), nextMinId, examId, courseId),
|
|
@@ -50,13 +52,13 @@ public class FixExamStudentId {
|
|
|
nextMinId = list.get(list.size() - 1).getId();
|
|
|
total += list.size();
|
|
|
|
|
|
- // this.fix(list, err);
|
|
|
+ // this.fix(list);
|
|
|
}
|
|
|
|
|
|
log.info("task end...");
|
|
|
}
|
|
|
|
|
|
- private void fix(List<ExamStudentVO> examStudentList, int err) {
|
|
|
+ private void fix(List<ExamStudentVO> examStudentList) {
|
|
|
for (ExamStudentVO vo : examStudentList) {
|
|
|
// 查询考务端考生表记录
|
|
|
Long realExamStudentId = this.queryExamStudentFromExamWork(vo.getExamId(), vo.getCourseId(), vo.getStudentId());
|
|
@@ -66,23 +68,41 @@ public class FixExamStudentId {
|
|
|
}
|
|
|
|
|
|
if (!vo.getExamStudentId().equals(realExamStudentId)) {
|
|
|
- err++;
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
+ msg.append(" curExamStudentId = ").append(vo.getExamStudentId());
|
|
|
+ msg.append(" realExamStudentId = ").append(realExamStudentId);
|
|
|
+
|
|
|
+ int a;
|
|
|
+ if (this.exist_ec_oe_exam_student_final_score(realExamStudentId)) {
|
|
|
+ a = this.delete_ec_oe_exam_student_final_score(vo.getExamStudentId());
|
|
|
+ msg.append("\n delete_ec_oe_exam_student_final_score - ").append(a);
|
|
|
+ } else {
|
|
|
+ a = this.update_ec_oe_exam_student_final_score(vo.getExamStudentId(), realExamStudentId);
|
|
|
+ msg.append("\n update_ec_oe_exam_student_final_score - ").append(a);
|
|
|
+ }
|
|
|
+
|
|
|
+ int b = this.update_ec_oe_exam_record_4_marking(vo.getExamStudentId(), realExamStudentId);
|
|
|
+ msg.append("\n update_ec_oe_exam_record_4_marking - ").append(b);
|
|
|
+
|
|
|
+ int c = this.update_ec_oe_exam_record_data(vo.getExamStudentId(), realExamStudentId);
|
|
|
+ msg.append("\n update_ec_oe_exam_record_data - ").append(c);
|
|
|
+
|
|
|
+ int d = this.update_ec_oes_exam_record_data(vo.getExamStudentId(), realExamStudentId);
|
|
|
+ msg.append("\n update_ec_oes_exam_record_data - ").append(d);
|
|
|
|
|
|
- int a = this.update_ec_oes_exam_record_data(vo.getExamStudentId(), realExamStudentId);
|
|
|
- int b = this.update_ec_oe_exam_record_data(vo.getExamStudentId(), realExamStudentId);
|
|
|
- int c = this.update_ec_oe_exam_student_final_score(vo.getExamStudentId(), realExamStudentId);
|
|
|
- int d = this.update_ec_oe_exam_record_4_marking(vo.getExamStudentId(), realExamStudentId);
|
|
|
int e = this.delete_ec_oe_exam_student(vo.getId());
|
|
|
+ msg.append("\n delete_ec_oe_exam_student - ").append(e);
|
|
|
+
|
|
|
+ errRecord++;
|
|
|
|
|
|
- String msg = String.format("curExamStudentId = %s realExamStudentId = %s fix--> %s - %s - %s - %s - %s",
|
|
|
- vo.getExamStudentId(), realExamStudentId, a, b, c, d, e);
|
|
|
- log.info(msg);
|
|
|
+ log.info(msg.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Long queryExamStudentFromExamWork(Long examId, Long courseId, Long studentId) {
|
|
|
String querySql = String.format("select id from ec_e_exam_student where exam_id = %s and course_id = %s and student_id = %s ", examId, courseId, studentId);
|
|
|
+
|
|
|
try {
|
|
|
return jdbcTemplate.queryForObject(querySql, Long.class);
|
|
|
} catch (EmptyResultDataAccessException e) {
|
|
@@ -90,13 +110,14 @@ public class FixExamStudentId {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private int update_ec_oes_exam_record_data(Long curExamStudentId, Long realExamStudentId) {
|
|
|
- String sql = String.format("update ec_oes_exam_record_data set exam_student_id = %s where exam_student_id = %s", realExamStudentId, curExamStudentId);
|
|
|
- return jdbcTemplate.update(sql);
|
|
|
+ private boolean exist_ec_oe_exam_student_final_score(Long curExamStudentId) {
|
|
|
+ String countSql = String.format("select count(1) from ec_oe_exam_student_final_score where exam_student_id = %s", curExamStudentId);
|
|
|
+ Long total = jdbcTemplate.queryForObject(countSql, Long.class);
|
|
|
+ return total > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
- private int update_ec_oe_exam_record_data(Long curExamStudentId, Long realExamStudentId) {
|
|
|
- String sql = String.format("update ec_oe_exam_record_data set exam_student_id = %s where exam_student_id = %s", realExamStudentId, curExamStudentId);
|
|
|
+ private int delete_ec_oe_exam_student_final_score(Long curExamStudentId) {
|
|
|
+ String sql = String.format("delete from ec_oe_exam_student_final_score where exam_student_id = %s", curExamStudentId);
|
|
|
return jdbcTemplate.update(sql);
|
|
|
}
|
|
|
|
|
@@ -110,6 +131,16 @@ public class FixExamStudentId {
|
|
|
return jdbcTemplate.update(sql);
|
|
|
}
|
|
|
|
|
|
+ private int update_ec_oe_exam_record_data(Long curExamStudentId, Long realExamStudentId) {
|
|
|
+ String sql = String.format("update ec_oe_exam_record_data set exam_student_id = %s where exam_student_id = %s", realExamStudentId, curExamStudentId);
|
|
|
+ return jdbcTemplate.update(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ private int update_ec_oes_exam_record_data(Long curExamStudentId, Long realExamStudentId) {
|
|
|
+ String sql = String.format("update ec_oes_exam_record_data set exam_student_id = %s where exam_student_id = %s", realExamStudentId, curExamStudentId);
|
|
|
+ return jdbcTemplate.update(sql);
|
|
|
+ }
|
|
|
+
|
|
|
private int delete_ec_oe_exam_student(Long id) {
|
|
|
String sql = String.format("delete from ec_oe_exam_student where id = %s", id);
|
|
|
return jdbcTemplate.update(sql);
|