Browse Source

准考证号长度限制

tags/正式版本
雍文秀 2 years ago
parent
commit
ee1ac40af8

+ 19
- 3
sapi/src/main/java/com/xhkjedu/sapi/controller/system/SchoolController.java View File

95
     @PostMapping("/detail")
95
     @PostMapping("/detail")
96
     public ResultVo detail(@RequestBody TSchool tSchool) {
96
     public ResultVo detail(@RequestBody TSchool tSchool) {
97
         Integer schoolid = tSchool.getSchoolid();
97
         Integer schoolid = tSchool.getSchoolid();
98
-        N_Utils.validation(new Object[]{schoolid,"学校id",1});
98
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
99
         TSchool school = schoolService.finById(schoolid);
99
         TSchool school = schoolService.finById(schoolid);
100
-        return new ResultVo(0,"获取学校详情成功", school);
100
+        return new ResultVo(0, "获取学校详情成功", school);
101
     }
101
     }
102
 
102
 
103
     @PostMapping("/list_sel")
103
     @PostMapping("/list_sel")
104
     public ResultVo listForSel() {
104
     public ResultVo listForSel() {
105
         List<Map> list = schoolService.listForSel();
105
         List<Map> list = schoolService.listForSel();
106
-        return new ResultVo(0,"获取学校选择列表成功", list);
106
+        return new ResultVo(0, "获取学校选择列表成功", list);
107
+    }
108
+
109
+    /**
110
+     * 获取准考证号长度限制
111
+     *
112
+     * @return com.xhkjedu.vo.ResultVo
113
+     * @Param [tSchool]
114
+     * @Author ywx
115
+     * @Date 2022/9/15 14:19
116
+     **/
117
+    @PostMapping("/get_limitenolen")
118
+    public ResultVo getLimiteNoLen(@RequestBody TSchool tSchool) {
119
+        Integer schoolid = tSchool.getSchoolid();
120
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
121
+        Integer limitenolen = schoolService.getLimiteNoLen(schoolid);
122
+        return new ResultVo(0, "获取成功", limitenolen);
107
     }
123
     }
108
 }
124
 }

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolMapper.java View File

57
 
57
 
58
     //根据域名获取学校id
58
     //根据域名获取学校id
59
     Integer getSchoolIdByDomain(String schooldomain, Integer schoolid);
59
     Integer getSchoolIdByDomain(String schooldomain, Integer schoolid);
60
+
61
+    //获取准考证号长度限制
62
+    Integer getLimiteNoLen(@Param("schoolid") Integer schoolid);
60
 }
63
 }

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/system/TSchool.java View File

38
     //学校域名地址
38
     //学校域名地址
39
     private String schooldomain;
39
     private String schooldomain;
40
 
40
 
41
+    //准考证号长度限制
42
+    private Integer limitenolen;
43
+
41
     //直播授权数量
44
     //直播授权数量
42
     private Integer livenum;
45
     private Integer livenum;
43
 
46
 

+ 5
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolService.java View File

415
     public Integer getYearById(Integer schoolid) {
415
     public Integer getYearById(Integer schoolid) {
416
         return schoolMapper.getYearById(schoolid);
416
         return schoolMapper.getYearById(schoolid);
417
     }
417
     }
418
+
419
+    //获取准考证号长度限制
420
+    public Integer getLimiteNoLen(Integer schoolid) {
421
+        return schoolMapper.getLimiteNoLen(schoolid);
422
+    }
418
 }
423
 }

+ 5
- 1
sapi/src/main/resources/mapper/system/SchoolMapper.xml View File

60
     <update id="updateById">
60
     <update id="updateById">
61
         update t_school set schoolname=#{school.schoolname},shortname=#{school.shortname},errorrate=#{school.errorrate}
61
         update t_school set schoolname=#{school.schoolname},shortname=#{school.shortname},errorrate=#{school.errorrate}
62
         ,bindmac=#{school.bindmac},docklc=#{school.docklc},usernum=#{school.usernum},livenum=#{school.livenum}
