| | |
| | | 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.service.ExamSubjectChoicesService; |
| | | import org.springblade.modules.exam.vo.ExamResultVO; |
| | | import org.springblade.modules.exam.vo.ExamScoreVO; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | 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 || examExaminationSubject.getExamSubjectChoices().getChoicesType() == 3){ |
| | | 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); |
| | | //内网新增 |
| | | try { |
| | | //arg.test01(arg.url+"/examScore/save",examScore); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //修改考试状态 |
| | | |
| | | if (i>0){ |
| | | //返回结果 |
| | | return true; |