瀏覽代碼

成绩导出标准版本加入缺考考生

wangliang 2 年之前
父節點
當前提交
c8235ed8d6

+ 65 - 53
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -204,11 +204,13 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             Map<Long, Map<String, Integer>> paperObjectiveAnswerMap = new HashMap<>();
             LinkedMultiValueMap<Long, ExcelDto> dynamicExcelHead = new LinkedMultiValueMap<>();
             LinkedMultiValueMap<Long, MarkResultStandardExportDto> markResultStandardExportDtoLinkedMultiValueMap = new LinkedMultiValueMap<>();
-            if (Objects.nonNull(markResultStandardExportDtoList) && markResultStandardExportDtoList.size() > 0) {
+            if (!CollectionUtils.isEmpty(markResultStandardExportDtoList)) {
+                Long currentPaperId = null;
                 for (MarkResultStandardExportDto m : markResultStandardExportDtoList) {
                     excelDtoMap = new HashMap<>();
                     Map<String, Integer> objectiveAnswerCacheBeanMap = null;
                     if (Objects.nonNull(m.getPaperId())) {//处理试卷
+                        currentPaperId = m.getPaperId();
                         if (!paperObjectiveAnswerMap.containsKey(m.getPaperId())) {
                             objectiveAnswerCacheBeanMap = teExamPaperService.getPaperStructCacheBean(m.getPaperId());
                             paperObjectiveAnswerMap.put(m.getPaperId(), objectiveAnswerCacheBeanMap);
@@ -230,64 +232,74 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                             objectiveAnswerCacheBeanMap = paperObjectiveAnswerMap.get(m.getPaperId());
                         }
                     } else {
+                        if (Objects.nonNull(currentPaperId)) {//有答题数据的
+                            markResultStandardExportDtoLinkedMultiValueMap.add(currentPaperId, m);
+                            List<MarkResultStandardExportDto> markResultStandardExportDtos = markResultStandardExportDtoLinkedMultiValueMap.get(-1L);
+                            if (!CollectionUtils.isEmpty(markResultStandardExportDtos)) {
+                                for (MarkResultStandardExportDto markResultStandardExportDto : markResultStandardExportDtos) {
+                                    markResultStandardExportDtoLinkedMultiValueMap.add(currentPaperId, markResultStandardExportDto);
+                                }
+                                markResultStandardExportDtoLinkedMultiValueMap.remove(-1L);
+                            }
+                        } else {
+                            markResultStandardExportDtoLinkedMultiValueMap.add(-1L, m);
+                        }
                         continue;
                     }
-                    if (Objects.nonNull(m.getRecordId())) {//处理考生答案
-                        QueryWrapper<TOeExamAnswer> tOeExamAnswerQueryWrapper = new QueryWrapper<>();
-                        tOeExamAnswerQueryWrapper.lambda().eq(TOeExamAnswer::getExamRecordId, Long.parseLong(m.getRecordId()));
-                        List<TOeExamAnswer> tOeExamAnswerList = tOeExamAnswerService.list(tOeExamAnswerQueryWrapper);
-                        for (TOeExamAnswer s : tOeExamAnswerList) {
-                            String questionsTitle = String.valueOf(s.getMainNumber());
-                            questionsTitle = Objects.nonNull(s.getSubNumber()) ?
-                                    questionsTitle + "_" + s.getSubNumber() :
-                                    questionsTitle;
-                            questionsTitle = Objects.nonNull(s.getSubIndex()) ?
-                                    questionsTitle + "_" + s.getSubIndex() :
-                                    questionsTitle;
-                            if (Objects.nonNull(s.getAnswer())) {
-                                Integer structType = objectiveAnswerCacheBeanMap.get(questionsTitle);
-                                if (Objects.nonNull(structType)) {
-                                    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", "");
-                                        if (Objects.nonNull(string) && !Objects.equals(string, "")) {
-                                            List<String> list = Arrays.asList(string.split(","));
-                                            List<String> answerList = new ArrayList<>();
-                                            for (String s1 : list) {
-                                                answerList.add(AnswerTypeEnum.convertToTitle(s1.toUpperCase()));
-                                            }
-                                            answer = answerList.toString();
+                    QueryWrapper<TOeExamAnswer> tOeExamAnswerQueryWrapper = new QueryWrapper<>();
+                    tOeExamAnswerQueryWrapper.lambda().eq(TOeExamAnswer::getExamRecordId, Long.parseLong(m.getRecordId()));
+                    List<TOeExamAnswer> tOeExamAnswerList = tOeExamAnswerService.list(tOeExamAnswerQueryWrapper);
+                    for (TOeExamAnswer s : tOeExamAnswerList) {
+                        String questionsTitle = String.valueOf(s.getMainNumber());
+                        questionsTitle = Objects.nonNull(s.getSubNumber()) ?
+                                questionsTitle + "_" + s.getSubNumber() :
+                                questionsTitle;
+                        questionsTitle = Objects.nonNull(s.getSubIndex()) ?
+                                questionsTitle + "_" + s.getSubIndex() :
+                                questionsTitle;
+                        if (Objects.nonNull(s.getAnswer())) {
+                            Integer structType = objectiveAnswerCacheBeanMap.get(questionsTitle);
+                            if (Objects.nonNull(structType)) {
+                                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", "");
+                                    if (Objects.nonNull(string) && !Objects.equals(string, "")) {
+                                        List<String> list = Arrays.asList(string.split(","));
+                                        List<String> answerList = new ArrayList<>();
+                                        for (String s1 : list) {
+                                            answerList.add(AnswerTypeEnum.convertToTitle(s1.toUpperCase()));
                                         }
-                                        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();
+                                        answer = answerList.toString();
                                     }
-                                    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(score) ? String.valueOf(score) : "0");
-                                    List<ExcelDto> excelDtoList = null;
-                                    if (!excelDtoMap.containsKey(m.getExamStudentId())) {
-                                        excelDtoList = new ArrayList<>();
-                                    } else {
-                                        excelDtoList = excelDtoMap.get(m.getExamStudentId());
+                                    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);
                                     }
-                                    excelDtoList.add(excelAnswerDto);
-                                    excelDtoList.add(excelScoreDto);
-                                    excelDtoMap.put(m.getExamStudentId(), excelDtoList);
                                 }
+                                ExcelDto excelScoreDto = new ExcelDto(title + "得分",
+                                        Objects.nonNull(score) ? String.valueOf(score) : "0");
+                                List<ExcelDto> excelDtoList = null;
+                                if (!excelDtoMap.containsKey(m.getExamStudentId())) {
+                                    excelDtoList = new ArrayList<>();
+                                } else {
+                                    excelDtoList = excelDtoMap.get(m.getExamStudentId());
+                                }
+                                excelDtoList.add(excelAnswerDto);
+                                excelDtoList.add(excelScoreDto);
+                                excelDtoMap.put(m.getExamStudentId(), excelDtoList);
                             }
                         }
                     }