Parcourir la source

批量解绑、修改密码、修改有效期、移除、转班

tags/正式3.2.5
雍文秀 il y a 2 ans
Parent
révision
b6e5aac866

+ 24
- 10
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java Voir le fichier

@@ -978,18 +978,32 @@ public class N_Utils {
978 978
         int a=nums[0];int b=nums[1];int i=0;
979 979
         int temp;
980 980
         if(a<b){
981
-            temp=a;
982
-            a=b;
983
-            b=temp;
984
-            temp=a%b;
985
-            while(temp!=0){
986
-                a=b;
987
-                b=temp;
988
-                temp=a%b;
981
+            temp = a;
982
+            a = b;
983
+            b = temp;
984
+            temp = a % b;
985
+            while (temp != 0) {
986
+                a = b;
987
+                b = temp;
988
+                temp = a % b;
989 989
             }
990
-            nums[i+1]=b;
990
+            nums[i + 1] = b;
991 991
         }
992
-        return nums[nums.length-1];
992
+        return nums[nums.length - 1];
993
+    }
994
+
995
+    /**
996
+     * 密码加密
997
+     *
998
+     * @param [pwd]
999
+     * @return java.lang.String
1000
+     * @author ywx
1001
+     * @date 2022/5/20 10:18
1002
+     */
1003
+    public static String getMD5Pwd(String pwd) {
1004
+        if (isEmpty(pwd)) return null;
1005
+        MD5 md5 = new MD5();
1006
+        return md5.getMD5ofStr(md5.getMD5ofStr(md5.getMD5ofStr(pwd)));
993 1007
     }
994 1008
 
995 1009
 }

+ 21
- 0
suser/src/main/java/com/xhkjedu/suser/controller/gradeclass/ClassStudentController.java Voir le fichier

@@ -191,4 +191,25 @@ public class ClassStudentController {
191 191
         classStudentService.delTgStu(loginname);
192 192
         return new ResultVo(0, "删除学生所有提高班和所在提高班直播课成功");
193 193
     }
194
+
195
+    @PostMapping("/batch_remove_bind")
196
+    public ResultVo batchMoveBind(@RequestBody List<Integer> studentids) {
197
+        if (N_Utils.isListEmpty(studentids)) return new ResultVo(1, "学生不能为空");
198
+        classStudentService.batchRemoveBind(studentids);
199
+        return new ResultVo(0, "批量解除mac绑定成功");
200
+    }
201
+
202
+    @PostMapping("/batch_delete")
203
+    public ResultVo batchDelete(@RequestBody List<TClassStudent> students) {
204
+        if (N_Utils.isListEmpty(students)) return new ResultVo(1, "学生不能为空");
205
+        classStudentService.batchDelete(students);
206
+        return new ResultVo(0, "批量移除成功");
207
+    }
208
+
209
+    @PostMapping("/batch_move_class")
210
+    public ResultVo batchMoveClass(@RequestBody List<TClassStudent> students) {
211
+        if (N_Utils.isListEmpty(students)) return new ResultVo(1, "学生不能为空");
212
+        classStudentService.batchMoveClass(students);
213
+        return new ResultVo(0, "批量转班成功");
214
+    }
194 215
 }

+ 36
- 0
suser/src/main/java/com/xhkjedu/suser/controller/system/UserController.java Voir le fichier

@@ -570,4 +570,40 @@ public class UserController {
570 570
         userService.unLock(userid);
571 571
         return new ResultVo(0, "解锁成功");
572 572
     }
573
+
574
+    /**
575
+     * 批量修改密码
576
+     *
577
+     * @param [map]
578
+     * @return com.xhkjedu.vo.ResultVo
579
+     * @author ywx
580
+     * @date 2022/5/20 11:18
581
+     */
582
+    @PostMapping("/batch_update_pwd2")
583
+    public ResultVo batchUpdatePwd2(@RequestBody Map map) {
584
+        String loginpwd = map.get("loginpwd").toString();
585
+        N_Utils.validation(new Object[]{loginpwd, "密码", 2});
586
+        List<Integer> userids = (List<Integer>) map.get("userids");
587
+        if (N_Utils.isListEmpty(userids)) return new ResultVo(1, "用户id集合不能为空");
588
+        userService.batchUpdatePwd2(loginpwd, userids);
589
+        return new ResultVo(0, "批量修改密码成功");
590
+    }
591
+
592
+    /**
593
+     * 批量修有效期
594
+     *
595
+     * @param [map]
596
+     * @return com.xhkjedu.vo.ResultVo
597
+     * @author ywx
598
+     * @date 2022/5/20 11:23
599
+     */
600
+    @PostMapping("/batch_update_time")
601
+    public ResultVo batchUpdateTime(@RequestBody Map map) {
602
+        String usertime = map.get("usertime").toString();
603
+        N_Utils.validation(new Object[]{usertime, "有效期", 2});
604
+        List<Integer> userids = (List<Integer>) map.get("userids");
605
+        if (N_Utils.isListEmpty(userids)) return new ResultVo(1, "用户id集合不能为空");
606
+        userService.batchUpdateTime(usertime, userids);
607
+        return new ResultVo(0, "批量修有效期成功");
608
+    }
573 609
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/gradeclass/ClassMapper.java Voir le fichier

