|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ynfy.buss.exam.exam.enums.PaperState;
|
|
|
+import com.ynfy.buss.exam.exam.service.IExamService;
|
|
|
import com.ynfy.buss.exam.examreview.dto.ExamPreviewDTO;
|
|
|
import com.ynfy.buss.exam.examreview.dto.PreviewSubmitDTO;
|
|
|
import com.ynfy.buss.exam.examreview.entity.ExamReview;
|
|
@@ -24,10 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -51,6 +49,8 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
@Autowired
|
|
|
private IUserExamResultService userExamResultService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IExamService examService;
|
|
|
|
|
|
/**
|
|
|
* 统计需阅卷的考试
|
|
@@ -97,23 +97,36 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
throw new JeecgBootException("考题查询失败");
|
|
|
}
|
|
|
|
|
|
- //获取主观题
|
|
|
- List<UserExamQuestion> subjectiveList = userExamQuestionList.stream().filter(o -> o.getQuestionType()
|
|
|
- .equals(QuestionType.SIMPLE.getCode())).collect(Collectors.toList());
|
|
|
- Map<Integer, UserExamQuestion> subjectiveMap = subjectiveList.stream().collect(Collectors
|
|
|
- .toMap(UserExamQuestion::getQuestionIndex, a -> a, (k1, k2) -> k1));
|
|
|
+ List<UserExamQuestion> rootQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && !r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ List<UserExamQuestion> childQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(rootQuestionList)) {
|
|
|
+ //组装题目、子题目和答案
|
|
|
+ examService.assembleUserExamQuestion(dto.getUserExamId(), rootQuestionList, childQuestionList, true, false, true, true, false);
|
|
|
+ }
|
|
|
+ Map<Integer, UserExamQuestion> userExamQuestionMap = rootQuestionList.stream().collect(Collectors.toMap(UserExamQuestion::getQuestionIndex, a -> a, (k1, k2) -> k1));
|
|
|
+
|
|
|
List<ExamPreviewDTO> examPreviews = dto.getExamPreviews();
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(examPreviews)) {
|
|
|
+ List<UserExamQuestion> resultList = new ArrayList<>();
|
|
|
int subjectiveScore = 0;
|
|
|
for (ExamPreviewDTO o : examPreviews) {
|
|
|
- UserExamQuestion userExamQuestion = subjectiveMap.get(o.getIndex());
|
|
|
+ //根据题目序号中获取考题
|
|
|
+ UserExamQuestion userExamQuestion = examService.getUserExamQuestionByIndex(o.getIndex(), userExamQuestionMap);
|
|
|
+ if (Objects.isNull(userExamQuestion) || userExamQuestion.getQuestionType() != QuestionType.SIMPLE.getCode()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
userExamQuestion.setActualScore(o.getActualScore());
|
|
|
userExamQuestion.setIsRight(o.getIsRight());
|
|
|
+ resultList.add(userExamQuestion);
|
|
|
subjectiveScore += o.getActualScore();
|
|
|
}
|
|
|
//更新评分
|
|
|
- userExamQuestionService.updateBatchById(userExamQuestionList);
|
|
|
+ if(!CollectionUtils.isEmpty(resultList)){
|
|
|
+ userExamQuestionService.updateBatchById(resultList);
|
|
|
+ }
|
|
|
|
|
|
//用户得分,主观题得分,更新阅卷人,阅卷时间,考试状态
|
|
|
userExam.setSubjectiveScore(subjectiveScore);//主观题得分
|