|
|
@@ -3,6 +3,7 @@ package com.xjrsoft.module.base.service.impl;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
@@ -89,37 +90,60 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
|
|
|
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())
|
|
|
;
|
|
|
- isSuccess = this.remove(baseClassCourseLambdaQueryWrapper);
|
|
|
+ List<BaseClassCourse> oldList = this.list(baseClassCourseLambdaQueryWrapper);
|
|
|
|
|
|
-
|
|
|
- // 获取所有班级的所有学生
|
|
|
- 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)
|
|
|
+ // 使用Stream API和Lambda表达式生成所需的字符串列表
|
|
|
+ Map<Long, List<String>> tourseId_textbookIdMap = oldList.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
|
- BaseStudentSchoolRoll::getClassId, // 根据classId分组
|
|
|
- Collectors.mapping(BaseStudentSchoolRoll::getUserId, // 提取userId
|
|
|
- Collectors.toList()) // 收集到List<Long>
|
|
|
+ BaseClassCourse::getClassId,
|
|
|
+ Collectors.mapping(
|
|
|
+ course -> course.getCourseId() + "_" + course.getTextbookId(),
|
|
|
+ Collectors.toList()
|
|
|
)
|
|
|
- );
|
|
|
+ ));
|
|
|
+
|
|
|
+// //删除班级的这学期的所有课程教材
|
|
|
+// LambdaQueryWrapper<BaseClassCourse> baseClassCourseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+// baseClassCourseLambdaQueryWrapper
|
|
|
+// .in(BaseClassCourse::getClassId, classIdList)
|
|
|
+// .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+// ;
|
|
|
+// isSuccess = this.remove(baseClassCourseLambdaQueryWrapper);
|
|
|
+
|
|
|
+// // 获取所有班级的所有学生
|
|
|
+// 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<>();
|
|
|
+// 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;
|
|
|
@@ -133,29 +157,47 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
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);
|
|
|
- }});
|
|
|
- }
|
|
|
+// // 添加学生领取教材数据
|
|
|
+// 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);
|
|
|
- }
|
|
|
+// for (TextbookStudentClaim textbookStudentClaim : textbookStudentClaimList) {
|
|
|
+// textbookStudentClaimMapper.insert(textbookStudentClaim);
|
|
|
+// }
|
|
|
return this.saveBatch(baseClassCourseList);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateRemoveCourseBook(Long classId, Long courseId, Long textbookId){
|
|
|
- baseClassCourseMapper.updateRemoveClassCourseTextbooks(classId, courseId, textbookId);
|
|
|
+ public Boolean updateRemoveCourseBook(ClassCourseTextbook dto){
|
|
|
+// baseClassCourseMapper.updateRemoveClassCourseTextbooks(classId, courseId, textbookId);
|
|
|
+ for (Long classId : dto.getClassIds()) {
|
|
|
+ for (String id : dto.getIds()) {
|
|
|
+ String[] idArr = id.split("_");
|
|
|
+ if (idArr[0].equals("") || idArr[1].equals("")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long courseId = Long.parseLong(idArr[0]);
|
|
|
+ Long textbookId = Long.parseLong(idArr[1]);
|
|
|
+ LambdaUpdateWrapper<BaseClassCourse> baseClassCourseLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ baseClassCourseLambdaUpdateWrapper
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(BaseClassCourse::getClassId, classId)
|
|
|
+ .eq(BaseClassCourse::getCourseId, classId)
|
|
|
+ .eq(BaseClassCourse::getTextbookId, textbookId)
|
|
|
+ ;
|
|
|
+ this.remove(baseClassCourseLambdaUpdateWrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|