| | |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.apply.entity.Apply; |
| | | import org.springblade.modules.apply.excel.ApplyInfoExcel; |
| | | import org.springblade.modules.exam.entity.ExamPaper; |
| | | import org.springblade.modules.exam.service.ExamPaperService; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserDeptService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private final IUserService userService; |
| | | |
| | | private final IUserDeptService userDeptService; |
| | | |
| | | private final ExamPaperService examPaperService; |
| | | |
| | | |
| | | @Override |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importTrainingRegistration(List<TrainingRegistrationExcel> data, Boolean isCovered) { |
| | | public void importTrainingRegistration(List<TrainingRegistrationExcel> data, Boolean isCovered,Long examId) { |
| | | if (data.size()>0){ |
| | | data.forEach(trainingRegistrationExcel -> { |
| | | TrainingRegistration trainingRegistration = new TrainingRegistration(); |
| | |
| | | trainingRegistration.setIsExam(1); |
| | | trainingRegistration.setCancel(1); |
| | | trainingRegistration.setTrainingTime(new Date()); |
| | | //如果examId不为空 |
| | | if (null!=examId){ |
| | | //查询考试信息 |
| | | ExamPaper examPaper = examPaperService.getById(examId); |
| | | trainingRegistration.setTrainExamId(examId.toString()); |
| | | //审核通过 |
| | | if (examPaper.getAuditStatus()==1){ |
| | | //生成准考证号 |
| | | trainingRegistration.setCandidateNo(getCandidateNo(trainingRegistration)); |
| | | } |
| | | } |
| | | //新增报名 |
| | | this.save(trainingRegistration); |
| | | |
| | | //修改保安报名状态 |
| | | user.setIsTrain(1); |
| | | userService.updateById(user); |
| | |
| | | trainingRegistration.setIsExam(1); |
| | | trainingRegistration.setCancel(1); |
| | | trainingRegistration.setTrainingTime(new Date()); |
| | | //如果examId不为空 |
| | | if (null!=examId){ |
| | | //查询考试信息 |
| | | ExamPaper examPaper = examPaperService.getById(examId); |
| | | trainingRegistration.setTrainExamId(examId.toString()); |
| | | //审核通过 |
| | | if (examPaper.getAuditStatus()==1){ |
| | | //生成准考证号 |
| | | trainingRegistration.setCandidateNo(getCandidateNo(trainingRegistration)); |
| | | } |
| | | } |
| | | //新增报名 |
| | | this.save(trainingRegistration); |
| | | //修改保安报名状态 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成准考证号码 |
| | | * @param trainingRegistration 考试报名信息对象 |
| | | */ |
| | | private String getCandidateNo(TrainingRegistration trainingRegistration) { |
| | | //获取考试信息 |
| | | ExamPaper examPaper = examPaperService.getById(trainingRegistration.getTrainExamId()); |
| | | if (null!=examPaper.getStartTime()){ |
| | | String format = new SimpleDateFormat("yyyy-MM-dd").format(examPaper.getStartTime()); |
| | | String year = format.substring(2,4); |
| | | String quarter = null; |
| | | String months = null; |
| | | int month = Integer.parseInt(format.substring(5,7)); |
| | | int day = Integer.parseInt(format.substring(8,10)); |
| | | String days = null; |
| | | if (month>0 && month<=3){ |
| | | quarter = "C"; |
| | | } |
| | | if (month>3 && month<=6){ |
| | | quarter = "X"; |
| | | } |
| | | if (month>6 && month<=9){ |
| | | quarter = "Q"; |
| | | } |
| | | if (month>9 && month<=12){ |
| | | quarter = "D"; |
| | | } |
| | | if (month<=9){ |
| | | months = "0" + month; |
| | | } |
| | | if (day<=9){ |
| | | days = "0" + day; |
| | | }else { |
| | | days = ""+day; |
| | | } |
| | | String type = null; |
| | | if (examPaper.getExamType()==1){ |
| | | type = "z"; |
| | | } |
| | | if (examPaper.getExamType()==2){ |
| | | type = "m"; |
| | | } |
| | | //获取考试名称前缀,去除数字,字母 |
| | | String examName |
| | | = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1); |
| | | |
| | | //前缀 = 年的最后两位 + 月份(两位) + 考试名称(中文拼音)首字母(去除数字,字母) + 考试类型 + 季度拼音首字母大写(春季就是 C) |
| | | // String result = year |
| | | // + months |
| | | // + toFirstChar(examName).toUpperCase() |
| | | // + examPaper.getExamType() |
| | | // + quarter; |
| | | |
| | | //前缀 = 年的最后两位 + 月份(两位) + 日 (两位) + 考试类型 正式考试 z 模拟考试 m |
| | | String result = year |
| | | + months |
| | | + days |
| | | + type; |
| | | //查询是当前前缀已生成的数量 |
| | | int count = this.getCandidateNoCount(result); |
| | | if (count==0){ |
| | | return result + "0000"; |
| | | } |
| | | //格式化 |
| | | DecimalFormat decimalFormat = new DecimalFormat("0000"); |
| | | //返回 |
| | | return result + (decimalFormat.format(count++)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 报名 |
| | | */ |