|
@@ -87,9 +87,11 @@ public class DataSyncThread implements Runnable {
|
|
try {
|
|
try {
|
|
// 获取考试信息
|
|
// 获取考试信息
|
|
Exam exam = examService.findById(dataSync.getExamId());
|
|
Exam exam = examService.findById(dataSync.getExamId());
|
|
|
|
+ dataSync.setSchoolId(exam.getSchoolId());
|
|
DataSync sync = dataSyncService.findByExamId(dataSync.getExamId());
|
|
DataSync sync = dataSyncService.findByExamId(dataSync.getExamId());
|
|
if (sync == null) {
|
|
if (sync == null) {
|
|
sync = dataSync;
|
|
sync = dataSync;
|
|
|
|
+ sync.setCreateTime(new Date());
|
|
}
|
|
}
|
|
JSONObject datas = new JSONObject();
|
|
JSONObject datas = new JSONObject();
|
|
datas.accumulate("examId", sync.getCloudExamId());
|
|
datas.accumulate("examId", sync.getCloudExamId());
|
|
@@ -100,26 +102,35 @@ public class DataSyncThread implements Runnable {
|
|
JSONObject subject = subjectArray.getJSONObject(i);
|
|
JSONObject subject = subjectArray.getJSONObject(i);
|
|
String subjectCode = subject.getString(SUBJECT_CODE);
|
|
String subjectCode = subject.getString(SUBJECT_CODE);
|
|
String subjectName = subject.getString(SUBJECT_NAME);
|
|
String subjectName = subject.getString(SUBJECT_NAME);
|
|
|
|
+ if (null != sync.getSubjectCode() && !subjectCode.equals(sync.getSubjectCode())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
Long startId = 0L;
|
|
Long startId = 0L;
|
|
|
|
+ if (null != sync.getNextId()) {
|
|
|
|
+ startId = sync.getNextId();
|
|
|
|
+ }
|
|
while (startId != null) {
|
|
while (startId != null) {
|
|
- datas.accumulate(SUBJECT_CODE, subjectCode);
|
|
|
|
- datas.accumulate(START_ID, startId);
|
|
|
|
- datas.accumulate(SIZE, pageSize);
|
|
|
|
|
|
+ datas.put(SUBJECT_CODE, subjectCode);
|
|
|
|
+ datas.put(START_ID, startId);
|
|
|
|
+ datas.put(SIZE, pageSize);
|
|
String studentResult = studentHttp.httpAction(null, datas.toString());
|
|
String studentResult = studentHttp.httpAction(null, datas.toString());
|
|
|
|
|
|
JSONObject studentJson = JSONObject.fromObject(studentResult);
|
|
JSONObject studentJson = JSONObject.fromObject(studentResult);
|
|
|
|
|
|
Long nextId = studentJson.getLong(NEXT_ID);
|
|
Long nextId = studentJson.getLong(NEXT_ID);
|
|
- if (startId == nextId) {
|
|
|
|
|
|
+ if (startId - nextId == 0) {
|
|
startId = null;
|
|
startId = null;
|
|
} else {
|
|
} else {
|
|
startId = nextId;
|
|
startId = nextId;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ Object obj = studentJson.get(DATA_LIST);
|
|
|
|
+ if (obj instanceof JSONObject && ((JSONObject) obj).isNullObject()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
JSONArray studentArray = studentJson.getJSONArray(DATA_LIST);
|
|
JSONArray studentArray = studentJson.getJSONArray(DATA_LIST);
|
|
List<ExamStudent> list = new ArrayList<ExamStudent>();
|
|
List<ExamStudent> list = new ArrayList<ExamStudent>();
|
|
for (int j = 0; j < studentArray.size(); j++) {
|
|
for (int j = 0; j < studentArray.size(); j++) {
|
|
- JSONObject student = studentArray.getJSONObject(i);
|
|
|
|
|
|
+ JSONObject student = studentArray.getJSONObject(j);
|
|
ExamStudent examStudent = new ExamStudent();
|
|
ExamStudent examStudent = new ExamStudent();
|
|
examStudent.setExamId(sync.getExamId());
|
|
examStudent.setExamId(sync.getExamId());
|
|
examStudent.setStudentCode(student.getString("studentCode"));
|
|
examStudent.setStudentCode(student.getString("studentCode"));
|
|
@@ -131,16 +142,20 @@ public class DataSyncThread implements Runnable {
|
|
examStudent.setSubjectCode(subjectCode);
|
|
examStudent.setSubjectCode(subjectCode);
|
|
examStudent.setSubjectName(subjectName);
|
|
examStudent.setSubjectName(subjectName);
|
|
examStudent.setExamNumber(student.getString("examNumber"));
|
|
examStudent.setExamNumber(student.getString("examNumber"));
|
|
|
|
+ examStudent.setPaperType(null);
|
|
|
|
|
|
examStudent.setSchoolId(exam.getSchoolId());
|
|
examStudent.setSchoolId(exam.getSchoolId());
|
|
examStudent.setAbsent(false);
|
|
examStudent.setAbsent(false);
|
|
- examStudent.setUpload(false);
|
|
|
|
|
|
+ examStudent.setUpload(true);
|
|
|
|
+ examStudent.setManualAbsent(false);
|
|
|
|
+ examStudent.setBreach(false);
|
|
examStudent.setException(false);
|
|
examStudent.setException(false);
|
|
examStudent.setSliceCount(0);
|
|
examStudent.setSliceCount(0);
|
|
examStudent.setSheetCount(0);
|
|
examStudent.setSheetCount(0);
|
|
examStudent.setObjectiveScore(0d);
|
|
examStudent.setObjectiveScore(0d);
|
|
examStudent.setSubjectiveScore(0d);
|
|
examStudent.setSubjectiveScore(0d);
|
|
-
|
|
|
|
|
|
+ examStudent.setAnswers(null);
|
|
|
|
+ examStudent.setBatchCode(null);
|
|
list.add(examStudent);
|
|
list.add(examStudent);
|
|
|
|
|
|
String answerJson = student.getString("subjectives");
|
|
String answerJson = student.getString("subjectives");
|
|
@@ -148,6 +163,7 @@ public class DataSyncThread implements Runnable {
|
|
PictureUrlBuilder.getAnswerJson(exam.getId(), subjectCode, null,
|
|
PictureUrlBuilder.getAnswerJson(exam.getId(), subjectCode, null,
|
|
examStudent.getExamNumber()));
|
|
examStudent.getExamNumber()));
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
file.createNewFile();
|
|
file.createNewFile();
|
|
}
|
|
}
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
FileOutputStream fos = new FileOutputStream(file);
|