Browse Source

修改考生考试次数不减少的BUG

chenken 7 years ago
parent
commit
1bf8997f52

+ 6 - 2
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -25,6 +25,7 @@ import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.service.examwork.entity.Exam;
 import cn.com.qmth.examcloud.service.examwork.service.ExamService;
+import cn.com.qmth.examcloud.service.examwork.service.ExamStudentService;
 
 /**
  * 考试服务API
@@ -42,6 +43,9 @@ public class ExamApi {
 
     @Autowired
     ExamStudentRepo examStudentRepo;
+    
+    @Autowired
+    ExamStudentService examStudentService;
 
     @ApiOperation(value="查询所有考试批次",notes = "分页带查询")
     @GetMapping("/exam/all/{curPage}/{pageSize}")
@@ -166,9 +170,9 @@ public class ExamApi {
 
     @ApiOperation(value = "网考初始化更新考务信息", notes = "网考初始化更新考务信息")
     @PutMapping("/exam/updateExamInfo")
-    public ResponseEntity disableUser(@RequestParam Long examId,@RequestParam Long examStuId) {
+    public ResponseEntity updateExamInfo(@RequestParam Long examId,@RequestParam Long examStuId) {
         examRepo.canNotDel(examId);
-        examStudentRepo.updateForFinished(examStuId,true);
+        examStudentService.updateExamStudentInfo(examStuId);
         return new ResponseEntity(HttpStatus.OK);
     }
 }

+ 20 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -701,6 +701,26 @@ public class ExamStudentService {
 			}
 		});
 	}
+	
+	/**
+	 * 当考生进入考试时
+	 * 1.设置考生不缺考
+	 * 2.考生考试次数加1
+	 * @param examStuId
+	 */
+	public void updateExamStudentInfo(Long examStuId){
+		 ExamStudent examStudent = examStudentRepo.findOne(examStuId);
+	     examStudent.setFinished(true);
+	     //进入考试时,判断考试次数是否小于考试信息(ecs_exam)中的考试次数,如果是,考试次数加一
+	     long examTimes = examStudent.getExam().getExamTimes();
+	     if(examTimes > examStudent.getNormalExamTimes()){
+	        examStudent.setNormalExamTimes(examStudent.getNormalExamTimes()+1);
+	     }
+	     examStudentRepo.save(examStudent);
+	}
+	
+	
+	
 	/**
 	 * 设置考生重考信息
 	 * @param examStudentId