From a0877d9c0e2cf8678c025ecd88a5045d6e581e56 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 29 十月 2024 14:19:31 +0800
Subject: [PATCH] 试卷标题不能为空

---
 src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
index 4997be2..c68c3e0 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -117,7 +117,7 @@
             throw new RuntimeException("鍙兘淇敼杩樻湭寮�濮嬬殑鑰冭瘯");
         }
         BeanUtils.copyProperties(form, entity);
-        entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), null));
+        entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), new Date()));
         // 濡傛灉淇敼鎴愬姛鍙戦�乵q娑堟伅
         if (baseMapper.updateById(entity) > 0) {
             this.sendMQ(entity, entity.getUpdateVersion());
@@ -214,6 +214,7 @@
                 item.setExamPaperId(null);
             }
         });
+        //
         return Result.ok().data(page.getRecords()).total(page.getTotal());
     }
 
@@ -254,9 +255,9 @@
                 .one();
         if (Objects.nonNull(hasJoin)) {
             // 鍏佽鎻愪氦鍚庣户缁綔绛�
-//            if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
-//                throw new RuntimeException("鎮ㄥ凡鎻愪氦璇曞嵎锛岃鍕块噸澶嶄綔绛�");
-//            }
+            if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){
+                throw new RuntimeException("鎮ㄥ凡鎻愪氦璇曞嵎锛岃鍕块噸澶嶄綔绛�");
+            }
             StartExamVO startExamVO = new StartExamVO();
             startExamVO.setExamName(exam.getExamName());
             startExamVO.setId(hasJoin.getExamId());
@@ -381,7 +382,6 @@
                 doQuestionVO.setQuestionType(item.getQuestionType());
                 //澧炲姞棰樼洰鍒嗘暟
                 doQuestionVO.setQuestionScore(question.getScore());
-
                 // 棰樼洰鍓湰
                 QuestionAnswerCopyVO copy = new QuestionAnswerCopyVO();
                 copy.setId(question.getId());
@@ -514,7 +514,6 @@
         ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper)
                 .eq(ExamSubmitTemp::getExamId, submitData.getId())
                 .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId())
-                .eq(ExamSubmitTemp::getDeleted, 0)
                 .one();
 
         if (Objects.nonNull(one)) {
@@ -634,12 +633,14 @@
         for (PaperFixQuestionVO titleItem : titleItems) {
             for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) {
                 Integer questionId = doQuestionVO.getId();
-                Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
-                if (first.isPresent()) {
-                    QuestionAnswerCopyVO answerCopyVO = first.get();
-                    doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
-                    doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
-                    doQuestionVO.setDifficult(answerCopyVO.getDifficult());
+                if(questionId!=null) {
+                    Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst();
+                    if (first.isPresent()) {
+                        QuestionAnswerCopyVO answerCopyVO = first.get();
+                        doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect());
+                        doQuestionVO.setAnalyze(answerCopyVO.getAnalyze());
+                        doQuestionVO.setDifficult(answerCopyVO.getDifficult());
+                    }
                 }
             }
         }
@@ -954,7 +955,7 @@
     /**
      * 浣滃簾
      *
-     * @param examId
+     * @param id
      * @return {@link Result }
      * @author
      */
@@ -977,13 +978,8 @@
         Date currentTime = new Date();
         Date startTime = examInfo.getStartTime();
         Date endTime = examInfo.getEndTime();
-        if (currentTime.before(startTime)) {
-            examInfo.setStatus(ExamStatusEnum.NOT_START);
-        } else if (currentTime.after(startTime) && currentTime.before(endTime)) {
-            examInfo.setStatus(ExamStatusEnum.ING);
-        } else {
-            examInfo.setStatus(ExamStatusEnum.FINISHED);
-        }
+        ExamStatusEnum statusByTime = ExamStatusEnum.getStatusByTime(startTime, endTime, currentTime);
+        examInfo.setStatus(statusByTime);
         // 淇敼褰撳墠鐨勮�冭瘯鐘舵��
         new LambdaUpdateChainWrapper<>(examMapper)
                 .eq(Exam::getId, id)

--
Gitblit v1.8.0