|
@@ -4,6 +4,7 @@ import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamQues
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamRecordQuestionVO;
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ExamStudentVO;
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.export_exam_student_score.vo.ScoreVO;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -99,7 +100,8 @@ public class ExportExamStudentScore {
|
|
|
|
|
|
boolean hasDynamicExcelHeaderSetting = false;
|
|
|
List<String> dynamicExcelHeaders = new ArrayList<>();// Excel动态列
|
|
|
- List<String> dynamicDefaultValues = new ArrayList<>();// Excel动态列默认值
|
|
|
+ List<String> defaultDynamicColumnValues = new ArrayList<>();// Excel动态列默认值
|
|
|
+ String paperStructKey = "";// 试卷结构关键值
|
|
|
|
|
|
for (ExamStudentVO examStudent : examStudents) {
|
|
|
if (!orgNameMaps.containsKey(examStudent.getOrgId())) {
|
|
@@ -185,29 +187,43 @@ public class ExportExamStudentScore {
|
|
|
if (!hasDynamicExcelHeaderSetting) {
|
|
|
for (ExamQuestionVO question : examQuestionEntities) {
|
|
|
String questionType = this.convertQuestionType(question.getQuestionType());
|
|
|
+
|
|
|
if ("SINGLE_CHOICE".equals(question.getQuestionType()) || "MULTIPLE_CHOICE".equals(question.getQuestionType()) || "TRUE_OR_FALSE".equals(question.getQuestionType())) {
|
|
|
dynamicExcelHeaders.add(String.format("%s%s-%s作答", questionType, question.getMainNumber(), question.getOrder()));
|
|
|
- dynamicDefaultValues.add("");
|
|
|
+ defaultDynamicColumnValues.add("");
|
|
|
|
|
|
dynamicExcelHeaders.add(String.format("%s%s-%s得分", questionType, question.getMainNumber(), question.getOrder()));
|
|
|
- dynamicDefaultValues.add("0");
|
|
|
+ defaultDynamicColumnValues.add("0");
|
|
|
} else {
|
|
|
// 主观题不设置“作答”列
|
|
|
dynamicExcelHeaders.add(String.format("%s%s-%s得分", questionType, question.getMainNumber(), question.getOrder()));
|
|
|
- dynamicDefaultValues.add("0");
|
|
|
+ defaultDynamicColumnValues.add("0");
|
|
|
}
|
|
|
+
|
|
|
hasDynamicExcelHeaderSetting = true;
|
|
|
+
|
|
|
+ paperStructKey += (question.getOrder() + question.getQuestionType());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ String curPaperStructKey = "";// 当前试卷结构关键值
|
|
|
+ List<String> curDynamicColumnValues = new ArrayList<>();// Excel动态列当前值
|
|
|
for (ExamQuestionVO question : examQuestionEntities) {
|
|
|
if ("SINGLE_CHOICE".equals(question.getQuestionType()) || "MULTIPLE_CHOICE".equals(question.getQuestionType()) || "TRUE_OR_FALSE".equals(question.getQuestionType())) {
|
|
|
- examStudent.addDetail(question.getStudentAnswer());
|
|
|
- examStudent.addDetail(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
|
|
|
+ curDynamicColumnValues.add(question.getStudentAnswer());
|
|
|
+ curDynamicColumnValues.add(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
|
|
|
} else {
|
|
|
- examStudent.addDetail(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
|
|
|
+ curDynamicColumnValues.add(question.getQuestionScore() != null ? question.getQuestionScore().toString() : "0");
|
|
|
}
|
|
|
+
|
|
|
+ curPaperStructKey += (question.getOrder() + question.getQuestionType());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!curPaperStructKey.equals(paperStructKey)) {
|
|
|
+ throw new StatusException("500", "考生之间存在试卷结构不一致的情况");
|
|
|
}
|
|
|
+
|
|
|
+ examStudent.setDetails(curDynamicColumnValues);
|
|
|
}
|
|
|
|
|
|
// 补全缺失的作答区
|
|
@@ -215,7 +231,7 @@ public class ExportExamStudentScore {
|
|
|
if (CollectionUtils.isNotEmpty(examStudent.getDetails())) {
|
|
|
continue;
|
|
|
}
|
|
|
- examStudent.setDetails(dynamicDefaultValues);
|
|
|
+ examStudent.setDetails(defaultDynamicColumnValues);
|
|
|
}
|
|
|
|
|
|
List<String> fixedExcelHeaders = Lists.newArrayList("学习中心", "课程代码", "课程名称", "层次", "是否缺考", "身份证号", "学号", "姓名", "年级", "专业", "客观总分", "主观总分", "总分");
|
|
@@ -295,15 +311,25 @@ public class ExportExamStudentScore {
|
|
|
}
|
|
|
|
|
|
private List<Map<String, Object>> queryExamRecordDataList(Long examId, Long courseId, Long examStudentId) {
|
|
|
- final String querySql = String.format("select id,exam_record_status from ec_oe_exam_record_data where exam_id = %s and course_id = %s and exam_student_id = %s", examId, courseId, examStudentId);
|
|
|
+ final String columns = "id,exam_record_status,is_illegality,is_warn,is_audit";
|
|
|
+ final String querySql = String.format("select %s from ec_oe_exam_record_data where exam_id = %s and course_id = %s and exam_student_id = %s", columns, examId, courseId, examStudentId);
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(querySql);
|
|
|
|
|
|
List<Map<String, Object>> okList = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(result)) {
|
|
|
for (Map<String, Object> row : result) {
|
|
|
- // 过滤无效数据
|
|
|
+ // 过滤考试记录状态情况
|
|
|
String examRecordStatus = (String) row.get("exam_record_status");
|
|
|
- if ("EXAM_END".equals(examRecordStatus) || "EXAM_OVERDUE".equals(examRecordStatus)) {
|
|
|
+ if (!"EXAM_END".equals(examRecordStatus) && !"EXAM_OVERDUE".equals(examRecordStatus)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Boolean isIllegality = (Boolean) row.get("is_illegality");// 是否违纪
|
|
|
+ Boolean isWarn = (Boolean) row.get("is_warn");// 是否警告
|
|
|
+ Boolean isAudit = (Boolean) row.get("is_audit");// 是否被审核过
|
|
|
+
|
|
|
+ // 没有违纪的 且 (没有警告 或 有警告已审核通过的),则有效
|
|
|
+ if (!isIllegality && (!isWarn || (isWarn && isAudit))) {
|
|
|
okList.add(row);
|
|
|
}
|
|
|
}
|