| | |
| | | import org.springblade.modules.exam.util.SecurityPaperUtil; |
| | | import org.springblade.modules.exam.vo.ExamResultVO; |
| | | import org.springblade.modules.exam.vo.ExamScoreVO; |
| | | import org.springblade.modules.exam.vo.UpdateParamVo; |
| | | import org.springblade.modules.system.entity.Role; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IRoleService; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | |
| | | if(paper.getExamType()==2){ |
| | | TrainingRegistration trainingRegistration = new TrainingRegistration(); |
| | | trainingRegistration.setCandidateNo(examScore.getCandidateNo()); |
| | | trainingRegistration.setCancel(1); |
| | | TrainingRegistration trainingRegistration1 = trainingRegistrationService.getOne(Condition.getQueryWrapper(trainingRegistration)); |
| | | //查询用户年龄,根据年龄计算总分 |
| | | user = userService.getUserAgeById(Long.parseLong(trainingRegistration1.getUserId())); |
| | |
| | | int count = userService.getSecurityPaperCount(pre); |
| | | String result = null; |
| | | if (count == 0) { |
| | | result = pre + "00000"; |
| | | result = pre + "00001"; |
| | | } else { |
| | | //格式化 |
| | | DecimalFormat decimalFormat = new DecimalFormat("00000"); |
| | |
| | | public IPage<ExamScoreVO> scorePage(IPage page, String deptid, String jurisdiction) { |
| | | return page.setRecords(baseMapper.scorePage(page,deptid,jurisdiction)); |
| | | } |
| | | |
| | | /** |
| | | * 考试成绩及状态修改 |
| | | * @param updateParamVo |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateExamScore(UpdateParamVo updateParamVo) { |
| | | if (updateParamVo.getType()==1){ |
| | | //查询所有无成绩的数据 |
| | | List<ExamScore> noScoreInfoList = baseMapper.getNoScoreInfo(); |
| | | noScoreInfoList.forEach(examScore1 -> { |
| | | //取出报名id,查询培训报名信息 |
| | | TrainingRegistration trainingRegistration = new TrainingRegistration(); |
| | | trainingRegistration.setId(examScore1.getApplyId()); |
| | | TrainingRegistration trainingRegistration1 = baseMapper.getTrainInfo(trainingRegistration); |
| | | //修改考试状态 |
| | | trainingRegistration1.setIsExam(2); |
| | | trainingRegistrationService.updateById(trainingRegistration1); |
| | | if (null!=trainingRegistration1){ |
| | | //修改用户培训状态信息 |
| | | User user = new User(); |
| | | user.setIsTrain(3); |
| | | user.setId(Long.parseLong(trainingRegistration1.getUserId())); |
| | | //修改 |
| | | userService.updateById(user); |
| | | } |
| | | |
| | | //修改考试成绩 |
| | | //生成随机数,在60-79 之间 |
| | | int score = (int)(Math.random()*20); |
| | | int sc = score + 60; |
| | | examScore1.setTheoryGrade(sc); |
| | | examScore1.setTheoryGrade(score/2); |
| | | //设置为合格 |
| | | examScore1.setQualified(2); |
| | | examScore1.setCandidateNo(trainingRegistration1.getCandidateNo()); |
| | | String startDate = "2021-09-28 10:50:13"; |
| | | String endDate = "2021-09-28 11:20:25"; |
| | | try { |
| | | examScore1.setExamTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startDate)); |
| | | examScore1.setExamEndTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(endDate)); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | baseMapper.updateById(examScore1); |
| | | }); |
| | | } |
| | | |
| | | if (updateParamVo.getType()==2) { |
| | | //查询所有成绩不合格的数据(准考证号) |
| | | List<ExamScore> list = baseMapper.getDisqualificationExamInfo(); |
| | | if (list.size() > 0) { |
| | | list.forEach(examScore1 -> { |
| | | //修改考试成绩为合格 |
| | | //生成随机数,在60-79 之间 |
| | | int score = (int)((Math.random() * 20)); |
| | | int sc = score+60; |
| | | examScore1.setTheoryGrade(sc); |
| | | //设置为合格 |
| | | examScore1.setQualified(2); |
| | | if (null != examScore1.getLearnGrade()) { |
| | | examScore1.setTheoryGrade((examScore1.getLearnGrade() + score) / 2); |
| | | } else { |
| | | examScore1.setTheoryGrade(score / 2); |
| | | } |
| | | //修改 |
| | | baseMapper.updateById(examScore1); |
| | | //根据准考证号查询培训报名信息 |
| | | TrainingRegistration trainingRegistration1 = new TrainingRegistration(); |
| | | trainingRegistration1.setCandidateNo(examScore1.getCandidateNo()); |
| | | TrainingRegistration trainingRegistration = baseMapper.getTrainInfo(trainingRegistration1); |
| | | if (null != trainingRegistration) { |
| | | //修改用户培训状态信息 |
| | | User user = new User(); |
| | | user.setIsTrain(3); |
| | | user.setId(Long.parseLong(trainingRegistration.getUserId())); |
| | | //修改 |
| | | userService.updateById(user); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (updateParamVo.getType()==3) { |
| | | //查询所有成绩不合格的数据(准考证号) |
| | | List<ExamScore> list = baseMapper.getLheoryGradeLess60(); |
| | | if (list.size() > 0) { |
| | | list.forEach(examScore1 -> { |
| | | //修改考试成绩为合格 |
| | | //生成随机数,在60-79 之间 |
| | | int score = (int)((Math.random() * 20)); |
| | | int sc = score+60; |
| | | examScore1.setTheoryGrade(sc); |
| | | //设置为合格 |
| | | examScore1.setQualified(2); |
| | | examScore1.setAllGrade(examScore1.getTheoryGrade() / 2); |
| | | //修改 |
| | | baseMapper.updateById(examScore1); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |