Kaynağa Gözat

导出成绩标准版主观题分数BUG修改

wangliang 2 yıl önce
ebeveyn
işleme
fc4621fcee

+ 8 - 4
themis-business/src/main/java/com/qmth/themis/business/enums/QuestionTypeEnum.java

@@ -33,10 +33,14 @@ public enum QuestionTypeEnum {
      * 套题
      */
     NESTED_ANSWER_QUESTION(6, "套题"),
-
-    AUDITION_QUESTION(7, "听力题"),
-
-    MATE_QUESTION(8, "配对题");
+    /**
+     * 听力
+     */
+    EAR_ANSWER_QUESTION(7, "听力题"),
+    /**
+     * 配对
+     */
+    PAIR_ANSWER_QUESTION(8, "配对题");
 
     private Integer type;
 

+ 48 - 7
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -1,6 +1,8 @@
 package com.qmth.themis.business.templete.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -43,6 +45,7 @@ import javax.annotation.Resource;
 import java.io.*;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -97,7 +100,8 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
         String zipPath = null;
         File zip = null;
         List<File> files = null;
-        int finalSize = 0, line = 0;
+        int finalSize = 0;
+        int min = 0, line = 0;
         try {
             taskExportCommon.getTxtList()
                     .add(DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN) + "->开始准备处理导出的成绩标准版数据");
@@ -117,6 +121,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                 markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
             }
 
