| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.ycl.jxkg.context.WebContext; |
| | | import com.ycl.jxkg.domain.entity.Exam; |
| | | import com.ycl.jxkg.domain.entity.ExamSubmitTemp; |
| | | import com.ycl.jxkg.domain.entity.Question; |
| | | import com.ycl.jxkg.domain.vo.DoQuestionVO; |
| | | import com.ycl.jxkg.domain.vo.ExamSubmitVO; |
| | | import com.ycl.jxkg.domain.entity.*; |
| | | import com.ycl.jxkg.domain.vo.*; |
| | | import com.ycl.jxkg.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.enums.general.ExamStatusEnum; |
| | | import com.ycl.jxkg.enums.general.ExamSubmitTempStatusEnum; |
| | | import com.ycl.jxkg.mapper.ExamMapper; |
| | | import com.ycl.jxkg.mapper.ExamSubmitTempMapper; |
| | | import com.ycl.jxkg.mapper.QuestionMapper; |
| | | import com.ycl.jxkg.mapper.*; |
| | | import com.ycl.jxkg.service.ExamService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.jxkg.domain.form.ExamForm; |
| | | import com.ycl.jxkg.domain.vo.ExamVO; |
| | | import com.ycl.jxkg.domain.query.ExamQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.ycl.jxkg.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private final WebContext webContext; |
| | | private final QuestionMapper questionMapper; |
| | | private final ExamSubmitTempMapper examSubmitTempMapper; |
| | | private final ClassesUserMapper classesUserMapper; |
| | | private final ExamPaperMapper examPaperMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | public Result page(ExamQuery query) { |
| | | IPage<ExamVO> page = PageUtil.getPage(query, ExamVO.class); |
| | | baseMapper.getPage(page, query); |
| | | page.getRecords().stream().forEach(item -> { |
| | | if (! StringUtils.hasText(item.getClassName())) { |
| | | item.setClassName("班级不存在或被删除"); |
| | | item.setClassesId(null); |
| | | } |
| | | if (! StringUtils.hasText(item.getExamPaperName())) { |
| | | item.setExamPaperName("试卷不存在或被删除"); |
| | | item.setExamPaperId(null); |
| | | } |
| | | }); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | examSubmitTemp.setStatus(status); |
| | | examSubmitTemp.setUserId(webContext.getCurrentUser().getId()); |
| | | examSubmitTemp.setExamSubmit(JSON.toJSONString(submitData.getQuestionList())); |
| | | examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.TEMP); |
| | | examSubmitTempMapper.insert(examSubmitTemp); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Result getMarkPaperInfo(Integer id) { |
| | | Exam exam = baseMapper.selectById(id); |
| | | if (Objects.isNull(exam)) { |
| | | throw new RuntimeException("该考试不存在"); |
| | | } |
| | | ExamPaper examPaper = examPaperMapper.selectById(exam.getExamPaperId()); |
| | | if (Objects.isNull(examPaper)) { |
| | | throw new RuntimeException("考试试卷不存在"); |
| | | } |
| | | List<ExamSubmitTemp> examSubmitTempList = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, id) |
| | | .list(); |
| | | // 参考人数 |
| | | Integer joinExamNum = examSubmitTempList.size(); |
| | | // 参考但未完成提交人数 |
| | | Integer joinButNotFinishedNum = Math.toIntExact(examSubmitTempList.stream().filter(item -> ExamSubmitTempStatusEnum.TEMP.equals(item.getStatus())).count()); |
| | | |
| | | List<StudentExamInfoVO> studentExamList = classesUserMapper.getClassesUserList(exam.getClassesId()); |
| | | // 应考人数 |
| | | Integer shouldUserNum = studentExamList.size(); |
| | | |
| | | studentExamList.stream().forEach(item -> { |
| | | if (StringUtils.hasText(item.getExamSubmit())) { |
| | | item.setQuestionList(JSON.parseArray(item.getExamSubmit(), DoQuestionVO.class)); |
| | | } |
| | | }); |
| | | |
| | | MarkPaperVO markPaperVO = new MarkPaperVO(); |
| | | markPaperVO.setExamName(exam.getExamName()); |
| | | markPaperVO.setExamId(exam.getId()); |
| | | markPaperVO.setJoinButNotFinishNum(joinButNotFinishedNum); |
| | | markPaperVO.setShouldJoinNum(shouldUserNum); |
| | | markPaperVO.setStudentExamInfoVOList(studentExamList); |
| | | markPaperVO.setMissJoinNum(shouldUserNum - joinExamNum); |
| | | markPaperVO.setJoinNum(joinExamNum); |
| | | markPaperVO.setExamPaperName(examPaper.getName()); |
| | | markPaperVO.setSuggestTime(examPaper.getSuggestTime()); |
| | | return Result.ok().data(markPaperVO); |
| | | } |
| | | } |