Jelajahi Sumber

自测bug fix

lideyin 5 tahun lalu
induk
melakukan
49b24c09e1

+ 26 - 12
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/SyncExamDataCloudServiceProvider.java

@@ -10,18 +10,12 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.*;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.*;
 import cn.com.qmth.examcloud.core.oe.admin.service.*;
 import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
-import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
-import cn.com.qmth.examcloud.support.enums.SyncStatus;
-import cn.com.qmth.examcloud.support.examing.ExamBoss;
-import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
-import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
-import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -97,10 +91,6 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
     @Transactional
     @Override
     public SyncExamDataResp syncExamData(@RequestBody SyncExamDataReq req) {
-//        String sequenceLockKey = Constants.EXAM_SYNC_CONTROL_LOCK_PREFIX + req.getExamRecordData().getStudentId();
-//
-//        //添加考试同步控制全局锁,自动解锁
-//        SequenceLockHelper.getLock(sequenceLockKey);
 
         //校验考试记录是否已同步,如果已同步,则直接返回
         if (hasSynced(req.getExamRecordData().getId())) {
@@ -110,6 +100,9 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         //临时考试记录
         ExamRecordDataBean transitionExamRecordData = req.getExamRecordData();
 
+        //必须先更新考生的考试次数,同步考试记录会用
+        increaseUsedExamTimes(transitionExamRecordData.getExamStudentId());
+
         //同步考试记录,并返回真实的考试记录id
         Long realExamRecordDataId = syncExamRecordData(transitionExamRecordData);
 
@@ -149,7 +142,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         if (FaceBiopsyHelper.isFaceEnable(transitionExamRecordData.getRootOrgId(), transitionExamRecordData.getExamId(), transitionExamRecordData.getStudentId())) {
             //计算违纪自动审核结果(无人脸或活检失败)
             boolean isNoPhotoAndIllegality = (null == req.getExamCaptures() || req.getExamCaptures().isEmpty());//是否无照片
-            saveAutoAudit(transitionExamRecordData, isNoPhotoAndIllegality,realExamRecordDataId);
+            saveAutoAudit(transitionExamRecordData, isNoPhotoAndIllegality, realExamRecordDataId);
         }
 
         //同步后续处理
@@ -158,6 +151,27 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         return new SyncExamDataResp();
     }
 
+    /**
+     * 增加考试次数
+     *
+     * @param examStudentId
+     */
+    private void increaseUsedExamTimes(Long examStudentId) {
+        ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
+        if (null == examStudentEntity) {
+            throw new StatusException("100101", "考生id不正确");
+        }
+
+        Integer usedTimes = examStudentEntity.getUsedNum() == null
+                ? 0
+                : examStudentEntity.getUsedNum();
+
+        examStudentEntity.setUsedNum(usedTimes + 1);
+
+        examStudentRepo.saveAndFlush(examStudentEntity);
+
+    }
+
     /**
      * 添加考试记录的同步记录
      *
@@ -305,7 +319,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
 
     }
 
-    private void saveAutoAudit(ExamRecordDataBean examRecordData, boolean isNoPhotoAndIllegality,Long realExamRecordDataId) {
+    private void saveAutoAudit(ExamRecordDataBean examRecordData, boolean isNoPhotoAndIllegality, Long realExamRecordDataId) {
         //无照片违纪自动审核
         if (isNoPhotoAndIllegality) {
             examAuditService.saveExamAuditByNoPhoto(realExamRecordDataId);