+            Map<Long, Map<String, Double>> subjectiveScoreMap = null;
             if (!CollectionUtils.isEmpty(markResultSimpleExportDtoList)) {
                 Set<String> examRecordIdsSet = new LinkedHashSet<>(markResultSimpleExportDtoList.size());
                 for (MarkResultSimpleExportDto markResultSimpleExportDto : markResultSimpleExportDtoList) {
@@ -146,9 +151,30 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                 //获取云阅卷同步成绩
                 List<TSyncExamStudentScore> tSyncExamStudentScoreList = tSyncExamStudentScoreService.findByExamRecordIds(examRecordIdsSet);
                 if (!CollectionUtils.isEmpty(tSyncExamStudentScoreList)) {
+                    subjectiveScoreMap = new LinkedHashMap<>(tSyncExamStudentScoreList.size());
                     for (TSyncExamStudentScore t : tSyncExamStudentScoreList) {
-                        MarkResultSimpleExportDto markResultSimpleExportDto = markResultSimpleExportDtoMap.get(Long.parseLong(t.getExamNumber()));
+                        MarkResultSimpleExportDto markResultSimpleExportDto = markResultSimpleExportDtoMap.get(t.getExamNumber());
                         if (Objects.nonNull(markResultSimpleExportDto)) {
+                            if (Objects.nonNull(t.getSubjectiveScoreDetail()) && !Objects.equals(t.getSubjectiveScoreDetail().trim(), "")) {
+                                JSONArray subjectiveScoreDetailJsonArray = JSONArray.parseArray(t.getSubjectiveScoreDetail());
+                                Map<String, Double> tOeExamAnswerMap = new LinkedHashMap<>(subjectiveScoreDetailJsonArray.size());
+                                for (int i = 0; i < subjectiveScoreDetailJsonArray.size(); i++) {
+                                    JSONObject jsonObject = subjectiveScoreDetailJsonArray.getJSONObject(i);
+                                    Integer mainNumber = jsonObject.getInteger("mainNumber");
+                                    Integer subNumber = jsonObject.getInteger("subNumber");
+                                    Integer subIndex = jsonObject.getInteger("subIndex");
+                                    Double score = jsonObject.getDouble("score");
+                                    String questionsTitle = String.valueOf(mainNumber);
+                                    questionsTitle = Objects.nonNull(subNumber) ?
+                                            questionsTitle + "_" + subNumber :
+                                            questionsTitle;
+                                    questionsTitle = Objects.nonNull(subIndex) ?
+                                            questionsTitle + "_" + subIndex :
+                                            questionsTitle;
+                                    tOeExamAnswerMap.put(questionsTitle, score);
+                                }
+                                subjectiveScoreMap.put(Long.parseLong(t.getExamNumber()), tOeExamAnswerMap);
+                            }
                             markResultSimpleExportDto.setSubjectiveScore(Objects.isNull(t.getSubjectiveScore()) ? "0" : String.valueOf(t.getSubjectiveScore()));
                             markResultSimpleExportDto.setSumScore(String.valueOf(Double.parseDouble(markResultSimpleExportDto.getObjectiveScore()) + Double.parseDouble(markResultSimpleExportDto.getSubjectiveScore())));
                         }
@@ -208,6 +234,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                                     String title = QuestionTypeEnum.convertToTitle(structType) + questionsTitle;
                                     String answer = null;
                                     ExcelDto excelAnswerDto = null;
+                                    Double score = null;
                                     if (structType.intValue() == 1 || structType.intValue() == 2) {
                                         String string = s.getAnswer().replace("[", "").replace("]", "")
                                                 .replaceAll(" ", "").replaceAll("\n", "");
@@ -220,13 +247,21 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                                             answer = answerList.toString();
                                         }
                                         excelAnswerDto = new ExcelDto(title + "作答", answer);
+                                        score = s.getScore();
                                     } else if (structType.intValue() == 3) {
                                         answer = AnswerTypeEnum
                                                 .convertToTitle(s.getAnswer().replaceAll("\n", "").toUpperCase());
                                         excelAnswerDto = new ExcelDto(title + "作答", answer);
+                                        score = s.getScore();
+                                    }
+                                    if (Objects.isNull(score) && !CollectionUtils.isEmpty(subjectiveScoreMap)) {
+                                        Map<String, Double> tOeExamAnswerMap = subjectiveScoreMap.get(s.getExamRecordId());
+                                        if (!CollectionUtils.isEmpty(tOeExamAnswerMap) && Objects.nonNull(tOeExamAnswerMap.get(questionsTitle))) {
+                                            score = tOeExamAnswerMap.get(questionsTitle);
+                                        }
                                     }
                                     ExcelDto excelScoreDto = new ExcelDto(title + "得分",
-                                            Objects.nonNull(s.getScore()) ? String.valueOf(s.getScore()) : null);
+                                            Objects.nonNull(score) ? String.valueOf(score) : "0");
                                     List<ExcelDto> excelDtoList = null;
                                     if (!excelDtoMap.containsKey(m.getExamStudentId())) {
                                         excelDtoList = new ArrayList<>();
@@ -253,8 +288,14 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                 stringJoiner.add(SystemConstant.FILES_DIR).add(File.separator);
             }
             excelSj.add(SystemConstant.FILES_DIR).add(File.separator);
-            stringJoiner = SystemConstant.getDirName(stringJoiner, false);
-            excelSj = SystemConstant.getDirName(excelSj, false);
+            LocalDateTime nowTime = LocalDateTime.now();
+            stringJoiner.add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getDayOfMonth()));
+
+            excelSj.add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getDayOfMonth()));
 
             SXSSFWorkbook wb = null;
             InputStream inputStream = null;
@@ -296,7 +337,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                         num++;
                     }
                     List<MarkResultStandardExportDto> markResultStandardExportDtoTempList = markResultStandardExportDtoLinkedMultiValueMap.get(entry.getKey());
-                    int min = 0, rowIndex = 0, cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultStandardExportDtoTempList
+                    int rowIndex = 0, cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultStandardExportDtoTempList
                             .size();
                     if (max >= size) {
                         max = size;
@@ -385,7 +426,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             }
             if (files.size() > 0) {
                 StringBuilder stringBuilder = new StringBuilder(excelSj.toString());
-                String uuid = SystemConstant.getNanoId();
+                String uuid = SystemConstant.getUuid();
                 StringBuilder zipStringBuilder = new StringBuilder(stringJoiner.toString());
                 zipPath = zipStringBuilder.append(File.separator).append(uuid).toString();
                 zip = new File(stringBuilder.append(File.separator).append(uuid).append(".zip").toString());