From 05d651ca0168025ec451702f1df88dab4f2a9559 Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期五, 10 五月 2024 17:58:19 +0800 Subject: [PATCH] feat:新增补考按钮 --- src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java | 49 ++++++++++++++++++------------------------------- 1 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java index f434bc1..8db064e 100644 --- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java +++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java @@ -10,7 +10,7 @@ import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.PaperExcelVO; -import com.mindskip.xzs.queue.ExamPaperTimeTask; +import com.mindskip.xzs.repository.ExamPaperAnswerMapper; import com.mindskip.xzs.repository.ExamPaperMapper; import com.mindskip.xzs.repository.QuestionMapper; import com.mindskip.xzs.repository.UserDepartmentMapper; @@ -20,22 +20,21 @@ import com.mindskip.xzs.utility.ExamUtil; import com.mindskip.xzs.utility.JsonUtil; import com.mindskip.xzs.utility.ModelMapperSingle; -import com.mindskip.xzs.utility.minio.DateUtils; import com.mindskip.xzs.viewmodel.admin.exam.*; import com.mindskip.xzs.viewmodel.admin.question.ExamQuestionVO; import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM; import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter; import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo; import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM; +import org.apache.commons.lang3.ObjectUtils; import org.modelmapper.ModelMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.util.*; -import java.util.concurrent.DelayQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -44,6 +43,7 @@ protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); private final ExamPaperMapper examPaperMapper; + private final ExamPaperAnswerMapper examPaperAnswerMapper; private final QuestionMapper questionMapper; private final TextContentService textContentService; private final QuestionService questionService; @@ -55,29 +55,14 @@ private final UserService userService; private final UserDepartmentMapper userDepartmentMapper; private final DepartmentService departmentService; - private final DelayQueue<ExamPaperTimeTask> QUEUE = new DelayQueue<>(); - /** - * 灏嗚繘琛屼腑鐨勫畾鏃惰瘯鍗峰姞鍏ュ埌闃熷垪涓紝骞跺惎鍔ㄤ竴涓嚎绋嬫潵杞闃熷垪 - */ - @PostConstruct - public void pollQueue() { - examPaperMapper.selectTimeTaskPaper(DateUtils.getNowDate()).forEach(this::addTimeTask); - new Thread(() -> { - try { - ExamPaperTimeTask task = QUEUE.take(); - saveMissExamUser(task.getExamPaperId()); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - }).start(); - } @Autowired - public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { + public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, ExamPaperAnswerMapper examPaperAnswerMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { super(examPaperMapper); this.examPaperMapper = examPaperMapper; + this.examPaperAnswerMapper = examPaperAnswerMapper; this.questionMapper = questionMapper; this.textContentService = textContentService; this.questionService = questionService; @@ -617,15 +602,17 @@ } @Override - public void addTimeTask(ExamPaper examPaper) { - ExamPaperTimeTask examPaperTimeTask = new ExamPaperTimeTask(); - examPaperTimeTask.setExamPaperId(examPaper.getId()); - examPaperTimeTask.setExpiry(examPaper.getLimitEndTime().getTime()); - QUEUE.add(examPaperTimeTask); - } - - @Override - public void saveMissExamUser(long examPaperId) { - examPaperMapper.saveMissExamUser(examPaperId); + @Transactional + public void missExam(ExamPaperEditRequestVM model) { + // 淇敼鍘熸潵鐨勮瘯鍗锋椂闂� + if (ObjectUtils.isNotEmpty(model.getLimitDateTime())) { + ExamPaper examPaper = new ExamPaper(); + examPaper.setId(model.getExamPaperId()); + examPaper.setLimitStartTime(DateTimeUtil.parse(model.getLimitDateTime().get(0), DateTimeUtil.STANDER_FORMAT)); + examPaper.setLimitEndTime(DateTimeUtil.parse(model.getLimitDateTime().get(1), DateTimeUtil.STANDER_FORMAT)); + examPaperMapper.updateByPrimaryKeySelective(examPaper); + } + // 鏍规嵁鑰冭瘯id灏嗛�夋嫨鐨勮ˉ鑰冭�冪敓鐨勮�冭瘯鎴愮哗璁剧疆涓烘棤鏁� + examPaperAnswerMapper.setMissExam(model); } } -- Gitblit v1.8.0