@@ -37,4 +37,7 @@ public interface ClassMapper extends TkMapper<TClass> {
37 37
 
38 38
     //班级下教师,以及教师科目
39 39
     List<Map> listTeacherSubject(Integer classid);
40
+
41
+    //获取班级信息
42
+    List<ClassVo> listByIds(@Param("classids") List<Integer> classids);
40 43
 }

+ 7
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/gradeclass/ClassStudentMapper.java Voir le fichier

@@ -8,6 +8,7 @@ import com.xhkjedu.suser.vo.gradeclass.ImportStudentVo;
8 8
 import org.apache.ibatis.annotations.Param;
9 9
 
10 10
 import java.util.List;
11
+import java.util.Map;
11 12
 
12 13
 public interface ClassStudentMapper extends TkMapper<TClassStudent> {
13 14
     //班级学生列表
@@ -59,4 +60,10 @@ public interface ClassStudentMapper extends TkMapper<TClassStudent> {
59 60
 
60 61
     //获取学生除某个班外的行政班和提高班ids
61 62
     String getClassIdsByCidAndSid(@Param("classid") Integer classid, @Param("studentid") Integer studentid);
63
+
64
+    //获取学生除某个班外的行政班和提高班ids
65
+    List<Map> listClassIdsByCidAndSid(@Param("students") List<TClassStudent> students);
66
+
67
+    //批量删除班级、分组对应学生
68
+    void deleteBatchStudent2(@Param("students") List<TClassStudent> students);
62 69
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/liveplay/CourseMapper.java Voir le fichier

@@ -17,4 +17,7 @@ public interface CourseMapper {
17 17
 
18 18
     //含某些班的直播课
19 19
     List<Map> listCourse(@Param("classids") String classids);
20
+
21
+    //指定班级的直播课
22
+    List<Map> listXzCourse2(@Param("classids") List<Integer> classids);
20 23
 }

+ 9
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java Voir le fichier

@@ -234,4 +234,13 @@ public interface UserMapper extends TkMapper<TUser> {
234 234
 
235 235
     //绑定手机号用户列表
236 236
     List<Map> listBindPhoneUser();
237
+
238
+    //批量解绑
239
+    void batchRemoveBind(@Param("userids") List<Integer> userids);
240
+
241
+    //批量修改密码
242
+    void batchUpdatePwd2(@Param("loginpwd") String loginpwd, @Param("userids") List<Integer> userids);
243
+
244
+    //批量修有效期
245
+    void batchUpdateTime(@Param("usertime") String usertime, @Param("userids") List<Integer> userids);
237 246
 }

+ 261
- 46
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java Voir le fichier

@@ -6,10 +6,10 @@ import com.xhkjedu.suser.mapper.gradeclass.ClassStudentMapper;
6 6
 import com.xhkjedu.suser.mapper.gradeclass.GroupStudentMapper;
7 7
 import com.xhkjedu.suser.mapper.gradeclass.SchoolMapper;
8 8
 import com.xhkjedu.suser.mapper.liveplay.CourseMapper;
9
+import com.xhkjedu.suser.mapper.system.UserMapper;
9 10
 import com.xhkjedu.suser.model.gradeclass.TClassStudent;
10 11
 import com.xhkjedu.suser.model.gradeclass.TGroupStudent;
11 12
 import com.xhkjedu.suser.model.system.TUser;
12
-import com.xhkjedu.suser.service.system.UserService;
13 13
 import com.xhkjedu.suser.utils.PoiUtils;
14 14
 import com.xhkjedu.suser.vo.gradeclass.ClassStudentVo;
15 15
 import com.xhkjedu.suser.vo.gradeclass.ClassVo;
@@ -41,7 +41,7 @@ public class ClassStudentService {
41 41
     @Resource
42 42
     private ClassStudentMapper classStudentMapper;
43 43
     @Resource
44
-    private UserService userService;
44
+    private UserMapper userMapper;
45 45
     @Resource
46 46
     private ClassMapper classMapper;
47 47
     @Resource
@@ -70,7 +70,6 @@ public class ClassStudentService {
70 70
             List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
71 71
             List<Map> courses = courseMapper.listXzCourse(classid);
72 72
             for (TClassStudent student : students) {
73
-                //save(student);
74 73
                 Integer studentid = student.getStudentid();
75 74
                 //全体分组
76 75
                 ImportStudentVo stu = getNumById(classid, studentid, year);
@@ -122,7 +121,6 @@ public class ClassStudentService {
122 121
             Integer schoolid = classVo.getSchoolid();
123 122
             Integer createid = classVo.getCreateid();
124 123
             Integer groupid = classVo.getGroupid();
125
-            Integer year = classVo.getYear();
126 124
             List<Integer> studentIds = classStudentMapper.listStudentIdByClassId(classid);//班级原有学生
127 125
             for (Integer studentid : newStuIds) {
128 126
                 if (!N_Utils.numInList(studentid, studentIds)) {//新添加的学生
@@ -136,7 +134,6 @@ public class ClassStudentService {
136 134
             Map<String, List<Map>> courseMap = new HashMap();//班级直播课
137 135
             for (Integer studentId : studentIds) {
138 136
                 if (!N_Utils.numInList(studentId, newStuIds)) {//删除的学生
139
-                    //deleteById(classid, studentId);
140 137
                     //把这个学生从此行政班、提高班关联的所有直播班移除
141 138
                     delStudentIdList.add(studentId);
142 139
                     String classids = classStudentMapper.getClassIdsByCidAndSid(classid, studentId);//获取学生除某个班外的行政班和提高班ids
@@ -198,35 +195,22 @@ public class ClassStudentService {
198 195
     public void save(TClassStudent model) throws Exception {
199 196
         try {
200 197
             model.setCreatetime(N_Utils.getSecondTimestamp());
198
+            Integer schoolid = model.getSchoolid();
201 199
             if (!N_Utils.isEmpty(model.getStudentno())) {
202 200
                 String headpic = model.getHeadpic();
203
-                TUser user = userService.getObjByLoginName(model.getStudentno());
201
+                TUser user = userMapper.getObjByLoginName(model.getStudentno());
204 202
                 if (user == null) {//学生信息在用户表不存在,添加学生信息
205
-                    user = new TUser();
206
-                    user.setUsertype(2);
207
-                    user.setUsername(model.getStudentname());
208
-                    user.setLoginname(model.getStudentno());
209
-                    user.setLoginpwd("123456");
210
-                    user.setUsersex(model.getUsersex());
211
-                    user.setStudentno(model.getStudentno());
212
-                    user.setCreateid(model.getCreateid());
213
-                    user.setSchoolid(model.getSchoolid());
214
-                    user.setUsertime(model.getUsertime());
215
-                    user.setHeadpic(headpic);
216
-                    user.setUserphone(model.getUserphone());
217
-                    ResultVo vo = userService.save(user);
218
-                    if (vo.getCode() != 0) throw new Exception(vo.getMsg());
219
-                    user.setUserid((Integer) vo.getObj());
203
+                    user = saveUser(model);//保存用户信息
220 204
                 } else if (user.getUsertype() != 2) {
221 205
                     throw new Exception("禁止添加非学生账号");
222
-                } else if (!model.getSchoolid().equals(user.getSchoolid())) {
206
+                } else if (!schoolid.equals(user.getSchoolid())) {
223 207
                     throw new Exception("禁止添加非本校学生账号");
224 208
                 } else if (N_Utils.isNotEmpty(headpic) || 1 != user.getUserstate()) {
225 209
                     TUser stu = new TUser();
226 210
                     Integer userid = user.getUserid();
227 211
                     stu.setUserid(userid);
228 212
                     if (N_Utils.isNotEmpty(headpic)) {
229
-                        TUser u = userService.getUserTypeAndHeadTime(userid);//获取用户类型和修改头像时间
213
+                        TUser u = userMapper.getUserTypeAndHeadTime(userid);//获取用户类型和修改头像时间
230 214
                         if (u.getHeadtime() == 0) {
231 215
                             throw new Exception("6个月内只能修改一次");
232 216
                         } else {
@@ -237,7 +221,7 @@ public class ClassStudentService {
237 221
                     if (1 != user.getUserstate()) {//已删除用户改为正常用户
238 222
                         stu.setUserstate(1);
239 223
                     }
240
-                    userService.updateByPrimaryKeySelective(stu);
224
+                    userMapper.updateByPrimaryKeySelective(stu);
241 225
                 }
242 226
 
243 227
                 model.setStudentid(user.getUserid());
@@ -263,7 +247,7 @@ public class ClassStudentService {
263 247
                     groupStudent.setGroupid(model.getGroupid());
264 248
                     groupStudent.setStudentid(model.getStudentid());
265 249
                     groupStudent.setCreateid(model.getCreateid());
266
-                    groupStudent.setSchoolid(model.getSchoolid());
250
+                    groupStudent.setSchoolid(schoolid);
267 251
                     addGroupStudentList.add(groupStudent);
268 252
                 }
269 253
                 List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
@@ -290,6 +274,60 @@ public class ClassStudentService {
290 274
         }
291 275
     }
292 276
 
277
+    /**
278
+     * 保存用户信息
279
+     *
280
+     * @param [model]
281
+     * @return com.xhkjedu.suser.model.system.TUser
282
+     * @author ywx
283
+     * @date 2022/5/20 10:22
284
+     */
285
+    private TUser saveUser(TClassStudent model) throws Exception {
286
+        Integer schoolid = model.getSchoolid();
287
+        TUser user = new TUser();
288
+        user.setUsertype(2);
289
+        user.setUsername(model.getStudentname());
290
+        user.setLoginname(model.getStudentno());
291
+        user.setLoginpwd(N_Utils.getMD5Pwd("123456"));
292
+        user.setUsersex(model.getUsersex());
293
+        user.setStudentno(model.getStudentno());
294
+        user.setCreateid(model.getCreateid());
295
+        user.setSchoolid(schoolid);
296
+        user.setUsertime(model.getUsertime());
297
+        user.setHeadpic(model.getHeadpic());
298
+        user.setUserphone(model.getUserphone());
299
+        Integer usernum = schoolMapper.getUserNumById(schoolid);
300
+        if (usernum != null) {
301
+            Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
302
+            usernum2 = usernum2 + 1;//学校账号数量+本次添加的人
303
+            if (usernum.compareTo(usernum2) == -1) {
304
+                throw new Exception("账号数量已超限,请联系管理员");
305
+            }
306
+        }
307
+        user.setUserstate(1);
308
+        user.setCreatetime(N_Utils.getSecondTimestamp());
309
+        Integer bindphoned = 0;
310
+        String userphone = user.getUserphone();
311
+        if (N_Utils.isNotEmpty(userphone)) {
312
+            //获取手机号绑定的其他用户数量
313
+            Integer num = userMapper.getNumByUserPhone(0, userphone);
314
+            if (num != 0) {//手机号被其他账号绑定,不保存返回提示信息
315
+                throw new Exception("手机号【" + userphone + "】已被绑定");
316
+            } else {//手机号未被其他账号绑定,设置已绑定手机号
317
+                bindphoned = 1;
318
+            }
319
+        }
320
+        user.setBindphoned(bindphoned);
321
+        if ("NaN-aN-aN".equals(user.getUsertime())) {//有效期异常值置空
322
+            user.setUsertime(null);
323
+        }
324
+        user.setBindsecret(0);
325
+        user.setUserlock(0);
326
+        userMapper.insertUseGeneratedKeys(user);
327
+        user.setUserid(user.getId());
328
+        return user;
329
+    }
330
+
293 331
     //删除
294 332
     @Transactional(rollbackFor = Exception.class)
295 333
     public void deleteById(Integer classid, Integer studentid) {
@@ -332,7 +370,7 @@ public class ClassStudentService {
332 370
 
333 371
     //修改
334 372
     public ResultVo update(TClassStudent model) {
335
-        TUser u = userService.getObjByLoginName(model.getStudentno());
373
+        TUser u = userMapper.getObjByLoginName(model.getStudentno());
336 374
         if (u != null && !model.getStudentid().equals(u.getUserid())) {
337 375
             return new ResultVo(1, "该账号已被【" + u.getUsername() + "】占用");
338 376
         }
@@ -346,8 +384,23 @@ public class ClassStudentService {
346 384
         user.setUserphone(model.getUserphone());
347 385
         user.setUsertime(model.getUsertime());
348 386
         user.setHeadpic(model.getHeadpic());
349
-        ResultVo vo = userService.update(user);
350
-        if (vo.getCode() != 0) return vo;
387
+        Integer bindphoned = 0;
388
+        String userphone = user.getUserphone();
389
+        if (N_Utils.isEmpty(userphone) || userphone.contains("****")) {//手机号为空或带星号不修改手机号和是否绑定手机号
390
+            bindphoned = null;
391
+            user.setUserphone(null);
392
+        } else if (N_Utils.isNotEmpty(userphone)) {
393
+            //获取手机号绑定的其他用户数量
394
+            Integer num = userMapper.getNumByUserPhone(user.getUserid(), userphone);
395
+            if (num != 0) return new ResultVo(1, "此手机号已被绑定");
396
+            bindphoned = 1;
397
+        }
398
+        user.setBindphoned(bindphoned);
399
+        if ("NaN-aN-aN".equals(user.getUsertime())) {//有效期异常值置空
400
+            user.setUsertime(null);
401
+        }
402
+        user.setCreatetime(N_Utils.getSecondTimestamp());
403
+        userMapper.updateByPrimaryKeySelective(user);
351 404
         return new ResultVo(0, "修改成功");
352 405
     }
353 406
 
@@ -378,22 +431,17 @@ public class ClassStudentService {
378 431
             }
379 432
             Integer usernum = schoolMapper.getUserNumById(schoolid);
380 433
             if (usernum != null) {
381
-                Integer usernum2 = userService.getUserNumBySchoolId(schoolid);
434
+                Integer usernum2 = userMapper.getUserNumBySchoolId(schoolid);
382 435
                 usernum2 = usernum2 + stunum;//学校账号数量+本次添加的人
383 436
                 if (usernum.compareTo(usernum2) == -1) {
384 437
                     return new ResultVo(1, "账号数量已超限,请联系管理员");
385 438
                 }
386 439
             }
387 440
             map.remove("users");//导入成功的学生信息不返回给前端
388
-            /*if (!CollectionUtils.isEmpty((List<TUser>)map.get("excelExisted"))) {
389
-                map.put("code",1);
390
-                return new ResultVo(0, "导入失败", map);
391
-            }*/
392 441
 
393 442
             List<TUser> users = new ArrayList<>();
394 443
             List<TClassStudent> classStudents = new ArrayList<>();
395 444
             List<TGroupStudent> groupStudents = new ArrayList<>();
396
-            //List<Integer> delClassidList = new ArrayList<>();//需要删除的班级学生信息
397 445
             List<TClassStudent> delStudentList = new ArrayList<>();//要删除的班级学生集合
398 446
             List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
399 447
             Map<Integer, List<Map>> courseMap = new HashMap<>();//要添加班级直播
@@ -401,7 +449,7 @@ public class ClassStudentService {
401 449
             // 以下学生信息已存在
402 450
             List<TUser> usersExisted = new ArrayList<>();
403 451
             for (TUser user : students) {
404
-                TUser u = userService.getObjByLoginName(user.getLoginname());
452
+                TUser u = userMapper.getObjByLoginName(user.getLoginname());
405 453
                 if (null == u) {
406 454
                     user.setSchoolid(schoolid);
407 455
                     user.setCreateid(createid);
@@ -421,7 +469,7 @@ public class ClassStudentService {
421 469
                         Integer classid = user.getClassid();
422 470
                         if (!classid.equals(oldclassid) && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
423 471
                             if (1 != u.getUserstate()) {
424
-                                userService.updateState(u.getUserid(), 1);
472
+                                userMapper.updateState(u.getUserid(), 1);
425 473
                             }
426 474
                             //要添加的班级
427 475
                             setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
@@ -466,7 +514,7 @@ public class ClassStudentService {
466 514
 
467 515
             //保存用户信息
468 516
             if (!CollectionUtils.isEmpty(users)) {
469
-                userService.batchSave(users);
517
+                userMapper.insertList(users);
470 518
                 for (TUser user : users) {
471 519
                     Integer studentid = user.getId();
472 520
                     Integer classid = user.getClassid();
@@ -478,12 +526,9 @@ public class ClassStudentService {
478 526
 
479 527
             List<Integer> classidlist = new ArrayList<>();
480 528
             if (N_Utils.isListNotEmpty(delStudentList)) {//要删除的班级学生集合
481
-                Map<Integer, List<TClassStudent>> slist = delStudentList.stream().collect(Collectors.groupingBy(m -> m.getStudentid()));
482
-                for (Map.Entry<Integer, List<TClassStudent>> entry : slist.entrySet()) {
483
-                    List<Integer> delClassidList = delStudentList.stream().map(TClassStudent::getClassid).collect(Collectors.toList());
484
-                    classStudentMapper.deleteBatchStudent(delClassidList, entry.getKey().toString());//批量移除班级学生
485
-                    classidlist.addAll(delClassidList);
486
-                }
529
+                List<Integer> delClassidList = delStudentList.stream().map(TClassStudent::getClassid).collect(Collectors.toList());
530
+                classStudentMapper.deleteBatchStudent2(delStudentList);//批量删除班级、分组对应学生
531
+                classidlist.addAll(delClassidList);
487 532
             }
488 533
 
489 534
             //保存学生关联信息
@@ -587,7 +632,7 @@ public class ClassStudentService {
587 632
             // 以下学生信息不存在
588 633
             List<TUser> usersNotExisted = new ArrayList<>();
589 634
             for (TUser user : students) {
590
-                TUser u = userService.getObjByLoginName(user.getLoginname());
635
+                TUser u = userMapper.getObjByLoginName(user.getLoginname());
591 636
                 if (null == u) {
592 637
                     user.setSchoolid(schoolid);
593 638
                     user.setCreateid(createid);
@@ -604,7 +649,7 @@ public class ClassStudentService {
604 649
                         usersNotExisted.add(u);
605 650
                     } else if (0 == classnum && 2 == u.getUsertype() && schoolid == u.getSchoolid()) {
606 651
                         if (1 != u.getUserstate()) {
607
-                            userService.updateState(u.getUserid(), 1);
652
+                            userMapper.updateState(u.getUserid(), 1);
608 653
                         }
609 654
                         setStudents(classid, schoolid, createid, user.getGroupid(), classStudents, groupStudents, studentid);//处理班级加入学生
610 655
                         List<Map> courses = listCourseByClassId(courseMap, classid);
@@ -803,7 +848,21 @@ public class ClassStudentService {
803 848
      * @Date 2020/9/18 11:56
804 849
      **/
805 850
     public void removeBind(Integer studentid) {
806
-        userService.removeBind(studentid);
851
+        List<Integer> studentids = new ArrayList<>();
852
+        studentids.add(studentid);
853
+        userMapper.batchRemoveBind(studentids);//批量解绑
854
+    }
855
+
856
+    /**
857
+     * 批量解绑
858
+     *
859
+     * @param [studentids]
860
+     * @return void
861
+     * @author ywx
862
+     * @date 2022/5/20 13:48
863
+     */
864
+    public void batchRemoveBind(List<Integer> studentids) {
865
+        userMapper.batchRemoveBind(studentids);//批量解绑
807 866
     }
808 867
 
809 868
     /**
@@ -870,4 +929,160 @@ public class ClassStudentService {
870 929
         }
871 930
         return new ResultVo(0, "取消选课成功");
872 931
     }
932
+
933
+    /**
934
+     * 批量移除学生
935
+     *
936
+     * @param [students]
937
+     * @return void
938
+     * @author ywx
939
+     * @date 2022/5/20 14:52
940
+     */
941
+    @Transactional(rollbackFor = Exception.class)
942
+    public void batchDelete(List<TClassStudent> students) {
943
+        try {
944
+            List<TClassStudent> delStudentList = new ArrayList<>();//要删除的班级学生集合
945
+            delStudentList.addAll(students);
946
+            List<Integer> delids = students.stream().map(TClassStudent::getClassid).distinct().collect(Collectors.toList());
947
+
948
+            List<Map> classMap = classStudentMapper.listClassIdsByCidAndSid(students);//获取学生除某个班外的行政班和提高班ids
949
+            Map<Integer, String> studentClassMap = new HashMap<>();//学生除某个班外的行政班和提高班ids集合
950
+            for (Map map : classMap) {
951
+                studentClassMap.put((Integer) map.get("studentid"), map.get("classids").toString());
952
+            }
953
+            List<Map> courseAll = courseMapper.listXzCourse2(delids);//指定班级的直播课
954
+            Map<Integer, List<Map>> delCourseMap = courseAll.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("oldclassid")));
955
+
956
+            List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
957
+            for (TClassStudent student : students) {
958
+                Integer classid = student.getClassid();
959
+                Integer studentid = student.getStudentid();
960
+                //把这个学生从此行政班、提高班关联的所有直播班移除
961
+                String classids = studentClassMap.get(studentid);//获取学生除某个班外的行政班和提高班ids
962
+                List<Map> courses = delCourseMap.get(classid);//指定班级的直播课
963
+                if (courses == null) courses = new ArrayList<>();//null时执行hs1.removeAll(hs2)报错
964
+                if (N_Utils.isNotEmpty(classids)) {
965
+                    List<Map> courses2 = courseMapper.listCourse(classids);//某些班的直播课
966
+                    if (N_Utils.isListNotEmpty(courses2)) {//要排除班级的直播不为空
967
+                        HashSet hs1 = new HashSet(courses);
968
+                        HashSet hs2 = new HashSet(courses2);
969
+                        hs1.removeAll(hs2);//指定班级排除某些班级的直播
970
+                        courses = new ArrayList<>();
971
+                        courses.addAll(hs1);
972
+                    }
973
+                }
974
+                handleDelClassCourse2(delStudentList, changeCourseidList, courses, studentid);//处理关联的直播课以及需要删除学生的直播班id
975
+            }
976
+
977
+            List<Integer> delClassidList = delStudentList.stream().map(TClassStudent::getClassid).distinct().collect(Collectors.toList());
978
+            classStudentMapper.deleteBatchStudent2(delStudentList);//批量删除班级、分组对应学生
979
+            String numclassids = delClassidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
980
+            classMapper.updateClassGroupNumByType(numclassids);//批量修改班级、班级分组数量
981
+            if (N_Utils.isListNotEmpty(changeCourseidList)) {
982
+                String numcourseids = changeCourseidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
983
+                courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
984
+            }
985
+        } catch (Exception e) {
986
+            log.error("批量移除学生出错:" + e.getMessage());
987
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
988
+            throw new MissingParametersException(e.getMessage());
989
+        }
990
+    }
991
+
992
+    /**
993
+     * 批量转班
994
+     *
995
+     * @param [students]
996
+     * @return void
997
+     * @author ywx
998
+     * @date 2022/5/20 17:07
999
+     */
1000
+    @Transactional(rollbackFor = Exception.class)
1001
+    public void batchMoveClass(List<TClassStudent> students) {
1002
+        try {
1003
+            List<TClassStudent> delStudentList = new ArrayList<>();//要删除的班级学生集合
1004
+            List<TClassStudent> addClassStudentList = new ArrayList<>();//新增的班级学生集合
1005
+            List<TGroupStudent> addGroupStudentList = new ArrayList<>();//新增的班级分组集合
1006
+            List<Integer> changeCourseidList = new ArrayList<>();//用户更新直播课中学生数量
1007
+
1008
+            List<Integer> classIds = students.stream().map(TClassStudent::getClassid).distinct().collect(Collectors.toList());
1009
+            List<ClassVo> classes = classMapper.listByIds(classIds);//获取新班级信息
1010
+            List<Map> addCourseAll = courseMapper.listXzCourse2(classIds);//指定班级的直播课
1011
+            Map<Integer, List<Map>> addCourseMap = addCourseAll.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("oldclassid")));
1012
+
1013
+            List<TClassStudent> oldStudents = new ArrayList<>();//要转班的班级学生集合
1014
+            for (TClassStudent student : students) {
1015
+                TClassStudent oldStu = new TClassStudent();
1016
+                oldStu.setClassid(student.getOldclassid());
1017
+                oldStu.setStudentid(student.getStudentid());
1018
+                oldStudents.add(oldStu);
1019
+            }
1020
+            List<Map> classMap = classStudentMapper.listClassIdsByCidAndSid(oldStudents);//获取学生除某个班外的行政班和提高班ids
1021
+            Map<Integer, String> studentClassMap = new HashMap<>();//学生除某个班外的行政班和提高班ids集合
1022
+            for (Map map : classMap) {
1023
+                studentClassMap.put((Integer) map.get("studentid"), map.get("classids").toString());
1024
+            }
1025
+            List<Integer> delids = students.stream().map(TClassStudent::getOldclassid).distinct().collect(Collectors.toList());
1026
+            List<Map> courseAll = courseMapper.listXzCourse2(delids);//指定班级的直播课
1027
+            Map<Integer, List<Map>> courseMap = courseAll.stream().collect(Collectors.groupingBy(m -> (Integer) m.get("oldclassid")));
1028
+            Map<String, List<Map>> delCourseMap = new HashMap();//要删除班级直播课
1029
+            for (TClassStudent student : students) {
1030
+                Integer studentid = student.getStudentid();
1031
+                Integer classid = student.getClassid();
1032
+                //把这个学生从此行政班、提高班关联的所有直播班移除
1033
+                String classids = studentClassMap.get(studentid);//获取学生除某个班外的行政班和提高班ids
1034
+                List<Map> courses = courseMap.get(student.getOldclassid());//指定班级的直播课
1035
+                if (courses == null) courses = new ArrayList<>();//null时执行hs1.removeAll(hs2)报错
1036
+                List<Map> courses2;
1037
+                if (N_Utils.isNotEmpty(classids)) {
1038
+                    courses2 = delCourseMap.get(classids);
1039
+                    if (N_Utils.isListEmpty(courses2)) {
1040
+                        courses2 = courseMapper.listCourse(classids);//某些班的直播课
1041
+                        delCourseMap.put(classids, courses2);
1042
+                    }
1043
+                    if (courses2 == null) {//要排除班级的直播为空
1044
+                        courses2 = courses;
1045
+                    } else {//要排除班级的直播不为空
1046
+                        HashSet hs1 = new HashSet(courses);
1047
+                        HashSet hs2 = new HashSet(courses2);
1048
+                        hs1.removeAll(hs2);//指定班级排除某些班级的直播
1049
+                        courses2 = new ArrayList<>();
1050
+                        courses2.addAll(hs1);
1051
+                    }
1052
+                } else {
1053
+                    courses2 = courses;//指定班级的直播课
1054
+                }
1055
+                handleDelClassCourse2(delStudentList, changeCourseidList, courses2, studentid);//处理关联的直播课以及需要删除学生的直播班id
1056
+
1057
+                //学生新添加班级的信息
1058
+                ClassVo classVo = classes.stream().filter(c -> c.getClassid().equals(classid)).findFirst().orElse(null);//获取新班级信息
1059
+                //学生要加入新的班级信息处理
1060
+                moveClassHandleAddGroupStudent(addClassStudentList, addGroupStudentList, classVo, studentid);
1061
+
1062
+                //获取新班级关联直播课关联的班级,并把学生加入
1063
+                courses = addCourseMap.get(classid);
1064
+                handleAddClassCourse(addClassStudentList, addGroupStudentList, changeCourseidList, courses, studentid);
1065
+            }
1066
+
1067
+            List<Integer> delClassidList = delStudentList.stream().map(TClassStudent::getClassid).distinct().collect(Collectors.toList());
1068
+            classStudentMapper.deleteBatchStudent2(delStudentList);//批量删除班级、分组对应学生
1069
+            classStudentMapper.saveBatchClassStudent(addClassStudentList);//批量新增班级学生
1070
+            groupStudentMapper.saveBatchGroupStudent(addGroupStudentList);//批量新增班级分组学生
1071
+
1072
+            //新增学生的班级id集合
1073
+            List<Integer> saveclassids = addClassStudentList.stream().map(TClassStudent::getClassid).distinct().collect(Collectors.toList());
1074
+            delClassidList.addAll(saveclassids);
1075
+
1076
+            String numclassids = delClassidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
1077
+            classMapper.updateClassGroupNumByType(numclassids);//批量修改班级、班级分组数量
1078
+            if (N_Utils.isListNotEmpty(changeCourseidList)) {
1079
+                String numcourseids = changeCourseidList.stream().distinct().map(String::valueOf).collect(Collectors.joining(","));
1080
+                courseMapper.updateStuNumBatch(numcourseids);//批量修改课程学生数量
1081
+            }
1082
+        } catch (Exception e) {
1083
+            log.error("批量转班出错:" + e.getMessage());
1084
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
1085
+            throw new MissingParametersException(e.getMessage());
1086
+        }
1087
+    }
873 1088
 }

+ 25
- 0
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java Voir le fichier

@@ -1164,4 +1164,29 @@ public class UserService extends JedisUtil {
1164 1164
     public void updateByPrimaryKeySelective(TUser user) {
1165 1165
         userMapper.updateByPrimaryKeySelective(user);
1166 1166
     }
1167
+
1168
+    /**
1169
+     * 批量修改密码
1170
+     *
1171
+     * @param [loginpwd, userids]
1172
+     * @return void
1173
+     * @author ywx
1174
+     * @date 2022/5/20 11:18
1175
+     */
1176
+    public void batchUpdatePwd2(String loginpwd, List<Integer> userids) {
1177
+        loginpwd = N_Utils.getMD5Pwd(loginpwd);
1178
+        userMapper.batchUpdatePwd2(loginpwd, userids);
1179
+    }
1180
+
1181
+    /**
1182
+     * 批量修改有效期
1183
+     *
1184
+     * @param [usertime, userids]
1185
+     * @return void
1186
+     * @author ywx
1187
+     * @date 2022/5/20 11:22
1188
+     */
1189
+    public void batchUpdateTime(String usertime, List<Integer> userids) {
1190
+        userMapper.batchUpdateTime(usertime, userids);
1191
+    }
1167 1192
 }

+ 10
- 0
suser/src/main/resources/mapper/gradeclass/ClassMapper.xml Voir le fichier

@@ -83,4 +83,14 @@
83 83
         left join t_subject_book sb on tp.lsbid=sb.lsbid
84 84
         where ct.classid=#{classid} group by ct.teacherid order by ct.teacherid
85 85
     </select>
86
+    <!--获取班级信息-->
87
+    <select id="listByIds" resultType="com.xhkjedu.suser.vo.gradeclass.ClassVo">
88
+        select c.classid,c.classname,c.gradeid,c.classnum,tg.groupid,c.classtype,c.createid,c.schoolid,c.year
89
+        from t_class c left join t_group tg on c.classid = tg.classid
90
+        where tg.grouptype=1 and c.classid in
91
+        <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
92
+            ${classid}
93
+        </foreach>
94
+        group by c.classid
95
+    </select>
86 96
 </mapper>

+ 21
- 0
suser/src/main/resources/mapper/gradeclass/ClassStudentMapper.xml Voir le fichier

@@ -153,4 +153,25 @@
153 153
         left join t_class_student cs on c.classid=cs.classid
154 154
         where tc.classid=#{classid} and c.classid!=#{classid} and c.classtype in(1,2) and cs.studentid=#{studentid}
155 155
     </select>
156
+    <!--获取学生除某个班外的行政班和提高班id-->
157
+    <select id="listClassIdsByCidAndSid" resultType="java.util.Map">
158
+        select group_concat(c.classid)classids,cs.studentid
159
+        from t_class tc left join t_class c on c.schoolid=tc.schoolid and c.`year`=tc.`year`
160
+        left join t_class_student cs on c.classid=cs.classid
161
+        where c.classtype in(1,2) and
162
+        <foreach collection="students" item="student" index="index" open="(" separator="or" close=")">
163
+            (tc.classid=${student.classid} and c.classid!=${student.classid} and cs.studentid=${student.studentid})
164
+        </foreach>
165
+        group by cs.studentid
166
+    </select>
167
+    <!--批量删除班级、分组对应学生-->
168
+    <delete id="deleteBatchStudent2">
169
+        delete cs.*,gs.*
170
+        from t_class_student cs left join t_group g on g.classid=cs.classid
171
+        left join t_group_student gs on g.groupid = gs.groupid AND gs.studentid=cs.studentid
172
+        where
173
+        <foreach collection="students" item="student" separator="or">
174
+            (cs.classid=${student.classid} and cs.studentid=${student.studentid})
175
+        </foreach>
176
+    </delete>
156 177
 </mapper>

+ 11
- 0
suser/src/main/resources/mapper/liveplay/CourseMapper.xml Voir le fichier

@@ -14,6 +14,17 @@
14 14
         where c.coursetype=1 and cc.classid=#{classid}
15 15
         group by c.courseid
16 16
     </select>
17
+    <!--指定班级的直播课-->
18
+    <select id="listXzCourse2" resultType="java.util.Map">
19
+        select c.courseid,c.classid,c.createid,c.schoolid,g.groupid,cc.classid oldclassid
20
+        from l_course c left join l_course_class cc on cc.courseid=c.courseid
21
+        left join t_group g on c.classid=g.classid and g.grouptype=1
22
+        where c.coursetype=1 and cc.classid in
23
+        <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
24
+            ${classid}
25
+        </foreach>
26
+        group by c.courseid,cc.classid
27
+    </select>
17 28
 
18 29
     <!--批量更改课程学生数量-->
19 30
     <update id="updateStuNumBatch">

+ 21
- 0
suser/src/main/resources/mapper/system/UserMapper.xml Voir le fichier

@@ -240,4 +240,25 @@
240 240
     <select id="listBindPhoneUser" resultType="java.util.Map">
241 241
         select loginname,userphone from t_user where userphone!=''
242 242
     </select>
243
+    <!--批量解绑-->
244
+    <update id="batchRemoveBind">
245
+        update t_user set bindmac=0,mac=NULL where userid in
246
+        <foreach collection="userids" item="userid" index="index" open="(" separator="," close=")">
247
+            ${userid}
248
+        </foreach>
249
+    </update>
250
+    <!--批量修改密码-->
251
+    <update id="batchUpdatePwd2">
252
+        update t_user set loginpwd=#{loginpwd} where userid in
253
+        <foreach collection="userids" item="userid" index="index" open="(" separator="," close=")">
254
+            ${userid}
255
+        </foreach>
256
+    </update>
257
+    <!--批量修有效期-->
258
+    <update id="batchUpdateTime">
259
+        update t_user set usertime=#{usertime} where userid in
260
+        <foreach collection="userids" item="userid" index="index" open="(" separator="," close=")">
261
+            ${userid}
262
+        </foreach>
263
+    </update>
243 264
 </mapper>

Chargement…
Annuler
Enregistrer