|
@@ -75,6 +75,8 @@ public class DataSyncThread implements Runnable {
|
|
|
|
|
|
public static final String SIZE = "size";
|
|
|
|
|
|
+ public static final String ERROR_CODE = "EX-101444";
|
|
|
+
|
|
|
public DataSyncThread(DataSync dataSync, Integer pageSize, LockService lockService,
|
|
|
DataSyncService dataSyncService, ExamService examService, ExamStudentService studentService,
|
|
|
ExamSubjectService subjectService, FileService fileService) {
|
|
@@ -98,6 +100,16 @@ public class DataSyncThread implements Runnable {
|
|
|
public void run() {
|
|
|
log.info("start data sync for examId=" + dataSync.getExamId());
|
|
|
try {
|
|
|
+ JSONObject datas = new JSONObject();
|
|
|
+ datas.accumulate("examId", dataSync.getCloudExamId());
|
|
|
+ String subjectResult = subjectHttp.httpAction(null, datas.toString());
|
|
|
+ JSONObject subjectJson = JSONObject.fromObject(subjectResult);
|
|
|
+ // 考试返回错误,无法创建阅卷
|
|
|
+ if (ERROR_CODE.equals(subjectJson.getString("code"))) {
|
|
|
+ log.error("data sync exception for cloud examId=" + dataSync.getCloudExamId(),
|
|
|
+ subjectJson.getString("desc"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 获取考试信息
|
|
|
Exam exam = examService.findById(dataSync.getExamId());
|
|
|
dataSync.setSchoolId(exam.getSchoolId());
|
|
@@ -107,10 +119,7 @@ public class DataSyncThread implements Runnable {
|
|
|
sync.setCreateTime(new Date());
|
|
|
dataSyncService.save(sync);
|
|
|
}
|
|
|
- JSONObject datas = new JSONObject();
|
|
|
- datas.accumulate("examId", sync.getCloudExamId());
|
|
|
- String subjectResult = subjectHttp.httpAction(null, datas.toString());
|
|
|
- JSONObject subjectJson = JSONObject.fromObject(subjectResult);
|
|
|
+
|
|
|
JSONArray subjectArray = subjectJson.getJSONArray(PAPER_STRUCT);
|
|
|
for (int i = 0; i < subjectArray.size(); i++) {
|
|
|
JSONObject subject = subjectArray.getJSONObject(i);
|
|
@@ -124,12 +133,15 @@ public class DataSyncThread implements Runnable {
|
|
|
byte[] paperData = paper.getBytes(StandardCharsets.UTF_8);
|
|
|
fileService.uploadPaper(new ByteArrayInputStream(paperData), BinaryUtil.encodeMD5(paperData),
|
|
|
exam.getId(), subjectCode, FormatType.JSON);
|
|
|
- // 获取考生
|
|
|
- Long startId = 0L;
|
|
|
+
|
|
|
ExamSubject examSubject = subjectService.find(exam.getId(), subjectCode);
|
|
|
if (examSubject != null && !subjectCode.equals(sync.getSubjectCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 创建科目
|
|
|
+ this.saveSubject(exam.getId(), subjectCode, subjectName);
|
|
|
+ // 获取考生
|
|
|
+ Long startId = 0L;
|
|
|
if (null != sync.getNextId()) {
|
|
|
startId = sync.getNextId();
|
|
|
}
|
|
@@ -221,4 +233,16 @@ public class DataSyncThread implements Runnable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void saveSubject(Integer examId, String subjectCode, String subjectName) {
|
|
|
+ ExamSubject subject = new ExamSubject();
|
|
|
+ subject.setExamId(examId);
|
|
|
+ subject.setCode(subjectCode);
|
|
|
+ subject.setName(subjectName);
|
|
|
+ subject.setPaperFileType(FormatType.JSON);
|
|
|
+ subject.setObjectiveScore(0d);
|
|
|
+ subject.setSubjectiveScore(0d);
|
|
|
+ subject.setTotalScore(0d);
|
|
|
+ subject.setUploadCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|