wangliang 4 年之前
父节点
当前提交
edae9f5aaa

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

@@ -0,0 +1,37 @@
+package com.qmth.themis.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: excel动态通用dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/10/21
+ */
+public class ExcelDto implements Serializable {
+
+    @ApiModelProperty(name = "标题")
+    private String title;
+
+    @ApiModelProperty(name = "内容")
+    private String content;
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 15 - 3
themis-business/src/main/java/com/qmth/themis/business/dto/MarkResultSimpleExportDto.java

@@ -73,18 +73,30 @@ public class MarkResultSimpleExportDto implements Serializable {
     @ExcelNote(value = "总分")
     private String sumScore;
 
+    @ApiModelProperty(value = "考试记录ID")
+    @ExcelNotExport
+    private Long recordId;
+
     @ApiModelProperty(value = "试卷ID")
     @ExcelNotExport
-    private String paperId;
+    private Long paperId;
 
-    public String getPaperId() {
+    public Long getPaperId() {
         return paperId;
     }
 
-    public void setPaperId(String paperId) {
+    public void setPaperId(Long paperId) {
         this.paperId = paperId;
     }
 
+    public Long getRecordId() {
+        return recordId;
+    }
+
+    public void setRecordId(Long recordId) {
+        this.recordId = recordId;
+    }
+
     public String getRoomCode() {
         return roomCode;
     }

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

@@ -73,18 +73,30 @@ public class MarkResultStandardExportDto implements Serializable{
     @ExcelNote(value = "总分")
     private String sumScore;
 
+    @ApiModelProperty(value = "考试记录ID")
+    @ExcelNotExport
+    private String recordId;
+
     @ApiModelProperty(value = "试卷ID")
     @ExcelNotExport
-    private String paperId;
+    private Long paperId;
 
-    public String getPaperId() {
+    public Long getPaperId() {
         return paperId;
     }
 
-    public void setPaperId(String paperId) {
+    public void setPaperId(Long paperId) {
         this.paperId = paperId;
     }
 
+    public String getRecordId() {
+        return recordId;
+    }
+
+    public void setRecordId(String recordId) {
+        this.recordId = recordId;
+    }
+
     public String getRoomCode() {
         return roomCode;
     }

+ 57 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/AnswerTypeEnum.java

@@ -0,0 +1,57 @@
+package com.qmth.themis.business.enums;
+
+/**
+ * @Description: 题目类型 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/10/21
+ */
+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;
+
+    private String title;
+
+    private AnswerTypeEnum(Long type, String title) {
+        this.type = type;
+        this.title = title;
+    }
+
+    public Long getType() {
+        return type;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+}

+ 53 - 0
themis-business/src/main/java/com/qmth/themis/business/enums/QuestionTypeEnum.java

@@ -0,0 +1,53 @@
+package com.qmth.themis.business.enums;
+
+/**
+ * @Description: 题目类型 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/10/21
+ */
+public enum QuestionTypeEnum {
+
+    /**
+     * 单选
+     */
+    SINGLE_ANSWER_QUESTION(1L, "单选题"),
+    /**
+     * 多选
+     */
+    MULTIPLE_ANSWER_QUESTION(2L, "多选题"),
+    /**
+     * 判断
+     */
+    BOOL_ANSWER_QUESTION(3L, "判断题"),
+    /**
+     * 填空
+     */
+    FILL_BLANK_QUESTION(4L, "填空题"),
+    /**
+     * 问答
+     */
+    TEXT_ANSWER_QUESTION(5L, "问答题"),
+    /**
+     * 套题
+     */
+    NESTED_ANSWER_QUESTION(6L, "套题");
+
+    private Long type;
+
+    private String title;
+
+    private QuestionTypeEnum(Long type, String title) {
+        this.type = type;
+        this.title = title;
+    }
+
+    public Long getType() {
+        return type;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+}

+ 42 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -1,14 +1,21 @@
 package com.qmth.themis.business.templete.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
+import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
+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.QuestionTypeEnum;
+import com.qmth.themis.business.service.TEExamPaperService;
 import com.qmth.themis.business.service.TEExamStudentService;
+import com.qmth.themis.business.service.TOeExamAnswerService;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
@@ -47,6 +54,12 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
     @Resource
     TempleteLogicService templeteLogicService;
 
+    @Resource
+    TOeExamAnswerService tOeExamAnswerService;
+
+    @Resource
+    TEExamPaperService teExamPaperService;
+
     /**
      * 考场导出模版
      *
@@ -76,6 +89,35 @@ 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, Map<String, ObjectiveAnswerCacheBean>> paperObjectiveAnswerMap = new HashMap<>();
+            if (Objects.nonNull(markResultStandardExportDtoList) && markResultStandardExportDtoList.size() > 0) {
+                for (MarkResultStandardExportDto m : markResultStandardExportDtoList) {
+                    Map<String, ObjectiveAnswerCacheBean> objectiveAnswerCacheBeanMap = null;
+                    if (Objects.nonNull(m.getPaperId())) {//处理试卷
+                        if (!paperObjectiveAnswerMap.containsKey(m.getPaperId())) {
+                            objectiveAnswerCacheBeanMap = teExamPaperService.getObjectiveAnswerCacheBean(m.getPaperId());
+                            paperObjectiveAnswerMap.put(m.getPaperId(), objectiveAnswerCacheBeanMap);
+                        } else {
+                            objectiveAnswerCacheBeanMap = paperObjectiveAnswerMap.get(m.getPaperId());
+                        }
+                    } else {
+                        continue;
+                    }
+                    if (Objects.nonNull(m.getRecordId())) {//处理考生答案
+                        QueryWrapper<TOeExamAnswer> tOeExamAnswerQueryWrapper = new QueryWrapper<>();
+                        tOeExamAnswerQueryWrapper.lambda().eq(TOeExamAnswer::getExamRecordId, m.getRecordId());
+                        List<TOeExamAnswer> tOeExamAnswerList = tOeExamAnswerService.list(tOeExamAnswerQueryWrapper);
+                        for (TOeExamAnswer s : tOeExamAnswerList) {
+                            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();
+                            }
+                        }
+                    }
+                }
+            }
             boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
             StringJoiner stringJoiner = new StringJoiner("");
             if (!oss) {

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

@@ -299,6 +299,7 @@
 		ifnull(t.objectiveScore,0) as sumScore,
 		t.examId,
 		t.examActivityId,
+		t.recordId,
 		t.paperId,
 		0 as subjectiveScore
 		from
@@ -313,20 +314,21 @@
 		(select sum(toer.breach_status) from t_oe_exam_record toer
 		where toer.exam_student_id = tees.id and toer.breach_status = 0) as breachCount,
 		temp.objective_score as objectiveScore,
+		temp.id as recordId,
 		temp.paper_id as paperId
 		from
 		t_e_student tes
 		left join t_e_exam_student tees on
 		tees.student_id = tes.id
 		left join (select
-			max(toer.objective_score) as objective_score,toer.paper_id,toer.exam_student_id
+			max(toer.objective_score) as objective_score,toer.id,toer.exam_student_id,toer.paper_id
 			from
 			t_oe_exam_record toer
 			where
 			(toer.breach_status = 1
 			or breach_status is null)
 			and (toer.status = 'FINISHED'
-			or toer.status = 'PERSISTED') group by paper_id,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) 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

+ 10 - 1
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamController.java

@@ -23,12 +23,14 @@ import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.exam.config.ExamConstant;
+import com.qmth.themis.exam.websocket.WebSocketOeServer;
 import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 @Api(tags = "考试Controller")
 @RestController
@@ -114,7 +116,14 @@ public class TEExamController {
         } else if (Objects.nonNull(status) && Objects.equals(ExamRecordStatusEnum.FIRST_PREPARE, status)) {
             ExamConstant.sendExamStopMsg(Long.valueOf(recordId), false);
         } else {
-            throw new BusinessException("考试状态出错");
+            if(Objects.nonNull(status)) {
+                throw new BusinessException("考试状态出错");
+            }
+        }
+        ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
+        WebSocketOeServer webSocketOeServer = webSocketMap.get(Long.parseLong(recordId));
+        if(Objects.nonNull(webSocketOeServer)){
+            webSocketOeServer.onClose();
         }
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }