| 
					
				 | 
			
			
				@@ -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查询是否已经私有分享当前课程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 |