62
         ,bindmac=#{school.bindmac},docklc=#{school.docklc},usernum=#{school.usernum},livenum=#{school.livenum}
63
-        ,livetime=#{school.livetime},coordinate=#{school.coordinate}
63
+        ,livetime=#{school.livetime},coordinate=#{school.coordinate},limitenolen=#{school.limitenolen}
64
         where schoolid=#{school.schoolid}
64
         where schoolid=#{school.schoolid}
65
     </update>
65
     </update>
66
     <!--根据域名获取学校id-->
66
     <!--根据域名获取学校id-->
67
     <select id="getSchoolIdByDomain" resultType="java.lang.Integer">
67
     <select id="getSchoolIdByDomain" resultType="java.lang.Integer">
68
         select schoolid from t_school where schoolid=#{schoolid} and schooldomain=#{schooldomain}
68
         select schoolid from t_school where schoolid=#{schoolid} and schooldomain=#{schooldomain}
69
     </select>
69
     </select>
70
+    <!--获取准考证号长度限制-->
71
+    <select id="getLimiteNoLen" resultType="java.lang.Integer">
72
+        select limitenolen from t_school where schoolid=#{schoolid}
73
+    </select>
70
 </mapper>
74
 </mapper>

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/gradeclass/SchoolMapper.java View File

16
 
16
 
17
     //更加用户id获取当前学校id和年份
17
     //更加用户id获取当前学校id和年份
18
     TSchool getSchoolInfoByUserid(Integer userid);
18
     TSchool getSchoolInfoByUserid(Integer userid);
19
+
20
+    //获取学校基本信息
21
+    TSchool getSchoolInfoById(Integer schoolid);
19
 }
22
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/model/gradeclass/TSchool.java View File

38
     //学校域名地址
38
     //学校域名地址
39
     private String schooldomain;
39
     private String schooldomain;
40
 
40
 
41
+    //准考证号长度限制
42
+    private Integer limitenolen;
43
+
41
     //直播授权数量
44
     //直播授权数量
42
     private Integer livenum;
45
     private Integer livenum;
43
 
46
 

+ 44
- 6
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java View File

9
 import com.xhkjedu.suser.mapper.system.UserMapper;
9
 import com.xhkjedu.suser.mapper.system.UserMapper;
10
 import com.xhkjedu.suser.model.gradeclass.TClassStudent;
10
 import com.xhkjedu.suser.model.gradeclass.TClassStudent;
11
 import com.xhkjedu.suser.model.gradeclass.TGroupStudent;
11
 import com.xhkjedu.suser.model.gradeclass.TGroupStudent;
12
+import com.xhkjedu.suser.model.gradeclass.TSchool;
12
 import com.xhkjedu.suser.model.system.TUser;
13
 import com.xhkjedu.suser.model.system.TUser;
13
 import com.xhkjedu.suser.utils.PoiUtils;
14
 import com.xhkjedu.suser.utils.PoiUtils;
14
 import com.xhkjedu.suser.vo.gradeclass.ClassStudentVo;
15
 import com.xhkjedu.suser.vo.gradeclass.ClassStudentVo;
210
                 } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()
211
                 } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()
