From 3a8e1524dcf0eeb610d38123d5f0a3ef838379cd Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期一, 12 四月 2021 15:44:53 +0800
Subject: [PATCH] Merge branch '20210406-maqv2' into 20210412-youhua

---
 src/main/java/com/ots/project/exam/service/impl/ExamPaperAnswerServiceImpl.java |  137 +++++++++++++--------------------------------
 1 files changed, 40 insertions(+), 97 deletions(-)

diff --git a/src/main/java/com/ots/project/exam/service/impl/ExamPaperAnswerServiceImpl.java b/src/main/java/com/ots/project/exam/service/impl/ExamPaperAnswerServiceImpl.java
index 2e84856..de8fd52 100644
--- a/src/main/java/com/ots/project/exam/service/impl/ExamPaperAnswerServiceImpl.java
+++ b/src/main/java/com/ots/project/exam/service/impl/ExamPaperAnswerServiceImpl.java
@@ -1,5 +1,4 @@
 package com.ots.project.exam.service.impl;
-
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ots.common.enums.QuestionTypeEnum;
@@ -27,18 +26,15 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
-
 @Service
 public class ExamPaperAnswerServiceImpl implements ExamPaperAnswerService {
     private static final Logger log = LoggerFactory.getLogger(ExamPaperAnswerServiceImpl.class);
-
     @Autowired
     private TExamPaperMapper examPaperMapper;
     @Autowired
@@ -47,7 +43,6 @@
     private ITTextContentService textContentService;
     @Autowired
     private TQuestionMapper questionMapper;
-
     @Override
     public ExamPaperAnswerInfo calculateExamPaperAnswer(ExamPaperSubmitVM examPaperSubmitVM, ExamUser user) {
         ExamPaperAnswerInfo examPaperAnswerInfo = new ExamPaperAnswerInfo();
@@ -57,103 +52,85 @@
         List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class);
         List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList());
         List<TQuestion> questions = questionMapper.selectByIds(questionIds);
-
-        // 鏄惁璺冲埌涓嬩竴娈�
+        
         setWhichPart(examPaperSubmitVM, examPaperAnswerInfo, examPaperTitleItemObjects, questions);
-
         examPaperAnswerInfo.setExamPaper(examPaper);
-
         return examPaperAnswerInfo;
     }
-
-    // 鍒ゆ柇鏄惁璺冲埌涓嬩竴娈�
+    
     private void setWhichPart(ExamPaperSubmitVM examPaperSubmitVM, ExamPaperAnswerInfo examPaperAnswerInfo, List<ExamPaperTitleItemObject> examPaperTitleItemObjects, List<TQuestion> questions) {
-        // 鍒嗙墖涓嶈冻澶氬皯鍒嗕笉鑳界瓟棰�,绛旈鏈簲璇ョ殑鍒嗘暟鏄惁鍒颁簡闃�鍊笺��
+        
         if (Objects.isNull(examPaperSubmitVM.getPartOrder())) {
             return;
         }
         int answerPartOrder = examPaperSubmitVM.getPartOrder();
-
         SubmitReport submitReport = new SubmitReport();
         if (Objects.isNull(answerPartOrder)) {
             submitReport.setJump("this");
             examPaperAnswerInfo.setSubmitReport(submitReport);
             return;
         }
-
-        // 璁$畻鏄惁寰楀垎
+        
         List<ExamPaperSubmitItemVM> answerItems = examPaperSubmitVM.getAnswerItems();
-
-        // 鐢ㄦ埛绛旂殑閫夐」
-        // (questionId, content绛旂殑椤�)
+        
+        
         Map<Integer, String> answerContentMap = getAnswerContentMap(answerItems);
-
-        // 鍘熷鍒嗙墖
+        
         Map<Integer, QuestionPart> partMap = getParts(examPaperTitleItemObjects);
-
-        // 閭d竴棰樻槸閭d竴鐗�
-        // (questionId, partOrder)
+        
+        
         Map<Integer, Integer> questionPartOrdeMap = getQuestionPartOrdeMap(examPaperTitleItemObjects);
-        // 鐢ㄦ埛绛斿灏戝垎寰楀垎
-        // (partOrder, score)
+        
+        
         Map<Integer, Integer> partAnswerScoreMap = new HashMap<>();
-        // 鏈鏈潵搴旇寰楀灏戝垎
-        // (partOrder, score)
+        
+        
         Map<Integer, Integer> partQuestionScoreMap = new HashMap<>();
-        // 鐢ㄦ埛鏈鑰楁椂
+        
         Map<Integer, Integer> partAnswerTimeMap = new HashMap<>();
-
         setAnswerScoreMap(questions, answerContentMap, questionPartOrdeMap, partAnswerScoreMap, partQuestionScoreMap);
+        
 
-        // 鏈簲寰楀灏戝垎鍒颁簡闃�鍊笺��
-//        System.out.println("鏈搴旇寰楀灏戝垎锛�" + partQuestionScoreMap.get(answerPartOrder));
-//        System.out.println("鏈鏈�浣庡垎锛�" + partMap.get(answerPartOrder).getLowestScore());
-//        System.out.println("鑷繁寰楀垎锛�" + partAnswerScoreMap.get(answerPartOrder));
-//        if (Objects.nonNull(answerPartOrder) && partQuestionScoreMap.get(answerPartOrder) >= partMap.get(answerPartOrder).getLowestScore()) {
-//            if (partAnswerScoreMap.get(answerPartOrder) < partQuestionScoreMap.get(answerPartOrder)) {
-//                submitReport.setJump("next");
-//            } else {
-//                submitReport.setJump("this");
-//            }
-//        } else {
-//            submitReport.setJump("this");
-//        }
+
+
+
+
+
+
+
+
+
+
+
         examPaperAnswerInfo.setSubmitReport(submitReport);
-        // 鏃堕棿鐨勫垽鏂�
-
+        
     }
