浏览代码

Merge branch 'feature/0529-live' of http://git.dayaedu.com/yonge/mec into master_saas

zouxuan 2 年之前
父节点
当前提交
67cc222884

+ 95 - 111
.idea/httpRequests/http-requests-log.http

@@ -1,3 +1,98 @@
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095605.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095427.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095323.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095238.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095217.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T095045.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 093517b0-c9a4-407b-b558-0d71bf157b16
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T094907.200.json
+
+###
+
+GET http://127.0.0.1:9001/studentVipGroup/joinLiveRoomByShare?courseScheduleId=2179
+Authorization: bearer 81d0c352-fcc8-4812-87f5-0f7a68d10451
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+<> 2023-06-12T094734.200.json
+
+###
+
+POST http://localhost:8005/imSendGroupMessage/send
+Content-Type: application/json
+tenantId: 1
+Authorization: bearer 9b756b90-f27a-4ca9-99b1-da854c72eb3f
+Content-Length: 99
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
+Accept-Encoding: br,deflate,gzip,x-gzip
+
+{"postType":"0","messageContent":"3の3","messageType":"TXT","targetIds":"232","isIncludeSender":0}
+
+<> 2023-06-09T174838.200.json
+
+###
+
 GET http://127.0.0.1:8005/task/closeLiveCourseRoom
 Connection: Keep-Alive
 User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
@@ -638,114 +733,3 @@ Accept-Encoding: br,deflate,gzip,x-gzip
 
 ###
 
-GET http://127.0.0.1:9002/teacherCourseSchedule/liveCourseScheduleTime?courseScheduleId=1678
-Authorization: bearer 2cd308e9-0b8b-4b08-b3cd-f34dc50a8dfd
-Proxy-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-07T152014.200.json
-
-###
-
-GET http://127.0.0.1:8005/teacher/findTeacherByTenantId
-Authorization: bearer 7e4145d6-111d-429b-893a-4546df0f58ed
-tenantId: 1
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-06T170540.200.json
-
-###
-
-GET http://127.0.0.1:9002/classGroup/findTeacherClassStudents?classGroupId=191
-Authorization: bearer 7957b8d7-63d0-43e1-9c06-8a36b2cc85a4
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-05T193543.200.json
-
-###
-
-GET http://127.0.0.1:9002/classGroup/findTeacherClassStudents?classGroupId=197
-Authorization: bearer 7957b8d7-63d0-43e1-9c06-8a36b2cc85a4
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-05T193534.200.json
-
-###
-
-GET http://127.0.0.1:9002/classGroup/findTeacherClassStudents?courseScheduleId=1819
-Authorization: bearer 7957b8d7-63d0-43e1-9c06-8a36b2cc85a4
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-05T193400.200.json
-
-###
-
-GET http://127.0.0.1:9002/classGroup/findTeacherClassStudents?courseScheduleId=1270
-Authorization: bearer 7957b8d7-63d0-43e1-9c06-8a36b2cc85a4
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-05T193335.200.json
-
-###
-
-GET http://127.0.0.1:9002/classGroup/findTeacherClassStudents
-Authorization: bearer 7957b8d7-63d0-43e1-9c06-8a36b2cc85a4
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-<> 2023-06-05T193308.200.json
-
-###
-
-POST http://127.0.0.1:8005/studentManage/userPage
-Authorization: bearer b897da27-5a37-47df-8e76-54d80a61a55d
-Content-Type: application/json
-coopId: 25
-Content-Length: 137
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-//  "keyword": "一",
-//    "musicGroupId": 23050516201200001,
-  //  "subjectId": 2,
-  //  "vipFlag": true,
-//  "studentId": 2248340
-
-}
-
-<> 2023-06-02T201036.200.json
-
-###
-
-POST http://127.0.0.1:8005/studentManage/userDetail
-Authorization: bearer 81d0c352-fcc8-4812-87f5-0f7a68d10451
-Content-Type: application/json
-coopId: 25
-Content-Length: 63
-Connection: Keep-Alive
-User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
-Accept-Encoding: br,deflate,gzip,x-gzip
-
-{
-  "studentId": 2248340,
-  "musicGroupId": 23042419330600001
-}
-
-<> 2023-06-02T201028.200.json
-
-###
-

+ 35 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseShareServiceImpl.java

@@ -61,7 +61,7 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
     /**
      * 导入数据错误信息最大长度
      */
-    private static final int IMPORT_ERR_MSG_MAX_LEN = 1000;
+    private static final int IMPORT_ERR_MSG_MAX_LEN = 50;
 
     private static final String TENANT_ID = "tenantId";
 
@@ -243,28 +243,28 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         }
         List<Organization> allOrgans = organizationDao.findAllOrgans(courseSchedule.getTenantId());
         Set<String> orgNames = allOrgans.stream().map(Organization::getName).collect(Collectors.toSet());
