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,14 +95,30 @@ public class SchoolController {
95 95
     @PostMapping("/detail")
96 96
     public ResultVo detail(@RequestBody TSchool tSchool) {
97 97
         Integer schoolid = tSchool.getSchoolid();
98
-        N_Utils.validation(new Object[]{schoolid,"学校id",1});
98
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
99 99
         TSchool school = schoolService.finById(schoolid);
100
-        return new ResultVo(0,"获取学校详情成功", school);
100
+        return new ResultVo(0, "获取学校详情成功", school);
101 101
     }
102 102
 
103 103
     @PostMapping("/list_sel")
104 104
     public ResultVo listForSel() {
105 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,4 +57,7 @@ public interface SchoolMapper extends TkMapper<TSchool> {
57 57
 
58 58
     //根据域名获取学校id
59 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,6 +38,9 @@ public class TSchool extends BaseBean {
38 38
     //学校域名地址
39 39
     private String schooldomain;
40 40
 
41
+    //准考证号长度限制
42
+    private Integer limitenolen;
43
+
41 44
     //直播授权数量
42 45
     private Integer livenum;
43 46
 

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

@@ -415,4 +415,9 @@ public class SchoolService {
415 415
     public Integer getYearById(Integer schoolid) {
416 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,11 +60,15 @@
60 60
     <update id="updateById">
61 61
         update t_school set schoolname=#{school.schoolname},shortname=#{school.shortname},errorrate=#{school.errorrate}
62 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 64
         where schoolid=#{school.schoolid}
65 65
     </update>
66 66
     <!--根据域名获取学校id-->
67 67
     <select id="getSchoolIdByDomain" resultType="java.lang.Integer">
68 68
         select schoolid from t_school where schoolid=#{schoolid} and schooldomain=#{schooldomain}
69 69
     </select>
70
+    <!--获取准考证号长度限制-->
71
+    <select id="getLimiteNoLen" resultType="java.lang.Integer">
72
+        select limitenolen from t_school where schoolid=#{schoolid}
73
+    </select>
70 74
 </mapper>

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

@@ -16,4 +16,7 @@ public interface SchoolMapper {
16 16
 
17 17
     //更加用户id获取当前学校id和年份
18 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,6 +38,9 @@ public class TSchool extends BaseBean {
38 38
     //学校域名地址
39 39
     private String schooldomain;
40 40
 
41
+    //准考证号长度限制
42
+    private Integer limitenolen;
43
+
41 44
     //直播授权数量
42 45
     private Integer livenum;
43 46
 

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

@@ -9,6 +9,7 @@ import com.xhkjedu.suser.mapper.liveplay.CourseMapper;
9 9
 import com.xhkjedu.suser.mapper.system.UserMapper;
10 10
 import com.xhkjedu.suser.model.gradeclass.TClassStudent;
11 11
 import com.xhkjedu.suser.model.gradeclass.TGroupStudent;
12
+import com.xhkjedu.suser.model.gradeclass.TSchool;
12 13
 import com.xhkjedu.suser.model.system.TUser;
13 14
 import com.xhkjedu.suser.utils.PoiUtils;
14 15
 import com.xhkjedu.suser.vo.gradeclass.ClassStudentVo;
@@ -210,6 +211,13 @@ public class ClassStudentService {
210 211
                 } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()
211 212
                         || (N_Utils.isNotEmpty(examno) && !examno.equals(user.getExamno()))) {
212 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 221
                     stu.setExamno(examno);
214 222
                     Integer userid = user.getUserid();
215 223
                     stu.setUserid(userid);
@@ -289,6 +297,12 @@ public class ClassStudentService {
289 297
      */
290 298
     private TUser saveUser(TClassStudent model) throws Exception {
291 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 306
         TUser user = new TUser();
293 307
         user.setUsertype(2);
294 308
         user.setUsername(model.getStudentname());
@@ -296,13 +310,13 @@ public class ClassStudentService {
296 310
         user.setLoginpwd(N_Utils.getMD5Pwd("123456"));
297 311
         user.setUsersex(model.getUsersex());
298 312
         user.setStudentno(model.getStudentno());
299
-        user.setExamno(model.getExamno());
313
+        user.setExamno(examno);
300 314
         user.setCreateid(model.getCreateid());
301 315
         user.setSchoolid(schoolid);
302 316
         user.setUsertime(model.getUsertime());
303 317
         user.setHeadpic(model.getHeadpic());
304 318
         user.setUserphone(model.getUserphone());
305
-        Integer usernum = schoolMapper.getUserNumById(schoolid);
319
+        Integer usernum = school.getUsernum();
306 320
         if (usernum != null) {
307 321
             Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
308 322
             usernum2 = usernum2 + 1;//学校账号数量+本次添加的人
@@ -380,13 +394,21 @@ public class ClassStudentService {
380 394
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
381 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 406
         TUser user = new TUser();
385 407
         user.setUserid(model.getStudentid());
386 408
         user.setUsersex(model.getUsersex());
387 409
         user.setUsername(model.getStudentname());
388 410
         user.setStudentno(model.getStudentno());
389
-        user.setExamno(model.getExamno());
411
+        user.setExamno(examno);
390 412
         user.setLoginname(model.getStudentno());
391 413
         user.setUserphone(model.getUserphone());
392 414
         user.setUsertime(model.getUsertime());
@@ -436,13 +458,21 @@ public class ClassStudentService {
436 458
             if (stunum.compareTo(lnum) != 0) {
437 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 463
             long examnum2 = elist.stream().distinct().count();
441 464
             Integer examnum = elist.size();
442 465
             if (examnum2 < examnum) {
443 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 476
             if (usernum != null) {
447 477
                 Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
448 478
                 usernum2 = usernum2 + stunum;//学校账号数量+本次添加的人
@@ -659,12 +689,20 @@ public class ClassStudentService {
659 689
             if (stunum.compareTo(lnum) != 0) {
660 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 694
             long examnum2 = elist.stream().distinct().count();
664 695
             Integer examnum = elist.size();
665 696
             if (examnum2 < examnum) {
666 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 706
             map.remove("users");//导入成功的学生信息不返回给前端
669 707
 
670 708
             List<TClassStudent> classStudents = new ArrayList<>();

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

@@ -20,4 +20,8 @@
20 20
         select s.schoolid,s.year from t_user u left join t_school s on u.schoolid=s.schoolid
21 21
         where u.userid=#{userid}
22 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 27
 </mapper>

Loading…
Cancel
Save