|
@@ -81,6 +81,100 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
return baseClassCourseMapper.getSelectedCourseBook(subjectGroupId, semester);
|
|
return baseClassCourseMapper.getSelectedCourseBook(subjectGroupId, semester);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean oneUpdateClassCoursesAndTextbooks(ClassCourseTextbook dto) {
|
|
|
|
|
+ if (dto.getClassIds() == null || dto.getClassIds().length == 0 || dto.getBaseSemesterId() == null || dto.getBaseSemesterId() == 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ boolean isSuccess = false;
|
|
|
|
|
+
|
|
|
|
|
+ // 根据班级id查出班级已经存在的课程和教程
|
|
|
|
|
+ List<Long> classIdList = Arrays.asList(dto.getClassIds());
|
|
|
|
|
+ LambdaQueryWrapper<BaseClassCourse> baseClassCourseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ baseClassCourseLambdaQueryWrapper
|
|
|
|
|
+ .in(BaseClassCourse::getClassId, classIdList)
|
|
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
|
|
+ ;
|
|
|
|
|
+ List<BaseClassCourse> oldList = this.list(baseClassCourseLambdaQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 使用Stream API和Lambda表达式生成所需的字符串列表
|
|
|
|
|
+ Map<Long, List<String>> tourseId_textbookIdMap = oldList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ BaseClassCourse::getClassId,
|
|
|
|
|
+ Collectors.mapping(
|
|
|
|
|
+ course -> course.getCourseId() + "_" + course.getTextbookId(),
|
|
|
|
|
+ Collectors.toList()
|
|
|
|
|
+ )
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ //删除班级的这学期的所有课程教材
|
|
|
|
|
+ LambdaUpdateWrapper<BaseClassCourse> baseClassCourseLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ baseClassCourseLambdaUpdateWrapper
|
|
|
|
|
+ .in(BaseClassCourse::getClassId, classIdList)
|
|
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
|
|
+ ;
|
|
|
|
|
+ isSuccess = this.remove(baseClassCourseLambdaUpdateWrapper);
|
|
|
|
|
+
|
|
|
|
|
+// // 获取所有班级的所有学生
|
|
|
|
|
+// LambdaQueryWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+// baseStudentSchoolRollLambdaQueryWrapper
|
|
|
|
|
+// .in(BaseStudentSchoolRoll::getClassId, classIdList)
|
|
|
|
|
+// .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
|
|
+// ;
|
|
|
|
|
+// List<BaseStudentSchoolRoll> baseStudentSchoolRolls = baseStudentSchoolRollMapper.selectList(baseStudentSchoolRollLambdaQueryWrapper);
|
|
|
|
|
+//
|
|
|
|
|
+// Map<Long, List<Long>> userIdsMap = baseStudentSchoolRolls.stream()
|
|
|
|
|
+// .filter(student -> student.getClassId() != null && student.getUserId() != null)
|
|
|
|
|
+// .collect(Collectors.groupingBy(
|
|
|
|
|
+// BaseStudentSchoolRoll::getClassId, // 根据classId分组
|
|
|
|
|
+// Collectors.mapping(BaseStudentSchoolRoll::getUserId, // 提取userId
|
|
|
|
|
+// Collectors.toList()) // 收集到List<Long>
|
|
|
|
|
+// )
|
|
|
|
|
+// );
|
|
|
|
|
+
|
|
|
|
|
+ List<BaseClassCourse> baseClassCourseList = new ArrayList<>();
|
|
|
|
|
+// List<TextbookStudentClaim> textbookStudentClaimList = new ArrayList<>();
|
|
|
|
|
+ for (Long classId : dto.getClassIds()) {
|
|
|
|
|
+ // 判断当前的班级是否已经有了该课程和教材
|
|
|
|
|
+ List<String> tourseId_textbookIdList = tourseId_textbookIdMap.get(classId);
|
|
|
|
|
+ for (String id : dto.getIds()) {
|
|
|
|
|
+ if(tourseId_textbookIdList.contains(id)){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String[] idArr = id.split("_");
|
|
|
|
|
+ if (idArr[0].equals("") || idArr[1].equals("")) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long courseId = Long.parseLong(idArr[0]);
|
|
|
|
|
+ Long textbookId = Long.parseLong(idArr[1]);
|
|
|
|
|
+ baseClassCourseList.add(new BaseClassCourse() {{
|
|
|
|
|
+ setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
|
|
+ setClassId(classId);
|
|
|
|
|
+ setCourseId(courseId);
|
|
|
|
|
+ setTextbookId(textbookId);
|
|
|
|
|
+ }});
|
|
|
|
|
+
|
|
|
|
|
+// // 添加学生领取教材数据
|
|
|
|
|
+// List<Long> userIds = userIdsMap.get(classId);
|
|
|
|
|
+// for (Long userId : userIds) {
|
|
|
|
|
+// textbookStudentClaimList.add(new TextbookStudentClaim() {{
|
|
|
|
|
+// setStudentUserId(userId);
|
|
|
|
|
+// setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
|
|
+// setClassId(classId);
|
|
|
|
|
+// setTextbookId(textbookId);
|
|
|
|
|
+// }});
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// for (TextbookStudentClaim textbookStudentClaim : textbookStudentClaimList) {
|
|
|
|
|
+// textbookStudentClaimMapper.insert(textbookStudentClaim);
|
|
|
|
|
+// }
|
|
|
|
|
+ return this.saveBatch(baseClassCourseList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public Boolean updateAddCourseBook(ClassCourseTextbook dto){
|
|
public Boolean updateAddCourseBook(ClassCourseTextbook dto){
|