|
@@ -44,11 +44,12 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
final String tempDir = "export_" + DateHelper.currentTimeMillis() + "_" + task.getId();
|
|
final String tempDir = "export_" + DateHelper.currentTimeMillis() + "_" + task.getId();
|
|
FileHelper.makeDirs(sysProperty.getDataDir() + "/" + tempDir);
|
|
FileHelper.makeDirs(sysProperty.getDataDir() + "/" + tempDir);
|
|
|
|
|
|
- User user = commonService.login(sysProperty.getServerRootOrgId(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
|
|
|
|
|
|
+ User user = null;//todo
|
|
this.execute(jsonParams, user, tempDir);
|
|
this.execute(jsonParams, user, tempDir);
|
|
|
|
|
|
// 压缩文件
|
|
// 压缩文件
|
|
- FileHelper.zip(new File(sysProperty.getDataDir() + "/" + tempDir), new File(sysProperty.getDataDir() + "/" + tempDir + ".zip"));
|
|
|
|
|
|
+ FileHelper.zip(new File(sysProperty.getDataDir() + "/" + tempDir),
|
|
|
|
+ new File(sysProperty.getDataDir() + "/" + tempDir + ".zip"));
|
|
task.setFilePath(tempDir + ".zip");
|
|
task.setFilePath(tempDir + ".zip");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -57,11 +58,12 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
String courseCodes = jsonParams.get("courseCodes").asText("");
|
|
String courseCodes = jsonParams.get("courseCodes").asText("");
|
|
Boolean needSubjective = jsonParams.get("needSubjective").asBoolean(false);
|
|
Boolean needSubjective = jsonParams.get("needSubjective").asBoolean(false);
|
|
Boolean needQuestionId = jsonParams.get("needQuestionId").asBoolean(false);
|
|
Boolean needQuestionId = jsonParams.get("needQuestionId").asBoolean(false);
|
|
- log.info("examId = {}, courseCodes = {}, needSubjective = {}, needQuestionId = {}", examId, courseCodes, needSubjective, needQuestionId);
|
|
|
|
|
|
+ log.info("examId = {}, courseCodes = {}, needSubjective = {}, needQuestionId = {}", examId, courseCodes,
|
|
|
|
+ needSubjective, needQuestionId);
|
|
|
|
|
|
// 待处理的课程列表(未指定课程则按考试的全部课程)
|
|
// 待处理的课程列表(未指定课程则按考试的全部课程)
|
|
List<CourseVO> todoCourses;
|
|
List<CourseVO> todoCourses;
|
|
- List<CourseVO> courses = commonService.getExamCourseList(user.getKey(), user.getToken(), examId);
|
|
|
|
|
|
+ List<CourseVO> courses = commonService.getExamCourseList(user, examId);
|
|
if (StringUtils.isNotBlank(courseCodes)) {
|
|
if (StringUtils.isNotBlank(courseCodes)) {
|
|
todoCourses = new ArrayList<>();
|
|
todoCourses = new ArrayList<>();
|
|
String[] courseCodeList = StringUtils.split(courseCodes, ",");
|
|
String[] courseCodeList = StringUtils.split(courseCodes, ",");
|
|
@@ -86,8 +88,10 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void export(Long examId, CourseVO course, Boolean needSubjective, Boolean needQuestionId, User user, String tempDir) {
|
|
|
|
- List<ExamStudentScoreVO> examStudentScoreList = this.getExamStudentScoreList(user.getKey(), user.getToken(), examId, course.getCourseId());
|
|
|
|
|
|
+ private void export(Long examId, CourseVO course, Boolean needSubjective, Boolean needQuestionId, User user,
|
|
|
|
+ String tempDir) {
|
|
|
|
+ List<ExamStudentScoreVO> examStudentScoreList = this.getExamStudentScoreList(user.getKey(), user.getToken(),
|
|
|
|
+ examId, course.getCourseId());
|
|
|
|
|
|
// Excel动态列
|
|
// Excel动态列
|
|
List<String> dynamicExcelHeaders = new ArrayList<>();
|
|
List<String> dynamicExcelHeaders = new ArrayList<>();
|
|
@@ -98,15 +102,14 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
index++;
|
|
index++;
|
|
if (index % 500 == 0) {
|
|
if (index % 500 == 0) {
|
|
float rate = index * 100f / examStudentScoreList.size();
|
|
float rate = index * 100f / examStudentScoreList.size();
|
|
- log.info("examId:{} courseId:{} 已获取考生作答明细数:{} 进度:{}%", examId, course.getCourseId(), index, rate);
|
|
|
|
|
|
+ log.info("examId:{} courseId:{} 已获取考生作答明细数:{} 进度:{}%", examId, course.getCourseId(), index,
|
|
|
|
+ rate);
|
|
}
|
|
}
|
|
|
|
|
|
List<String> rowValues = Lists.newArrayList(vo.getOrgName(), vo.getCourseCode(), vo.getCourseName(),
|
|
List<String> rowValues = Lists.newArrayList(vo.getOrgName(), vo.getCourseCode(), vo.getCourseName(),
|
|
vo.getCourseLevel(), vo.getIdentityNumber(), vo.getStudentCode(), vo.getStudentName(),
|
|
vo.getCourseLevel(), vo.getIdentityNumber(), vo.getStudentCode(), vo.getStudentName(),
|
|
- vo.getGrade(), vo.getSpecialtyName(), vo.getIsAbsent(),
|
|
|
|
- vo.getObjectiveScore().replace("--", "0"),
|
|
|
|
- vo.getSubjectiveScore().replace("--", "0"),
|
|
|
|
- vo.getFinalExamScore().replace("--", "0"),
|
|
|
|
|
|
+ vo.getGrade(), vo.getSpecialtyName(), vo.getIsAbsent(), vo.getObjectiveScore().replace("--", "0"),
|
|
|
|
+ vo.getSubjectiveScore().replace("--", "0"), vo.getFinalExamScore().replace("--", "0"),
|
|
vo.getBasePaperId());
|
|
vo.getBasePaperId());
|
|
excelRows.add(rowValues);
|
|
excelRows.add(rowValues);
|
|
|
|
|
|
@@ -118,7 +121,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取考试试题作答记录
|
|
// 获取考试试题作答记录
|
|
- List<ExamQuestionVO> examQuestions = this.getExamRecordQuestions(user.getKey(), user.getToken(), vo.getExamRecordDataId());
|
|
|
|
|
|
+ List<ExamQuestionVO> examQuestions = this.getExamRecordQuestions(user.getKey(), user.getToken(),
|
|
|
|
+ vo.getExamRecordDataId());
|
|
|
|
|
|
if (dynamicExcelHeaders.isEmpty()) {
|
|
if (dynamicExcelHeaders.isEmpty()) {
|
|
for (ExamQuestionVO question : examQuestions) {
|
|
for (ExamQuestionVO question : examQuestions) {
|
|
@@ -128,11 +132,18 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
}
|
|
}
|
|
|
|
|
|
if (needQuestionId) {
|
|
if (needQuestionId) {
|
|
- dynamicExcelHeaders.add(String.format("%s%s-%s-ID", question.getQuestionType().getDesc(), question.getMainNumber(), question.getOrder()));
|
|
|
|
|
|
+ dynamicExcelHeaders.add(String.format("%s%s-%s-ID", question.getQuestionType().getDesc(),
|
|
|
|
+ question.getMainNumber(), question.getOrder()));
|
|
}
|
|
}
|
|
- dynamicExcelHeaders.add(String.format("%s%s-%s答案", question.getQuestionType().getDesc(), question.getMainNumber(), question.getOrder()));
|
|
|
|
- dynamicExcelHeaders.add(String.format("%s%s-%s作答", question.getQuestionType().getDesc(), question.getMainNumber(), question.getOrder()));
|
|
|
|
- dynamicExcelHeaders.add(String.format("%s%s-%s得分", question.getQuestionType().getDesc(), question.getMainNumber(), question.getOrder()));
|
|
|
|
|
|
+ dynamicExcelHeaders.add(
|
|
|
|
+ String.format("%s%s-%s答案", question.getQuestionType().getDesc(), question.getMainNumber(),
|
|
|
|
+ question.getOrder()));
|
|
|
|
+ dynamicExcelHeaders.add(
|
|
|
|
+ String.format("%s%s-%s作答", question.getQuestionType().getDesc(), question.getMainNumber(),
|
|
|
|
+ question.getOrder()));
|
|
|
|
+ dynamicExcelHeaders.add(
|
|
|
|
+ String.format("%s%s-%s得分", question.getQuestionType().getDesc(), question.getMainNumber(),
|
|
|
|
+ question.getOrder()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -147,7 +158,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
Map<String, Double> subjectiveQuestionScores = null;
|
|
Map<String, Double> subjectiveQuestionScores = null;
|
|
if (existSubjectiveQuestion && needSubjective) {
|
|
if (existSubjectiveQuestion && needSubjective) {
|
|
// 获取阅卷端考生考试记录中主观题的得分明细
|
|
// 获取阅卷端考生考试记录中主观题的得分明细
|
|
- subjectiveQuestionScores = this.getSubjectiveQuestionScores(user.getKey(), user.getToken(), vo.getExamRecordDataId());
|
|
|
|
|
|
+ subjectiveQuestionScores = this.getSubjectiveQuestionScores(user.getKey(), user.getToken(),
|
|
|
|
+ vo.getExamRecordDataId());
|
|
}
|
|
}
|
|
|
|
|
|
// Excel动态列值
|
|
// Excel动态列值
|
|
@@ -169,7 +181,9 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
dynamicColumnValues.add(correctAnswer);
|
|
dynamicColumnValues.add(correctAnswer);
|
|
dynamicColumnValues.add(studentAnswer);
|
|
dynamicColumnValues.add(studentAnswer);
|
|
if (correctAnswer.equals(studentAnswer)) {
|
|
if (correctAnswer.equals(studentAnswer)) {
|
|
- dynamicColumnValues.add(question.getQuestionScore() != null ? String.valueOf(question.getQuestionScore()) : "0");
|
|
|
|
|
|
+ dynamicColumnValues.add(question.getQuestionScore() != null ?
|
|
|
|
+ String.valueOf(question.getQuestionScore()) :
|
|
|
|
+ "0");
|
|
} else {
|
|
} else {
|
|
dynamicColumnValues.add("0");
|
|
dynamicColumnValues.add("0");
|
|
}
|
|
}
|
|
@@ -183,7 +197,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
String studentAnswer = question.getStudentAnswer() != null ? question.getStudentAnswer() : "";
|
|
String studentAnswer = question.getStudentAnswer() != null ? question.getStudentAnswer() : "";
|
|
dynamicColumnValues.add(Jsoup.clean(studentAnswer, Safelist.simpleText()));
|
|
dynamicColumnValues.add(Jsoup.clean(studentAnswer, Safelist.simpleText()));
|
|
|
|
|
|
- Double studentScore = subjectiveQuestionScores.get(question.getMainNumber() + "-" + question.getOrder());
|
|
|
|
|
|
+ Double studentScore = subjectiveQuestionScores.get(
|
|
|
|
+ question.getMainNumber() + "-" + question.getOrder());
|
|
dynamicColumnValues.add(studentScore != null ? String.valueOf(studentScore) : "0");
|
|
dynamicColumnValues.add(studentScore != null ? String.valueOf(studentScore) : "0");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -195,12 +210,14 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
"学号", "姓名", "年级", "专业", "是否缺考", "客观总分", "主观总分", "总分", "试卷ID");
|
|
"学号", "姓名", "年级", "专业", "是否缺考", "客观总分", "主观总分", "总分", "试卷ID");
|
|
excelHeaders.addAll(dynamicExcelHeaders);
|
|
excelHeaders.addAll(dynamicExcelHeaders);
|
|
|
|
|
|
- final String filePath = sysProperty.getDataDir() + "/" + tempDir + "/" + examId + "_" + course.getCourseCode() + ".xlsx";
|
|
|
|
|
|
+ final String filePath =
|
|
|
|
+ sysProperty.getDataDir() + "/" + tempDir + "/" + examId + "_" + course.getCourseCode() + ".xlsx";
|
|
EasyExcel.write(filePath).head(ExcelHelper.buildHeaders(excelHeaders))
|
|
EasyExcel.write(filePath).head(ExcelHelper.buildHeaders(excelHeaders))
|
|
- .registerWriteHandler(ExcelHelper.sheetStrategy())
|
|
|
|
- .registerWriteHandler(ExcelHelper.styleStrategy()).sheet().doWrite(excelRows);
|
|
|
|
|
|
+ .registerWriteHandler(ExcelHelper.sheetStrategy()).registerWriteHandler(ExcelHelper.styleStrategy())
|
|
|
|
+ .sheet().doWrite(excelRows);
|
|
|
|
|
|
- log.info("examId:{} courseId:{} courseCode:{} totalRows:{} 已处理!", examId, course.getCourseId(), course.getCourseCode(), excelRows.size());
|
|
|
|
|
|
+ log.info("examId:{} courseId:{} courseCode:{} totalRows:{} 已处理!", examId, course.getCourseId(),
|
|
|
|
+ course.getCourseCode(), excelRows.size());
|
|
|
|
|
|
excelRows.clear();
|
|
excelRows.clear();
|
|
excelHeaders.clear();
|
|
excelHeaders.clear();
|
|
@@ -211,7 +228,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
* 是否为客观题
|
|
* 是否为客观题
|
|
*/
|
|
*/
|
|
private boolean isObjectiveQuestion(QuestionType type) {
|
|
private boolean isObjectiveQuestion(QuestionType type) {
|
|
- return QuestionType.SINGLE_CHOICE == type || QuestionType.MULTIPLE_CHOICE == type || QuestionType.TRUE_OR_FALSE == type;
|
|
|
|
|
|
+ return QuestionType.SINGLE_CHOICE == type || QuestionType.MULTIPLE_CHOICE == type
|
|
|
|
+ || QuestionType.TRUE_OR_FALSE == type;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -222,7 +240,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
headers.put("key", key);
|
|
headers.put("key", key);
|
|
headers.put("token", token);
|
|
headers.put("token", token);
|
|
|
|
|
|
- String url = sysProperty.getServerUrl() + "/api/ecs_marking/student/paper/getSubjectiveQuestionScores/" + examRecordDataId;
|
|
|
|
|
|
+ String url = sysProperty.getServerUrl() + "/api/ecs_marking/student/paper/getSubjectiveQuestionScores/"
|
|
|
|
+ + examRecordDataId;
|
|
String json = HttpHelper.post(url, headers, null);
|
|
String json = HttpHelper.post(url, headers, null);
|
|
|
|
|
|
JsonMapper jsonMapper = new JsonMapper();
|
|
JsonMapper jsonMapper = new JsonMapper();
|
|
@@ -283,6 +302,7 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
String json = HttpHelper.post(url, headers, params);
|
|
String json = HttpHelper.post(url, headers, params);
|
|
|
|
|
|
Pager<ExamStudentScoreVO> page = jsonMapper.parseJson(json, new TypeReference<Pager<ExamStudentScoreVO>>() {
|
|
Pager<ExamStudentScoreVO> page = jsonMapper.parseJson(json, new TypeReference<Pager<ExamStudentScoreVO>>() {
|
|
|
|
+
|
|
});
|
|
});
|
|
if (page == null || CollectionUtils.isEmpty(page.getContent())) {
|
|
if (page == null || CollectionUtils.isEmpty(page.getContent())) {
|
|
break;
|
|
break;
|