211
                         || (N_Utils.isNotEmpty(examno) && !examno.equals(user.getExamno()))) {
212
                         || (N_Utils.isNotEmpty(examno) && !examno.equals(user.getExamno()))) {
212
                     TUser stu = new TUser();
213
                     TUser stu = new TUser();
214
+                    if (N_Utils.isNotEmpty(examno)) {
215
+                        TSchool school = schoolMapper.getSchoolInfoById(schoolid);
216
+                        Integer limitenolen = school.getLimitenolen();
217
+                        if (!N_Utils.isEmptyInteger(limitenolen) && !limitenolen.equals(examno.length())) {
218
+                            throw new Exception("准考证号长度不符合要求");
219
+                        }
220
+                    }
213
                     stu.setExamno(examno);
221
                     stu.setExamno(examno);
214
                     Integer userid = user.getUserid();
222
                     Integer userid = user.getUserid();
215
                     stu.setUserid(userid);
223
                     stu.setUserid(userid);
289
      */
297
      */
290
     private TUser saveUser(TClassStudent model) throws Exception {
298
     private TUser saveUser(TClassStudent model) throws Exception {
291
         Integer schoolid = model.getSchoolid();
299
         Integer schoolid = model.getSchoolid();
300
+        TSchool school = schoolMapper.getSchoolInfoById(schoolid);
301
+        Integer limitenolen = school.getLimitenolen();
302
+        String examno = model.getExamno();
303
+        if (N_Utils.isNotEmpty(examno) && !N_Utils.isEmptyInteger(limitenolen) && !limitenolen.equals(examno.length())) {
304
+            throw new Exception("准考证号长度不符合要求");
305
+        }
292
         TUser user = new TUser();
306
         TUser user = new TUser();
293
         user.setUsertype(2);
307
         user.setUsertype(2);
294
         user.setUsername(model.getStudentname());
308
         user.setUsername(model.getStudentname());
296
         user.setLoginpwd(N_Utils.getMD5Pwd("123456"));
310
         user.setLoginpwd(N_Utils.getMD5Pwd("123456"));
297
         user.setUsersex(model.getUsersex());
311
         user.setUsersex(model.getUsersex());
298
         user.setStudentno(model.getStudentno());
312
         user.setStudentno(model.getStudentno());
299
-        user.setExamno(model.getExamno());
313
+        user.setExamno(examno);
300
         user.setCreateid(model.getCreateid());
314
         user.setCreateid(model.getCreateid());
301
         user.setSchoolid(schoolid);
315
         user.setSchoolid(schoolid);
302
         user.setUsertime(model.getUsertime());
316
         user.setUsertime(model.getUsertime());
303
         user.setHeadpic(model.getHeadpic());
317
         user.setHeadpic(model.getHeadpic());
304
         user.setUserphone(model.getUserphone());
318
         user.setUserphone(model.getUserphone());
305
-        Integer usernum = schoolMapper.getUserNumById(schoolid);
319
+        Integer usernum = school.getUsernum();
306
         if (usernum != null) {
320
         if (usernum != null) {
307
             Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
321
             Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
308
             usernum2 = usernum2 + 1;//学校账号数量+本次添加的人
322
             usernum2 = usernum2 + 1;//学校账号数量+本次添加的人
380
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
394
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
381
             return new ResultVo(1, "此账号已被【" + u.getUsername() + "】占用");
395
             return new ResultVo(1, "此账号已被【" + u.getUsername() + "】占用");
382
         }
396
         }
397
+        String examno = model.getExamno();
398
+        if (N_Utils.isNotEmpty(examno)) {
399
+            TSchool school = schoolMapper.getSchoolInfoById(model.getSchoolid());
400
+            Integer limitenolen = school.getLimitenolen();
401
+            if (!N_Utils.isEmptyInteger(limitenolen) && !limitenolen.equals(examno.length())) {
402
+                return new ResultVo(1, "准考证号长度不符合要求");
403
+            }
404
+        }
383
         //修改学生信息
405
         //修改学生信息
384
         TUser user = new TUser();
406
         TUser user = new TUser();
385
         user.setUserid(model.getStudentid());
407
         user.setUserid(model.getStudentid());
386
         user.setUsersex(model.getUsersex());
408
         user.setUsersex(model.getUsersex());
387
         user.setUsername(model.getStudentname());
409
         user.setUsername(model.getStudentname());
388
         user.setStudentno(model.getStudentno());
410
         user.setStudentno(model.getStudentno());
389
-        user.setExamno(model.getExamno());
411
+        user.setExamno(examno);
390
         user.setLoginname(model.getStudentno());
412
         user.setLoginname(model.getStudentno());
391
         user.setUserphone(model.getUserphone());
413
         user.setUserphone(model.getUserphone());
392
         user.setUsertime(model.getUsertime());
414
         user.setUsertime(model.getUsertime());
436
             if (stunum.compareTo(lnum) != 0) {
458
             if (stunum.compareTo(lnum) != 0) {
437
                 return new ResultVo(1, "有重复的登录学号");
459
                 return new ResultVo(1, "有重复的登录学号");
438
             }
460
             }
439
-            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno())).map(TUser::getExamno).collect(Collectors.toList());
461
+            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno()))
462
+                    .map(TUser::getExamno).collect(Collectors.toList());
440
             long examnum2 = elist.stream().distinct().count();
