فهرست منبع

推送云阅卷功能修改

wangliang 2 سال پیش
والد
کامیت
3fc222ee39
16فایلهای تغییر یافته به همراه169 افزوده شده و 127 حذف شده
  1. 6 4
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java
  2. 1 1
      themis-admin/src/main/resources/application-main-temp.properties
  3. 1 1
      themis-admin/src/main/resources/application-test.properties
  4. 24 14
      themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/FileUploadParams.java
  5. 3 3
      themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveExamParams.java
  6. 9 9
      themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveStudentParams.java
  7. 26 26
      themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveSubjectParams.java
  8. 1 1
      themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/StudentScoreParams.java
  9. 7 0
      themis-business/src/main/java/com/qmth/themis/business/service/TOeExamRecordService.java
  10. 17 5
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java
  11. 26 24
      themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java
  12. 8 17
      themis-business/src/main/java/com/qmth/themis/business/util/CloudMarkUtil.java
  13. 37 19
      themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java
  14. 1 1
      themis-task/src/main/resources/application-dev.properties
  15. 1 1
      themis-task/src/main/resources/application-main-temp.properties
  16. 1 1
      themis-task/src/main/resources/application-test.properties

+ 6 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -509,10 +509,12 @@ public class TEExamController {
 //                examPropCountDto.get().setNotComplete(list.get(3) + list.get(4));
                 examPropCountDto.get().setNotComplete(list.get(3));
             }
-            BigDecimal completionRate = new BigDecimal(examPropCountDto.get().getAlreadyComplete())
-                    .divide(new BigDecimal(examPropCountDto.get().getAllCount()), 2, BigDecimal.ROUND_HALF_UP)
-                    .setScale(2, BigDecimal.ROUND_HALF_UP);
-            examPropCountDto.get().setCompletionRate(completionRate);
+            if (Objects.nonNull(examPropCountDto.get().getAllCount()) && examPropCountDto.get().getAllCount().intValue() > 0) {
+                BigDecimal completionRate = new BigDecimal(examPropCountDto.get().getAlreadyComplete())
+                        .divide(new BigDecimal(examPropCountDto.get().getAllCount()), 2, BigDecimal.ROUND_HALF_UP)
+                        .setScale(2, BigDecimal.ROUND_HALF_UP);
+                examPropCountDto.get().setCompletionRate(completionRate);
+            }
         }
 //        long end = System.currentTimeMillis();
 //        log.info("============prop/count耗时============:{}秒", (end - start) / 1000);

+ 1 - 1
themis-admin/src/main/resources/application-main-temp.properties

@@ -145,7 +145,7 @@ prefix.url.notify=api/notify
 no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/client/save,/api/admin/client/upload,/api/admin/client/query,/api/admin/app/save,/api/admin/app/query,/api/notify/monitor/record/tencent,/api/notify/monitor/status/tencent
 common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/sys/exam/privilegeQuery,/api/admin/student/photo/upload,/api/admin/sys/getPlayUrls,/api/admin/sys/exam/finish/query,/api/admin/sys/get_tencent_video
 
-cloud.mark.url=http://192.168.10.225:8000
+cloud.mark.url=http://192.168.10.225:8080
 cloud.mark.studentScoreApi=/api/exam/student/score
 cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save

+ 1 - 1
themis-admin/src/main/resources/application-test.properties

@@ -159,7 +159,7 @@ sys.config.adminLogoUrl=http://qmth-test.oss-cn-shenzhen.aliyuncs.com/frontend/w
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
-cloud.mark.url=http://192.168.10.225:8000
+cloud.mark.url=http://192.168.10.225:8080
 cloud.mark.studentScoreApi=/api/exam/student/score
 cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save

+ 24 - 14
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/FileUploadParams.java