-
     private void setAnswerScoreMap(List<TQuestion> questions, Map<Integer, String> answerContentMap, Map<Integer, Integer> questionPartOrdeMap, Map<Integer, Integer> partAnswerScoreMap, Map<Integer, Integer> partQuestionScoreMap) {
         for (TQuestion tQuestion : questions) {
-            // 棰樼洰鐨勬
+            
             int partOrder = questionPartOrdeMap.get(tQuestion.getId().intValue());
-
-            // 鍒濆鍊奸泦鍚�
+            
             if (Objects.isNull(partQuestionScoreMap.get(partOrder))){
                 partQuestionScoreMap.put(partOrder, 0);
             }
-
             if (Objects.isNull(partAnswerScoreMap.get(partOrder))) {
                 partAnswerScoreMap.put(partOrder, 0);
             }
-
-            // 鏈潵搴旇鐨勫灏戝垎
-            // 鐢ㄦ埛鑳界瓟澶氬皯鍒嗗緱鍒�
+            
+            
             if (Objects.nonNull(answerContentMap.get(tQuestion.getId().intValue()))) {
                 setAnswerScoreMap(partQuestionScoreMap, tQuestion, partOrder);
             }
+            
 
-            // 鍒嗘暟鐨勫垽鏂�
-//            System.out.println("棰樼洰鍙凤細" + tQuestion.getId().intValue());
-//            System.out.println("棰樼洰鐨勬纭瓟妗堬細" + tQuestion.getCorrect());
-//            System.out.println("鑷繁閫夋嫨锛�" + answerContentMap.get(tQuestion.getId().intValue()));
+
+
             if (Objects.equals(tQuestion.getCorrect(), answerContentMap.get(tQuestion.getId().intValue()))) {
-                // 鐢ㄦ埛鑳界瓟澶氬皯鍒嗗緱鍒�
+                
                 setAnswerScoreMap(partAnswerScoreMap, tQuestion, partOrder);
             }
         }
     }
-
     private Map<Integer, Integer> getQuestionPartOrdeMap(List<ExamPaperTitleItemObject> examPaperTitleItemObjects) {
         Map<Integer, Integer> questionPartOrdeMap = new HashMap<>();
         for (ExamPaperTitleItemObject examPaperTitleItemObject : examPaperTitleItemObjects) {
@@ -164,17 +141,15 @@
         }
         return questionPartOrdeMap;
     }
-
     private Map<Integer, QuestionPart> getParts(List<ExamPaperTitleItemObject> examPaperTitleItemObjects) {
         List<QuestionPart> parts = examPaperTitleItemObjects.get(0).getParts();
-        // (partOrder, questionPart)
+        
         Map<Integer, QuestionPart> partMap = new HashMap<>();
         for (QuestionPart questionPart : parts) {
             partMap.put(questionPart.getPartOrder(), questionPart);
         }
         return partMap;
     }
