wangliang 2 年 前
コミット
993fe4f2bb
25 ファイル変更304 行追加496 行削除
  1. 3 5
      themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java
  2. 2 4
      themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java
  3. 0 100
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java
  4. 0 6
      themis-admin/src/main/resources/application-dev.properties
  5. 1 1
      themis-business/src/main/java/com/qmth/themis/business/config/MapApiReader.java
  6. 148 0
      themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java
  7. 4 5
      themis-business/src/main/java/com/qmth/themis/business/forkjoin/ExamStudentImportForkJoin.java
  8. 3 5
      themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java
  9. 23 22
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamPaperServiceImpl.java
  10. 2 3
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java
  11. 12 111
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEOpenServiceImpl.java
  12. 2 3
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java
  13. 2 3
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TMRocketMessageServiceImpl.java
  14. 6 8
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java
  15. 2 3
      themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java
  16. 2 3
      themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java
  17. 2 3
      themis-business/src/main/java/com/qmth/themis/business/templete/TaskSyncCommon.java
  18. 56 56
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamPaperImportTemplete.java
  19. 3 4
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultSimpleExportTemplete.java
  20. 4 5
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java
  21. 13 125
      themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java
  22. 3 5
      themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java
  23. 4 6
      themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketMobileServer.java
  24. 4 6
      themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketOeServer.java
  25. 3 4
      themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

+ 3 - 5
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import com.qmth.boot.core.solar.config.SolarProperties;
 import com.qmth.boot.core.solar.service.SolarService;
 import com.qmth.themis.admin.config.DictionaryConfig;
