|
@@ -1,9 +1,11 @@
|
|
|
package com.xjrsoft.module.base.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
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.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
@@ -12,20 +14,17 @@ import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.UseSemesterTypeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
-import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
|
|
|
-import com.xjrsoft.module.base.dto.ClassCourseReuseDto;
|
|
|
+import com.xjrsoft.module.base.dto.*;
|
|
|
import com.xjrsoft.module.base.entity.*;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseClassAdminCourseMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassCourseService;
|
|
|
-import com.xjrsoft.module.base.vo.BaseClassCourseExportListVo;
|
|
|
-import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
|
|
|
+import com.xjrsoft.module.base.vo.*;
|
|
|
import com.xjrsoft.module.generator.entity.ImportConfig;
|
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
|
|
|
-import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
|
|
|
-import com.xjrsoft.module.base.vo.ClassCourseTextbookExportQueryVo;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import com.xjrsoft.module.textbook.entity.Textbook;
|
|
|
import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
|
|
@@ -66,114 +65,92 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
|
|
|
private final BaseClassMapper baseClassMapper;
|
|
|
|
|
|
+ private final BaseClassAdminCourseMapper baseClassAdminCourseMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<BaseClassCoursePageVo> getPage(Page<BaseClassCoursePageVo> page, BaseClassCoursePageDto dto) {
|
|
|
return baseClassCourseMapper.getPage(page, dto);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<BaseClassCourseListVo> oneClassClassCourseList(BaseClassCourseListDto dto) {
|
|
|
+ MPJLambdaWrapper<BaseClassAdminCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseClassCourseMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .select(BaseClassCourse::getId)
|
|
|
+ .selectAs(BaseClass::getName, BaseClassCourseListVo::getClassIdCn)
|
|
|
+ .selectAs(BaseCourseSubject::getName, BaseClassCourseListVo::getCourseIdCn)
|
|
|
+ .selectAs(Textbook::getBookName, BaseClassCourseListVo::getTextbookIdCn)
|
|
|
+ .selectAs(BaseSemester::getName, BaseClassCourseListVo::getBaseSemesterIdCn)
|
|
|
+ .select(BaseClassCourse.class, x -> VoToColumnUtil.fieldsToColumns(BaseClassCourseListVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClassAdminCourse::getId)
|
|
|
+ .leftJoin(BaseClass.class, BaseClass::getId, BaseClassAdminCourse::getClassId)
|
|
|
+ .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassAdminCourse::getBaseSemesterId)
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .eq(dto.getBaseSemesterId() != null && dto.getBaseSemesterId() > 0, BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(dto.getClassId() != null && dto.getClassId() > 0, BaseClassAdminCourse::getClassId, dto.getClassId())
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+
|
|
|
+ return baseClassAdminCourseMapper.selectJoinList(BaseClassCourseListVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BaseClassCourseMobileListVo> mobileOneClassClassCourseList(BaseClassCourseListDto dto) {
|
|
|
+ MPJLambdaWrapper<BaseClassAdminCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseClassCourseMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .select(BaseClassCourse::getId)
|
|
|
+ .selectAs(BaseCourseSubject::getName, BaseClassCourseMobileListVo::getCourseName)
|
|
|
+ .selectAs(Textbook::getBookName, BaseClassCourseMobileListVo::getBookName)
|
|
|
+ .selectAs(Textbook::getPrice, BaseClassCourseMobileListVo::getPrice)
|
|
|
+ .selectAs(DictionaryDetail::getName, BaseClassCourseMobileListVo::getTextbookTypeName)
|
|
|
+ .select(BaseClassCourse.class, x -> VoToColumnUtil.fieldsToColumns(BaseClassCourseMobileListVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClassAdminCourse::getId)
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode,Textbook::getTextbookType)
|
|
|
+ .eq(dto.getBaseSemesterId() != null && dto.getBaseSemesterId() > 0, BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(dto.getClassId() != null && dto.getClassId() > 0, BaseClassAdminCourse::getClassId, dto.getClassId())
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+ return baseClassAdminCourseMapper.selectJoinList(BaseClassCourseMobileListVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<CourseBookInfo> getAllCourseBook(Long[] classIds, Long subjectGroupId, Long semester){
|
|
|
return baseClassCourseMapper.getAllCourseBook(classIds, subjectGroupId, semester);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CourseBookInfo> getSelectedCourseBook(Long[] subjectGroupId, Long semester){
|
|
|
- return baseClassCourseMapper.getSelectedCourseBook(subjectGroupId, semester);
|
|
|
+ public List<CourseBookInfo> getSelectedCourseBook(Long[] classIds, Long semester){
|
|
|
+ return baseClassCourseMapper.getSelectedCourseBook(classIds, semester);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean oneUpdateClassCoursesAndTextbooks(ClassCourseTextbook dto) {
|
|
|
- if (ObjectUtils.isEmpty(dto.getClassIds()) || ObjectUtils.isEmpty(dto.getBaseSemesterId())) {
|
|
|
- throw new MyException("请选中班级和学期");
|
|
|
- }
|
|
|
-
|
|
|
- boolean isSuccess = false;
|
|
|
-
|
|
|
- List<Long> classIdList = Arrays.asList(dto.getClassIds());
|
|
|
-
|
|
|
- //删除班级的这学期的所有课程教材
|
|
|
- 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()) {
|
|
|
- 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]);
|
|
|
- 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);
|
|
|
+ return updateAddCourseBook(dto);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean updateAddCourseBook(ClassCourseTextbook dto){
|
|
|
- if (ObjectUtils.isEmpty(dto.getClassIds()) || ObjectUtils.isEmpty(dto.getBaseSemesterId())) {
|
|
|
- throw new MyException("请选中班级和学期");
|
|
|
+ if (ObjectUtils.isEmpty(dto.getBaseClassAdminCourseIds())) {
|
|
|
+ throw new MyException("添加课程的班级无效,请刷新重试");
|
|
|
}
|
|
|
|
|
|
- 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())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getBaseClassAdminCourseIds())
|
|
|
.eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
;
|
|
|
List<BaseClassCourse> oldList = this.list(baseClassCourseLambdaQueryWrapper);
|
|
|
|
|
|
// 使用Stream API和Lambda表达式生成所需的字符串列表
|
|
|
- Map<Long, List<String>> tourseId_textbookIdMap = oldList.stream()
|
|
|
+ Map<Long, List<String>> courseIdTextbookIdMap = oldList.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
|
BaseClassCourse::getClassId,
|
|
|
Collectors.mapping(
|
|
@@ -182,96 +159,78 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
)
|
|
|
));
|
|
|
|
|
|
-// //删除班级的这学期的所有课程教材
|
|
|
-// 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>
|
|
|
-// )
|
|
|
-// );
|
|
|
+ // 处理所有需要新增的教材
|
|
|
+ Map<String, BaseClassCourse> newClassCourseTextbookMap = new HashMap<>();
|
|
|
+ for (String id : dto.getIds()) {
|
|
|
+ String[] idArr = id.split("_");
|
|
|
+ if (idArr[0].isEmpty() || idArr[1].isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long courseId = Long.parseLong(idArr[0]);
|
|
|
+ Long textbookId = Long.parseLong(idArr[1]);
|
|
|
+ newClassCourseTextbookMap.put(id, new BaseClassCourse() {{
|
|
|
+ setCourseId(courseId);
|
|
|
+ setTextbookId(textbookId);
|
|
|
+ setCreateDate(new Date());
|
|
|
+ }});
|
|
|
+ }
|
|
|
|
|
|
+ // 处理每一个班需要新增的课程
|
|
|
List<BaseClassCourse> baseClassCourseList = new ArrayList<>();
|
|
|
-// List<TextbookStudentClaim> textbookStudentClaimList = new ArrayList<>();
|
|
|
- for (Long classId : dto.getClassIds()) {
|
|
|
+ for (Long classId : dto.getBaseClassAdminCourseIds()) {
|
|
|
// 判断当前的班级是否已经有了该课程和教材
|
|
|
- List<String> tourseId_textbookIdList = tourseId_textbookIdMap.get(classId);
|
|
|
- for (String id : dto.getIds()) {
|
|
|
- if(ObjectUtils.isNotEmpty(tourseId_textbookIdList) && !tourseId_textbookIdList.isEmpty() && tourseId_textbookIdList.contains(id)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String[] idArr = id.split("_");
|
|
|
- if (idArr[0].equals("") || idArr[1].equals("")) {
|
|
|
+ List<String> tourseIdTextbookIdList = null;
|
|
|
+ if(ObjectUtils.isNotEmpty(courseIdTextbookIdMap)){
|
|
|
+ tourseIdTextbookIdList = courseIdTextbookIdMap.get(classId);
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, BaseClassCourse> entry : newClassCourseTextbookMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ BaseClassCourse value = entry.getValue();
|
|
|
+ if(ObjectUtils.isNotEmpty(tourseIdTextbookIdList) && !tourseIdTextbookIdList.isEmpty() && tourseIdTextbookIdList.contains(key)){
|
|
|
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);
|
|
|
-// }});
|
|
|
-// }
|
|
|
+ value.setClassId(classId);
|
|
|
+ baseClassCourseList.add(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// for (TextbookStudentClaim textbookStudentClaim : textbookStudentClaimList) {
|
|
|
-// textbookStudentClaimMapper.insert(textbookStudentClaim);
|
|
|
-// }
|
|
|
return this.saveBatch(baseClassCourseList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean updateRemoveCourseBook(ClassCourseTextbook dto){
|
|
|
- if (ObjectUtils.isEmpty(dto.getClassIds()) || ObjectUtils.isEmpty(dto.getBaseSemesterId())) {
|
|
|
- throw new MyException("请选中班级和学期");
|
|
|
+ if (ObjectUtils.isEmpty(dto.getBaseClassAdminCourseIds())) {
|
|
|
+ throw new MyException("移除课程的班级无效,请刷新重试");
|
|
|
}
|
|
|
|
|
|
-// 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;
|
|
|
+ Map<String, BaseClassCourse> newClassCourseTextbookMap = new HashMap<>();
|
|
|
+ for (String id : dto.getIds()) {
|
|
|
+ String[] idArr = id.split("_");
|
|
|
+ if (idArr[0].isEmpty() || idArr[1].isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long courseId = Long.parseLong(idArr[0]);
|
|
|
+ Long textbookId = Long.parseLong(idArr[1]);
|
|
|
+ newClassCourseTextbookMap.put(id, new BaseClassCourse() {{
|
|
|
+ setCourseId(courseId);
|
|
|
+ setTextbookId(textbookId);
|
|
|
+ }});
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Long classId : dto.getBaseClassAdminCourseIds()) {
|
|
|
+ for (Map.Entry<String, BaseClassCourse> entry : newClassCourseTextbookMap.entrySet()) {
|
|
|
+ BaseClassCourse value = entry.getValue();
|
|
|
+ if(ObjectUtils.isNotEmpty(value)){
|
|
|
+ // 移除
|
|
|
+ LambdaUpdateWrapper<BaseClassCourse> baseClassCourseLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ baseClassCourseLambdaUpdateWrapper
|
|
|
+ .eq(BaseClassCourse::getClassId, classId)
|
|
|
+ .eq(BaseClassCourse::getCourseId, value.getCourseId())
|
|
|
+ .eq(BaseClassCourse::getTextbookId, value.getTextbookId())
|
|
|
+ ;
|
|
|
+ this.remove(baseClassCourseLambdaUpdateWrapper);
|
|
|
}
|
|
|
- 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, courseId)
|
|
|
- .eq(BaseClassCourse::getTextbookId, textbookId)
|
|
|
- ;
|
|
|
- this.remove(baseClassCourseLambdaUpdateWrapper);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -285,43 +244,106 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean duplicateCourseBook(ClassCourseReuseDto dto){
|
|
|
- LambdaQueryWrapper<BaseClassCourse> baseClassCourseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ // 根据旧的学期和班级找到所有的课程
|
|
|
+ MPJLambdaWrapper<BaseClassAdminCourse> baseClassCourseLambdaQueryWrapper = new MPJLambdaWrapper<>();
|
|
|
baseClassCourseLambdaQueryWrapper
|
|
|
- .eq(dto.getOldClassId() != null && dto.getOldClassId() > 0, BaseClassCourse::getClassId, dto.getOldClassId())
|
|
|
- .eq(dto.getOldBaseSemesterId() != null && dto.getOldBaseSemesterId() > 0, BaseClassCourse::getBaseSemesterId, dto.getOldBaseSemesterId())
|
|
|
+ .select(BaseClassCourse.class, x -> VoToColumnUtil.fieldsToColumns(BaseClassCourse.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClassAdminCourse::getId)
|
|
|
+ .eq(BaseClassAdminCourse::getClassId, dto.getOldClassId())
|
|
|
+ .eq(BaseClassAdminCourse::getBaseSemesterId, dto.getOldBaseSemesterId())
|
|
|
;
|
|
|
- List<BaseClassCourse> baseClassCourseList = this.list(baseClassCourseLambdaQueryWrapper);
|
|
|
+ List<BaseClassCourse> baseClassCourseList = baseClassAdminCourseMapper.selectJoinList(BaseClassCourse.class, baseClassCourseLambdaQueryWrapper);
|
|
|
if(baseClassCourseList == null || baseClassCourseList.isEmpty()){
|
|
|
- throw new MyException("该学期的该班级没有可以复用的课程!");
|
|
|
+ throw new MyException("被复用的学期的被复用班级没有可以复用的课程!");
|
|
|
}
|
|
|
|
|
|
- boolean isSuccess = false;
|
|
|
+ // 已经维护了课程教材信息的班级和所在学期
|
|
|
+ List<BaseClassAdminCourse> baseClassAdminCourses = baseClassAdminCourseMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(BaseClassAdminCourse.class)
|
|
|
+ .eq(BaseClassAdminCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+ Map<String, Long> classSemester = new HashMap<>();
|
|
|
+ for (BaseClassAdminCourse baseClassAdminCourse : baseClassAdminCourses) {
|
|
|
+ classSemester.put(baseClassAdminCourse.getClassId() + "_" + baseClassAdminCourse.getBaseSemesterId(), baseClassAdminCourse.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断复用的学期复用的班级是否已经进入了班级课程列表
|
|
|
+ // 判断本学期本班级是否已经加入课程管理的班级中
|
|
|
+ List<Long> classAdminCourseIds = new ArrayList<>();
|
|
|
+ for (Long classId : dto.getNewClassIds()){
|
|
|
+ String newClassSemester = classId + "_" + dto.getNewBaseSemesterId();
|
|
|
+ Long classAdminCourseId = null;
|
|
|
+ BaseClassAdminCourse baseClassAdminCourse = null;
|
|
|
+ if(ObjectUtils.isNotEmpty(classSemester) && ObjectUtils.isNotEmpty(classSemester.get(newClassSemester))){
|
|
|
+ classAdminCourseId = classSemester.get(newClassSemester);
|
|
|
+ } else {
|
|
|
+ baseClassAdminCourse = new BaseClassAdminCourse();
|
|
|
+ baseClassAdminCourse.setClassId(classId);
|
|
|
+ baseClassAdminCourse.setBaseSemesterId(dto.getNewBaseSemesterId());
|
|
|
+ baseClassAdminCourseMapper.insert(baseClassAdminCourse);
|
|
|
+
|
|
|
+ classAdminCourseId = baseClassAdminCourse.getId();
|
|
|
+ classSemester.put(newClassSemester, classAdminCourseId);
|
|
|
+ }
|
|
|
+ classAdminCourseIds.add(classAdminCourseId);
|
|
|
+ }
|
|
|
|
|
|
//删除班级的所有课程教材
|
|
|
LambdaQueryWrapper<BaseClassCourse> removeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
removeLambdaQueryWrapper
|
|
|
- .in(BaseClassCourse::getClassId, dto.getNewClassIds())
|
|
|
- .eq(BaseClassCourse::getBaseSemesterId, dto.getNewBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, classAdminCourseIds)
|
|
|
;
|
|
|
- isSuccess = this.remove(removeLambdaQueryWrapper);
|
|
|
+ this.remove(removeLambdaQueryWrapper);
|
|
|
|
|
|
List<BaseClassCourse> newBaseClassCourseList = new ArrayList<>();
|
|
|
- for (Long newClassId : dto.getNewClassIds()){
|
|
|
+ for (Long classAdminCourseId : classAdminCourseIds){
|
|
|
for (BaseClassCourse baseClassCourse : baseClassCourseList){
|
|
|
Long courseId = baseClassCourse.getCourseId();
|
|
|
Long textbookId = baseClassCourse.getTextbookId();
|
|
|
newBaseClassCourseList.add(new BaseClassCourse(){{
|
|
|
- setBaseSemesterId(dto.getNewBaseSemesterId());
|
|
|
- setClassId(newClassId);
|
|
|
+ setClassId(classAdminCourseId);
|
|
|
setCourseId(courseId);
|
|
|
setTextbookId(textbookId);
|
|
|
+ setCreateDate(new Date());
|
|
|
}});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- isSuccess = this.saveBatch(newBaseClassCourseList);
|
|
|
- return isSuccess;
|
|
|
- //baseClassCourseMapper.insertClassCourseTextbookCombinations(newClassId, sourceClassId, semester);
|
|
|
+ this.saveBatch(newBaseClassCourseList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean settingUpClasses(AddBaseClassAdminCourseDto dto) {
|
|
|
+ if(ObjectUtils.isEmpty(dto.getBaseSemesterId())){
|
|
|
+ throw new MyException("请选择需要设置课程的学期");
|
|
|
+ }
|
|
|
+ if(ObjectUtils.isEmpty(dto.getClassIds()) || dto.getClassIds().isEmpty()){
|
|
|
+ throw new MyException("请选择需要设置课程的班级");
|
|
|
+ }
|
|
|
+ BaseClassAdminCourse baseClassAdminCourse;
|
|
|
+ for(Long classId : dto.getClassIds()){
|
|
|
+ baseClassAdminCourse = new BaseClassAdminCourse();
|
|
|
+ baseClassAdminCourse.setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
+ baseClassAdminCourse.setClassId(classId);
|
|
|
+ baseClassAdminCourseMapper.insert(baseClassAdminCourse);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean deleteSettingUpClasses(List<Long> ids) {
|
|
|
+ // 先移除已经添加的课程数据
|
|
|
+ LambdaUpdateWrapper<BaseClassCourse> baseClassCourseLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ baseClassCourseLambdaUpdateWrapper
|
|
|
+ .in(BaseClassCourse::getClassId, ids)
|
|
|
+ ;
|
|
|
+ this.remove(baseClassCourseLambdaUpdateWrapper);
|
|
|
+
|
|
|
+ baseClassAdminCourseMapper.deleteBatchIds(ids);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -387,7 +409,7 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
|
|
|
@Override
|
|
|
public ByteArrayOutputStream classCourseTextbookExportQuery(ClassCourseTextbookExportQueryDto dto) throws IOException {
|
|
|
- MPJLambdaWrapper<BaseClass> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ MPJLambdaWrapper<BaseClassAdminCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
baseClassCourseMPJLambdaWrapper
|
|
|
.disableSubLogicDel()
|
|
|
.selectAs(BaseSemester::getName, ClassCourseTextbookExportQueryVo::getSemester)
|
|
@@ -399,39 +421,35 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
|
|
|
.selectAs(Textbook::getUseType, ClassCourseTextbookExportQueryVo::getUseType)
|
|
|
.selectAs(Textbook::getPrice, ClassCourseTextbookExportQueryVo::getPrice)
|
|
|
.selectAs(Textbook::getDiscountPrice, ClassCourseTextbookExportQueryVo::getDiscountPrice)
|
|
|
+ .leftJoin(BaseClassCourse.class,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .eq(BaseClassCourse::getClassId, BaseClassAdminCourse::getId)
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ )
|
|
|
|
|
|
- .leftJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClass::getId)
|
|
|
- .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassCourse::getBaseSemesterId)
|
|
|
- .leftJoin(BaseClass.class, BaseClass::getId, BaseClassCourse::getClassId)
|
|
|
+ .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassAdminCourse::getBaseSemesterId)
|
|
|
+
|
|
|
+ .leftJoin(BaseClass.class, BaseClass::getId, BaseClassAdminCourse::getClassId)
|
|
|
.leftJoin(Department.class, Department::getId, BaseClass::getOrgId)
|
|
|
+
|
|
|
.leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
|
|
|
.leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
.leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
wrapper -> wrapper
|
|
|
.selectAs(DictionaryDetail::getName, ClassCourseTextbookExportQueryVo::getTextbookType)
|
|
|
)
|
|
|
- .in(ObjectUtils.isNotEmpty(dto.getClassIds()) && !dto.getClassIds().isEmpty(), BaseClassCourse::getClassId, dto.getClassIds())
|
|
|
+
|
|
|
+ .in(ObjectUtils.isNotEmpty(dto.getClassIds()) && !dto.getClassIds().isEmpty(), BaseClassAdminCourse::getClassId, dto.getClassIds())
|
|
|
.like(StringUtils.isNotBlank(dto.getClassName()), BaseClass::getName, dto.getClassName())
|
|
|
.eq(ObjectUtils.isNotEmpty(dto.getDeptId()), Department::getId, dto.getDeptId())
|
|
|
- .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 1, "HAVING LENGTH(course_name) > 0")
|
|
|
- .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 2, "HAVING COALESCE(LENGTH(course_name), 0) = 0")
|
|
|
- .and(ObjectUtils.isNotEmpty(dto.getSemester()),
|
|
|
- wrapper -> wrapper
|
|
|
- .eq(BaseClassCourse::getBaseSemesterId, dto.getSemester())
|
|
|
- .or()
|
|
|
- .isNull(BaseClassCourse::getBaseSemesterId)
|
|
|
- )
|
|
|
- .and(wrapper -> wrapper
|
|
|
- .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
- .or()
|
|
|
- .isNull(BaseClassCourse::getDeleteMark)
|
|
|
- )
|
|
|
- .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+// .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 1, "HAVING LENGTH(course_name) > 0")
|
|
|
+// .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 2, "HAVING COALESCE(LENGTH(course_name), 0) = 0")
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getSemester()),BaseClassAdminCourse::getBaseSemesterId, dto.getSemester())
|
|
|
.orderByDesc(BaseCourseSubject::getName)
|
|
|
.orderByDesc(Textbook::getBookName)
|
|
|
;
|
|
|
|
|
|
- List<ClassCourseTextbookExportQueryVo> dataList = baseClassMapper.selectJoinList(ClassCourseTextbookExportQueryVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
+ List<ClassCourseTextbookExportQueryVo> dataList = baseClassAdminCourseMapper.selectJoinList(ClassCourseTextbookExportQueryVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
|
|
|
// 根据班级分组
|
|
|
Map<Long, List<ClassCourseTextbookExportQueryVo>> dataMapByClassId = dataList.stream()
|