智慧保安后台管理-外网项目备份
Administrator
2021-10-08 9a4a283a1413188ff5763b5e2e72c26bc2f5db3d
准考证生成修改
3 files modified
124 ■■■■ changed files
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java 102 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
@@ -328,6 +328,8 @@
            }
            if (month<=9){
                months = "0" + month;
            }else {
                months = String.valueOf(month);
            }
            if (day<=9){
                days = "0" + day;
@@ -342,8 +344,8 @@
                type = "m";
            }
            //获取考试名称前缀,去除数字,字母
            String examName
                = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1);
//            String examName
//                = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1);
            //前缀 = 年的最后两位  + 月份(两位) + 考试名称(中文拼音)首字母(去除数字,字母) + 考试类型 + 季度拼音首字母大写(春季就是 C)
//            String result = year
src/main/java/org/springblade/modules/training/controller/TrainingRegistrationController.java
@@ -406,57 +406,57 @@
     * 生成准考证号码
     * @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;
            String days = null;
            int month = Integer.parseInt(format.substring(5,7));
            int day = Integer.parseInt(format.substring(8,10));
            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;
            }
            //获取考试名称前缀,去除数字,字母
            String examName
                = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1);
            //前缀 = 年的最后两位  + 月份(两位) + 考试名称(中文拼音)首字母(去除数字,字母) + 考试类型 + 季度拼音首字母大写(春季就是 C)
            String result = year
                + months
                + toFirstChar(examName).toUpperCase()
                + examPaper.getExamType()
                + quarter;
            //查询是当前前缀已生成的数量
            int count = trainingRegistrationService.getCandidateNoCount(result);
            if (count==0){
                return result + "0000";
            }
            //格式化
            DecimalFormat decimalFormat = new DecimalFormat("0000");
            //返回
            return result + (decimalFormat.format(count++));
        }
        return null;
    }
//    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;
//            String days = null;
//            int month = Integer.parseInt(format.substring(5,7));
//            int day = Integer.parseInt(format.substring(8,10));
//            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;
//            }
//            //获取考试名称前缀,去除数字,字母
//            String examName
//                = examPaper.getExamName().replaceAll("\\s*", "").replaceAll("[^(\\u4e00-\\u9fa5)]", "").substring(0,1);
//
//            //前缀 = 年的最后两位  + 月份(两位) + 考试名称(中文拼音)首字母(去除数字,字母) + 考试类型 + 季度拼音首字母大写(春季就是 C)
//            String result = year
//                + months
//                + toFirstChar(examName).toUpperCase()
//                + examPaper.getExamType()
//                + quarter;
//            //查询是当前前缀已生成的数量
//            int count = trainingRegistrationService.getCandidateNoCount(result);
//            if (count==0){
//                return result + "0000";
//            }
//            //格式化
//            DecimalFormat decimalFormat = new DecimalFormat("0000");
//            //返回
//            return result + (decimalFormat.format(count++));
//        }
//        return null;
//    }
    /**
src/main/java/org/springblade/modules/training/service/impl/TrainingRegistrationServiceImpl.java
@@ -190,6 +190,8 @@
            }
            if (month<=9){
                months = "0" + month;
            }else {
                months = String.valueOf(month);
            }
            if (day<=9){
                days = "0" + day;
@@ -215,19 +217,19 @@
//                            + quarter;
            //前缀 = 年的最后两位  + 月份(两位) + 日 (两位) + 考试类型 正式考试  z   模拟考试   m
            String result = year
            String pre = year
                + months
                + days
                + type;
            //查询是当前前缀已生成的数量
            int count = this.getCandidateNoCount(result);
            if (count==0){
                return result + "0000";
            }
            //查询是当前前缀已生成准考证号码最大的一位
            int count = examPaperService.getCandidateNoCount(pre);
            String result = null;
            //格式化
            DecimalFormat decimalFormat = new DecimalFormat("0000");
            count++;
            result = pre + (decimalFormat.format(count));
            //返回
            return result + (decimalFormat.format(count++));
            return result;
        }
        return null;
    }