-        StringBuilder sb = new StringBuilder();
         List<Student> studentList = new ArrayList<>();
         Set<String> phoneNos = new HashSet<>();
+        HashMap<Integer, String> rowIndexMsg = new LinkedHashMap<>();
         for (int index = 0; index < students.size(); index++) {
             Map<String, Object> row = students.get(index);
-            Student student = checkExcelData(sb, orgNames, phoneNos, index, row);
+            Student student = checkExcelData(rowIndexMsg, orgNames, phoneNos, index, row);
             if (student == null) {
                 // 空行过滤
                 continue;
             }
             // 避免导入数据存在大量错误数据,出现长时间等待
-            if (sb.length() > IMPORT_ERR_MSG_MAX_LEN) {
+            if (rowIndexMsg.keySet().size() > IMPORT_ERR_MSG_MAX_LEN) {
                 break;
             }
             studentList.add(student);
         }
-        if (sb.length() > 0) {
-            throw new BizException(sb.toString());
+        if (!rowIndexMsg.keySet().isEmpty()) {
+            List<String> msgList = new ArrayList<>(rowIndexMsg.values());
+            throw new BizException(String.join("\n", msgList));
         }
 
         // 判断导入的学生数据是否在库中匹配到,过滤非法的学生数据
-        SysUser sysUser = userService.getUser();
         Map<Integer, String> orgIdNameMap = allOrgans.stream()
                 .collect(Collectors.toMap(Organization::getId, Organization::getName));
 
@@ -295,33 +295,45 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
                     next.setUserId(legalStudentMap.get(key).getUserId());
                     return false;
                 }
+                rowIndexMsg.put(next.getUserId(), String.format("错误的学生姓名:%s,手机号:%s", next.getUsername(),
+                        next.getPhone()));
                 return true;
             });
         }
+
+        if (!rowIndexMsg.keySet().isEmpty()) {
+            List<String> msgList = new ArrayList<>(rowIndexMsg.values());
+            throw new BizException(String.join("\n", msgList));
+        }
         List<Student> legalStudents = studentGroupByOrg.values().stream()
                 .flatMap(Collection::stream).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(legalStudents)) {
-            throw new BizException("未解析到合法的学生");
-        }
 
         // 处理导入数据中存在已经分享的数据再次入库
         List<CourseShare> existShares = courseShareDao.selectByCourseId(courseId);
         if (CollectionUtils.isNotEmpty(existShares)) {
             Set<String> existShareKeys = existShares.stream()
                     .map(next -> (next.getCourseId() + "_" + next.getUserId())).collect(Collectors.toSet());
-            legalStudents.removeIf(next -> existShareKeys.contains(courseId + "_" + next.getUserId()));
+            legalStudents.removeIf(next -> {
+                if (existShareKeys.contains(courseId + "_" + next.getUserId())) {
+                    rowIndexMsg.put(next.getUserId(), "数据重复");
+                    return true;
+                }
+                return false;
+            });
         }
+        SysUser sysUser = userService.getUser();
+        Integer tenantId = TenantIdThreadLocal.get();
         List<CourseShare> courseShares = legalStudents.stream().map(next -> {
             CourseShare courseShare = new CourseShare();
             courseShare.setUserId(next.getUserId());
-            courseShare.setTenantId(TenantIdThreadLocal.get());
+            courseShare.setTenantId(tenantId);
             courseShare.setCourseId(courseId);
             courseShare.setCreateTime(new Date());
             courseShare.setCreateBy(sysUser.getId());
             return courseShare;
         }).collect(Collectors.toList());
         batchInsert(courseShares);
-        return String.format("成功导入%s条数据", courseShares.size());
+        return String.format("成功导入数据%s条%n重复数据%s条", courseShares.size(), rowIndexMsg.keySet().size());
     }
 
     @Override
@@ -330,15 +342,18 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         return true;
     }
 
