|
@@ -4,6 +4,8 @@ import cn.com.qmth.examcloud.tool.config.SysProperty;
|
|
|
import cn.com.qmth.examcloud.tool.entity.TaskEntity;
|
|
|
import cn.com.qmth.examcloud.tool.service.CommonService;
|
|
|
import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.CourseVO;
|
|
|
+import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.ExamQuestionVO;
|
|
|
+import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.ExamRecordQuestionsVO;
|
|
|
import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.ExamStudentScoreVO;
|
|
|
import cn.com.qmth.examcloud.tool.utils.*;
|
|
|
import cn.com.qmth.examcloud.tool.vo.Pager;
|
|
@@ -87,7 +89,8 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
|
private void export(Long examId, CourseVO course, User user, String tempDir) {
|
|
|
List<ExamStudentScoreVO> examStudentScoreList = this.getExamStudentScoreList(user.getKey(), user.getToken(), examId, course.getCourseId());
|
|
|
|
|
|
- //todo
|
|
|
+ // Excel动态列
|
|
|
+ List<String> dynamicExcelHeaders = new ArrayList<>();
|
|
|
|
|
|
List<List<Object>> excelRows = new ArrayList<>();
|
|
|
for (ExamStudentScoreVO vo : examStudentScoreList) {
|
|
@@ -106,9 +109,35 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
|
vo.getSubjectiveScore(),
|
|
|
vo.getFinalExamScore());
|
|
|
excelRows.add(rowValues);
|
|
|
+
|
|
|
+ if (vo.getExamRecordDataId() == null) {
|
|
|
+ // 跳过缺考的情况
|
|
|
+ log.info("identityNumber={} finished={} absent={}", vo.getIdentityNumber(), vo.getIsFinished(), vo.getIsAbsent());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取考试试题作答记录
|
|
|
+ List<ExamQuestionVO> questions = this.getExamRecordQuestions(user.getKey(), user.getToken(), vo.getExamRecordDataId());
|
|
|
+
|
|
|
+ if (dynamicExcelHeaders.isEmpty()) {
|
|
|
+ for (ExamQuestionVO question : questions) {
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Excel动态列值
|
|
|
+ List<Object> dynamicColumnValues = new ArrayList<>();
|
|
|
+ for (ExamQuestionVO question : questions) {
|
|
|
+ dynamicColumnValues.add(question.getStudentAnswer());
|
|
|
+ dynamicColumnValues.add("0");
|
|
|
+ }
|
|
|
+ rowValues.addAll(dynamicColumnValues);
|
|
|
}
|
|
|
|
|
|
List<String> excelHeaders = Lists.newArrayList("学习中心", "课程代码", "课程名称", "课程层次", "是否缺考", "身份证号", "学号", "姓名", "年级", "专业", "客观总分", "主观总分", "总分");
|
|
|
+ excelHeaders.addAll(dynamicExcelHeaders);
|
|
|
+
|
|
|
final String filePath = sysProperty.getDataDir() + "/" + tempDir + "/" + examId + "_" + course.getCourseCode() + ".xlsx";
|
|
|
EasyExcel.write(filePath)
|
|
|
.head(ExcelHelper.buildHeaders(excelHeaders))
|
|
@@ -117,6 +146,29 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
|
.sheet().doWrite(excelRows);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取考试试题作答记录
|
|
|
+ */
|
|
|
+ private List<ExamQuestionVO> getExamRecordQuestions(String key, String token, Long examRecordDataId) {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("examRecordDataId", String.valueOf(examRecordDataId));
|
|
|
+
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("key", key);
|
|
|
+ headers.put("token", token);
|
|
|
+
|
|
|
+ String url = sysProperty.getServerUrl() + "/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions";
|
|
|
+ String json = HttpHelper.get(url, headers, params);
|
|
|
+
|
|
|
+ JsonMapper jsonMapper = new JsonMapper();
|
|
|
+ ExamRecordQuestionsVO examRecordQuestions = jsonMapper.parseJson(json, ExamRecordQuestionsVO.class);
|
|
|
+ if (examRecordQuestions == null || CollectionUtils.isEmpty(examRecordQuestions.getExamQuestionEntities())) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ return examRecordQuestions.getExamQuestionEntities();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取考生成绩明细列表
|
|
|
*/
|
|
@@ -148,7 +200,7 @@ public class ExportStudentAnswerAndScoreDetailTask {
|
|
|
|
|
|
sum += page.getContent().size();
|
|
|
float rate = sum * 100f / page.getTotalElements();
|
|
|
- log.info("已获取考生成绩明细数:{} 进度:{}%", sum, rate);
|
|
|
+ log.info("examId={} courseId={} 已获取考生成绩明细数:{} 进度:{}%", examId, courseId, sum, rate);
|
|
|
}
|
|
|
|
|
|
return all;
|