| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.utils.arg; |
| | | import org.springblade.modules.exam.entity.ExamExaminationSubject; |
| | | import org.springblade.modules.exam.entity.ExamPaper; |
| | | import org.springblade.modules.exam.entity.ExamScore; |
| | | import org.springblade.modules.exam.entity.ExamSubjectChoices; |
| | | import org.springblade.modules.exam.excel.ExamScoreExcel; |
| | | import org.springblade.modules.exam.mapper.ExamScoreMapper; |
| | | import org.springblade.modules.exam.service.ExamPaperService; |
| | | import org.springblade.modules.exam.service.ExamScoreService; |
| | | import org.springblade.modules.exam.vo.ExamPaperSubjectVO; |
| | | import org.springblade.modules.exam.service.ExamSubjectChoicesService; |
| | | import org.springblade.modules.exam.vo.ExamResultVO; |
| | | import org.springblade.modules.exam.vo.ExamScoreVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.bstek.ureport.expression.model.condition.Join.and; |
| | | |
| | | /** |
| | | * 考试成绩服务实现类 |
| | |
| | | public class ExamScoreServiceImpl extends ServiceImpl<ExamScoreMapper, ExamScore> implements ExamScoreService { |
| | | |
| | | private final ExamPaperService examPaperService; |
| | | |
| | | private final ExamSubjectChoicesService examSubjectChoicesService; |
| | | |
| | | /** |
| | | * 自定义分页数据 |
| | |
| | | if (examScore.getExamResultVOS().size()>0){ |
| | | List<ExamResultVO> examResultVOS = examScore.getExamResultVOS(); |
| | | //获取试卷的内容(题号,答案) |
| | | ExamPaper examPaper = new ExamPaper(); |
| | | examPaper.setId(examScore.getPapersId()); |
| | | List<ExamExaminationSubject> examExaminationSubjects |
| | | = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects(); |
| | | // ExamPaper examPaper = new ExamPaper(); |
| | | // examPaper.setId(examScore.getPapersId()); |
| | | // List<ExamExaminationSubject> examExaminationSubjects |
| | | // = examPaperService.PagerSubject(examPaper).getExamExaminationSubjects(); |
| | | List<ExamSubjectChoices> list = examSubjectChoicesService.list(); |
| | | //比对考试结果 |
| | | //声明理论得分 |
| | | int theoryGrade = 0; |
| | | for (ExamResultVO examResultVO : examResultVOS) { |
| | | for (ExamExaminationSubject examExaminationSubject : examExaminationSubjects) { |
| | | for (ExamSubjectChoices es: list) { |
| | | //对比题目id |
| | | if (examResultVO.getSubjectChoicesId().equals(examExaminationSubject.getExamSubjectChoices().getId())) { |
| | | if (examResultVO.getSubjectChoicesId().equals(es.getId())) { |
| | | //对比答案 |
| | | |
| | | if (examExaminationSubject.getExamSubjectChoices().getChoicesType() == 2){ |
| | | if (es.getChoicesType() == 2 || es.getChoicesType() == 3){ |
| | | //判断题逻辑 |
| | | if (examResultVO.getValue().equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) { |
| | | if (examResultVO.getValue().equals(es.getAnswer())) { |
| | | theoryGrade += examResultVO.getGrade(); |
| | | } |
| | | }else if(examExaminationSubject.getExamSubjectChoices().getChoicesType() == 0 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 1){ |
| | | }else if(es.getChoicesType() == 0 || es.getChoicesType() == 1){ |
| | | //处理多选题的答案排序 |
| | | String[] split = examResultVO.getValue().split(","); |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | Arrays.sort(arrayCh); |
| | | String sub0 = Arrays.toString(arrayCh); |
| | | String sub = sub0.substring(1,sub0.length()-1).replaceAll(" ",""); |
| | | if (sub.equals(examExaminationSubject.getExamSubjectChoices().getAnswer())) { |
| | | if (sub.equals(es.getAnswer())) { |
| | | theoryGrade += examResultVO.getGrade(); |
| | | } |
| | | } |
| | | //移除当前试卷题目答案对象 |
| | | examExaminationSubjects.remove(examExaminationSubject); |
| | | list.remove(es); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | //保存成绩数据 |
| | | int i = baseMapper.insert(examScore); |
| | | //修改考试状态 |
| | | |
| | | if (i>0){ |
| | | //返回结果 |
| | | return true; |
| | |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 导入实操成绩 |
| | | * @param examScoreExcelList |
| | | * @param isCovered 是否覆盖 |
| | | */ |
| | | @Override |
| | | public void importExamScore(List<ExamScoreExcel> examScoreExcelList, Boolean isCovered) { |
| | | if (examScoreExcelList.size()>0){ |
| | | examScoreExcelList.forEach(examScoreExcel -> { |
| | | if (null!=examScoreExcel.getLearnGrade() && null!=examScoreExcel.getIdCardNo() && examScoreExcel.getIdCardNo()!=""){ |
| | | ExamScore examScore = baseMapper.getExamScoreInfoByIdCardNo(examScoreExcel.getIdCardNo()); |
| | | if (null!=examScore) { |
| | | examScore.setLearnGrade(examScoreExcel.getLearnGrade()); |
| | | if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) { |
| | | //合格 |
| | | examScore.setQualified(0); |
| | | } else { |
| | | //不合格 |
| | | examScore.setQualified(1); |
| | | } |
| | | //更新成绩数据 |
| | | baseMapper.updateById(examScore); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> scoreStatistics() { |
| | | return baseMapper.scoreStatistics(); |
| | | } |
| | | } |