deason 3 years ago
parent
commit
4aa1c9fe45

+ 1 - 1
src/main/java/cn/com/qmth/dp/examcloud/oe/Task.java

@@ -51,7 +51,7 @@ public class Task {
 
             // SpringContextHolder.getBean(ImportPaperDzkdService.class).start();
             // SpringContextHolder.getBean(FixCorrectAnswerAndResetScoreService.class).start();
-            // SpringContextHolder.getBean(ExportExamStudentScore.class).start();
+            // SpringContextHolder.getBean(ExportExamStudentScore.class).start(123L);
             // SpringContextHolder.getBean(GetStduentOneAnswerService.class).start(1213L, 1, "01");
             // SpringContextHolder.getBean(GetStduentAnswerDetailService.class).start(1627L, "000004");
             // SpringContextHolder.getBean(InitUserDataRule.class).start();

+ 36 - 3
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/export_exam_student_score/ExportExamStudentScore.java

@@ -84,9 +84,9 @@ public class ExportExamStudentScore {
         List<String> defaultDynamicColumnValues = new ArrayList<>();// Excel动态列默认值
         String paperStructKey = "";// 试卷结构关键值
 
-        int index = 0;
+        int index = 0, total = examStudents.size();
         for (ExamStudentVO examStudent : examStudents) {
-            log.debug((++index) + "---> examStudentId is " + examStudent.getExamStudentId());
+            index++;
 
             if (!orgNameMaps.containsKey(examStudent.getOrgId())) {
                 String orgName = this.queryOrgName(examStudent.getOrgId());
@@ -109,6 +109,7 @@ public class ExportExamStudentScore {
 
             if (!examStudent.getFinished()) {
                 // 跳过缺考的情况
+                log.warn("---> {}-{} examStudentId={}, finished=false", total, index, examStudent.getExamStudentId());
                 continue;
             }
 
@@ -116,6 +117,7 @@ public class ExportExamStudentScore {
             List<Map<String, Object>> examRecordDataList = this.queryExamRecordDataList(examId, courseId, examStudent.getExamStudentId());
             if (CollectionUtils.isEmpty(examRecordDataList)) {
                 // 跳过暂无有效考试记录的情况
+                log.warn("---> {}-{} examStudentId={}, examRecordData is empty", total, index, examStudent.getExamStudentId());
                 continue;
             }
 
@@ -163,12 +165,17 @@ public class ExportExamStudentScore {
                 examStudent.setTotalScore(okScore.getTotalScore());
             }
 
+            log.info("---> {}-{} examStudentId={}, examRecordDataId={}", total, index, examStudent.getExamStudentId(), okExamRecordDataId);
+
             // 获取试题作答记录
             ExamRecordQuestionVO questions = this.queryExamRecordQuestions(okExamRecordDataId);
             if (questions == null || CollectionUtils.isEmpty(questions.getExamQuestionEntities())) {
                 continue;
             }
 
+            // 查询阅卷端考生考试记录中主观题的得分明细
+            Map<String, Double> subjectiveQuestionScores = needSubjective ? this.querySubjectiveQuestionScores(okExamRecordDataId) : new HashMap<>();
+
             List<ExamQuestionVO> examQuestionEntities = questions.getExamQuestionEntities();
 
             if (!hasDynamicExcelHeaderSetting) {
@@ -221,7 +228,8 @@ public class ExportExamStudentScore {
                     if (needSubjective) {
                         curDynamicColumnValues.add(Jsoup.clean(question.getStudentAnswer() != null ? question.getStudentAnswer() : "", Safelist.relaxed()));
 
-                        curDynamicColumnValues.add(question.getStudentScore() != null ? question.getStudentScore().toString() : "0");
+                        Double studentScore = subjectiveQuestionScores.get(question.getMainNumber() + "-" + question.getOrder());
+                        curDynamicColumnValues.add(studentScore != null ? studentScore.toString() : "0");
                     }
                 }
 
@@ -391,6 +399,31 @@ public class ExportExamStudentScore {
         return score;
     }
 
+    private Map<String, Double> querySubjectiveQuestionScores(Long examRecordDataId) {
+        StringBuilder querySql = new StringBuilder()
+                .append(" select mi.main_number,mi.orders,ri.score")
+                .append(" from ec_m_student_paper sp")
+                .append(" left join ec_m_mark_item mi on mi.work_id=sp.work_id and mi.base_paper_id=sp.base_paper_id")
+                .append(" left join ec_m_mark_result mr on mr.student_paper_id=sp.id")
+                .append(" left join ec_m_result_item ri on ri.mark_item_id=mi.id and ri.mark_result_id=mr.id")
+                .append(" where sp.exam_record_data_id=").append(examRecordDataId);
+
+        List<Map<String, Object>> result = jdbcTemplate.queryForList(querySql.toString());
+
+        Map<String, Double> scores = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(result)) {
+            for (Map<String, Object> row : result) {
+                Integer mainNumber = (Integer) row.get("main_number");
+                Integer orders = (Integer) row.get("orders");
+                Double score = (Double) row.get("score");
+
+                scores.put(mainNumber + "-" + orders, score);
+            }
+        }
+
+        return scores;
+    }
+
     private ExamRecordQuestionVO queryExamRecordQuestions(Long examRecordDataId) {
         Query query = new Query();
         query.addCriteria(Criteria.where("examRecordDataId").is(examRecordDataId));