-
     private Map<Integer, String> getAnswerContentMap(List<ExamPaperSubmitItemVM> answerItems) {
         Map<Integer, String> answerContentMap = new HashMap<>();
         answerItems.stream().forEach(answerItem ->{
@@ -182,7 +157,6 @@
         });
         return answerContentMap;
     }
-
     private void setAnswerScoreMap(Map<Integer, Integer> partQuestionScoreMap, TQuestion tQuestion, int partOrder) {
         int questonScore = Objects.nonNull(tQuestion.getScore()) ? tQuestion.getScore().intValue() : 0;
         if (Objects.nonNull(partQuestionScoreMap.get(partOrder))) {
@@ -192,24 +166,13 @@
             partQuestionScoreMap.put(partOrder, questonScore);
         }
     }
-
-    /**
-     * 鐢ㄦ埛鎻愪氦绛旀鐨勮浆鍖栧瓨鍌ㄥ璞�
-     *
-     * @param question               question
-     * @param customerQuestionAnswer customerQuestionAnswer
-     * @param examPaper              examPaper
-     * @param itemOrder              itemOrder
-     * @param user                   user
-     * @param now                    now
-     * @return ExamPaperQuestionCustomerAnswer
-     */
+    
     private ExamPaperQuestionCustomerAnswer ExamPaperQuestionCustomerAnswerFromVM(TQuestion question, ExamPaperSubmitItemVM customerQuestionAnswer, TExamPaper examPaper, Integer itemOrder, ExamUser user, Date now) {
         ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = new ExamPaperQuestionCustomerAnswer();
         examPaperQuestionCustomerAnswer.setQuestionId(question.getId().intValue());
         examPaperQuestionCustomerAnswer.setExamPaperId(examPaper.getId().intValue());
-        // examPaperQuestionCustomerAnswer.setWhichPart(question.getScore().intValue());
-        // examPaperQuestionCustomerAnswer.setSubjectId(examPaper.getSubjectId().intValue());
+        
+        
         examPaperQuestionCustomerAnswer.setItemOrder(itemOrder);
         examPaperQuestionCustomerAnswer.setCreateTime(now);
         examPaperQuestionCustomerAnswer.setCreateUser(user.getId());
@@ -222,14 +185,7 @@
         }
         return examPaperQuestionCustomerAnswer;
     }
-
-    /**
-     * 鍒ゆ柇鎻愪氦绛旀鏄惁姝g‘锛屼繚鐣欑敤鎴锋彁浜ょ殑绛旀
-     *
-     * @param examPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer
-     * @param question                        question
-     * @param customerQuestionAnswer          customerQuestionAnswer
-     */
+    
     private void setSpecialFromVM(ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer, TQuestion question, ExamPaperSubmitItemVM customerQuestionAnswer) {
         QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
         switch (questionTypeEnum) {
@@ -256,60 +212,47 @@
                 break;
         }
     }
-
-
     @Override
     public PageInfo<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVM requestVM) {
         return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
                 examPaperAnswerMapper.studentPage(requestVM));
     }
-
-
     @Override
     public String judge(ExamPaperSubmitVM examPaperSubmitVM) {
         return null;
     }
-
     @Override
     public ExamPaperSubmitVM examPaperAnswerToVM(Integer id) {
         return null;
     }
-
     @Override
     public Integer selectAllCount() {
         return null;
     }
-
     @Override
     public List<Integer> selectMothCount() {
         return null;
     }
-
     @Override
     public int deleteById(Integer id) {
         return 0;
     }
-
     @Override
     public int insert(ExamPaperAnswer record) {
         return examPaperAnswerMapper.insertSelective(record);
     }
-
     @Override
     public int insertByFilter(ExamPaperAnswer record) {
         return examPaperAnswerMapper.insertSelective(record);
     }
-
     @Override
     public ExamPaperAnswer selectById(Integer id) {
         return null;
     }
-
     @Override
     public int updateByIdFilter(ExamPaperAnswer record) {
         return 0;
     }
-
     @Override
     public int updateById(ExamPaperAnswer record) {
         return 0;

--
Gitblit v1.9.1