Browse Source

识别对照客户端调试修复

yin 3 months ago
parent
commit
716028b387

+ 9 - 6
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanOmrTaskServiceImpl.java

@@ -600,6 +600,7 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     @Transactional
     public ScanOmrTaskSaveDto submitTask(@NotNull List<ScanOmrTaskResultDto> results, @NotNull Long userId) {
         Long studentId = null;
+        MarkStudent markStudent = null;
         for (ScanOmrTaskResultDto result : results) {
             ScanOmrTask task = this.getById(result.getId());
             if (task == null) {
@@ -608,13 +609,15 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
             if (studentId == null) {
                 studentId = task.getStudentId();
             }
-            if (!Objects.equals(studentId, task.getStudentId())) {
-                throw new ParameterException("任务非同一个学生");
+            if(markStudent == null ){
+                markStudent = studentService.getById(studentId);
             }
-            MarkStudent markStudent = studentService.getById(studentId);
             if (markStudent == null) {
                 throw new ParameterException("考生不存在");
             }
+            if (!Objects.equals(studentId, task.getStudentId())) {
+                throw new ParameterException("任务非同一个学生");
+            }
             MarkPaper markPaper = markPaperService.getByExamIdAndCoursePaperId(markStudent.getExamId(),
                     markStudent.getCoursePaperId());
             if (markPaper == null) {
@@ -673,11 +676,11 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
                 task.setUserId(userId);
                 task.setUpdateTime(System.currentTimeMillis());
                 this.saveOrUpdate(task);
-                this.releaseByTask(markStudent);
             } finally {
                 concurrentService.getReadWriteLock(LockType.STUDENT + "-" + task.getStudentId()).writeLock().unlock();
             }
         }
+        this.releaseByTask(markStudent);
         ScanOmrTaskSaveDto vo = new ScanOmrTaskSaveDto();
         vo.setStudentId(studentId);
         vo.setUpdateTime(System.currentTimeMillis());
@@ -820,7 +823,7 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     @Override
     public boolean apply(MarkStudent t, Long userId) {
         TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
-        boolean lock = taskLock.add(t.getId(),userId.toString(), new HashSet<>());
+        boolean lock = taskLock.add(t.getId(),userId, new HashSet<>());
         // 上锁失败直接返回
         if (!lock) {
             return false;
@@ -844,6 +847,6 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     @Override
     public boolean hasApplied(MarkStudent t, Long userId) {
         TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
-        return taskLock.exist(t.getId(), userId.toString());
+        return taskLock.exist(t.getId(), userId);
     }
 }