瀏覽代碼

Merge branch 'master' of http://49.234.186.218:9000/root/ieplus

jinxia.mo 1 月之前
父節點
當前提交
4742bc4410

+ 0 - 8
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontPaperController.java

@@ -1,7 +1,5 @@
 package com.ruoyi.web.controller.front;
 
-import com.alibaba.fastjson2.JSONObject;
-import com.google.common.collect.Maps;
 import com.ruoyi.common.core.content.VistorContextHolder;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult2;
@@ -12,15 +10,10 @@ import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
 import com.ruoyi.enums.PaperType;
-import com.ruoyi.learn.domain.LearnKnowledgeTree;
-import com.ruoyi.learn.domain.LearnPaper;
 import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.domain.LearnTest;
-import com.ruoyi.learn.service.ILearnPaperQuestionService;
-import com.ruoyi.learn.service.ILearnPaperService;
 import com.ruoyi.learn.service.ILearnStudentService;
 import com.ruoyi.learn.service.ILearnTestService;
-import com.ruoyi.web.service.ExamService;
 import com.ruoyi.web.service.LearnTeacherService;
 import com.ruoyi.web.service.PaperService;
 import com.ruoyi.web.service.StudentService;
@@ -35,7 +28,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 

+ 6 - 4
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -35,6 +35,7 @@ public class ExamService {
     private final LearnExamineeMapper learnExamineeMapper;
     private final LearnStudentMapper learnStudentMapper;
     private final ILearnPlanService learnPlanService;
+    private final LearnQuestionsMapper learnQuestionsMapper;
     private Set<PaperType> paperTypeSet = Sets.newHashSet(PaperType.Real, PaperType.Custom, PaperType.Test);
     private final LearnPaperMapper paperMapper;
     private final LearnKnowledgeTreeMapper knowledgeTreeMapper;
@@ -44,7 +45,7 @@ public class ExamService {
     private final IAMarjorPlanService marjorPlanService;
     private final ISysUserService sysUserService;
 
-    public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService) {
+    public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService, LearnQuestionsMapper learnQuestionsMapper) {
         this.paperMapper = paperMapper;
         this.knowledgeTreeMapper = knowledgeTreeMapper;
         this.examineeMapper = examineeMapper;
@@ -56,6 +57,7 @@ public class ExamService {
         this.sysUserService = sysUserService;
         this.learnStudentMapper = learnStudentMapper;
         this.learnPlanService = learnPlanService;
+        this.learnQuestionsMapper = learnQuestionsMapper;
     }
 
     /**
@@ -102,7 +104,7 @@ public class ExamService {
         aCond.setExamineeId(examineeId);
         Map<Long, LearnAnswer> answerMap = learnAnswerMapper.selectLearnAnswerList(aCond).stream().collect(Collectors.toMap(LearnAnswer::getQuestionId, t -> t));
         LearnPaper learnPaper = learnPaperService.selectLearnPaperById(examinee.getPaperId());
-        List<PaperVO.QuestionAnswer> questionList = paperService.loadPaperQuestionAnswers(examinee.getPaperId(), answerMap, !examContinue);
+        List<PaperVO.QuestionAnswer> questionList = paperService.loadPaperQuestionAnswers(SecurityUtils.getUserId(), examinee.getPaperId(), answerMap, !examContinue);
         AnswerSheet answerSheet = buildAnswerSheet(learnPaper, examinee);
         answerSheet.setTotalCount(questionList.size());
         answerSheet.setWrongCount(examinee.getWrongCount());
@@ -123,7 +125,7 @@ public class ExamService {
         LearnAnswer aCond = new LearnAnswer();
         aCond.setExamineeId(answerSheet.getExamineeId());
         Map<Long, LearnAnswer> answerMap = learnAnswerMapper.selectLearnAnswerList(aCond).stream().collect(Collectors.toMap(LearnAnswer::getQuestionId, t -> t));
-        Map<Long, PaperVO.QuestionAnswer> questionMap = paperService.loadPaperQuestionAnswers(answerSheet.getPaperId(), answerMap, true).stream().collect(Collectors.toMap(PaperVO.QuestionAnswer::getId, t -> t));
+        Map<Long, PaperVO.QuestionAnswer> questionMap = paperService.loadPaperQuestionAnswers(null, exitExaminee.getPaperId(), answerMap, true).stream().collect(Collectors.toMap(PaperVO.QuestionAnswer::getId, t -> t));
 
         List<LearnAnswer> addList = Lists.newArrayList();
         List<LearnAnswer> updateList = Lists.newArrayList();
@@ -273,7 +275,7 @@ public class ExamService {
                 LearnAnswer aCond = new LearnAnswer();
                 aCond.setExamineeId(examinee.getExamineeId());
                 Map<Long, LearnAnswer> answerMap = learnAnswerMapper.selectLearnAnswerList(aCond).stream().collect(Collectors.toMap(LearnAnswer::getQuestionId, t -> t));
-                List<PaperVO.QuestionAnswer> questionList = paperService.loadPaperQuestionAnswers(examinee.getPaperId(), answerMap, false);
+                List<PaperVO.QuestionAnswer> questionList = paperService.loadPaperQuestionAnswers(SecurityUtils.getUserId(), examinee.getPaperId(), answerMap, false);
                 AnswerSheet answerSheet = buildAnswerSheet(existPaper, examinee);
                 answerSheet.setQuestions(questionList);
                 answerSheet.setKnowledgeId(existPaper.getRelateId());

+ 9 - 2
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -5,12 +5,15 @@ import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.enums.PaperStatus;
 import com.ruoyi.enums.PaperType;
 import com.ruoyi.enums.QuestionType;
 import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.mapper.*;
+import com.ruoyi.learn.service.ILearnQuestionsService;
+import com.ruoyi.learn.service.impl.LearnQuestionsServiceImpl;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.apache.commons.collections4.CollectionUtils;
@@ -31,12 +34,14 @@ public class PaperService {
     private final LearnPaperMapper paperMapper;
     private final LearnPaperQuestionMapper paperQuestionMapper;
     private final LearnQuestionsMapper questionsMapper;
+    private final ILearnQuestionsService learnQuestionsService;
 
 
-    PaperService(LearnPaperMapper paperMapper, LearnPaperQuestionMapper paperQuestionMapper, LearnQuestionsMapper questionsMapper) {
+    PaperService(LearnPaperMapper paperMapper, LearnPaperQuestionMapper paperQuestionMapper, LearnQuestionsMapper questionsMapper, ILearnQuestionsService learnQuestionsService) {
         this.paperMapper = paperMapper;
         this.paperQuestionMapper = paperQuestionMapper;
         this.questionsMapper = questionsMapper;
+        this.learnQuestionsService = learnQuestionsService;
     }
 
     public void test() {
@@ -91,8 +96,9 @@ public class PaperService {
         return paperQuestionList;
     }
 
-    public List<PaperVO.QuestionAnswer> loadPaperQuestionAnswers(Long paperId, Map<Long, LearnAnswer> answerMap, boolean withParse) {
+    public List<PaperVO.QuestionAnswer> loadPaperQuestionAnswers(Long userId, Long paperId, Map<Long, LearnAnswer> answerMap, boolean withParse) {
         List<LearnQuestions> questions = questionsMapper.selectQuestionByPaperId(paperId);
+        learnQuestionsService.fillCollectInfo(userId, questions);
         Map<String, PaperVO.QuestionAnswer> gropuMap = Maps.newHashMap();
         List<PaperVO.QuestionAnswer> paperQuestionList = Lists.newArrayList();
         LearnAnswer answer;
@@ -105,6 +111,7 @@ public class PaperService {
             }
             QuestionType qt = QuestionType.of(lqs.getQtpye());
             qs.setTypeId(qt.getVal());
+            qs.setIsFavorite(lqs.isCollect());
             if(null != answerMap && null != (answer = answerMap.get(lqs.getId()))) {
                 qs.setAnswerId(answer.getAnswerId());
                 qs.setAnswers(Arrays.asList(answer.getAnswer().split(",")));

+ 1 - 1
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnQuestionsServiceImpl.java

@@ -106,7 +106,7 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
 
     @Override
     public void fillCollectInfo(Long userId, List<LearnQuestions> questions) {
-        if (CollectionUtils.isEmpty(questions)) {
+        if (null == userId || CollectionUtils.isEmpty(questions)) {
             return;
         }
         List<Long> ids = questions.stream().map(LearnQuestions::getId).collect(Collectors.toList());