-    private Student checkExcelData(StringBuilder sb, Set<String> orgNames, Set<String> phoneNos, int i, Map<String,
-            Object> row) {
+    private Student checkExcelData(HashMap<Integer, String> rowIndexMsg, Set<String> orgNames, Set<String> phoneNos,
+                                   int rowIndex, Map<String, Object> row) {
         Student student = new Student();
+        // 临时用作记录导入数据的行号
+        int currentRowIndex = rowIndex + 2;
+        student.setUserId(currentRowIndex);
         if (row.size() == 0) {
             return null;
         }
         Object orgName = row.get(STUDENT_TEMPLATE_FIELDS.get(0));
         if (Objects.isNull(orgName) || !orgNames.contains(orgName.toString().trim())) {
-            sb.append(String.format("第%s行分部数据格式错误或者所属分部不存在%n", (i + 2)));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行分部数据格式错误或者所属分部不存在%n", currentRowIndex));
         } else {
             student.setOrganName(orgName.toString().trim());
         }
@@ -346,19 +361,19 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         if (Objects.nonNull(studentName)) {
             student.setUsername(studentName.toString().trim());
         } else {
-            sb.append(String.format("第%s行学生姓名数据格式错误%n", (i + 2)));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行学生姓名数据格式错误%n", currentRowIndex));
         }
         Object phoneNo = row.get(STUDENT_TEMPLATE_FIELDS.get(2));
         if (Objects.nonNull(phoneNo)) {
             String phone = phoneNo.toString().trim();
             if (phoneNos.contains(phone)) {
-                sb.append(String.format("第%s行手机号重复%n", (i + 2)));
+                rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号重复%n", currentRowIndex));
                 return null;
             }
             student.setPhone(phone);
             phoneNos.add(phone);
         } else {
-            sb.append(String.format("第%s行手机号数据格式错误%n", (i + 2)));
+            rowIndexMsg.put(currentRowIndex, String.format("第%s行手机号数据格式错误%n", currentRowIndex));
         }
         return student;
     }
@@ -378,6 +393,7 @@ public class CourseShareServiceImpl extends BaseServiceImpl<Integer, CourseShare
         }
         return courseSchedule;
     }
+
     /**
      * 根据用户id和课程id查询是否已经私有分享当前课程
      *

+ 13 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -384,7 +384,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         classGroup.setName(vipGroupApplyBaseInfoDto.getName());
         classGroup.setTotalClassTimes(totalClassTimes);
         classGroup.setType(ClassGroupTypeEnum.valueOf(groupType));
-        classGroup.setDelFlag(1);
         classGroup.setGroupType(GroupType.valueOf(groupType));
         classGroup.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
 
@@ -4623,7 +4622,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 
         imGroupService.create(classGroup.getId().toString(), null, classGroup.getName(), classGroup.getName(),
-                vipGroup.getName(), null, "https://gyt.ks3-cn-beijing.ksyuncs.com/icon_live_class_group_avatar.png", vipGroup.getGroupType(), ImGroup.GroupTypeEnum.valueOf(vipGroup.getGroupType()));
+                vipGroup.getName(), null, "https://gyt.ks3-cn-beijing.ksyuncs.com/icon_live_class_group_avatar.png",
+                vipGroup.getGroupType(), ImGroup.GroupTypeEnum.valueOf(vipGroup.getGroupType()));
         imGroupMemberService.join(classGroup.getId().toString(), userRoleMap);
         imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(), classGroup.getGroupType());
         classGroupDao.update(classGroup);
@@ -5188,15 +5188,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             throw new BizException("课程不存在");
         }
 
-        // 课程是否开始
-        if(CourseStatusEnum.NOT_START.equals(courseSchedule.getStatus())) {
-            throw new BizException("课程未开始");
-        }
-
-        // 是否结束
-        if (CourseStatusEnum.OVER.equals(courseSchedule.getStatus())) {
-            throw new BizException("课程已结束");
-        }
 
         // 分享类型  是否能进入
         if (ShareModeEnum.NO_SHARE.equals(courseSchedule.getShareMode())) {
@@ -5210,6 +5201,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             }
         }
 
+
+        // 课程是否开始
+        if(CourseStatusEnum.NOT_START.equals(courseSchedule.getStatus())) {
+            throw new BizException("课程未开始");
+        }
+
+        // 是否结束
+        if (CourseStatusEnum.OVER.equals(courseSchedule.getStatus())) {
+            throw new BizException("课程已结束");
+        }
+
         return LiveGroupWrapper.LiveCourseInfo.builder()
                 .studentId(studentId)
                 .canJoinShareRoom(true)

+ 9 - 2
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -283,8 +283,13 @@ public class TaskController extends BaseController {
 	public void updateVipGroupToFinishedStatus() {
 		//更新vip课程状态
 		vipGroupService.updateVipGroupStatusToFinished();
-		//更新直播课状态
-		vipGroupService.createLiveCourse();
+		List<TenantInfo> tenantInfos = tenantInfoService.list(new QueryWrapper<TenantInfo>().eq("state_",1));
+		if(tenantInfos != null && tenantInfos.size() > 0){
+			for (TenantInfo tenantInfo : tenantInfos) {
+				//更新直播课状态
+				vipGroupService.createLiveCourse();
+			}
+		}
 	}
 
 	@GetMapping("/stopVipGroupWithNoCreate")
@@ -298,7 +303,9 @@ public class TaskController extends BaseController {
 		List<TenantInfo> tenantInfos = tenantInfoService.list(new QueryWrapper<TenantInfo>().eq("state_",1));
 		if(tenantInfos != null && tenantInfos.size() > 0){
 			for (TenantInfo tenantInfo : tenantInfos) {
+				TenantContextHolder.setTenantId(tenantInfo.getId());
 				teacherAttendanceService.pushNoSignOutMessage(tenantInfo.getId());
+				TenantContextHolder.clearTenantId();
 			}
 		}
 	}