wangliang 4 years ago
parent
commit
1c0762ab95

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/ExcelDto.java

@@ -19,6 +19,15 @@ public class ExcelDto implements Serializable {
     @ApiModelProperty(name = "内容")
     private String content;
 
+    public ExcelDto() {
+
+    }
+
+    public ExcelDto(String title, String content) {
+        this.title = title;
+        this.content = content;
+    }
+
     public String getTitle() {
         return title;
     }

+ 14 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/MarkResultSimpleExportDto.java

@@ -1,5 +1,7 @@
 package com.qmth.themis.business.dto;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
 import io.swagger.annotations.ApiModelProperty;
@@ -81,6 +83,18 @@ public class MarkResultSimpleExportDto implements Serializable {
     @ExcelNotExport
     private Long paperId;
 
+    @ApiModelProperty(value = "考生ID")
+    @ExcelNotExport
+    private Long examStudentId;
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
     public Long getPaperId() {
         return paperId;
     }

+ 29 - 3
themis-business/src/main/java/com/qmth/themis/business/dto/MarkResultStandardExportDto.java

@@ -5,6 +5,8 @@ import com.qmth.themis.business.annotation.ExcelNote;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 成绩标准版导出 dto
@@ -75,12 +77,36 @@ public class MarkResultStandardExportDto implements Serializable{
 
     @ApiModelProperty(value = "考试记录ID")
     @ExcelNotExport
-    private String recordId;
+    private Long recordId;
 
     @ApiModelProperty(value = "试卷ID")
     @ExcelNotExport
     private Long paperId;
 
+    @ApiModelProperty(value = "考生ID")
+    @ExcelNotExport
+    private Long examStudentId;
+
+    @ApiModelProperty(value = "答题记录")
+    @ExcelNotExport
+    private Map<Long, List<ExcelDto>> answerExcetDto;
+
+    public Map<Long, List<ExcelDto>> getAnswerExcetDto() {
+        return answerExcetDto;
+    }
+
+    public void setAnswerExcetDto(Map<Long, List<ExcelDto>> answerExcetDto) {
+        this.answerExcetDto = answerExcetDto;
+    }
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
     public Long getPaperId() {
         return paperId;
     }
@@ -89,11 +115,11 @@ public class MarkResultStandardExportDto implements Serializable{
         this.paperId = paperId;
     }
 
-    public String getRecordId() {
+    public Long getRecordId() {
         return recordId;
     }
 
-    public void setRecordId(String recordId) {
+    public void setRecordId(Long recordId) {
         this.recordId = recordId;
     }
 

+ 25 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/MarkResultDto.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.dto.response;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.business.annotation.ExcelNotExport;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -75,6 +76,30 @@ public class MarkResultDto implements Serializable {
     @ApiModelProperty(value = "试卷ID")
     private Long paperId;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "考试记录ID")
+    private Long recordId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "考生ID")
+    private Long examStudentId;
+
+    public Long getRecordId() {
+        return recordId;
+    }
+
+    public void setRecordId(Long recordId) {
+        this.recordId = recordId;
+    }
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
     public Long getPaperId() {
         return paperId;
     }

+ 49 - 32
themis-business/src/main/java/com/qmth/themis/business/enums/AnswerTypeEnum.java

@@ -1,5 +1,7 @@
 package com.qmth.themis.business.enums;
 
+import java.util.Objects;
+
 /**
  * @Description: 题目类型 enum
  * @Param:
@@ -9,45 +11,60 @@ package com.qmth.themis.business.enums;
  */
 public enum AnswerTypeEnum {
 
-    A(1L, "A"),
-    B(2L, "B"),
-    C(3L, "C"),
-    D(4L, "D"),
-    E(5L, "E"),
-    F(6L, "F"),
-    G(7L, "G"),
-    H(8L, "H"),
-    I(9L, "I"),
-    J(10L, "J"),
-    K(11L, "K"),
-    L(12L, "L"),
-    M(13L, "M"),
-    N(14L, "N"),
-    O(15L, "O"),
-    P(16L, "P"),
-    Q(17L, "Q"),
-    R(18L, "R"),
-    S(19L, "S"),
-    T(20L, "T"),
-    U(21L, "U"),
-    V(22L, "V"),
-    W(23L, "W"),
-    X(24L, "X"),
-    Y(25L, "Y"),
-    Z(26L, "Z"),
-    TRUE(27L, "对"),
-    FALSE(28L, "错");
-
-    private Long type;
+    A("1", "A"),
+    B("2", "B"),
+    C("3", "C"),
+    D("4", "D"),
+    E("5", "E"),
+    F("6", "F"),
+    G("7", "G"),
+    H("8", "H"),
+    I("9", "I"),
+    J("10", "J"),
+    K("11", "K"),
+    L("12", "L"),
+    M("13", "M"),
+    N("14", "N"),
+    O("15", "O"),
+    P("16", "P"),
+    Q("17", "Q"),
+    R("18", "R"),
+    S("19", "S"),
+    T("20", "T"),
+    U("21", "U"),
+    V("22", "V"),
+    W("23", "W"),
+    X("24", "X"),
+    Y("25", "Y"),
+    Z("26", "Z"),
+    TRUE("TRUE", "对"),
+    FALSE("FALSE", "错");
+
+    private String type;
 
     private String title;
 
-    private AnswerTypeEnum(Long type, String title) {
+    private AnswerTypeEnum(String type, String title) {
         this.type = type;
         this.title = title;
     }
 
-    public Long getType() {
+    /**
+     * 状态转换 toTitle
+     *
+     * @param value
+     * @return
+     */
+    public static String convertToTitle(String value) {
+        for (AnswerTypeEnum e : AnswerTypeEnum.values()) {
+            if (Objects.equals(value, e.getType())) {
+                return e.getTitle();
+            }
+        }
+        return null;
+    }
+
+    public String getType() {
         return type;
     }
 

+ 24 - 9
themis-business/src/main/java/com/qmth/themis/business/enums/QuestionTypeEnum.java

@@ -12,38 +12,53 @@ public enum QuestionTypeEnum {
     /**
      * 单选
      */
-    SINGLE_ANSWER_QUESTION(1L, "单选题"),
+    SINGLE_ANSWER_QUESTION(1, "单选题"),
     /**
      * 多选
      */
-    MULTIPLE_ANSWER_QUESTION(2L, "多选题"),
+    MULTIPLE_ANSWER_QUESTION(2, "多选题"),
     /**
      * 判断
      */
-    BOOL_ANSWER_QUESTION(3L, "判断题"),
+    BOOL_ANSWER_QUESTION(3, "判断题"),
     /**
      * 填空
      */
-    FILL_BLANK_QUESTION(4L, "填空题"),
+    FILL_BLANK_QUESTION(4, "填空题"),
     /**
      * 问答
      */
-    TEXT_ANSWER_QUESTION(5L, "问答题"),
+    TEXT_ANSWER_QUESTION(5, "问答题"),
     /**
      * 套题
      */
-    NESTED_ANSWER_QUESTION(6L, "套题");
+    NESTED_ANSWER_QUESTION(6, "套题");
 
-    private Long type;
+    private Integer type;
 
     private String title;
 
-    private QuestionTypeEnum(Long type, String title) {
+    private QuestionTypeEnum(Integer type, String title) {
         this.type = type;
         this.title = title;
     }
 
-    public Long getType() {
+    /**
+     * 状态转换 toTitle
+     *
+     * @param value
+     * @return
+     */
+    public static String convertToTitle(Integer value) {
+        for (QuestionTypeEnum e : QuestionTypeEnum.values()) {
+            if (value.intValue() == e.getType().intValue()) {
+                return e.getTitle();
+            }
+        }
+        return null;
+    }
+
+    public Integer getType() {
         return type;
     }
 

+ 27 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -12,6 +12,7 @@ import com.qmth.themis.business.dto.ExcelDto;
 import com.qmth.themis.business.dto.MarkResultSimpleExportDto;
 import com.qmth.themis.business.dto.MarkResultStandardExportDto;
 import com.qmth.themis.business.entity.TOeExamAnswer;
+import com.qmth.themis.business.enums.AnswerTypeEnum;
 import com.qmth.themis.business.enums.QuestionTypeEnum;
 import com.qmth.themis.business.service.TEExamPaperService;
 import com.qmth.themis.business.service.TEExamStudentService;
@@ -89,10 +90,11 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             Gson gson = new Gson();
             List<MarkResultStandardExportDto> markResultStandardExportDtoList = gson.fromJson(gson.toJson(markResultSimpleExportDtoList), new TypeToken<List<MarkResultStandardExportDto>>() {
             }.getType());
-            Map<Long, ExcelDto> excelDtoMap = new HashMap<>();
+            Map<Long, List<ExcelDto>> excelDtoMap = null;
             Map<Long, Map<String, ObjectiveAnswerCacheBean>> paperObjectiveAnswerMap = new HashMap<>();
             if (Objects.nonNull(markResultStandardExportDtoList) && markResultStandardExportDtoList.size() > 0) {
                 for (MarkResultStandardExportDto m : markResultStandardExportDtoList) {
+                    excelDtoMap = new HashMap<>();
                     Map<String, ObjectiveAnswerCacheBean> objectiveAnswerCacheBeanMap = null;
                     if (Objects.nonNull(m.getPaperId())) {//处理试卷
                         if (!paperObjectiveAnswerMap.containsKey(m.getPaperId())) {
@@ -112,10 +114,33 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                             String questionsTitle = s.getMainNumber() + "_" + s.getSubNumber();
                             if (Objects.nonNull(s.getAnswer())) {
                                 ObjectiveAnswerCacheBean objectiveAnswerCacheBean = objectiveAnswerCacheBeanMap.get(questionsTitle);
-//                                String questionType = QuestionTypeEnum.valueOf(Long.parseLong(objectiveAnswerCacheBean.getStructType())).getTitle();
+                                String title = QuestionTypeEnum.convertToTitle(objectiveAnswerCacheBean.getStructType()) + questionsTitle;
+                                String answer = null;
+                                if (objectiveAnswerCacheBean.getStructType().intValue() == 1 || objectiveAnswerCacheBean.getStructType().intValue() == 2) {
+                                    List<String> list = Arrays.asList(s.getAnswer().replace("[", "").replace("]", "").replaceAll(" ", "").replaceAll("\n", "").split(","));
+                                    List<String> answerList = new ArrayList<>();
+                                    for (String s1 : list) {
+                                        answerList.add(AnswerTypeEnum.convertToTitle(s1.toUpperCase()));
+                                    }
+                                    answer = answerList.toString();
+                                } else if (objectiveAnswerCacheBean.getStructType().intValue() == 3) {
+                                    answer = AnswerTypeEnum.convertToTitle(s.getAnswer().toUpperCase());
+                                }
+                                ExcelDto excelAnswerDto = new ExcelDto(title + "作答", answer);
+                                ExcelDto excelScoreDto = new ExcelDto(title + "得分", String.valueOf(s.getScore()));
+                                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);
                             }
                         }
                     }
+                    m.setAnswerExcetDto(excelDtoMap);
                 }
             }
             boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);

+ 4 - 3
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -301,10 +301,11 @@
 		t.examActivityId,
 		t.recordId,
 		t.paperId,
-		0 as subjectiveScore
+		0 as subjectiveScore,
+		t.examStudentId
 		from
 		(
-		select tee.id as examId,tee.name as examName,teea.id as examActivityId, teea.code as examActivityCode, tes.name, tes.`identity`, tees.course_code as courseCode, tees.course_name as courseName, tees.room_code as roomCode, tees.room_name as roomName, tees.grade, tees.class_no as classNo, (
+		select tees.id as examStudentId,tee.id as examId,tee.name as examName,teea.id as examActivityId, teea.code as examActivityCode, tes.name, tes.`identity`, tees.course_code as courseCode, tees.course_name as courseName, tees.room_code as roomCode, tees.room_name as roomName, tees.grade, tees.class_no as classNo, (
 		select
 		count(1)
 		from
@@ -328,7 +329,7 @@
 			(toer.breach_status = 1
 			or breach_status is null)
 			and (toer.status = 'FINISHED'
-			or toer.status = 'PERSISTED') group by toer.id,toer.paper_id,toer.exam_student_id) temp on temp.exam_student_id = tees.id
+			or toer.status = 'PERSISTED') group by toer.id,toer.paper_id,toer.exam_student_id order by toer.id desc limit 1) temp on temp.exam_student_id = tees.id
 		left join t_e_exam tee on
 		tee.id = tees.exam_id
 		left join t_e_exam_activity teea on