@@ -21,6 +20,7 @@ import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.tencentcloudapi.vod.v20180717.models.MediaBasicInfo;
@@ -340,8 +340,7 @@ public class SysController {
         }
         List<TEExamQueryDto> teExamQueryDtoList = null;
         if (!CollectionUtils.isEmpty(teExamList)) {
-            Gson gson = new Gson();
-            teExamQueryDtoList = gson.fromJson(gson.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
+            teExamQueryDtoList = GsonUtil.fromJson(GsonUtil.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
             }.getType());
             if (Objects.nonNull(warnCount) && warnCount) {
                 List<Long> examIdList = new ArrayList<>(teExamQueryDtoList.size());
@@ -465,8 +464,7 @@ public class SysController {
         List<TEExam> teExamList = teExamService.list(teExamQueryWrapper);
         List<TEExamQueryDto> teExamQueryDtoList = null;
         if (!CollectionUtils.isEmpty(teExamList)) {
-            Gson gson = new Gson();
-            teExamQueryDtoList = gson.fromJson(gson.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
+            teExamQueryDtoList = GsonUtil.fromJson(GsonUtil.toJson(teExamList), new TypeToken<List<TEExamQueryDto>>() {
             }.getType());
         }
         return ResultUtil.ok(teExamQueryDtoList);

+ 2 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java

@@ -3,7 +3,6 @@ package com.qmth.themis.admin.api;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -25,6 +24,7 @@ import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
@@ -450,7 +450,6 @@ public class TBUserController {
     //        teExamStudentService.save(teExamStudent);
     //
     //        //todo
-    ////        Gson gson = new Gson();
     ////        MTEStudentEntity mteStudentEntity = gson.fromJson(gson.toJson(teStudent), MTEStudentEntity.class);
     ////        MTEExamEntity mteExamEntity = gson.fromJson(gson.toJson(teExam), MTEExamEntity.class);
     ////        MTEExamActivityEntity mteExamActivityEntity = gson.fromJson(gson.toJson(teExamActivity), MTEExamActivityEntity.class);
@@ -622,8 +621,7 @@ public class TBUserController {
             dbUser = cacheService.addAccountCache(Long.parseLong(String.valueOf(mapParameter.get(SystemConstant.ID))));
             authDto = cacheService.addAccountAuthCache(dbUser.getId());
         }
-        Gson gson = new Gson();
-        TBUser tbUser = gson.fromJson(gson.toJson(mapParameter), TBUser.class);
+        TBUser tbUser = GsonUtil.fromJson(GsonUtil.toJson(mapParameter), TBUser.class);
         if ((Objects.isNull(tbUser.getPassword()) || Objects.equals(tbUser.getPassword(), "")) && Objects.nonNull(dbUser)) {
             tbUser.setPassword(dbUser.getPassword());
         }

+ 0 - 100
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -85,9 +85,6 @@ public class TEExamController {
     @Resource
     CacheService cacheService;
 
-//    @Resource
-//    MyThreadPool myThreadPool;
-
     @Resource
     TSLogService tsLogService;
 
@@ -636,103 +633,6 @@ public class TEExamController {
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.TASK_ID, tbTaskHistory.getId()));
     }
 
-//    @Resource
-//    CloudMarkUtil cloudMarkUtil;
-//
-//    @Resource
-//    TEExamPaperService teExamPaperService;
-//
-//    @Resource
-//    TEExamStudentService teExamStudentService;
-//
-//    @ApiOperation(value = "http测试发送接口")
-//    @RequestMapping(value = "/http/test/send", method = RequestMethod.POST)
-//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
-//    public Result httpTestSend() throws IOException {
-//        Long orgId = 240069373300576256L, examId = 307119709605072896L, paperId = 307120792277622784L,
-//                examStudentId = 1574244332533293057L, examRecordId = 307148263382851584L;
-//        TBOrg tbOrg = cacheService.addOrgCache(orgId);
-//        ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
-//
-////        //测试考试
-////        SaveExamParams saveExamParams = new SaveExamParams(orgId, examCacheBean.getId(), examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN));
-////        cloudMarkUtil.callExamSaveApi(saveExamParams);
-////
-////        //测试科目试卷
-////        ExamPaperCacheBean examPaperCacheBean = teExamPaperService.getExamPaperCacheBean(paperId);
-////        SaveSubjectParams saveSubjectParams = new SaveSubjectParams(orgId, examCacheBean.getId(), examPaperCacheBean.getCode(), examPaperCacheBean.getName());
-////        cloudMarkUtil.callSubjectSaveApi(saveSubjectParams);
-////
-////        //测试考生
-//        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-////        SaveStudentParams saveStudentParams = new SaveStudentParams(orgId, examId, String.valueOf(examRecordId),
-////                examStudentCacheBean.getIdentity(),
-////                examStudentCacheBean.getName(),
-////                tbOrg.getName(),
-////                examStudentCacheBean.getClassNo(), "#",
-////                examStudentCacheBean.getCourseCode(),
-////                examStudentCacheBean.getCourseName());
-////        cloudMarkUtil.callStudentSaveApi(saveStudentParams);
-//
-////        //测试上传文件json
-////        File fileJson = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a");
-////        FileUploadParams fileUploadParamsJson = new FileUploadParams(orgId, examId, String.valueOf(examRecordId), fileJson);
-////        fileUploadParamsJson.setFormat(CloudMarkFileUploadTypeEnum.JSON.getCode());
-////        cloudMarkUtil.callFileUploadApi(fileUploadParamsJson);
-////
-//        File filePaper = new File("/Users/king/Downloads/1");
-//        FileUploadParams fileUploadParamsPaper = new FileUploadParams(orgId, examId, examStudentCacheBean.getIdentity(), CloudMarkFileUploadTypeEnum.PAPER, filePaper);
-//        cloudMarkUtil.callFileUploadApi(fileUploadParamsPaper);
-//        return ResultUtil.ok(true);
-//    }
-//
-//    @ApiOperation(value = "http测试考试接口")
-//    @RequestMapping(value = "/http/test/save", method = RequestMethod.POST)
-//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
-//    public Result httpTestApiExamSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
-//        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
-//        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
-//        log.info("httpTestApiExamSave,result:{}", decodeJson);
-//        return ResultUtil.ok(Collections.singletonMap("id", 1L));
-//    }
-//
-//    @ApiOperation(value = "http测试科目接口")
-//    @RequestMapping(value = "/http/test/subject/save", method = RequestMethod.POST)
-//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
-//    public Result httpTestApiSubjectSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
-//        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
-//        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
-//        log.info("httpTestApiSubjectSave,result:{}", JacksonUtil.parseJson(decodeJson));
-//        return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
-//    }
-//
-//    @ApiOperation(value = "http测试考生接口")
-//    @RequestMapping(value = "/http/test/student/save", method = RequestMethod.POST)
-//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
-//    public Result httpTestApiStudentSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
-//        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
-//        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
-//        log.info("httpTestApiStudentSave,result:{}", decodeJson);
-//        return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
-//    }
-//
-//    @ApiOperation(value = "http测试文件接口")
-//    @RequestMapping(value = "/http/test/file/{type}/upload", method = RequestMethod.POST)
-//    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
-//    public Result httpTestFileUpload(@PathVariable("type") String type,
-//                                     @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
-//                                     @ApiParam(value = "准考证号") @RequestParam(required = false) String examNumber,
-//                                     @ApiParam(value = "科目编码") @RequestParam(required = false) String subjectCode,
-//                                     @ApiParam(value = "格式") @RequestParam(required = false) String format,
-//                                     @ApiParam(value = "文件", required = true) @RequestParam MultipartFile file,
-//                                     @ApiParam(value = "文件md5", required = true) @RequestParam String md5) throws IOException {
-//        if (Objects.nonNull(file)) {
-//            File fileNew = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a-new");
-//            IOUtils.copy(file.getInputStream(), new FileOutputStream(fileNew));
-//        }
-//        return ResultUtil.ok(Collections.singletonMap("success", true));
-//    }
-
     @ApiOperation(value = "修正作答记录缓存到数据库")
     @RequestMapping(value = "/persisted_answer", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})

+ 0 - 6
themis-admin/src/main/resources/application-dev.properties

@@ -163,12 +163,6 @@ cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save
 cloud.mark.studentSaveApi=/api/exam/student/save
 cloud.mark.fileUploadApi=/api/file/{type}/upload
-#cloud.mark.url=http://127.0.0.1:6001
-#cloud.mark.studentScoreApi=/api/admin/exam/http/test/student/score
-#cloud.mark.examSaveApi=/api/admin/exam/http/test/save
-#cloud.mark.subjectSaveApi=/api/admin/exam/http/test/subject/save
-#cloud.mark.studentSaveApi=/api/admin/exam/http/test/student/save
-#cloud.mark.fileUploadApi=/api/admin/exam/http/test/file/{type}/upload
 
 #============================================================================
 # \u914D\u7F6Erocketmq

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/config/MapApiReader.java

@@ -50,7 +50,7 @@ public class MapApiReader implements ParameterBuilderPlugin {
                 ApiJsonProperty[] properties = optional.get().value();
                 parameterContext.getDocumentationContext().getAdditionalModels().add(typeResolver.resolve(createRefModel(properties, name)));  //像documentContext的Models中添加我们新生成的Class
                 parameterContext.parameterBuilder()  //修改Map参数的ModelRef为我们动态生成的class
-                        .parameterType("body")
+                        .parameterType(SystemConstant.BODY)
                         .modelRef(new ModelRef(name))
                         .name(name);
             }

+ 148 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -1,12 +1,21 @@
 package com.qmth.themis.business.constant;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Sets;
+import com.google.common.reflect.TypeToken;
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerBean;
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerStructBean;
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerTempBean;
+import com.qmth.themis.business.bean.admin.OpenRecordNeedMarkBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
+import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.dto.ExpireTimeDTO;
 import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.CacheService;
+import com.qmth.themis.business.service.TEExamPaperService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.SessionUtil;
@@ -16,9 +25,13 @@ import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Base64Util;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.IpUtil;
 import org.apache.commons.io.IOUtils;
 import org.lionsoul.ip2region.xdb.Searcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -39,6 +52,7 @@ import java.util.stream.Collectors;
  * @Date: 2019/10/11
  */
 public class SystemConstant {
+    private final static Logger log = LoggerFactory.getLogger(SystemConstant.class);
 
     public static final String PATTERN = "^[A-Za-z0-9]*";
 
@@ -92,6 +106,16 @@ public class SystemConstant {
     /**
      * 系统相关
      */
+    public static final String BODY = "body";
+    public static final String SUB_QUESTIONS = "subQuestions";
+    public static final String ANSWER = "answer";
+    public static final String STRUCT_TYPE = "structType";
+    public static final String NUMBER = "number";
+    public static final String DETAILS = "details";
+    public static final String QUESTIONS = "questions";
+    public static final String SCORE = "score";
+    public static final String OPTIONS = "options";
+    public static final String JSON_PREFIX = ".json";
     public static final String JOINT_MARK = "_";
     public static final String VALUE_OF_BLANK_REQUIRED_FIELD = "#";
     public static final String MULTI_MEDIA = "MULTI_MEDIA";
@@ -816,4 +840,128 @@ public class SystemConstant {
         }
         return null;
     }
+
+    /**
+     * 过滤题目
+     *
+     * @param questions
+     * @param answers
+     * @param acceptObjective
+     * @param acceptSubjective
+     * @return
+     */
+    public static JSONArray filterQuestions(JSONArray questions, JSONArray answers, boolean acceptObjective,
+                                            boolean acceptSubjective) {
+        JSONArray collection = new JSONArray();
+        for (int i = 0; i < questions.size(); i++) {
+            JSONObject question = questions.getJSONObject(i);
+            //根据题号查找答案
+            JSONObject answer = findJsonObject(answers, question.getIntValue(SystemConstant.NUMBER));
+            boolean accept = true;
+            //判断结构类型
+            switch (question.getIntValue(SystemConstant.STRUCT_TYPE)) {
+                case 1:
+                    //单选
+                case 2:
+                    //多选
+                case 3:
+                    //判断
+                    accept = acceptObjective;
+                    break;
+                case 4:
+                    //填空
+                case 5:
+                    //问答
+                    accept = acceptSubjective;
+                    break;
+                case 6:
+                    //套题
+                    //按条件过滤套题下所有子题
+                    JSONArray subAnswers = answer != null ? answer.getJSONArray(SystemConstant.SUB_QUESTIONS) : null;
+                    JSONArray subCollection = filterQuestions(question.getJSONArray(SystemConstant.SUB_QUESTIONS), subAnswers,
+                            acceptObjective, acceptSubjective);
+                    //没有子题,则本题也被过滤掉
+                    if (subCollection.size() > 0) {
+                        question.put(SystemConstant.SUB_QUESTIONS, subCollection);
+                    } else {
+                        accept = false;
+                    }
+                    break;
+                default:
+                    accept = false;
+            }
+            if (accept) {
+                if (answer != null) {
+                    question.put(SystemConstant.ANSWER, answer.get(SystemConstant.ANSWER));
+                }
+                collection.add(question);
+            }
+        }
+        return collection;
+    }
+
+    /**
+     * 过滤答案
+     *
+     * @param array
+     * @param number
+     * @return
+     */
+    public static JSONObject findJsonObject(JSONArray array, int number) {
+        if (array != null) {
+            for (int i = 0; i < array.size(); i++) {
+                JSONObject item = array.getJSONObject(i);
+                if (item.getIntValue(SystemConstant.NUMBER) == number) {
+                    return item;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 过滤答案
+     *
+     * @param openRecordNeedMarkBean
+     * @param answersTemp
+     * @param paperStructMap
+     * @return
+     */
+    public static OpenRecordNeedMarkBean filterAnswer(OpenRecordNeedMarkBean openRecordNeedMarkBean,
+                                                      List<OpenRecordAnswerTempBean> answersTemp,
+                                                      Map<Long, Map<String, Integer>> paperStructMap) {
+        if (!CollectionUtils.isEmpty(answersTemp)) {
+            TEExamPaperService teExamPaperService = SpringContextHolder.getBean(TEExamPaperService.class);
+            List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
+            List<OpenRecordAnswerBean> finalAnswers = answers;
+            answersTemp.forEach(s -> {
+                OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
+                try {
+                    openRecordAnswerBean.setAnswer(GsonUtil.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
+                    }.getType()));
+                } catch (Exception e) {
+                    log.error("错误答案:{}", s.getAnswer(), e);
+                }
+                finalAnswers.add(openRecordAnswerBean);
+            });
+            openRecordNeedMarkBean.setAnswers(answers.stream().filter(answer -> {
+                Map<String, Integer> struct = paperStructMap.get(openRecordNeedMarkBean.getPaperId());
+                if (struct == null) {
+                    struct = teExamPaperService.getPaperStructCacheBean(openRecordNeedMarkBean.getPaperId());
+                    if (struct != null) {
+                        paperStructMap.put(openRecordNeedMarkBean.getPaperId(), struct);
+                    } else {
+                        log.error("找不到对应的试卷结构,paperId=" + openRecordNeedMarkBean.getPaperId());
+                        return false;
+                    }
+                }
+                Integer type = struct.get(RedisKeyHelper
+                        .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
+                                answer.getSubIndex()));
+                //过滤单选、多选、判断题
+                return type != null && type != 1 && type != 2 && type != 3;
+            }).collect(Collectors.toList()));
+        }
+        return openRecordNeedMarkBean;
+    }
 }

+ 4 - 5
themis-business/src/main/java/com/qmth/themis/business/forkjoin/ExamStudentImportForkJoin.java

@@ -1,7 +1,6 @@
 package com.qmth.themis.business.forkjoin;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.Gson;
 import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -14,6 +13,7 @@ import com.qmth.themis.business.service.TEExamCourseService;
 import com.qmth.themis.business.service.TEExamStudentService;
 import com.qmth.themis.business.service.TEStudentService;
 import com.qmth.themis.common.util.Base64Util;
+import com.qmth.themis.common.util.GsonUtil;
 import org.springframework.util.CollectionUtils;
 
 import java.io.UnsupportedEncodingException;
@@ -69,14 +69,13 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
     @Override
     protected Set<String> compute() {
         if ((end - start) <= MAX) {
-            Gson gson = new Gson();
             TEExamActivity teExamActivity = null;
             if (Objects.equals(modeEnum, ExamModeEnum.ANYTIME)) {
                 Iterator iterator = teExamActivityMap.entrySet().iterator();
                 while (iterator.hasNext()) {
                     Map.Entry<String, Map> entry = (Map.Entry<String, Map>) iterator.next();
                     Map m = entry.getValue();
-                    teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
+                    teExamActivity = GsonUtil.fromJson(GsonUtil.toJson(m), TEExamActivity.class);
                 }
             }
             TEExamStudentService teExamStudentService = SpringContextHolder.getBean(TEExamStudentService.class);
@@ -91,7 +90,7 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
                 ExamStudentImportDto examStudentImportDto = (ExamStudentImportDto) list.get(i);
                 if (Objects.equals(modeEnum, ExamModeEnum.TOGETHER)) {
                     Map m = (Map) teExamActivityMap.get(examStudentImportDto.getExamActivityCode());
-                    teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
+                    teExamActivity = GsonUtil.fromJson(GsonUtil.toJson(m), TEExamActivity.class);
                 }
                 //先根据证件号+科目代码查询考生是否存在,存在则更新,不存在则插入
                 QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
@@ -112,7 +111,7 @@ public class ExamStudentImportForkJoin extends RecursiveTask<Set<String>> {
                         teStudentExists = true;
                         teStudent = new TEStudent(orgId, examStudentImportDto.getIdentity(), examStudentImportDto.getName(), createId);
                     }
-                    teExamStudent = gson.fromJson(gson.toJson(examStudentImportDto), TEExamStudent.class);
+                    teExamStudent = GsonUtil.fromJson(GsonUtil.toJson(examStudentImportDto), TEExamStudent.class);
                     teExamStudent.setIdentity(examStudentImportDto.getIdentity());
                     teExamStudent.setExamId(examId);
                     teExamStudent.setStudentId(teStudent.getId());

+ 3 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java

@@ -1,7 +1,6 @@
 package com.qmth.themis.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.Gson;
 import com.qmth.boot.core.solar.model.AppInfo;
 import com.qmth.boot.core.solar.model.OrgInfo;
 import com.qmth.boot.core.solar.service.SolarService;
@@ -15,6 +14,7 @@ import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.cache.annotation.CacheEvict;
@@ -306,8 +306,7 @@ public class CacheServiceImpl implements CacheService {
     @Cacheable(value = SystemConstant.studentAccount, key = "#p0", unless = "#result == null")
     public TEStudentCacheDto addStudentAccountCache(Long studentId) {
         TEStudent teStudent = teStudentService.getById(studentId);
-        Gson gson = new Gson();
-        return gson.fromJson(gson.toJson(teStudent), TEStudentCacheDto.class);
+        return GsonUtil.fromJson(GsonUtil.toJson(teStudent), TEStudentCacheDto.class);
     }
 
     /**
@@ -320,8 +319,7 @@ public class CacheServiceImpl implements CacheService {
     @CachePut(value = SystemConstant.studentAccount, key = "#p0", condition = "#result != null")
     public TEStudentCacheDto updateStudentAccountCache(Long studentId) {
         TEStudent teStudent = teStudentService.getById(studentId);
-        Gson gson = new Gson();
-        return gson.fromJson(gson.toJson(teStudent), TEStudentCacheDto.class);
+        return GsonUtil.fromJson(GsonUtil.toJson(teStudent), TEStudentCacheDto.class);
     }
 
     /**

+ 23 - 22
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamPaperServiceImpl.java

@@ -9,6 +9,7 @@ import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
+import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.dao.TEExamPaperMapper;
 import com.qmth.themis.business.entity.TEExamPaper;
@@ -189,36 +190,36 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
     private Map<String, ObjectiveAnswerCacheBean> buildObjectiveAnswerCache(String answerStr) {
         Map<String, ObjectiveAnswerCacheBean> map = new HashMap<String, ObjectiveAnswerCacheBean>();
         JSONObject answerJson = JSONObject.parseObject(answerStr);
-        JSONArray answerdetails = answerJson.getJSONArray("details");
+        JSONArray answerdetails = answerJson.getJSONArray(SystemConstant.DETAILS);
         for (int i = 0; i < answerdetails.size(); i++) {
-            Integer mainNum = answerdetails.getJSONObject(i).getInteger("number");
-            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray("questions");
+            Integer mainNum = answerdetails.getJSONObject(i).getInteger(SystemConstant.NUMBER);
+            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             for (int j = 0; j < answerdetailquestions.size(); j++) {
                 JSONObject answerquestion = answerdetailquestions.getJSONObject(j);
-                Integer subNum = answerquestion.getInteger("number");
-                Double score = answerquestion.getDouble("score");
-                Integer structType = answerquestion.getInteger("structType");
+                Integer subNum = answerquestion.getInteger(SystemConstant.NUMBER);
+                Double score = answerquestion.getDouble(SystemConstant.SCORE);
+                Integer structType = answerquestion.getInteger(SystemConstant.STRUCT_TYPE);
                 if (structType.intValue() == 1 || structType.intValue() == 2 || structType.intValue() == 3) {
                     ObjectiveAnswerCacheBean bean = new ObjectiveAnswerCacheBean();
                     bean.setScore(score);
                     bean.setStructType(structType);
                     if (structType.intValue() == 1 || structType.intValue() == 2) {
-                        JSONArray answer = answerquestion.getJSONArray("answer");
+                        JSONArray answer = answerquestion.getJSONArray(SystemConstant.ANSWER);
                         bean.setChoiceAnswer(answer);
                     }
                     if (structType.intValue() == 3) {
-                        Boolean answer = answerquestion.getBoolean("answer");
+                        Boolean answer = answerquestion.getBoolean(SystemConstant.ANSWER);
                         bean.setBoolAnswer(answer);
                     }
                     map.put(RedisKeyHelper.examAnswerHashKey(mainNum, subNum, null), bean);
                 }
                 if (structType.intValue() == 6 || structType.intValue() == 8) {
-                    JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
+                    JSONArray answersubQuestions = answerquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
                     for (int k = 0; k < answersubQuestions.size(); k++) {
                         JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
-                        Integer subIndex = answersubquestion.getInteger("number");
-                        Double subScore = answersubquestion.getDouble("score");
-                        Integer subStructType = answersubquestion.getInteger("structType");
+                        Integer subIndex = answersubquestion.getInteger(SystemConstant.NUMBER);
+                        Double subScore = answersubquestion.getDouble(SystemConstant.SCORE);
+                        Integer subStructType = answersubquestion.getInteger(SystemConstant.STRUCT_TYPE);
 
                         if (subStructType.intValue() == 1 || subStructType.intValue() == 2
                                 || subStructType.intValue() == 3) {
@@ -226,11 +227,11 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
                             bean.setScore(subScore);
                             bean.setStructType(subStructType);
                             if (subStructType.intValue() == 1 || subStructType.intValue() == 2) {
-                                JSONArray answer = answersubquestion.getJSONArray("answer");
+                                JSONArray answer = answersubquestion.getJSONArray(SystemConstant.ANSWER);
                                 bean.setChoiceAnswer(answer);
                             }
                             if (subStructType.intValue() == 3) {
-                                Boolean answer = answersubquestion.getBoolean("answer");
+                                Boolean answer = answersubquestion.getBoolean(SystemConstant.ANSWER);
                                 bean.setBoolAnswer(answer);
                             }
                             map.put(RedisKeyHelper.examAnswerHashKey(mainNum, subNum, subIndex), bean);
@@ -350,21 +351,21 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
     private Map<String, Integer> buildPaperStructCache(String structStr) {
         Map<String, Integer> map = new LinkedHashMap<String, Integer>();
         JSONObject structJson = JSONObject.parseObject(structStr);
-        JSONArray structdetails = structJson.getJSONArray("details");
+        JSONArray structdetails = structJson.getJSONArray(SystemConstant.DETAILS);
         for (int i = 0; i < structdetails.size(); i++) {
-            Integer mainNum = structdetails.getJSONObject(i).getInteger("number");
-            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
+            Integer mainNum = structdetails.getJSONObject(i).getInteger(SystemConstant.NUMBER);
+            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             for (int j = 0; j < structdetailquestions.size(); j++) {
                 JSONObject structquestion = structdetailquestions.getJSONObject(j);
-                Integer subNum = structquestion.getInteger("number");
-                Integer structType = structquestion.getInteger("structType");
+                Integer subNum = structquestion.getInteger(SystemConstant.NUMBER);
+                Integer structType = structquestion.getInteger(SystemConstant.STRUCT_TYPE);
                 map.put(RedisKeyHelper.examAnswerHashKey(mainNum, subNum, null), structType);
                 if (structType.intValue() == 6 || structType.intValue() == 8) {
-                    JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
+                    JSONArray structsubQuestions = structquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
                     for (int k = 0; k < structsubQuestions.size(); k++) {
                         JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
-                        Integer subIndex = structsubquestion.getInteger("number");
-                        Integer subStructType = structsubquestion.getInteger("structType");
+                        Integer subIndex = structsubquestion.getInteger(SystemConstant.NUMBER);
+                        Integer subStructType = structsubquestion.getInteger(SystemConstant.STRUCT_TYPE);
                         map.put(RedisKeyHelper.examAnswerHashKey(mainNum, subNum, subIndex), subStructType);
                     }
                 }

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.google.gson.Gson;
 import com.qmth.themis.business.bean.admin.OpenExamBean;
 import com.qmth.themis.business.bean.exam.*;
 import com.qmth.themis.business.cache.ExamBreakCacheUtil;
@@ -35,6 +34,7 @@ import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.HexUtils;
 import com.qmth.themis.common.util.IpUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -1602,7 +1602,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      */
     @Override
     public TEExam cacheConvert(ExamCacheBean examCacheBean) {
-        Gson gson = new Gson();
-        return gson.fromJson(gson.toJson(examCacheBean), TEExam.class);
+        return GsonUtil.fromJson(GsonUtil.toJson(examCacheBean), TEExam.class);
     }
 }

+ 12 - 111
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEOpenServiceImpl.java

@@ -5,10 +5,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import com.qmth.themis.business.bean.admin.*;
-import com.qmth.themis.business.cache.RedisKeyHelper;
+import com.qmth.themis.business.bean.admin.OpenExamBean;
+import com.qmth.themis.business.bean.admin.OpenExamCourseBean;
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerTempBean;
+import com.qmth.themis.business.bean.admin.OpenRecordNeedMarkBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -92,7 +92,7 @@ public class TEOpenServiceImpl implements TEOpenService {
         //解析答案JSON文件
         JSONObject answerJson = JSONObject
                 .parseObject(new String(ossUtil.download(false, paper.getAnswerPath()), StandardCharsets.UTF_8));
-        JSONArray answerDetails = answerJson.getJSONArray("details");
+        JSONArray answerDetails = answerJson.getJSONArray(SystemConstant.DETAILS);
         //解析试卷JSON文件
         JSONObject paperResult = JSONObject
                 .parseObject(new String(ossUtil.download(false, paper.getPaperViewPath()), StandardCharsets.UTF_8));
@@ -100,87 +100,25 @@ public class TEOpenServiceImpl implements TEOpenService {
         paperResult.put("code", paper.getCode());
         paperResult.put(SystemConstant.NAME, paper.getName());
         JSONArray detailCollection = new JSONArray();
-        JSONArray paperDetails = paperResult.getJSONArray("details");
+        JSONArray paperDetails = paperResult.getJSONArray(SystemConstant.DETAILS);
         for (int i = 0; i < paperDetails.size(); i++) {
             //遍历所有大题
             JSONObject paperDetail = paperDetails.getJSONObject(i);
-            JSONObject answerDetail = findJsonObject(answerDetails, paperDetail.getIntValue("number"));
+            JSONObject answerDetail = SystemConstant.findJsonObject(answerDetails, paperDetail.getIntValue(SystemConstant.NUMBER));
             //按条件过滤需要的小题同时合并答案
-            JSONArray questionCollection = filterQuestions(paperDetail.getJSONArray("questions"),
-                    answerDetail != null ? answerDetail.getJSONArray("questions") : null, acceptObjective,
+            JSONArray questionCollection = SystemConstant.filterQuestions(paperDetail.getJSONArray(SystemConstant.QUESTIONS),
+                    answerDetail != null ? answerDetail.getJSONArray(SystemConstant.QUESTIONS) : null, acceptObjective,
                     acceptSubjective);
             //有小题的情况下,本大题才需要被包含
             if (questionCollection.size() > 0) {
-                paperDetail.put("questions", questionCollection);
+                paperDetail.put(SystemConstant.QUESTIONS, questionCollection);
                 detailCollection.add(paperDetail);
             }
         }
-        paperResult.put("details", detailCollection);
+        paperResult.put(SystemConstant.DETAILS, detailCollection);
         return paperResult;
     }
 
-    private JSONArray filterQuestions(JSONArray questions, JSONArray answers, boolean acceptObjective,
-                                      boolean acceptSubjective) {
-        JSONArray collection = new JSONArray();
-        for (int i = 0; i < questions.size(); i++) {
-            JSONObject question = questions.getJSONObject(i);
-            //根据题号查找答案
-            JSONObject answer = findJsonObject(answers, question.getIntValue("number"));
-            boolean accept = true;
-            //判断结构类型
-            switch (question.getIntValue("structType")) {
-                case 1:
-                    //单选
-                case 2:
-                    //多选
-                case 3:
-                    //判断
-                    accept = acceptObjective;
-                    break;
-                case 4:
-                    //填空
-                case 5:
-                    //问答
-                    accept = acceptSubjective;
-                    break;
-                case 6:
-                    //套题
-                    //按条件过滤套题下所有子题
-                    JSONArray subAnswers = answer != null ? answer.getJSONArray("subQuestions") : null;
-                    JSONArray subCollection = filterQuestions(question.getJSONArray("subQuestions"), subAnswers,
-                            acceptObjective, acceptSubjective);
-                    //没有子题,则本题也被过滤掉
-                    if (subCollection.size() > 0) {
-                        question.put("subQuestions", subCollection);
-                    } else {
-                        accept = false;
-                    }
-                    break;
-                default:
-                    accept = false;
-            }
-            if (accept) {
-                if (answer != null) {
-                    question.put("answer", answer.get("answer"));
-                }
-                collection.add(question);
-            }
-        }
-        return collection;
-    }
-
-    private JSONObject findJsonObject(JSONArray array, int number) {
-        if (array != null) {
-            for (int i = 0; i < array.size(); i++) {
-                JSONObject item = array.getJSONObject(i);
-                if (item.getIntValue("number") == number) {
-                    return item;
-                }
-            }
-        }
-        return null;
-    }
-
     private TEExam checkExam(Long examId) {
         ExamCacheBean examCacheBean = examService.getExamCacheBean(examId);
         TEExam exam = examService.cacheConvert(examCacheBean);
@@ -194,15 +132,6 @@ public class TEOpenServiceImpl implements TEOpenService {
             throw new BusinessException("考试批次监考未结束");
         }
         return exam;
-        //        List<TEExamCourse> courses = examCourseService.findByExamId(examId);
-        //        if (courses == null || courses.size() == 0) {
-        //            throw new BusinessException("考试批次下没有课程");
-        //        }
-        //        for (TEExamCourse course : courses) {
-        //            if (course.getHasAnswer() == null || course.getHasAnswer().intValue() == 0) {
-        //                throw new BusinessException("考试批次下标答未齐全");
-        //            }
-        //        }
     }
 
     @Override
@@ -229,35 +158,7 @@ public class TEOpenServiceImpl implements TEOpenService {
                 for (OpenRecordNeedMarkBean record : recordList) {
                     //查询所有单题作答结果
                     List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(record.getId());
-                    List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
-                    Gson gson = new Gson();
-                    answersTemp.forEach(s -> {
-                        OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
-                        try {
-                            openRecordAnswerBean.setAnswer(gson.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
-                            }.getType()));
-                        } catch (Exception e) {
-                            log.error("错误答案:{}", s.getAnswer(), e);
-                        }
-                        answers.add(openRecordAnswerBean);
-                    });
-                    record.setAnswers(answers.stream().filter(answer -> {
-                        Map<String, Integer> struct = paperStructMap.get(record.getPaperId());
-                        if (struct == null) {
-                            struct = examPaperService.getPaperStructCacheBean(record.getPaperId());
-                            if (struct != null) {
-                                paperStructMap.put(record.getPaperId(), struct);
-                            } else {
-                                log.error("找不到对应的试卷结构,paperId=" + record.getPaperId());
-                                return false;
-                            }
-                        }
-                        Integer type = struct.get(RedisKeyHelper
-                                .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
-                                        answer.getSubIndex()));
-                        //过滤单选、多选、判断题
-                        return type != null && type != 1 && type != 2 && type != 3;
-                    }).collect(Collectors.toList()));
+                    record = SystemConstant.filterAnswer(record, answersTemp, paperStructMap);
                 }
                 obj.put("records", recordList);
                 result.add(obj);

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import com.qmth.themis.business.bean.StudentParams;
 import com.qmth.themis.business.bean.admin.StudentPhotoUploadResponseBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
@@ -26,6 +25,7 @@ import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.HexUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -95,8 +95,7 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
         IPage<TEStudentExamRecordDto> teStudentExamRecordDtoIPage = teStudentMapper.studentExamRecordQuery(iPage, studentId, examId);
         for (TEStudentExamRecordDto t : teStudentExamRecordDtoIPage.getRecords()) {
             if (Objects.nonNull(t.getTencentVideoUrl()) && !Objects.equals(t.getTencentVideoUrl().trim(), "")) {
-                Gson gson = new Gson();
-                List<TEStudentMonitorRecordDto> monitorRecordList = gson.fromJson(t.getTencentVideoUrl(), new TypeToken<List<TEStudentMonitorRecordDto>>() {
+                List<TEStudentMonitorRecordDto> monitorRecordList = GsonUtil.fromJson(t.getTencentVideoUrl(), new TypeToken<List<TEStudentMonitorRecordDto>>() {
                 }.getType());
                 Set<MonitorVideoSourceEnum> set = new LinkedHashSet<>(monitorRecordList.size());
                 for (TEStudentMonitorRecordDto teStudentMonitorRecordDto : monitorRecordList) {

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TMRocketMessageServiceImpl.java

@@ -1,7 +1,6 @@
 package com.qmth.themis.business.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dao.TMRocketMessageMapper;
 import com.qmth.themis.business.dto.MqDto;
@@ -9,6 +8,7 @@ import com.qmth.themis.business.entity.TMRocketMessage;
 import com.qmth.themis.business.service.TMRocketMessageService;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.common.util.GsonUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -55,8 +55,7 @@ public class TMRocketMessageServiceImpl extends ServiceImpl<TMRocketMessageMappe
      * @param key
      */
     protected void saveMessage(MqDto mqDto, String key) {
-        Gson gson = new Gson();
-        TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
+        TMRocketMessage tmRocketMessage = GsonUtil.fromJson(GsonUtil.toJson(mqDto), TMRocketMessage.class);
         tmRocketMessage.setBody(JacksonUtil.parseJson(tmRocketMessage.getBody()));
 //        tmRocketMessage.setSourceId(tmRocketMessage.getId());
 //        tmRocketMessage.setId(SystemConstant.getUuid());

+ 6 - 8
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import com.qmth.themis.business.bean.admin.*;
 import com.qmth.themis.business.bean.status.*;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
@@ -29,6 +28,7 @@ import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.FileUtil;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.IpUtil;
 import com.qmth.themis.common.util.SimpleBeanUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -373,7 +373,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         File dfile = new File(dir);
         try {
             dfile.mkdirs();
-            String structFilePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + ".json";
+            String structFilePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX;
             ExamStudentPaperStructCacheBean struct = (ExamStudentPaperStructCacheBean) redisUtil
                     .get(RedisKeyHelper.studentPaperStructKey(recordId));
 
@@ -383,7 +383,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
 
             //保存考试记录
             TOeExamRecord er = this.getCacheExamRecord(recordId);
-            if (Objects.isNull(er)) {
+            if (Objects.isNull(er.getExamId()) || Objects.isNull(er.getExamStudentId())) {
                 er = SystemConstant.getExamRecord(recordId);
                 er.setStatus(ExamRecordStatusEnum.PERSISTED);
                 er.setUpdateTime(timestamp);
@@ -465,8 +465,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             if (Objects.nonNull(o) && o instanceof BreachStatusBean) {
                 record.put(ExamRecordFieldEnum.breach_status.getCode(), ((BreachStatusBean) o).getStatus());
             }
-            Gson gson = new Gson();
-            er = gson.fromJson(gson.toJson(record), TOeExamRecord.class);
+            er = GsonUtil.fromJson(GsonUtil.toJson(record), TOeExamRecord.class);
         }
         return er;
     }
@@ -715,8 +714,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         IPage<InvigilateListProgressBean> invigilateListProgressBeanIPage = tOeExamRecordMapper.invigilatePageProgressList(iPage, examId, examActivityId, roomCode, courseCode, name, identity, status, userId, orgId);
         for (InvigilateListProgressBean t : invigilateListProgressBeanIPage.getRecords()) {
             if (Objects.nonNull(t.getTencentVideoUrl()) && !Objects.equals(t.getTencentVideoUrl().trim(), "")) {
-                Gson gson = new Gson();
-                List<TEStudentMonitorRecordDto> monitorRecordList = gson.fromJson(t.getTencentVideoUrl(), new TypeToken<List<TEStudentMonitorRecordDto>>() {
+                List<TEStudentMonitorRecordDto> monitorRecordList = GsonUtil.fromJson(t.getTencentVideoUrl(), new TypeToken<List<TEStudentMonitorRecordDto>>() {
                 }.getType());
                 Set<MonitorVideoSourceEnum> set = new LinkedHashSet<>(monitorRecordList.size());
                 for (TEStudentMonitorRecordDto teStudentMonitorRecordDto : monitorRecordList) {
@@ -1317,7 +1315,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
         List<TOeExamAnswer> tOeExamAnswerList = tOeExamAnswerService.list(tOeExamAnswerQueryWrapper);
 
         if (Objects.nonNull(tOeExamAnswerList) && tOeExamAnswerList.size() > 0) {
-            List<ExamRecordAnswerBean> examRecordAnswerBeanList = new Gson().fromJson(JacksonUtil.parseJson(tOeExamAnswerList), new TypeToken<List<ExamRecordAnswerBean>>() {
+            List<ExamRecordAnswerBean> examRecordAnswerBeanList = GsonUtil.fromJson(JacksonUtil.parseJson(tOeExamAnswerList), new TypeToken<List<ExamRecordAnswerBean>>() {
             }.getType());
             examStudentAnswerJson = JacksonUtil.parseJson(examRecordAnswerBeanList);
         }

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -2,7 +2,6 @@ package com.qmth.themis.business.templete;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.SysConfig;
@@ -14,6 +13,7 @@ import com.qmth.themis.business.service.TBAttachmentService;
 import com.qmth.themis.business.service.TBTaskHistoryService;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.util.GsonUtil;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Row;
@@ -70,7 +70,6 @@ public class TaskExportCommon {
      */
     public void init() {
         OssUtil ossUtil = SpringContextHolder.getBean(OssUtil.class);
-        Gson gson = new Gson();
         if (Objects.nonNull(this.map.get(SystemConstant.ORG_ID))) {
             this.orgId = Long.parseLong(String.valueOf(this.map.get(SystemConstant.ORG_ID)));
         }
@@ -79,7 +78,7 @@ public class TaskExportCommon {
         this.ossEnv = ossUtil.getAliYunOssPrivateDomain().getMap();
         this.type = (boolean) this.ossEnv.get(SystemConstant.OSS) ? SystemConstant.OSS : SystemConstant.LOCAL;
         Map tbTaskHistoryMap = (Map) this.map.get("tbTaskHistory");
-        this.tbTaskHistory = gson.fromJson(gson.toJson(tbTaskHistoryMap), TBTaskHistory.class);
+        this.tbTaskHistory = GsonUtil.fromJson(GsonUtil.toJson(tbTaskHistoryMap), TBTaskHistory.class);
         this.tbTaskHistoryService = SpringContextHolder.getBean(TBTaskHistoryService.class);
         this.tbAttachmentService = SpringContextHolder.getBean(TBAttachmentService.class);
         map.put("tbTaskHistory", tbTaskHistory);

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -2,7 +2,6 @@ package com.qmth.themis.business.templete;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.SysConfig;
@@ -13,6 +12,7 @@ import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.business.service.TBTaskHistoryService;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.util.GsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
@@ -73,7 +73,6 @@ public class TaskImportCommon {
      */
     public void init() {
         OssUtil ossUtil = SpringContextHolder.getBean(OssUtil.class);
-        Gson gson = new Gson();
         if (Objects.nonNull(this.map.get("mode"))) {
             this.mode = String.valueOf(this.map.get("mode"));
         }
@@ -91,7 +90,7 @@ public class TaskImportCommon {
         this.ossUtil = SpringContextHolder.getBean(OssUtil.class);
         this.ossEnv = ossUtil.getAliYunOssPrivateDomain().getMap();
         Map tbTaskHistoryMap = (Map) this.map.get("tbTaskHistory");
-        this.tbTaskHistory = gson.fromJson(gson.toJson(tbTaskHistoryMap), TBTaskHistory.class);
+        this.tbTaskHistory = GsonUtil.fromJson(GsonUtil.toJson(tbTaskHistoryMap), TBTaskHistory.class);
         this.tbTaskHistoryService = SpringContextHolder.getBean(TBTaskHistoryService.class);
         map.put("tbTaskHistory", tbTaskHistory);
     }

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/templete/TaskSyncCommon.java

@@ -2,7 +2,6 @@ package com.qmth.themis.business.templete;
 
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.SysConfig;
@@ -14,6 +13,7 @@ import com.qmth.themis.business.service.TBAttachmentService;
 import com.qmth.themis.business.service.TBTaskHistoryService;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.util.GsonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,7 +67,6 @@ public class TaskSyncCommon {
      */
     public void init() {
         OssUtil ossUtil = SpringContextHolder.getBean(OssUtil.class);
-        Gson gson = new Gson();
         if (Objects.nonNull(this.map.get(SystemConstant.ORG_ID))) {
             this.orgId = Long.parseLong(String.valueOf(this.map.get(SystemConstant.ORG_ID)));
         }
@@ -76,7 +75,7 @@ public class TaskSyncCommon {
         this.ossEnv = ossUtil.getAliYunOssPrivateDomain().getMap();
         this.type = (boolean) this.ossEnv.get(SystemConstant.OSS) ? SystemConstant.OSS : SystemConstant.LOCAL;
         Map tbTaskHistoryMap = (Map) this.map.get("tbTaskHistory");
-        this.tbTaskHistory = gson.fromJson(gson.toJson(tbTaskHistoryMap), TBTaskHistory.class);
+        this.tbTaskHistory = GsonUtil.fromJson(GsonUtil.toJson(tbTaskHistoryMap), TBTaskHistory.class);
         this.tbTaskHistoryService = SpringContextHolder.getBean(TBTaskHistoryService.class);
         this.tbAttachmentService = SpringContextHolder.getBean(TBAttachmentService.class);
         map.put("tbTaskHistory", tbTaskHistory);

+ 56 - 56
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamPaperImportTemplete.java

@@ -284,7 +284,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                     throw new BusinessException("试卷编码不匹配");
                 }
                 String structPath = paper.getStructPath();
-                structFile = new File(rootDir + SystemConstant.getUuid() + ".json");
+                structFile = new File(rootDir + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX);
                 ossUtil.download(false, structPath, structFile.getAbsolutePath());
             }
             disposeAnswer(rootDir, paper, answerFile, structFile, attachmentDir);
@@ -298,33 +298,33 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
     private void disposeViewPaper(String rootDir, TEExamPaper paper, File paperFile, File attachmentDir)
             throws IOException {
         JSONObject structJson = JSONObject.parseObject(FileUtil.readFileContent(paperFile));
-        JSONArray structdetails = structJson.getJSONArray("details");
+        JSONArray structdetails = structJson.getJSONArray(SystemConstant.DETAILS);
         if (structdetails == null || structdetails.size() == 0) {
             return;
         }
         for (int i = 0; i < structdetails.size(); i++) {
-            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
+            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             if (structdetailquestions != null && structdetailquestions.size() >= 0) {
                 for (int j = 0; j < structdetailquestions.size(); j++) {
                     JSONObject structquestion = structdetailquestions.getJSONObject(j);
-                    JSONObject body = structquestion.getJSONObject("body");
+                    JSONObject body = structquestion.getJSONObject(SystemConstant.BODY);
                     disposeQuestionBodyUrl(rootDir, body, paper.getId(), attachmentDir);
-                    JSONArray options = structquestion.getJSONArray("options");
+                    JSONArray options = structquestion.getJSONArray(SystemConstant.OPTIONS);
                     disposeQuestionOptionsUrl(rootDir, options, paper.getId(), attachmentDir);
-                    if (structquestion.getInteger("structType").intValue() == 6 || structquestion.getInteger("structType").intValue() == 8) {
-                        JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
+                    if (structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 6 || structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 8) {
+                        JSONArray structsubQuestions = structquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
                         for (int k = 0; k < structsubQuestions.size(); k++) {
                             JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
-                            JSONObject subbody = structsubquestion.getJSONObject("body");
+                            JSONObject subbody = structsubquestion.getJSONObject(SystemConstant.BODY);
                             disposeQuestionBodyUrl(rootDir, subbody, paper.getId(), attachmentDir);
-                            JSONArray suboptions = structsubquestion.getJSONArray("options");
+                            JSONArray suboptions = structsubquestion.getJSONArray(SystemConstant.OPTIONS);
                             disposeQuestionOptionsUrl(rootDir, suboptions, paper.getId(), attachmentDir);
                         }
                     }
                 }
             }
         }
-        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + ".json";
+        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX;
         paper.setPaperViewPath(filePath);
         ossUtil.upload(false, filePath, structJson.toJSONString());
     }
@@ -360,7 +360,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         for (int i = 0; i < options.size(); i++) {
             JSONObject option = options.getJSONObject(i);
             if (option != null) {
-                JSONObject body = option.getJSONObject("body");
+                JSONObject body = option.getJSONObject(SystemConstant.BODY);
                 if (body != null) {
                     JSONArray sections = body.getJSONArray("sections");
                     if (sections != null && sections.size() > 0) {
@@ -409,18 +409,18 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
             return;
         }
         JSONObject paperJson = JSONObject.parseObject(FileUtil.readFileContent(paperFile));
-        JSONArray details = paperJson.getJSONArray("details");
+        JSONArray details = paperJson.getJSONArray(SystemConstant.DETAILS);
         for (int i = 0; i < details.size(); i++) {
-            JSONArray questions = details.getJSONObject(i).getJSONArray("questions");
+            JSONArray questions = details.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             for (int j = 0; j < questions.size(); j++) {
                 JSONObject question = questions.getJSONObject(j);
-                question.remove("body");
-                question.remove("options");
-                Double score = question.getDouble("score");
+                question.remove(SystemConstant.BODY);
+                question.remove(SystemConstant.OPTIONS);
+                Double score = question.getDouble(SystemConstant.SCORE);
                 if (score == null) {
                     score = 0.0;
                 }
-                Integer structType = question.getInteger("structType");
+                Integer structType = question.getInteger(SystemConstant.STRUCT_TYPE);
                 if (structType.intValue() != 1 && structType.intValue() != 2 && structType.intValue() != 3
                         && structType.intValue() != 6 && structType.intValue() != 8) {//主观题
                     subTotal = subTotal.add(new BigDecimal(score));
@@ -428,16 +428,16 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                     obTotal = obTotal.add(new BigDecimal(score));
                 }
                 if (structType.intValue() == 6 || structType.intValue() == 8) {
-                    JSONArray subQuestions = question.getJSONArray("subQuestions");
+                    JSONArray subQuestions = question.getJSONArray(SystemConstant.SUB_QUESTIONS);
                     for (int k = 0; k < subQuestions.size(); k++) {
                         JSONObject subquestion = subQuestions.getJSONObject(k);
-                        subquestion.remove("body");
-                        subquestion.remove("options");
-                        Double subScore = subquestion.getDouble("score");
+                        subquestion.remove(SystemConstant.BODY);
+                        subquestion.remove(SystemConstant.OPTIONS);
+                        Double subScore = subquestion.getDouble(SystemConstant.SCORE);
                         if (subScore == null) {
                             subScore = 0.0;
                         }
-                        Integer subStructType = subquestion.getInteger("structType");
+                        Integer subStructType = subquestion.getInteger(SystemConstant.STRUCT_TYPE);
                         if (subStructType.intValue() != 1 && subStructType.intValue() != 2
                                 && subStructType.intValue() != 3) {//主观题
                             subTotal = subTotal.add(new BigDecimal(subScore));
@@ -448,7 +448,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                 }
             }
         }
-        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + ".json";
+        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX;
         paper.setStructPath(filePath);
         ByteArrayOutputStream out = null;
         try {
@@ -475,40 +475,40 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
             return;
         }
         JSONObject answerJson = JSONObject.parseObject(FileUtil.readFileContent(answerFile));
-        JSONArray answerdetails = answerJson.getJSONArray("details");
+        JSONArray answerdetails = answerJson.getJSONArray(SystemConstant.DETAILS);
         JSONObject structJson = JSONObject.parseObject(FileUtil.readFileContent(structFile));
-        JSONArray structdetails = structJson.getJSONArray("details");
+        JSONArray structdetails = structJson.getJSONArray(SystemConstant.DETAILS);
         for (int i = 0; i < answerdetails.size(); i++) {
-            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray("questions");
-            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
+            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
+            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             for (int j = 0; j < answerdetailquestions.size(); j++) {
                 JSONObject answerquestion = answerdetailquestions.getJSONObject(j);
                 JSONObject structquestion = structdetailquestions.getJSONObject(j);
-                int structType = structquestion.getInteger("structType").intValue();
-                answerquestion.put("structType", structType);
-                answerquestion.put("score", structquestion.getDouble("score"));
+                int structType = structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue();
+                answerquestion.put(SystemConstant.STRUCT_TYPE, structType);
+                answerquestion.put(SystemConstant.SCORE, structquestion.getDouble(SystemConstant.SCORE));
                 if (structType != 1 && structType != 2 && structType != 3 && structType != 6 && structType != 8) {
-                    JSONArray answer = answerquestion.getJSONArray("answer");
+                    JSONArray answer = answerquestion.getJSONArray(SystemConstant.ANSWER);
                     disposeAnswerUrl(rootDir, answer, paper.getId(), attachmentDir);
                 }
-                if (structquestion.getInteger("structType").intValue() == 6 || structquestion.getInteger("structType").intValue() == 8) {
-                    JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
-                    JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
+                if (structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 6 || structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 8) {
+                    JSONArray answersubQuestions = answerquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
+                    JSONArray structsubQuestions = structquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
                     for (int k = 0; k < answersubQuestions.size(); k++) {
                         JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
                         JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
-                        int subStructType = structsubquestion.getInteger("structType").intValue();
-                        answersubquestion.put("structType", subStructType);
-                        answersubquestion.put("score", structsubquestion.getDouble("score"));
+                        int subStructType = structsubquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue();
+                        answersubquestion.put(SystemConstant.STRUCT_TYPE, subStructType);
+                        answersubquestion.put(SystemConstant.SCORE, structsubquestion.getDouble(SystemConstant.SCORE));
                         if (subStructType != 1 && subStructType != 2 && subStructType != 3) {
-                            JSONArray answer = answersubquestion.getJSONArray("answer");
+                            JSONArray answer = answersubquestion.getJSONArray(SystemConstant.ANSWER);
                             disposeAnswerUrl(rootDir, answer, paper.getId(), attachmentDir);
                         }
                     }
                 }
             }
         }
-        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + ".json";
+        String filePath = DateUtil.format(new Date(), Constants.DATE_PATTERN) + "/" + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX;
         paper.setAnswerPath(filePath);
         ossUtil.upload(false, filePath, answerJson.toJSONString());
     }
@@ -694,15 +694,15 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
 
     private void compareAnswerAndPaper(String courseCode, String paperCode, File answerFile, File structFile) {
         JSONObject answerJson = JSONObject.parseObject(FileUtil.readFileContent(answerFile));
-        JSONArray answerdetails = answerJson.getJSONArray("details");
+        JSONArray answerdetails = answerJson.getJSONArray(SystemConstant.DETAILS);
         JSONObject structJson = JSONObject.parseObject(FileUtil.readFileContent(structFile));
-        JSONArray structdetails = structJson.getJSONArray("details");
+        JSONArray structdetails = structJson.getJSONArray(SystemConstant.DETAILS);
         if (answerdetails.size() != structdetails.size()) {
             throw new BusinessException("科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷大题数量不一致");
         }
         for (int i = 0; i < answerdetails.size(); i++) {
-            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray("questions");
-            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray("questions");
+            JSONArray answerdetailquestions = answerdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
+            JSONArray structdetailquestions = structdetails.getJSONObject(i).getJSONArray(SystemConstant.QUESTIONS);
             if (answerdetailquestions.size() != structdetailquestions.size()) {
                 throw new BusinessException(
                         "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题的小题数量不一致");
@@ -710,26 +710,26 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
             for (int j = 0; j < answerdetailquestions.size(); j++) {
                 JSONObject answerquestion = answerdetailquestions.getJSONObject(j);
                 JSONObject structquestion = structdetailquestions.getJSONObject(j);
-                if (structquestion.getInteger("structType").intValue() == 1
-                        || structquestion.getInteger("structType").intValue() == 2) {
-                    JSONArray answer = answerquestion.getJSONArray("answer");
+                if (structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 1
+                        || structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 2) {
+                    JSONArray answer = answerquestion.getJSONArray(SystemConstant.ANSWER);
                     if (answer == null || answer.size() == 0) {
                         throw new BusinessException(
                                 "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
                                         + "小题没有答案");
                     }
                 }
-                if (structquestion.getInteger("structType").intValue() == 3) {
-                    Boolean answer = answerquestion.getBoolean("answer");
+                if (structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 3) {
+                    Boolean answer = answerquestion.getBoolean(SystemConstant.ANSWER);
                     if (answer == null) {
                         throw new BusinessException(
                                 "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
                                         + "小题没有答案");
                     }
                 }
-                if (structquestion.getInteger("structType").intValue() == 6) {
-                    JSONArray answersubQuestions = answerquestion.getJSONArray("subQuestions");
-                    JSONArray structsubQuestions = structquestion.getJSONArray("subQuestions");
+                if (structquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 6) {
+                    JSONArray answersubQuestions = answerquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
+                    JSONArray structsubQuestions = structquestion.getJSONArray(SystemConstant.SUB_QUESTIONS);
                     if (answersubQuestions.size() != structsubQuestions.size()) {
                         throw new BusinessException(
                                 "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
@@ -738,17 +738,17 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
                     for (int k = 0; k < answersubQuestions.size(); k++) {
                         JSONObject answersubquestion = answersubQuestions.getJSONObject(k);
                         JSONObject structsubquestion = structsubQuestions.getJSONObject(k);
-                        if (structsubquestion.getInteger("structType").intValue() == 1
-                                || structsubquestion.getInteger("structType").intValue() == 2) {
-                            JSONArray answer = answersubquestion.getJSONArray("answer");
+                        if (structsubquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 1
+                                || structsubquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 2) {
+                            JSONArray answer = answersubquestion.getJSONArray(SystemConstant.ANSWER);
                             if (answer == null || answer.size() == 0) {
                                 throw new BusinessException(
                                         "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)
                                                 + "小题第" + (k + 1) + "子题没有答案");
                             }
                         }
-                        if (structsubquestion.getInteger("structType").intValue() == 3) {
-                            Boolean answer = answersubquestion.getBoolean("answer");
+                        if (structsubquestion.getInteger(SystemConstant.STRUCT_TYPE).intValue() == 3) {
+                            Boolean answer = answersubquestion.getBoolean(SystemConstant.ANSWER);
                             if (answer == null) {
                                 throw new BusinessException(
                                         "科目 " + courseCode + " 试卷 " + paperCode + " 答案和试卷第" + (i + 1) + "大题第" + (j + 1)

+ 3 - 4
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultSimpleExportTemplete.java

@@ -3,7 +3,6 @@ package com.qmth.themis.business.templete.impl;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-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.ExamCacheBean;
@@ -18,6 +17,7 @@ import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import org.apache.poi.ss.usermodel.*;
@@ -95,11 +95,10 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
                 markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
             }
 
-            Gson gson = new Gson();
             if (Objects.nonNull(markResultSimpleExportDtoList) && markResultSimpleExportDtoList.size() > 0) {
                 for (MarkResultSimpleExportDto markResultSimpleExportDto : markResultSimpleExportDtoList) {
-                    MarkResultDto markResultDto = gson
-                            .fromJson(gson.toJson(markResultSimpleExportDto), MarkResultDto.class);
+                    MarkResultDto markResultDto = GsonUtil
+                            .fromJson(GsonUtil.toJson(markResultSimpleExportDto), MarkResultDto.class);
                     if (Objects.nonNull(markResultDto.getExamId())) {
                         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(markResultDto.getExamId());
                         TOeExamRecord tOeExamRecord = tOeExamRecordService

+ 4 - 5
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ExcelDynamicExport;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
@@ -26,6 +25,7 @@ import com.qmth.themis.business.templete.TaskExportTemplete;
 import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.util.FileUtil;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import org.apache.commons.io.FileUtils;
@@ -111,11 +111,10 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                 markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
             }
 
-            Gson gson = new Gson();
             if (Objects.nonNull(markResultSimpleExportDtoList) && markResultSimpleExportDtoList.size() > 0) {
                 for (MarkResultSimpleExportDto markResultSimpleExportDto : markResultSimpleExportDtoList) {
-                    MarkResultDto markResultDto = gson
-                            .fromJson(gson.toJson(markResultSimpleExportDto), MarkResultDto.class);
+                    MarkResultDto markResultDto = GsonUtil
+                            .fromJson(GsonUtil.toJson(markResultSimpleExportDto), MarkResultDto.class);
                     if (Objects.nonNull(markResultDto.getExamId())) {
                         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(markResultDto.getExamId());
                         TOeExamRecord tOeExamRecord = tOeExamRecordService
@@ -134,7 +133,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                     }
                 }
             }
-            List<MarkResultStandardExportDto> markResultStandardExportDtoList = gson.fromJson(gson.toJson(markResultSimpleExportDtoList),
+            List<MarkResultStandardExportDto> markResultStandardExportDtoList = GsonUtil.fromJson(GsonUtil.toJson(markResultSimpleExportDtoList),
                     new TypeToken<List<MarkResultStandardExportDto>>() {
                     }.getType());
             Map<Long, List<ExcelDto>> excelDtoMap = null;

+ 13 - 125
themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java

@@ -5,16 +5,12 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import com.qmth.themis.business.bean.admin.OpenRecordAnswerBean;
-import com.qmth.themis.business.bean.admin.OpenRecordAnswerStructBean;
 import com.qmth.themis.business.bean.admin.OpenRecordAnswerTempBean;
 import com.qmth.themis.business.bean.admin.OpenRecordNeedMarkBean;
 import com.qmth.themis.business.bean.cloudmark.FileUploadParams;
 import com.qmth.themis.business.bean.cloudmark.SaveExamParams;
 import com.qmth.themis.business.bean.cloudmark.SaveStudentParams;
 import com.qmth.themis.business.bean.cloudmark.SaveSubjectParams;
-import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -130,7 +126,6 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
         List<String> txtList = (List<String>) map.get("txtList");
         TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
         List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
-        Gson gson = new Gson();
         Set<String> roomCodeAndNameSet = new HashSet<>();
         Map<String, TEExamActivity> teExamActivityMap = (Map<String, TEExamActivity>) map.get("teExamActivityMap");
         Map<String, String> courseCodeMap = (Map<String, String>) map.get("courseCodeMap");
@@ -158,7 +153,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
         for (int i = 0; i < finalList.size(); i++) {
             LinkedMultiValueMap<Integer, Object> finalMap = finalList.get(i);
             List<Object> examStudentImportDtoList = finalMap.get(i);
-            List<ExamStudentImportDto> gsonList = gson.fromJson(GsonUtil.toJson(examStudentImportDtoList), new TypeToken<List<ExamStudentImportDto>>() {
+            List<ExamStudentImportDto> gsonList = GsonUtil.fromJson(GsonUtil.toJson(examStudentImportDtoList), new TypeToken<List<ExamStudentImportDto>>() {
             }.getType());
             ExamStudentImportForkJoin myTask = new ExamStudentImportForkJoin(0, examStudentImportDtoList.size() - 1, gsonList, modeEnum, teExamActivityMap, examId, orgId, createId);
             ForkJoinTask<Set<String>> forkJoinTask = forkJoinThreadPool.taskForkJoinPool().submit(myTask);
@@ -556,40 +551,11 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                             SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
                             courseCode,
                             t.getCourseName()));
-                    Gson gson = new Gson();
-                    OpenRecordNeedMarkBean openRecordNeedMarkBean = gson.fromJson(gson.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
+                    OpenRecordNeedMarkBean openRecordNeedMarkBean = GsonUtil.fromJson(GsonUtil.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
                     List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(tOeExamRecord.getId());
-                    if (!CollectionUtils.isEmpty(answersTemp)) {
-                        List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
-                        List<OpenRecordAnswerBean> finalAnswers = answers;
-                        answersTemp.forEach(s -> {
-                            OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
-                            try {
-                                openRecordAnswerBean.setAnswer(gson.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
-                                }.getType()));
-                            } catch (Exception e) {
-                                log.error("错误答案:{}", s.getAnswer(), e);
-                            }
-                            finalAnswers.add(openRecordAnswerBean);
-                        });
-                        openRecordNeedMarkBean.setAnswers(answers.stream().filter(answer -> {
-                            Map<String, Integer> struct = paperStructMap.get(tOeExamRecord.getPaperId());
-                            if (struct == null) {
-                                struct = teExamPaperService.getPaperStructCacheBean(tOeExamRecord.getPaperId());
-                                if (struct != null) {
-                                    paperStructMap.put(tOeExamRecord.getPaperId(), struct);
-                                } else {
-                                    log.error("找不到对应的试卷结构,paperId=" + tOeExamRecord.getPaperId());
-                                    return false;
-                                }
-                            }
-                            Integer type = struct.get(RedisKeyHelper
-                                    .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
-                                            answer.getSubIndex()));
-                            //过滤单选、多选、判断题
-                            return type != null && type != 1 && type != 2 && type != 3;
-                        }).collect(Collectors.toList()));
-                        File fileAnswerJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.ANSWER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
+                    openRecordNeedMarkBean = SystemConstant.filterAnswer(openRecordNeedMarkBean, answersTemp, paperStructMap);
+                    if (!CollectionUtils.isEmpty(openRecordNeedMarkBean.getAnswers())) {
+                        File fileAnswerJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.ANSWER.getCode() + File.separator + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX);
                         if (!fileAnswerJson.exists()) {
                             fileAnswerJson.getParentFile().mkdirs();
                             fileAnswerJson.createNewFile();
@@ -757,28 +723,28 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                         paperResult.put(SystemConstant.NAME, t.getName());
                         if (Objects.nonNull(t.getAnswerPath())) {
                             JSONArray detailCollection = new JSONArray();
-                            JSONArray paperDetails = paperResult.getJSONArray("details");
+                            JSONArray paperDetails = paperResult.getJSONArray(SystemConstant.DETAILS);
                             //解析答案JSON文件
                             JSONObject answerJson = JSONObject.parseObject(new String(ossUtil.download(false, t.getAnswerPath()), StandardCharsets.UTF_8));
-                            JSONArray answerDetails = answerJson.getJSONArray("details");
+                            JSONArray answerDetails = answerJson.getJSONArray(SystemConstant.DETAILS);
                             for (int j = 0; j < paperDetails.size(); j++) {
                                 //遍历所有大题
                                 JSONObject paperDetail = paperDetails.getJSONObject(j);
-                                JSONObject answerDetail = findJsonObject(answerDetails, paperDetail.getIntValue("number"));
+                                JSONObject answerDetail = SystemConstant.findJsonObject(answerDetails, paperDetail.getIntValue(SystemConstant.NUMBER));
                                 //按条件过滤需要的小题同时合并答案
-                                JSONArray questionCollection = filterQuestions(paperDetail.getJSONArray("questions"),
-                                        Objects.nonNull(answerDetail) ? answerDetail.getJSONArray("questions") : null, false,
+                                JSONArray questionCollection = SystemConstant.filterQuestions(paperDetail.getJSONArray(SystemConstant.QUESTIONS),
+                                        Objects.nonNull(answerDetail) ? answerDetail.getJSONArray(SystemConstant.QUESTIONS) : null, false,
                                         true);
                                 //有小题的情况下,本大题才需要被包含
                                 if (questionCollection.size() > 0) {
-                                    paperDetail.put("questions", questionCollection);
+                                    paperDetail.put(SystemConstant.QUESTIONS, questionCollection);
                                     detailCollection.add(paperDetail);
                                 }
                             }
-                            paperResult.put("details", detailCollection);
+                            paperResult.put(SystemConstant.DETAILS, detailCollection);
                         }
 
-                        File filePaperJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.PAPER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
+                        File filePaperJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.PAPER.getCode() + File.separator + SystemConstant.getUuid() + SystemConstant.JSON_PREFIX);
                         if (!filePaperJson.exists()) {
                             filePaperJson.getParentFile().mkdirs();
                             filePaperJson.createNewFile();
@@ -844,84 +810,6 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
         }
     }
 
-    /**
-     * 过滤答案
-     *
-     * @param array
-     * @param number
-     * @return
-     */
-    private JSONObject findJsonObject(JSONArray array, int number) {
-        if (array != null) {
-            for (int i = 0; i < array.size(); i++) {
-                JSONObject item = array.getJSONObject(i);
-                if (item.getIntValue("number") == number) {
-                    return item;
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 过滤题目
-     *
-     * @param questions
-     * @param answers
-     * @param acceptObjective
-     * @param acceptSubjective
-     * @return
-     */
-    private JSONArray filterQuestions(JSONArray questions, JSONArray answers, boolean acceptObjective,
-                                      boolean acceptSubjective) {
-        JSONArray collection = new JSONArray();
-        for (int i = 0; i < questions.size(); i++) {
-            JSONObject question = questions.getJSONObject(i);
-            //根据题号查找答案
-            JSONObject answer = findJsonObject(answers, question.getIntValue("number"));
-            boolean accept = true;
-            //判断结构类型
-            switch (question.getIntValue("structType")) {
-                case 1:
-                    //单选
-                case 2:
-                    //多选
-                case 3:
-                    //判断
-                    accept = acceptObjective;
-                    break;
-                case 4:
-                    //填空
-                case 5:
-                    //问答
-                    accept = acceptSubjective;
-                    break;
-                case 6:
-                    //套题
-                    //按条件过滤套题下所有子题
-                    JSONArray subAnswers = answer != null ? answer.getJSONArray("subQuestions") : null;
-                    JSONArray subCollection = filterQuestions(question.getJSONArray("subQuestions"), subAnswers,
-                            acceptObjective, acceptSubjective);
-                    //没有子题,则本题也被过滤掉
-                    if (subCollection.size() > 0) {
-                        question.put("subQuestions", subCollection);
-                    } else {
-                        accept = false;
-                    }
-                    break;
-                default:
-                    accept = false;
-            }
-            if (accept) {
-                if (answer != null) {
-                    question.put("answer", answer.get("answer"));
-                }
-                collection.add(question);
-            }
-        }
-        return collection;
-    }
-
     /**
      * 查询监考帐号是否存在
      *

+ 3 - 5
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -1,7 +1,6 @@
 package com.qmth.themis.exam.api;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.StudentParams;
@@ -35,6 +34,7 @@ import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.Platform;
 import com.qmth.themis.common.enums.Source;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.exam.config.ExamConstant;
@@ -50,7 +50,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import javax.validation.Valid;
 import java.io.File;
 import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
@@ -342,9 +341,8 @@ public class TEStudentController {
                 ExamRecordCacheUtil.getEndTime(recordId), ExamRecordCacheUtil.getOpeningSeconds(recordId),
                 ExamRecordCacheUtil.getMinDurationSeconds(recordId),
                 ExamRecordCacheUtil.getMaxDurationSeconds(recordId), ExamRecordCacheUtil.getForceFinish(recordId));
-        Gson gson = new Gson();
-        ExamActivityUnFinishBean examActivityUnFinishBean = gson
-                .fromJson(gson.toJson(teExamActivityWaitDto), ExamActivityUnFinishBean.class);
+        ExamActivityUnFinishBean examActivityUnFinishBean = GsonUtil
+                .fromJson(GsonUtil.toJson(teExamActivityWaitDto), ExamActivityUnFinishBean.class);
         examActivityUnFinishBean.setRecordId(recordId);
         return new ExamUnFinishBean(ec.getId(), ec.getName(), examActivityUnFinishBean);
     }

+ 4 - 6
themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketMobileServer.java

@@ -1,13 +1,11 @@
 package com.qmth.themis.exam.websocket;
 
 import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.WebsocketDto;
-import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.MqDtoService;
@@ -16,6 +14,7 @@ import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.exam.listener.service.MqOeLogicService;
 import com.qmth.themis.exam.websocket.interceptor.WebSocketMobileHandshakeInterceptor;
 import com.qmth.themis.exam.websocketTemplete.WebSocketMobileMessageTemplete;
@@ -174,10 +173,9 @@ public class WebSocketMobileServer implements Concurrently {
                     MqUtil mqUtil = SpringContextHolder.getBean(MqUtil.class);
                     MqDtoService mqDtoService = SpringContextHolder.getBean(MqDtoService.class);
 
-                    Gson gson = new Gson();
-                    WebsocketDto websocketDto = gson.fromJson(gson.toJson(jsonObject), WebsocketDto.class);
-                    jsonObject.getJSONObject("body").put(SystemConstant.RECORD_ID, this.recordId);
-                    websocketDto.setBody(jsonObject.getJSONObject("body"));
+                    WebsocketDto websocketDto = GsonUtil.fromJson(GsonUtil.toJson(jsonObject), WebsocketDto.class);
+                    jsonObject.getJSONObject(SystemConstant.BODY).put(SystemConstant.RECORD_ID, this.recordId);
+                    websocketDto.setBody(jsonObject.getJSONObject(SystemConstant.BODY));
                     //2022.04.13 补发exam_stop消息
                     ExamRecordStatusEnum statusEnum = ExamRecordCacheUtil.getStatus(this.recordId);
                     if (Objects.isNull(statusEnum)) {

+ 4 - 6
themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketOeServer.java

@@ -1,13 +1,11 @@
 package com.qmth.themis.exam.websocket;
 
 import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.WebsocketDto;
-import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.enums.ExamRecordStatusEnum;
 import com.qmth.themis.business.enums.MqTagEnum;
 import com.qmth.themis.business.enums.WebsocketStatusEnum;
@@ -18,6 +16,7 @@ import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.exam.listener.service.MqOeLogicService;
 import com.qmth.themis.exam.websocket.interceptor.WebSocketOeHandshakeInterceptor;
 import com.qmth.themis.exam.websocketTemplete.WebSocketOeMessageTemplete;
@@ -180,10 +179,9 @@ public class WebSocketOeServer implements Concurrently {
                 if (Objects.nonNull(jsonObject)) {
                     WebSocketOeMessageTemplete webSocketOeMessageTemplete = SpringContextHolder
                             .getBean(WebSocketOeMessageTemplete.class);
-                    Gson gson = new Gson();
-                    WebsocketDto websocketDto = gson.fromJson(gson.toJson(jsonObject), WebsocketDto.class);
-                    jsonObject.getJSONObject("body").put(SystemConstant.RECORD_ID, this.recordId);
-                    websocketDto.setBody(jsonObject.getJSONObject("body"));
+                    WebsocketDto websocketDto = GsonUtil.fromJson(GsonUtil.toJson(jsonObject), WebsocketDto.class);
+                    jsonObject.getJSONObject(SystemConstant.BODY).put(SystemConstant.RECORD_ID, this.recordId);
+                    websocketDto.setBody(jsonObject.getJSONObject(SystemConstant.BODY));
                     WebsocketTypeEnum websocketTypeEnum = WebsocketTypeEnum
                             .valueOf(websocketDto.getType().toUpperCase());
                     if (Objects.nonNull(websocketTypeEnum) && (websocketTypeEnum == WebsocketTypeEnum.SYNC_STATUS

+ 3 - 4
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.google.gson.Gson;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
@@ -26,6 +25,7 @@ import com.qmth.themis.business.util.TencentYunUtil;
 import com.qmth.themis.business.util.UidUtil;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.SimpleBeanUtil;
 import com.qmth.themis.mq.service.MqLogicService;
 import com.tencentcloudapi.vod.v20180717.models.MediaBasicInfo;
@@ -730,7 +730,6 @@ public class MqLogicServiceImpl implements MqLogicService {
     @Override
     @Transactional
     public void execMqLogLogic(MqDto mqDto, String key) {
-        Gson gson = new Gson();
         String tag = mqDto.getTag();
         if (Objects.equals(MqTagEnum.MONITOR_LOG.name(), tag)) {//监考日志
             TIeExamInvigilateCallLog tIeExamInvigilateCallLog = JacksonUtil
@@ -760,8 +759,8 @@ public class MqLogicServiceImpl implements MqLogicService {
                     .getOne(tIeExamInvigilateCallQueryWrapper);
             //根据examRecordId和source取TIeExamInvigilateCall记录
             if (Objects.isNull(tIeExamInvigilateCall)) {//没有新增
-                tIeExamInvigilateCall = gson
-                        .fromJson(gson.toJson(tIeExamInvigilateCallLog), TIeExamInvigilateCall.class);
+                tIeExamInvigilateCall = GsonUtil
+                        .fromJson(GsonUtil.toJson(tIeExamInvigilateCallLog), TIeExamInvigilateCall.class);
                 tIeExamInvigilateCall.setId(uidUtil.getId());
             } else {//否则更新
                 tIeExamInvigilateCall.setLiveUrl(tIeExamInvigilateCallLog.getLiveUrl());