@@ -37,48 +37,58 @@ public class FileUploadParams extends BaseParams implements Serializable {
     @ApiModelProperty(value = "文件md5")
     private String md5;
 
-    @ApiModelProperty(value = "文件类型")
+    @ApiModelProperty(value = "文件格式")
     private String format;
 
     @ApiModelProperty(value = "科目代码")
     private String subjectCode;
 
+    @ApiModelProperty(value = "文件类型")
+    private CloudMarkFileUploadTypeEnum type;
+
     public FileUploadParams() {
 
     }
 
-    public FileUploadParams(Long orgId, Long examId, String examNumber, File file) throws IOException {
+    public FileUploadParams(Long orgId, Long examId, String examNumber, File file, CloudMarkFileUploadTypeEnum type) throws IOException {
         super(orgId, null, null);
         this.examId = examId;
         this.examNumber = examNumber;
         this.file = file;
+        this.type = type;
         this.md5 = DigestUtils.md5Hex(new FileInputStream(file));
     }
 
-    public FileUploadParams(Long orgId, Long examId, String subjectCode, CloudMarkFileUploadTypeEnum format, File file) throws IOException {
+    public FileUploadParams(Long orgId, Long examId, String subjectCode, CloudMarkFileUploadTypeEnum format, File file, CloudMarkFileUploadTypeEnum type) throws IOException {
         super(orgId, null, null);
         this.examId = examId;
         this.subjectCode = subjectCode;
         this.format = format.getCode();
         this.file = file;
+        this.type = type;
         this.md5 = DigestUtils.md5Hex(new FileInputStream(file));
     }
 
-    public void vaildParamsType() {
-        if (Objects.isNull(this.format)) {
-            throw new BusinessException("文件类型不能为空");
-        }
+    public CloudMarkFileUploadTypeEnum getType() {
+        return type;
     }
 
-    public void vaildParams(CloudMarkFileUploadTypeEnum format) {
-        switch (format) {
+    public void setType(CloudMarkFileUploadTypeEnum type) {
+        this.type = type;
+    }
+
+    public void vaildParams() {
+        if (Objects.isNull(this.type)) {
+            throw new BusinessException("文件类型不能为空");
+        }
+        switch (this.type) {
             case JSON:
-                if (Objects.isNull(examNumber)) {
+                if (Objects.isNull(this.examNumber)) {
                     throw new BusinessException("准考证号不能为空");
                 }
                 break;
             case PAPER:
-                if (Objects.isNull(subjectCode)) {
+                if (Objects.isNull(this.subjectCode)) {
                     throw new BusinessException("科目编码不能为空");
                 }
                 if (Objects.isNull(this.format)) {
@@ -88,13 +98,13 @@ public class FileUploadParams extends BaseParams implements Serializable {
             default:
                 break;
         }
-        if (Objects.isNull(examId)) {
+        if (Objects.isNull(this.examId)) {
             throw new BusinessException("云阅卷考试id不能为空");
         }
-        if (Objects.isNull(file)) {
+        if (Objects.isNull(this.file)) {
             throw new BusinessException("文件不能为空");
         }
-        if (Objects.isNull(md5)) {
+        if (Objects.isNull(this.md5)) {
             throw new BusinessException("文件md5不能为空");
         }
     }

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveExamParams.java

@@ -64,13 +64,13 @@ public class SaveExamParams extends BaseParams implements Serializable {
      * 校验参数
      */
     public void vaildParams() {
-        if (Objects.isNull(id) && Objects.isNull(code)) {
+        if (Objects.isNull(this.id) && Objects.isNull(this.code)) {
             throw new BusinessException("id或code必填一个");
         }
-        if (Objects.isNull(name)) {
+        if (Objects.isNull(this.name)) {
             throw new BusinessException("考试名称不能为空");
         }
-        if (Objects.isNull(examTime)) {
+        if (Objects.isNull(this.examTime)) {
             throw new BusinessException("考试时间不能为空");
         }
     }

+ 9 - 9
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveStudentParams.java

@@ -91,31 +91,31 @@ public class SaveStudentParams extends BaseParams implements Serializable {
     }
 
     public void vaildParams() {
-        if (Objects.isNull(examId)) {
+        if (Objects.isNull(this.examId)) {
             throw new BusinessException("云阅卷考试id不能为空");
         }
-        if (Objects.isNull(examNumber)) {
+        if (Objects.isNull(this.examNumber)) {
             throw new BusinessException("准考证号不能为空");
         }
-        if (Objects.isNull(studentCode)) {
+        if (Objects.isNull(this.studentCode)) {
             throw new BusinessException("学号不能为空");
         }
-        if (Objects.isNull(name)) {
+        if (Objects.isNull(this.name)) {
             throw new BusinessException("姓名不能为空");
         }
-        if (Objects.isNull(college)) {
+        if (Objects.isNull(this.college)) {
             throw new BusinessException("学院不能为空");
         }
-        if (Objects.isNull(className)) {
+        if (Objects.isNull(this.className)) {
             throw new BusinessException("班级名称不能为空");
         }
-        if (Objects.isNull(teacher)) {
+        if (Objects.isNull(this.teacher)) {
             throw new BusinessException("教师不能为空");
         }
-        if (Objects.isNull(subjectCode)) {
+        if (Objects.isNull(this.subjectCode)) {
             throw new BusinessException("科目编码不能为空");
         }
-        if (Objects.isNull(subjectName)) {
+        if (Objects.isNull(this.subjectName)) {
             throw new BusinessException("科目名称不能为空");
         }
     }

+ 26 - 26
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/SaveSubjectParams.java

@@ -19,64 +19,64 @@ public class SaveSubjectParams extends BaseParams implements Serializable {
 
     @ApiModelProperty(value = "云阅卷考试id")
     @JsonSerialize(using = ToStringSerializer.class)
-    Long yunExamId;
+    Long examId;
 
     @ApiModelProperty(value = "科目编码")
-    String courseCode;
+    String code;
 
     @ApiModelProperty(value = "科目名称")
-    String courseName;
+    String name;
 
-    public SaveSubjectParams(Long orgId, Long yunExamId, String courseCode, String courseName) {
+    public SaveSubjectParams(Long orgId, Long examId, String code, String name) {
         super(orgId, null, null);
-        this.yunExamId = yunExamId;
-        this.courseCode = courseCode;
-        this.courseName = courseName;
+        this.examId = examId;
+        this.code = code;
+        this.name = name;
     }
 
-    public SaveSubjectParams(Long orgId, Long yunExamId, String courseCode, String courseName, String accessKey, String accessSecret) {
+    public SaveSubjectParams(Long orgId, Long examId, String code, String name, String accessKey, String accessSecret) {
         super(orgId, accessKey, accessSecret);
-        this.yunExamId = yunExamId;
-        this.courseCode = courseCode;
-        this.courseName = courseName;
+        this.examId = examId;
+        this.code = code;
+        this.name = name;
     }
 
     /**
      * 校验参数
      */
     public void vaildParams() {
-        if (Objects.isNull(yunExamId)) {
+        if (Objects.isNull(this.examId)) {
             throw new BusinessException("云阅卷考试id不能为空");
         }
-        if (Objects.isNull(courseCode)) {
+        if (Objects.isNull(this.code)) {
             throw new BusinessException("科目编码不能为空");
         }
-        if (Objects.isNull(courseName)) {
+        if (Objects.isNull(this.name)) {
             throw new BusinessException("科目名称不能为空");
         }
     }
 
-    public Long getYunExamId() {
-        return yunExamId;
+    public Long getExamId() {
+        return examId;
     }
 
-    public void setYunExamId(Long yunExamId) {
-        this.yunExamId = yunExamId;
+    public void setExamId(Long examId) {
+        this.examId = examId;
     }
 
-    public String getCourseCode() {
-        return courseCode;
+    public String getCode() {
+        return code;
     }
 
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
+    public void setCode(String code) {
+        this.code = code;
     }
 
-    public String getCourseName() {
-        return courseName;
+    public String getName() {
+        return name;
     }
 
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
+    public void setName(String name) {
+        this.name = name;
     }
 }

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/StudentScoreParams.java

@@ -44,7 +44,7 @@ public class StudentScoreParams extends BaseParams implements Serializable {
      * 校验参数
      */
     public void vaildParams() {
-        if (Objects.isNull(examId) && Objects.isNull(examCode)) {
+        if (Objects.isNull(this.examId) && Objects.isNull(this.examCode)) {
             throw new BusinessException("examId或examCode必填一个");
         }
     }

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TOeExamRecordService.java

@@ -548,4 +548,11 @@ public interface TOeExamRecordService extends IService<TOeExamRecord> {
      * @param recordId
      */
     public void saveDataByCachePersistedAnswer(Long recordId);
+
+    /**
+     * 修正考试状态
+     *
+     * @return
+     */
+    public List<TOeExamRecord> updateExamStatus();
 }

+ 17 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -388,7 +388,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                 er.setStatus(ExamRecordStatusEnum.PERSISTED);
                 er.setUpdateTime(timestamp);
             }
-            if (struct != null) {
+            if (Objects.nonNull(struct)) {
                 er.setPaperStructPath(structFilePath);
             }
             er.setPaperStructUpload(1);
@@ -409,11 +409,9 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
                 examAnswerService.saveOrUpdateBatch(tOeExamAnswerList);
             }
             //更新考生信息
-            if (Objects.nonNull(er)) {
-                teExamStudentService.updateExamStudentByCache(er.getExamStudentId());
-            }
+            teExamStudentService.updateExamStudentByCache(er.getExamStudentId());
             //上传个人试卷结构
-            if (struct != null) {
+            if (Objects.nonNull(struct)) {
                 ossUtil.upload(false, structFilePath, struct.getContent());
             }
         } finally {
@@ -1496,4 +1494,18 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             //考试断点延时消息 发送mq end
         }
     }
+
+    /**
+     * 修正考试状态
+     *
+     * @return
+     */
+    @Override
+    public List<TOeExamRecord> updateExamStatus() {
+        QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
+        tOeExamRecordQueryWrapper.lambda().isNotNull(TOeExamRecord::getFirstStartTime)
+                .isNotNull(TOeExamRecord::getFinishTime)
+                .eq(TOeExamRecord::getStatus, ExamRecordStatusEnum.FINISHED);
+        return this.list(tOeExamRecordQueryWrapper);
+    }
 }

+ 26 - 24
themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java

@@ -334,8 +334,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
 
         TEExam teExam = teExamService.cacheConvert(examCacheBean);
         if (Objects.isNull(tbTaskHistory.getEntityId())) {
-            cloudMarkExamId = cloudMarkUtil.callExamSaveApi(new SaveExamParams(orgId, examId, examCode, examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN)));
-//            cloudMarkExamId = Long.parseLong((int) (Math.random() * 1000) + "");
+            cloudMarkExamId = cloudMarkUtil.callExamSaveApi(new SaveExamParams(orgId, null, examCode, examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN)));
             teExam.setUpdateTime(System.currentTimeMillis());
             teExam.setThirdExamId(String.valueOf(cloudMarkExamId));
             teExamService.updateById(teExam);
@@ -438,22 +437,23 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
         Long examId = (Long) map.get(SystemConstant.EXAM_ID);
         TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
         List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.findExamRecordNeedMarkAll(examId, examPaperIdSet, false);
-        if (CollectionUtils.isEmpty(tOeExamRecordList)) {
-            throw new BusinessException("没有待阅卷的考试记录");
-        }
-        jsonObject.put("examRecordListSize", tOeExamRecordList.size());
+        if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
+            jsonObject.put("examRecordListSize", tOeExamRecordList.size());
 
-        Integer totalTaskSize = jsonObject.getInteger("totalTaskSize");
-        Integer currentTaskSize = jsonObject.getInteger("currentTaskSize");
+            Integer totalTaskSize = jsonObject.getInteger("totalTaskSize");
+            Integer currentTaskSize = jsonObject.getInteger("currentTaskSize");
 
-        BigDecimal progress = new BigDecimal(0);
-        BigDecimal b = new BigDecimal(100);
-        progress = new BigDecimal(currentTaskSize).divide(new BigDecimal(totalTaskSize), 2, BigDecimal.ROUND_HALF_UP).multiply(b);
-        if (Objects.isNull(tbTaskHistory.getProgress()) || (Objects.nonNull(tbTaskHistory.getProgress()) && tbTaskHistory.getProgress().doubleValue() < progress.doubleValue())) {
-            tbTaskHistory.setProgress(progress.doubleValue());
-            tbTaskHistoryService.updateById(tbTaskHistory);
+            BigDecimal progress = new BigDecimal(0);
+            BigDecimal b = new BigDecimal(100);
+            progress = new BigDecimal(currentTaskSize).divide(new BigDecimal(totalTaskSize), 2, BigDecimal.ROUND_HALF_UP).multiply(b);
+            if (Objects.isNull(tbTaskHistory.getProgress()) || (Objects.nonNull(tbTaskHistory.getProgress()) && tbTaskHistory.getProgress().doubleValue() < progress.doubleValue())) {
+                tbTaskHistory.setProgress(progress.doubleValue());
+                tbTaskHistoryService.updateById(tbTaskHistory);
+            }
+            tbTaskHistory.setRemark(jsonObject.toJSONString());
+        } else {
+            tOeExamRecordList = new ArrayList<>();
         }
-        tbTaskHistory.setRemark(jsonObject.toJSONString());
         return tOeExamRecordList;
     }
 
@@ -543,16 +543,19 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                     tbTaskHistory.setRemark(jsonObject.toJSONString());
                     continue;
                 } else {
-                    cloudMarkUtil.callStudentSaveApi(new SaveStudentParams(orgId, cloudMarkExamId, SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
+                    TOeExamRecord tOeExamRecord = tOeExamRecordMap.get(t.getId());
+                    if (Objects.isNull(tOeExamRecord)) {
+                        continue;
+                    }
+                    String courseCode = t.getCourseCode() + SystemConstant.JOINT_MARK + tOeExamRecord.getPaperId();
+                    cloudMarkUtil.callStudentSaveApi(new SaveStudentParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()),
                             t.getIdentity(),
                             t.getName(),
                             tbOrg.getName(),
-                            t.getClassNo(), SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
-                            t.getCourseCode(),
+                            Objects.isNull(t.getClassNo()) ? SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD : t.getClassNo(),
+                            SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
+                            courseCode,
                             t.getCourseName()));
-                    TOeExamRecord tOeExamRecord = tOeExamRecordMap.get(t.getId());
-                    Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
-
                     Gson gson = new Gson();
                     OpenRecordNeedMarkBean openRecordNeedMarkBean = gson.fromJson(gson.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
                     List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(tOeExamRecord.getId());
@@ -593,7 +596,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                     }
                     IOUtils.write(JacksonUtil.parseJson(openRecordNeedMarkBean).getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(fileAnswerJson));
                     recordJsonList.add(fileAnswerJson);
-                    cloudMarkUtil.callFileUploadApi(new FileUploadParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), fileAnswerJson));
+                    cloudMarkUtil.callFileUploadApi(new FileUploadParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), fileAnswerJson, CloudMarkFileUploadTypeEnum.JSON));
 
                     jsonObject.put("currentTaskSize", currentTaskSize);
                     currentTaskSize++;
@@ -782,8 +785,7 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                         }
                         IOUtils.write(paperResult.toJSONString().getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(filePaperJson));
                         paperJsonList.add(filePaperJson);
-                        FileUploadParams fileUploadParamsPaperJson = new FileUploadParams(orgId, cloudMarkExamId, courseCode, CloudMarkFileUploadTypeEnum.PAPER, filePaperJson);
-                        fileUploadParamsPaperJson.setFormat(CloudMarkFileUploadTypeEnum.JSON.getCode());
+                        FileUploadParams fileUploadParamsPaperJson = new FileUploadParams(orgId, cloudMarkExamId, courseCode, CloudMarkFileUploadTypeEnum.JSON, filePaperJson, CloudMarkFileUploadTypeEnum.PAPER);
                         cloudMarkUtil.callFileUploadApi(fileUploadParamsPaperJson);
 
                         jsonObject.put("currentTaskSize", currentTaskSize);

+ 8 - 17
themis-business/src/main/java/com/qmth/themis/business/util/CloudMarkUtil.java

@@ -6,7 +6,6 @@ import com.qmth.themis.business.bean.cloudmark.*;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.domain.CloudMarkDomain;
 import com.qmth.themis.business.entity.TBOrg;
-import com.qmth.themis.business.enums.CloudMarkFileUploadTypeEnum;
 import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
@@ -135,8 +134,7 @@ public class CloudMarkUtil {
             throw new BusinessException("云阅卷推送考试信息失败");
         }
         Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
-//        return Long.parseLong(String.valueOf(resultMap.get("id")));
-        return null;
+        return Long.parseLong(String.valueOf(resultMap.get("id")));
     }
 
     /**
@@ -162,8 +160,7 @@ public class CloudMarkUtil {
             throw new BusinessException("云阅卷推送考试科目信息失败");
         }
         Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
-//        return String.valueOf(resultMap.get("updateTime"));
-        return null;
+        return String.valueOf(resultMap.get("updateTime"));
     }
 
     /**
@@ -189,8 +186,7 @@ public class CloudMarkUtil {
             throw new BusinessException("云阅卷推送考生信息失败");
         }
         Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
-//        return String.valueOf(resultMap.get("updateTime"));
-        return null;
+        return String.valueOf(resultMap.get("updateTime"));
     }
 
     /**
@@ -201,22 +197,18 @@ public class CloudMarkUtil {
      * @throws IOException
      */
     public Boolean callFileUploadApi(FileUploadParams fileUploadParams) throws IOException {
-        fileUploadParams.vaildParamsType();
-        CloudMarkFileUploadTypeEnum cloudMarkFileUploadTypeEnum = CloudMarkFileUploadTypeEnum.convertToEnum(fileUploadParams.getFormat());
-        fileUploadParams.vaildParams(cloudMarkFileUploadTypeEnum);
+        fileUploadParams.vaildParams();
         this.getAccessKeyAndAccessSecret(fileUploadParams);
 
         String host = cloudMarkDomain.getUrl();
         String api = cloudMarkDomain.getFileUploadApi();
-        api = api.replaceAll(SystemConstant.FILE_UPLOAD_VARIABLE_URL, fileUploadParams.getFormat());
+        api = api.replaceAll(SystemConstant.FILE_UPLOAD_VARIABLE_URL, fileUploadParams.getType().getCode());
         String url = host + api;
         long timestamp = System.currentTimeMillis();
-        String accessToken = SignatureInfo.build(SignatureType.SECRET, SystemConstant.METHOD, cloudMarkDomain.getStudentSaveApi(), timestamp, fileUploadParams.getAccessKey(), fileUploadParams.getAccessSecret());
+        String accessToken = SignatureInfo.build(SignatureType.SECRET, SystemConstant.METHOD, api, timestamp, fileUploadParams.getAccessKey(), fileUploadParams.getAccessSecret());
         fileUploadParams.resetDefaultData();
-        if (cloudMarkFileUploadTypeEnum == CloudMarkFileUploadTypeEnum.JSON) {
-            fileUploadParams.setFormat(null);
-        }
         Map<String, Object> params = JSON.parseObject(JSON.toJSONString(fileUploadParams), Map.class);
+        params.remove("type");
         String result = HttpUtil.postFile(url, params, accessToken, timestamp);
         result = StringEscapeUtils.unescapeHtml4(result);
         if (result.contains("HTTP")) {
@@ -224,7 +216,6 @@ public class CloudMarkUtil {
             throw new BusinessException("云阅卷推送文件信息失败");
         }
         Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
-//        return (Boolean) resultMap.get("success");
-        return null;
+        return (Boolean) resultMap.get("success");
     }
 }

+ 37 - 19
themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java

@@ -3,9 +3,9 @@ package com.qmth.themis.task.quartz;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TEExamActivity;
-import com.qmth.themis.business.entity.TEExamStudent;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.ExamRecordStatusEnum;
 import com.qmth.themis.business.enums.FinishTypeEnum;
@@ -47,6 +47,9 @@ public class MqActivityJob extends QuartzJobBean {
     @Resource
     CommonService commonService;
 
+    @Resource
+    CacheService cacheService;
+
     /**
      * 每天凌晨定时任务
      *
@@ -132,26 +135,41 @@ public class MqActivityJob extends QuartzJobBean {
             teExamService.saveOrUpdateBatch(teExamList);
         }
 
-        //答案补救
-        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.persistedAnswerBatch(null, null, null);
+//        //答案补救
+//        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.persistedAnswerBatch(null, null, null);
+//        if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
+//            for (TOeExamRecord t : tOeExamRecordList) {
+//                try {
+//                    tOeExamRecordService.saveDataByCachePersistedAnswer(t.getId());
+//                } catch (Exception e) {
+//                    log.error(SystemConstant.LOG_ERROR, e);
+//                }
+//            }
+//        }
+//
+//        //更新考生缓存
+//        List<TEExamStudent> teExamStudentList = teExamStudentService.findAlreadyExamCountZero(null, null, null, null);
+//        if (!CollectionUtils.isEmpty(teExamStudentList)) {
+//            for (TEExamStudent t : teExamStudentList) {
+//                try {
+//                    teExamStudentService.updateExamStudentByCache(t.getId());
+//                } catch (Exception e) {
+//                    log.error(SystemConstant.LOG_ERROR, e);
+//                }
+//            }
+//        }
+
+        //修正考试状态
+        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.updateExamStatus();
         if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
             for (TOeExamRecord t : tOeExamRecordList) {
-                try {
-                    tOeExamRecordService.saveDataByCachePersistedAnswer(t.getId());
-                } catch (Exception e) {
-                    log.error(SystemConstant.LOG_ERROR, e);
-                }
-            }
-        }
-
-        //更新考生缓存
-        List<TEExamStudent> teExamStudentList = teExamStudentService.findAlreadyExamCountZero(null, null, null, null);
-        if (!CollectionUtils.isEmpty(teExamStudentList)) {
-            for (TEExamStudent t : teExamStudentList) {
-                try {
-                    teExamStudentService.updateExamStudentByCache(t.getId());
-                } catch (Exception e) {
-                    log.error(SystemConstant.LOG_ERROR, e);
+                if ((System.currentTimeMillis() - t.getFinishTime().longValue()) / 1000 / 60 >= 30) {//超过30分钟则改状态
+                    try {
+                        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(t.getExamStudentId());
+                        TEStudentCacheDto teStudent = cacheService.addStudentAccountCache(examStudentCacheBean.getStudentId());
+                        commonService.persisted(t.getId(), teStudent.getId());
+                    } catch (Exception e) {
+                    }
                 }
             }
         }

+ 1 - 1
themis-task/src/main/resources/application-dev.properties

@@ -218,7 +218,7 @@ tencentyun.sdk.trtcRegion=ap-guangzhou
 monitor.config.prefix=oe_test
 
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
-cloud.mark.url=http://192.168.10.225:8000
+cloud.mark.url=http://192.168.10.224:80
 cloud.mark.studentScoreApi=/api/exam/student/score
 cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save

+ 1 - 1
themis-task/src/main/resources/application-main-temp.properties

@@ -170,7 +170,7 @@ mq.config.map.WEBSOCKET_OE_MOBILE_GROUP=themis-group-exam-websocketOeMobile
 mq.config.map.TENCENT_VIDEO_GROUP=themis-group-exam-tencentVideo
 
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
-cloud.mark.url=http://192.168.10.225:8000
+cloud.mark.url=http://192.168.10.225:8080
 cloud.mark.studentScoreApi=/api/exam/student/score
 cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save

+ 1 - 1
themis-task/src/main/resources/application-test.properties

@@ -233,7 +233,7 @@ tencentyun.sdk.trtcRegion=ap-guangzhou
 monitor.config.prefix=oe_test
 
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
-cloud.mark.url=http://192.168.10.225:8000
+cloud.mark.url=http://192.168.10.225:8080
 cloud.mark.studentScoreApi=/api/exam/student/score
 cloud.mark.examSaveApi=/api/exam/save
 cloud.mark.subjectSaveApi=/api/exam/subject/save