BatchExamStudentsServiceImpl.java
2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.meishu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.meishu.model.BatchExamStudentsDO;
import com.meishu.mapper.BatchExamsStudentsMapper;
import com.meishu.service.BatchExamStudentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meishu.vo.exam.BatchExamStudentScoreVO;
import com.meishu.vo.paper.PapersVO;
import com.meishu.vo.student.StudentExamsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* <p>
* 学生考试映射表 服务实现类
* </p>
*
* @author Tuyp
* @since 2023-07-11
*/
@Service
public class BatchExamStudentsServiceImpl extends ServiceImpl<BatchExamsStudentsMapper, BatchExamStudentsDO> implements BatchExamStudentsService {
public List<PapersVO> exams(BatchExamStudentsDO studentExamsDO) throws Exception{
List<PapersVO> exams = this.baseMapper.exams(studentExamsDO.getStudentId());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (PapersVO vo : exams) {
//未开始 进行中 已结束
if (simpleDateFormat.parse(vo.getStartDate()).after(new Date())) {
vo.setStatus("未开始");
} else if (simpleDateFormat.parse(vo.getEndDate()).before(new Date())) {
vo.setStatus("已结束");
} else {
vo.setStatus("进行中");
}
//是否已经参加过考试了
BatchExamStudentsDO batchExamStudentsDO = this.baseMapper.selectOne(new QueryWrapper<BatchExamStudentsDO>()
.lambda()
.eq(BatchExamStudentsDO::getBatchExamId,vo.getId())
.eq(BatchExamStudentsDO::getStudentId,studentExamsDO.getStudentId()));
if (null == batchExamStudentsDO.getScore()){
vo.setSubmitStatus(false);
}else {
vo.setSubmitStatus(true);
}
}
return exams;
}
public List<StudentExamsVO> studentExams(BatchExamStudentsDO studentExamsDO) {
return this.baseMapper.studentScore(studentExamsDO.getStudentId());
}
public List<BatchExamStudentScoreVO> batchExamStudentScore(BatchExamStudentsDO batchExamStudentsDO) {
return this.baseMapper.batchExamStudentScore(batchExamStudentsDO.getBatchExamId());
}
}