deason 2 年之前
父節點
當前提交
4417a19011

+ 9 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordQuestionsServiceImpl.java

@@ -22,6 +22,8 @@ import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -34,6 +36,8 @@ import java.util.stream.Collectors;
 @Service("examRecordQuestionsService")
 public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsService {
 
+    private static final Logger log = LoggerFactory.getLogger(ExamRecordQuestionsServiceImpl.class);
+
     @Autowired
     private ExamRecordQuestionsRepo examRecordQuestionsRepo;
 
@@ -176,6 +180,11 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
             //如果考试作答记录id为空,则根据考试记录id获取考试作答记录,并将考试作答记录id保存至examRecordData表中
             examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
 
+            if (examRecordQuestions == null) {
+                log.warn("examRecordQuestions is null, examRecordDataId = {} examType:{}", examRecordData.getId(), examRecordData.getExamType());
+                throw new StatusException("201101", "examRecordQuestions为空");
+            }
+
             //将考试作答记录id保存至examRecordData表中,目的:纠正历史数据
             examRecordData.setExamRecordQuestionsId(examRecordQuestions.getId());
             examRecordDataRepo.updateExamRecordDataQuestionIdById(examRecordQuestions.getId(), examRecordData.getId());