463
             long examnum2 = elist.stream().distinct().count();
441
             Integer examnum = elist.size();
464
             Integer examnum = elist.size();
442
             if (examnum2 < examnum) {
465
             if (examnum2 < examnum) {
443
                 return new ResultVo(1, "有重复的准考证号");
466
                 return new ResultVo(1, "有重复的准考证号");
444
             }
467
             }
445
-            Integer usernum = schoolMapper.getUserNumById(schoolid);
468
+            TSchool school = schoolMapper.getSchoolInfoById(schoolid);
469
+            Integer limitenolen = school.getLimitenolen();
470
+            for (String examno : elist) {
471
+                if (!N_Utils.isEmptyInteger(limitenolen) && !limitenolen.equals(examno.length())) {
472
+                    throw new Exception("准考证号长度不符合要求");
473
+                }
474
+            }
475
+            Integer usernum = school.getUsernum();
446
             if (usernum != null) {
476
             if (usernum != null) {
447
                 Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
477
                 Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
448
                 usernum2 = usernum2 + stunum;//学校账号数量+本次添加的人
478
                 usernum2 = usernum2 + stunum;//学校账号数量+本次添加的人
659
             if (stunum.compareTo(lnum) != 0) {
689
             if (stunum.compareTo(lnum) != 0) {
660
                 return new ResultVo(1, "有重复的登录学号");
690
                 return new ResultVo(1, "有重复的登录学号");
661
             }
691
             }
662
-            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno())).map(TUser::getExamno).collect(Collectors.toList());
692
+            List<String> elist = students.stream().filter(u -> N_Utils.isNotEmpty(u.getExamno()))
693
+                    .map(TUser::getExamno).collect(Collectors.toList());
663
             long examnum2 = elist.stream().distinct().count();
694
             long examnum2 = elist.stream().distinct().count();
664
             Integer examnum = elist.size();
695
             Integer examnum = elist.size();
665
             if (examnum2 < examnum) {
696
             if (examnum2 < examnum) {
666
                 return new ResultVo(1, "有重复的准考证号");
697
                 return new ResultVo(1, "有重复的准考证号");
667
             }
698
             }
699
+            TSchool school = schoolMapper.getSchoolInfoById(schoolid);
700
+            Integer limitenolen = school.getLimitenolen();
701
+            for (String examno : elist) {
702
+                if (!N_Utils.isEmptyInteger(limitenolen) && !limitenolen.equals(examno.length())) {
703
+                    throw new Exception("准考证号长度不符合要求");
704
+                }
705
+            }
668
             map.remove("users");//导入成功的学生信息不返回给前端
706
             map.remove("users");//导入成功的学生信息不返回给前端
669
 
707
 
670
             List<TClassStudent> classStudents = new ArrayList<>();
708
             List<TClassStudent> classStudents = new ArrayList<>();

+ 4
- 0
suser/src/main/resources/mapper/gradeclass/SchoolMapper.xml View File

20
         select s.schoolid,s.year from t_user u left join t_school s on u.schoolid=s.schoolid
20
         select s.schoolid,s.year from t_user u left join t_school s on u.schoolid=s.schoolid
21
         where u.userid=#{userid}
21
         where u.userid=#{userid}
22
     </select>
22
     </select>
23
+    <!--获取学校基本信息-->
24
+    <select id="getSchoolInfoById" resultType="com.xhkjedu.suser.model.gradeclass.TSchool">
25
+        select usernum,limitenolen from t_school where schoolid=#{schoolid}
26
+    </select>
23
 </mapper>
27
 </mapper>

Loading…
Cancel
Save