Browse Source

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/resources/sqlScript/20250120_sql.sql
dzx 1 month ago
parent
commit
499925f1e9
19 changed files with 774 additions and 415 deletions
  1. 131 110
      src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java
  2. 48 0
      src/main/java/com/xjrsoft/module/base/dto/AddBaseClassAdminCourseDto.java
  3. 5 1
      src/main/java/com/xjrsoft/module/base/dto/ClassCourseReuseDto.java
  4. 98 0
      src/main/java/com/xjrsoft/module/base/entity/BaseClassAdminCourse.java
  5. 1 1
      src/main/java/com/xjrsoft/module/base/entity/BaseClassCourse.java
  6. 6 10
      src/main/java/com/xjrsoft/module/base/entity/ClassCourseTextbook.java
  7. 17 0
      src/main/java/com/xjrsoft/module/base/mapper/BaseClassAdminCourseMapper.java
  8. 10 3
      src/main/java/com/xjrsoft/module/base/service/IBaseClassCourseService.java
  9. 209 191
      src/main/java/com/xjrsoft/module/base/service/impl/BaseClassCourseServiceImpl.java
  10. 0 1
      src/main/java/com/xjrsoft/module/organization/controller/UserController.java
  11. 0 1
      src/main/java/com/xjrsoft/module/textbook/controller/SubjectGroupCourseController.java
  12. 28 8
      src/main/java/com/xjrsoft/module/textbook/controller/TextbookSubscriptionController.java
  13. 0 3
      src/main/java/com/xjrsoft/module/textbook/dto/TextbookSubscriptionListDto.java
  14. 83 35
      src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java
  15. 20 17
      src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookSubscriptionServiceImpl.java
  16. 37 33
      src/main/resources/mapper/base/BaseClassCourse.xml
  17. 32 1
      src/main/resources/sqlScript/20250120_sql.sql
  18. 24 0
      src/main/resources/sqlScript/textbook_sql.sql
  19. 25 0
      src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

+ 131 - 110
src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java

@@ -4,37 +4,32 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 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.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.VoToColumnUtil;
-import com.xjrsoft.module.base.dto.AddBaseClassCourseDto;
-import com.xjrsoft.module.base.dto.BaseClassCourseListDto;
-import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
-import com.xjrsoft.module.base.dto.ClassCourseReuseDto;
-import com.xjrsoft.module.base.dto.UpdateBaseClassCourseDto;
-import com.xjrsoft.module.base.entity.BaseClass;
-import com.xjrsoft.module.base.entity.BaseClassCourse;
-import com.xjrsoft.module.base.entity.BaseCourseSubject;
-import com.xjrsoft.module.base.entity.BaseSemester;
-import com.xjrsoft.module.base.entity.ClassCourseTextbook;
-import com.xjrsoft.module.base.entity.CourseBookInfo;
+import com.xjrsoft.module.base.dto.*;
+import com.xjrsoft.module.base.entity.*;
+import com.xjrsoft.module.base.mapper.BaseClassAdminCourseMapper;
 import com.xjrsoft.module.base.service.IBaseClassCourseService;
 import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.base.service.IBaseCourseSubjectService;
 import com.xjrsoft.module.base.service.IBaseSemesterService;
 import com.xjrsoft.module.base.vo.*;
-import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.textbook.entity.Textbook;
 import com.xjrsoft.module.textbook.service.ITextbookService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.ResponseEntity;
@@ -56,6 +51,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @title: 班级课程
@@ -68,23 +64,20 @@ import java.util.Map;
 @Api(value = "/base" + "/baseClassCourse", tags = "班级课程代码")
 @AllArgsConstructor
 public class BaseClassCourseController {
-
-
     private static final Logger log = LoggerFactory.getLogger(BaseClassCourseController.class);
     private final IBaseClassCourseService baseClassCourseService;
     private final IBaseCourseSubjectService subjectService;
     private final ITextbookService textbookService;
     private final IBaseClassService classService;
     private final IBaseSemesterService semesterService;
+    private final BaseClassAdminCourseMapper baseClassAdminCourseMapper;
 
     @GetMapping(value = "/page")
     @ApiOperation(value = "班级课程列表(分页)")
     @SaCheckPermission("baseclasscourse:detail")
     public RT<PageOutput<BaseClassCoursePageVo>> page(@Valid BaseClassCoursePageDto dto) {
         if(dto.getSemester() == null || dto.getSemester() == 0){
-            Page<BaseClassCoursePageVo> page = new Page<>();
-            page.setRecords(new ArrayList<>());
-            return RT.ok(ConventPage.getPageOutput(page, BaseClassCoursePageVo.class));
+            return RT.ok(ConventPage.getPageOutputNull(BaseClassCoursePageVo.class));
         }
         Page<BaseClassCoursePageVo> page = baseClassCourseService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         PageOutput<BaseClassCoursePageVo> pageOutput = ConventPage.getPageOutput(page, BaseClassCoursePageVo.class);
@@ -94,49 +87,16 @@ public class BaseClassCourseController {
     @GetMapping(value = "/list")
     @ApiOperation(value = "单个班级班级课程列表")
     @SaCheckPermission("baseclasscourse:detail")
-    public RT<List<BaseClassCourseListVo>> list(@Valid BaseClassCourseListDto dto) {
-        MPJLambdaWrapper<BaseClassCourse> 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()))
-                .leftJoin(BaseClass.class, BaseClass::getId, BaseClassCourse::getClassId)
-                .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
-                .leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
-                .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassCourse::getBaseSemesterId)
-                .eq(dto.getBaseSemesterId() != null && dto.getBaseSemesterId() > 0, BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .eq(dto.getClassId() != null && dto.getClassId() > 0, BaseClassCourse::getClassId, dto.getClassId())
-                .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
-                ;
-        List<BaseClassCourseListVo> baseClassCourseListVoList = baseClassCourseService.selectJoinList(BaseClassCourseListVo.class, baseClassCourseMPJLambdaWrapper);
+    public RT<List<BaseClassCourseListVo>> oneClassClassCourseList(@Valid BaseClassCourseListDto dto) {
+        List<BaseClassCourseListVo> baseClassCourseListVoList = baseClassCourseService.oneClassClassCourseList(dto);
         return RT.ok(baseClassCourseListVoList);
     }
 
     @GetMapping(value = "/mobile-list")
-    @ApiOperation(value = "单个班级班级课程列表")
+    @ApiOperation(value = "单个班级班级课程列表(移动端)")
     @SaCheckPermission("baseclasscourse:detail")
-    public RT<List<BaseClassCourseMobileListVo>> mobileList(@Valid BaseClassCourseListDto dto) {
-        MPJLambdaWrapper<BaseClassCourse> 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()))
-                .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, BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .eq(dto.getClassId() != null && dto.getClassId() > 0, BaseClassCourse::getClassId, dto.getClassId())
-                .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
-        ;
-        List<BaseClassCourseMobileListVo> baseClassCourseListVoList = baseClassCourseService.selectJoinList(BaseClassCourseMobileListVo.class, baseClassCourseMPJLambdaWrapper);
+    public RT<List<BaseClassCourseMobileListVo>> mobileOneClassClassCourseList(@Valid BaseClassCourseListDto dto) {
+        List<BaseClassCourseMobileListVo> baseClassCourseListVoList = baseClassCourseService.mobileOneClassClassCourseList(dto);
         return RT.ok(baseClassCourseListVoList);
     }
 
@@ -168,7 +128,7 @@ public class BaseClassCourseController {
     }
 
     @GetMapping("/getAllSelectedCoursesAndTextbooks")
-    @ApiOperation(value = "获取所有以选择课程教材")
+    @ApiOperation(value = "获取所有已经选择的课程教材")
     @SaCheckPermission("baseclasscourse:detail")
     public RT<List<CourseBookInfo>> getAllSelectedCoursesAndTextbooks(@RequestParam(required = false) Long[] classIds, @RequestParam(required = false) Long semester) {
         List<CourseBookInfo> data = baseClassCourseService.getSelectedCourseBook(classIds, semester);
@@ -179,6 +139,9 @@ public class BaseClassCourseController {
     @ApiOperation(value = "单个班级更新课程教材")
     @SaCheckPermission("baseclasscourse:detail")
     public RT<Boolean> oneUpdateClassCoursesAndTextbooks(@Valid @RequestBody ClassCourseTextbook dto) {
+        if (ObjectUtils.isEmpty(dto.getBaseClassAdminCourseIds())) {
+            throw new MyException("请选中班级");
+        }
         return RT.ok(baseClassCourseService.oneUpdateClassCoursesAndTextbooks(dto));
     }
 
@@ -186,6 +149,9 @@ public class BaseClassCourseController {
     @ApiOperation(value = "更新增加课程教材")
     @SaCheckPermission("baseclasscourse:detail")
     public RT<Boolean> updateAddCoursesAndTextbooks(@Valid @RequestBody ClassCourseTextbook dto) {
+        if (ObjectUtils.isEmpty(dto.getBaseClassAdminCourseIds())) {
+            throw new MyException("请选中班级");
+        }
         return RT.ok(baseClassCourseService.updateAddCourseBook(dto));
     }
 
@@ -203,6 +169,14 @@ public class BaseClassCourseController {
         return RT.ok(baseClassCourseService.duplicateCourseBook(dto));
     }
 
+    @PostMapping("/setting_up_classes")
+    @ApiOperation(value = "设置需要进行课程管理的班级")
+    @SaCheckPermission("baseclasscourse:add")
+    public RT<Boolean> settingUpClasses(@Valid @RequestBody AddBaseClassAdminCourseDto dto) {
+        boolean isSuccess = baseClassCourseService.settingUpClasses(dto);
+        return RT.ok(isSuccess);
+    }
+
     @PostMapping
     @ApiOperation(value = "新增班级课程")
     @SaCheckPermission("baseclasscourse:add")
@@ -229,8 +203,19 @@ public class BaseClassCourseController {
         return RT.ok(baseClassCourseService.removeBatchByIds(ids));
     }
 
+    @DeleteMapping("/deleteSetting_up_classes")
+    @ApiOperation(value = "移除需要进行课程管理的班级")
+    @SaCheckPermission("baseclasscourse:add")
+    public RT<Boolean> deleteSettingUpClasses(@Valid @RequestBody List<Long> ids) {
+        if(ObjectUtils.isEmpty(ids) || ids.isEmpty()){
+            return RT.ok(true);
+        }
+        boolean isSuccess = baseClassCourseService.deleteSettingUpClasses(ids);
+        return RT.ok(isSuccess);
+    }
+
     @PostMapping("/import")
-    @ApiOperation(value = "导入")
+    @ApiOperation(value = "班级课程导入")
     public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
         List<BaseClassCourseExcelVo> savedDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(BaseClassCourseExcelVo.class).sheet().doReadSync();
 
@@ -242,84 +227,120 @@ public class BaseClassCourseController {
         for (BaseClass baseClass : classList) {
             classMap.put(baseClass.getName(), baseClass.getId());
         }
+        if(ObjectUtils.isEmpty(classMap)){
+            throw new MyException("系统中还没有维护班级数据");
+        }
         List<BaseCourseSubject> courseSubjectList = subjectService.list(new QueryWrapper<BaseCourseSubject>());
         Map<String, Long> courseSubjectMap = new HashMap<>();
         for (BaseCourseSubject baseCourseSubject : courseSubjectList) {
             courseSubjectMap.put(baseCourseSubject.getName(), baseCourseSubject.getId());
         }
+        if(ObjectUtils.isEmpty(courseSubjectMap)){
+            throw new MyException("系统中还没有维护课程学科数据");
+        }
         List<Textbook> textbookList = textbookService.list(new QueryWrapper<Textbook>());
         Map<String, Long> textbookMap = new HashMap<>();
         for (Textbook textbook : textbookList) {
             textbookMap.put(textbook.getBookName(), textbook.getId());
         }
-
+        if(ObjectUtils.isEmpty(textbookMap)){
+            throw new MyException("系统中还没有维护教材数据");
+        }
         List<BaseSemester> semesterList = semesterService.list(new QueryWrapper<BaseSemester>());
         Map<String, Long> semesterMap = new HashMap<>();
         for (BaseSemester baseSemester : semesterList) {
             semesterMap.put(baseSemester.getName(), baseSemester.getId());
         }
-
-        for (BaseClassCourseExcelVo vo : savedDataList) {
-            if(vo.getClassName() == null){
+        if(ObjectUtils.isEmpty(semesterMap)){
+            throw new MyException("系统中还没有维护学期数据");
+        }
+        // 已经维护了课程教材信息的班级和所在学期
+        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<BaseClassCourse> oldList = baseClassCourseService.list(
+                Wrappers.lambdaQuery(BaseClassCourse.class)
+                        .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
+        );
+        // 使用Stream API和Lambda表达式生成所需的字符串列表
+        Map<Long, List<String>> courseIdTextbookIdMap = oldList.stream()
+                .collect(Collectors.groupingBy(
+                        BaseClassCourse::getClassId,
+                        Collectors.mapping(
+                                course -> course.getCourseId() + "_" + course.getTextbookId(),
+                                Collectors.toList()
+                        )
+                ));
+
+        // 开始处理导入
+        BaseClassCourse baseClassCourse;
+        for (int i = 0; i < savedDataList.size(); i++) {
+            baseClassCourse = new BaseClassCourse();
+            BaseClassCourseExcelVo vo = savedDataList.get(i);
+            if(ObjectUtils.isEmpty(vo.getClassName())
+                || ObjectUtils.isEmpty(vo.getSemester())
+            ){
                 continue;
             }
-            if(vo.getTextbookName() != null){
-                String[] textbookNames = vo.getTextbookName().split(" ");
-                for (String textbookName : textbookNames) {
-                    try {
-                        Long classId = classMap.get(vo.getClassName());
-                        Long courseId = courseSubjectMap.get(vo.getCourseName());
-                        Long textbookId = textbookMap.get(textbookName);
-                        Long baseSemesterId = semesterMap.get(vo.getSemester());
-
-                        if (baseClassCourseService.checkExits(classId, courseId, textbookId)) {
-                            duplicateLogs.add(String.format("[输入的信息重复添加] 班级: %s, 课程: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
-                            continue;
-                        }
-
-                        if (classId != null && courseId != null && textbookId != null && baseSemesterId != null) {
-                            BaseClassCourse baseClassCourse = new BaseClassCourse();
-                            baseClassCourse.setClassId(classId);
-                            baseClassCourse.setCourseId(courseId);
-                            baseClassCourse.setTextbookId(textbookId);
-                            baseClassCourse.setCreateDate(new Date());
-                            baseClassCourse.setDeleteMark(0);
-                            baseClassCourse.setBaseSemesterId(baseSemesterId);
-                            baseClassCourses.add(baseClassCourse);
-                        }
-                    } catch (NumberFormatException e) {
-                        errorLogs.add(String.format("[无法解析输入的信息] 班级: %s, 班级: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
-                    } catch (Exception e) {
-                        errorLogs.add(String.format("[意外错误(检查输入的名称是否正确且存在,输入错误可能返回 null)] 班级: %s, 课程: %s, 教材: %s - 错误信息:%s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName(), e.getMessage()));
-                    }
-                }
-            }else{
-                Long classId = classMap.get(vo.getClassName());
-                Long courseId = courseSubjectMap.get(vo.getCourseName());
-                Long baseSemesterId = semesterMap.get(vo.getSemester());
-                if (baseClassCourseService.checkExitsWithoutTextbook(classId, courseId)) {
-                    continue;
-                }
 
-                BaseClassCourse baseClassCourse = new BaseClassCourse();
-                baseClassCourse.setClassId(classId);
+            // 判断当前学期当前班级是否已经成为添加课程的班级
+            Long classId = classMap.get(vo.getClassName());;
+            Long baseSemesterId = semesterMap.get(vo.getSemester());
+            if(ObjectUtils.isEmpty(classId)){
+                throw new MyException("第" + (i + 4) + "行数据的班级信息不存在于系统中");
+            }
+            if(ObjectUtils.isEmpty(baseSemesterId)){
+                throw new MyException("第" + (i + 4) + "行数据的学期信息不存在于系统中");
+            }
+
+            // 判断本学期本班级是否已经加入课程管理的班级中
+            String newClassSemester = classId + "_" + baseSemesterId;
+            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(baseSemesterId);
+                baseClassAdminCourseMapper.insert(baseClassAdminCourse);
+                classSemester.put(newClassSemester, baseClassAdminCourse.getId());
+            }
+
+            baseClassCourse.setClassId(classAdminCourseId);
+
+            Long courseId = null;
+            Long textbookId = null;
+            if(ObjectUtils.isNotEmpty(vo.getCourseName())){
+                courseId = courseSubjectMap.get(vo.getCourseName());
                 baseClassCourse.setCourseId(courseId);
-                baseClassCourse.setCreateDate(new Date());
-                baseClassCourse.setDeleteMark(0);
-                baseClassCourse.setBaseSemesterId(baseSemesterId);
-                baseClassCourse.setCreateDate(new Date());
-                baseClassCourses.add(baseClassCourse);
             }
 
-        }
+            if(ObjectUtils.isNotEmpty(vo.getTextbookName())){
+                textbookId = textbookMap.get(vo.getTextbookName());
+                baseClassCourse.setTextbookId(textbookId);
+            }
 
-        Boolean result = baseClassCourseService.saveBatch(baseClassCourses);
+            if(ObjectUtils.isNotEmpty(courseId) && ObjectUtils.isNotEmpty(textbookId)){
+                String courseIdTextbookId = courseId + "_" + textbookId;
+                if(ObjectUtils.isNotEmpty(courseIdTextbookIdMap) && ObjectUtils.isNotEmpty(courseIdTextbookIdMap.get(classAdminCourseId))){
+                    List<String> courseIdTextbookIdList = courseIdTextbookIdMap.get(classAdminCourseId);
+                    if(courseIdTextbookIdList.contains(courseIdTextbookId)){
+                        continue;
+                    }
+                }
+            }
 
-        if (!duplicateLogs.isEmpty() || !errorLogs.isEmpty()) {
-            String detailedMessage = String.format("[导入完成但存在问题] 问题: %s. 其他错误: %s", String.join("; ", duplicateLogs), String.join("; ", errorLogs));
-            return RT.error(400, detailedMessage);
+            baseClassCourses.add(baseClassCourse);
         }
 
+        Boolean result = baseClassCourseService.saveBatch(baseClassCourses);
         return RT.ok(result);
     }
 

+ 48 - 0
src/main/java/com/xjrsoft/module/base/dto/AddBaseClassAdminCourseDto.java

@@ -0,0 +1,48 @@
+package com.xjrsoft.module.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Date;
+
+
+
+/**
+* @title: 需要进行课程管理的班级
+* @Author phoenix
+* @Date: 2025-01-20
+* @Version 1.0
+*/
+@Data
+public class AddBaseClassAdminCourseDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 序号
+    */
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+    /**
+    * 备注
+    */
+    @ApiModelProperty("备注")
+    private String remark;
+    /**
+    * 班级id(base_class)
+    */
+    @ApiModelProperty("班级id(base_class)")
+    private List<Long> classIds;
+    /**
+    * 学期id
+    */
+    @ApiModelProperty("学期id")
+    private Long baseSemesterId;
+
+}

+ 5 - 1
src/main/java/com/xjrsoft/module/base/dto/ClassCourseReuseDto.java

@@ -2,7 +2,9 @@ package com.xjrsoft.module.base.dto;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.NonNull;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.List;
 
@@ -22,6 +24,7 @@ public class ClassCourseReuseDto implements Serializable {
     * 旧的班级id
     */
     @ApiModelProperty("旧的班级id")
+    @NotNull(message = "被复用的班级不能为空")
     private Long oldClassId;
     /**
      * 新的班级id集合
@@ -31,7 +34,8 @@ public class ClassCourseReuseDto implements Serializable {
     /**
      * 旧的学期ID
      */
-    @ApiModelProperty("旧的学期ID")
+    @ApiModelProperty(value = "旧的学期ID", required = true)
+    @NotNull(message = "被复用的学期不能为空")
     private Long oldBaseSemesterId;
     /**
      * 新的学期ID

+ 98 - 0
src/main/java/com/xjrsoft/module/base/entity/BaseClassAdminCourse.java

@@ -0,0 +1,98 @@
+package com.xjrsoft.module.base.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.github.yulichang.annotation.EntityMapping;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+import java.time.LocalTime;
+import java.time.LocalDateTime;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Date;
+
+
+/**
+* @title: 需要进行课程管理的班级
+* @Author phoenix
+* @Date: 2025-01-20
+* @Version 1.0
+*/
+@Data
+@TableName("base_class_admin_course")
+@ApiModel(value = "base_class_admin_course", description = "需要进行课程管理的班级")
+public class BaseClassAdminCourse implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键编号
+    */
+    @ApiModelProperty("主键编号")
+    @TableId
+    private Long id;
+    /**
+    * 创建人
+    */
+    @ApiModelProperty("创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private Long createUserId;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createDate;
+    /**
+    * 修改人
+    */
+    @ApiModelProperty("修改人")
+    @TableField(fill = FieldFill.UPDATE)
+    private Long modifyUserId;
+    /**
+    * 修改时间
+    */
+    @ApiModelProperty("修改时间")
+    @TableField(fill = FieldFill.UPDATE)
+    private Date modifyDate;
+    /**
+    * 删除标记
+    */
+    @ApiModelProperty("删除标记")
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer deleteMark;
+    /**
+    * 有效标志
+    */
+    @ApiModelProperty("有效标志")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer enabledMark;
+    /**
+    * 序号
+    */
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+    /**
+    * 备注
+    */
+    @ApiModelProperty("备注")
+    private String remark;
+    /**
+    * 班级id(base_class)
+    */
+    @ApiModelProperty("班级id(base_class)")
+    private Long classId;
+    /**
+    * 学期id
+    */
+    @ApiModelProperty("学期id")
+    private Long baseSemesterId;
+
+
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/base/entity/BaseClassCourse.java

@@ -77,7 +77,7 @@ public class BaseClassCourse implements Serializable {
     /**
     * 班级id(base_class)
     */
-    @ApiModelProperty("班级id(base_class)")
+    @ApiModelProperty("需要进行课程管理的班级id(base_class_admin_course)(原有班级主键id字段)")
     private Long classId;
     /**
     * 课程id(base_course_subject)

+ 6 - 10
src/main/java/com/xjrsoft/module/base/entity/ClassCourseTextbook.java

@@ -3,19 +3,15 @@ package com.xjrsoft.module.base.entity;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class ClassCourseTextbook {
-    @ApiModelProperty("班级id")
-    private Long[] classIds;
-
-    @ApiModelProperty("主键id")
-    private String[] ids;
-
-    @ApiModelProperty(value = "课程id", hidden = true)
-    private Long[] courseId;
+    @ApiModelProperty("需要设置课程教材的班级id")
+    private List<Long> baseClassAdminCourseIds;
 
-    @ApiModelProperty(value = "教材id", hidden = true)
-    private Long[] textbookId;
+    @ApiModelProperty("课程主键和教材主键合并的id")
+    private List<String> ids;
 
     /**
      * 学期ID(base_semester)

+ 17 - 0
src/main/java/com/xjrsoft/module/base/mapper/BaseClassAdminCourseMapper.java

@@ -0,0 +1,17 @@
+package com.xjrsoft.module.base.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.base.entity.BaseClassAdminCourse;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @title: 需要进行课程管理的班级
+* @Author phoenix
+* @Date: 2025-01-20
+* @Version 1.0
+*/
+@Mapper
+public interface BaseClassAdminCourseMapper extends MPJBaseMapper<BaseClassAdminCourse> {
+
+}

+ 10 - 3
src/main/java/com/xjrsoft/module/base/service/IBaseClassCourseService.java

@@ -2,13 +2,13 @@ package com.xjrsoft.module.base.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
-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.BaseClassCourse;
 import com.xjrsoft.module.base.entity.ClassCourseTextbook;
 import com.xjrsoft.module.base.entity.CourseBookInfo;
+import com.xjrsoft.module.base.vo.BaseClassCourseListVo;
+import com.xjrsoft.module.base.vo.BaseClassCourseMobileListVo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
-import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -26,6 +26,9 @@ public interface IBaseClassCourseService extends MPJBaseService<BaseClassCourse>
 
     Page<BaseClassCoursePageVo> getPage(Page<BaseClassCoursePageVo> objectPage, BaseClassCoursePageDto dto);
 
+    List<BaseClassCourseListVo> oneClassClassCourseList(BaseClassCourseListDto dto);
+
+    List<BaseClassCourseMobileListVo> mobileOneClassClassCourseList(BaseClassCourseListDto dto);
 
     List<CourseBookInfo> getAllCourseBook(Long[] classIds, Long subjectGroupId, Long semester);
 
@@ -41,6 +44,10 @@ public interface IBaseClassCourseService extends MPJBaseService<BaseClassCourse>
 
     Boolean duplicateCourseBook(ClassCourseReuseDto dto);
 
+    Boolean settingUpClasses(AddBaseClassAdminCourseDto dto);
+
+    Boolean deleteSettingUpClasses(List<Long> ids);
+
     Map<String, Map<String, Object>> getSemesterTree();
 
     Long GetClassIdByName(String name);

+ 209 - 191
src/main/java/com/xjrsoft/module/base/service/impl/BaseClassCourseServiceImpl.java

@@ -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()

+ 0 - 1
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -170,7 +170,6 @@ public class UserController {
     @GetMapping(value = "/list")
     @ApiOperation(value = "用户列表(不分页)")
     public R list(String keyword) {
-
         List<User> list = userService.list(Wrappers.lambdaQuery(User.class)
                 .like(StrUtil.isNotBlank(keyword), User::getUserName, keyword)
                 .like(StrUtil.isNotBlank(keyword), User::getCode, keyword)

+ 0 - 1
src/main/java/com/xjrsoft/module/textbook/controller/SubjectGroupCourseController.java

@@ -77,7 +77,6 @@ public class SubjectGroupCourseController {
         return RT.ok(BeanUtil.toBean(subjectGroupCourse, SubjectGroupCourseVo.class));
     }
 
-
     @PostMapping
     @ApiOperation(value = "新增学科组课程管理")
     @SaCheckPermission("subjectgroupcourse:add")

+ 28 - 8
src/main/java/com/xjrsoft/module/textbook/controller/TextbookSubscriptionController.java

@@ -17,8 +17,7 @@ import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.student.entity.BaseClassMajorSet;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.textbook.dto.*;
-import com.xjrsoft.module.textbook.entity.TextbookSubscription;
-import com.xjrsoft.module.textbook.entity.TextbookSubscriptionClass;
+import com.xjrsoft.module.textbook.entity.*;
 import com.xjrsoft.module.textbook.service.ITextbookSubscriptionService;
 import com.xjrsoft.module.textbook.vo.*;
 import io.swagger.annotations.Api;
@@ -75,6 +74,27 @@ public class TextbookSubscriptionController {
         return RT.ok(listVos);
     }
 
+    @GetMapping(value = "/history-list")
+    @ApiOperation(value="教材教辅征订历史列表(分页)")
+    @SaCheckPermission("wftextbooksubscription:detail")
+    public RT<List<TextbookSubscriptionHistoryListVo>> historyList(@Valid TextbookSubscriptionHistoryListDto dto){
+
+        MPJLambdaWrapper<TextbookSubscription> queryWrapper = new MPJLambdaWrapper<>();
+        queryWrapper
+                .selectSum(TextbookSubscriptionItem::getStudentNum, TextbookSubscriptionHistoryListVo::getStudentSubscriptionNumber)
+                .selectSum(TextbookSubscriptionItem::getTeacherNum, TextbookSubscriptionHistoryListVo::getTeacherSubscriptionNumber)
+                .selectAs(TextbookSubscription::getCreateDate, TextbookSubscriptionHistoryListVo::getCreateDate)
+                .rightJoin(TextbookSubscriptionItem.class, TextbookSubscriptionItem::getTextbookSubscriptionId, TextbookSubscription::getId)
+                .eq(TextbookSubscriptionItem::getTextbookId, dto.getTextbookId())
+                .eq(TextbookSubscription::getBaseSemesterId, dto.getBaseSemesterId())
+                .groupBy(TextbookSubscription::getId)
+                .groupBy(TextbookSubscriptionItem::getTextbookId)
+        ;
+        List<TextbookSubscriptionHistoryListVo> list = textbookSubscriptionService.selectJoinList(TextbookSubscriptionHistoryListVo.class, queryWrapper);
+        return RT.ok(list);
+    }
+
+
     @GetMapping(value = "/instockroom-list")
     @ApiOperation(value = "教材教辅征订入库用页面")
     @SaCheckPermission("textbooksubscription:detail")
@@ -157,7 +177,7 @@ public class TextbookSubscriptionController {
     public RT<Boolean> add(@Valid @RequestBody AddTextbookSubscriptionDto dto){
         TextbookSubscription textbookSubscription = BeanUtil.toBean(dto, TextbookSubscription.class);
         boolean isSuccess = textbookSubscriptionService.add(textbookSubscription);
-    return RT.ok(isSuccess);
+        return RT.ok(isSuccess);
     }
 
     @PutMapping
@@ -216,12 +236,12 @@ public class TextbookSubscriptionController {
         return RT.fileStream(bot.toByteArray(), "TextbookSubscription" + ExcelTypeEnum.XLSX.getValue());
     }
 
-//    @PostMapping("/textbook-subscription-export-query")
-//    @ApiOperation(value = "教材征订条件导出")
-//    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid @RequestBody TextbookSubscriptionExportQueryListDto dto) {
-    @GetMapping("/textbook-subscription-export-query")
+    @PostMapping("/textbook-subscription-export-query")
     @ApiOperation(value = "教材征订条件导出")
-    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid TextbookSubscriptionExportQueryListDto dto) {
+    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid @RequestBody TextbookSubscriptionExportQueryListDto dto) {
+//    @GetMapping("/textbook-subscription-export-query")
+//    @ApiOperation(value = "教材征订条件导出")
+//    public ResponseEntity<byte[]> textbookSubscriptionExportQuery(@Valid TextbookSubscriptionExportQueryListDto dto) {
         List<TextbookSubscriptionExportQueryListVo> customerList = textbookSubscriptionService.textbookSubscriptionExportQuery(dto);
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
         EasyExcel.write(bot, TextbookSubscriptionExportQueryListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);

+ 0 - 3
src/main/java/com/xjrsoft/module/textbook/dto/TextbookSubscriptionListDto.java

@@ -28,7 +28,4 @@ public class TextbookSubscriptionListDto extends PageInput {
 
     @ApiModelProperty("学期id")
     public Long baseSemesterId;
-
-    @ApiModelProperty(value = "班级ids", hidden = true)
-    public List<String> classIdList;
 }

+ 83 - 35
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java

@@ -23,10 +23,7 @@ import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.common.utils.excel.ExcelFillCellMergePrevColUtil;
 import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
-import com.xjrsoft.module.base.entity.BaseClass;
-import com.xjrsoft.module.base.entity.BaseClassCourse;
-import com.xjrsoft.module.base.entity.BaseCourseSubject;
-import com.xjrsoft.module.base.entity.BaseSemester;
+import com.xjrsoft.module.base.entity.*;
 import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
 import com.xjrsoft.module.base.mapper.BaseCourseSubjectMapper;
 import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
@@ -968,7 +965,6 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
             String[] classIdArr =  dto.getClassIds().split(",");
             classIdList = Arrays.asList(classIdArr);
         }
-        dto.setClassIdList(classIdList);
 
         // 找到可以使用多个学期且已经征订的教材
         MPJLambdaWrapper<BaseClassCourse> subscribedTextbook = new MPJLambdaWrapper<>();
@@ -984,7 +980,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                 .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
                 .gt(Textbook::getUseType, 1)
                 .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .in(BaseClassCourse::getClassId, dto.getClassIdList())
+                .in(BaseClassCourse::getClassId, classIdList)
         ;
         List<BaseClassCourse> baseClassCourses = baseClassCourseMapper.selectJoinList(BaseClassCourse.class, subscribedTextbook);
 
@@ -1007,7 +1003,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                         .selectAs(DictionaryDetail::getName, TextbookSubscriptionListVo::getTextbookTypeCn)
                 )
                 .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .in(BaseClassCourse::getClassId, dto.getClassIdList())
+                .in(BaseClassCourse::getClassId, classIdList)
                 .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
                 .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
                 .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
@@ -1024,7 +1020,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                         .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
                         .eq(BaseClassCourse::getTextbookId, t.getTextbookId())
                         .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                        .in(BaseClassCourse::getClassId, dto.getClassIdList())
+                        .in(BaseClassCourse::getClassId, classIdList)
                         .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
                         .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
                 ;
@@ -1040,28 +1036,33 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
 
     @Override
     public List<TextbookSubscriptionListVo> getSubscriptionListByClass(TextbookSubscriptionListDto dto) {
-        List<String> classIdList = new ArrayList<>();
-        if(dto.getClassIds() != null && !"".equals(dto.getClassIds())){
-            String[] classIdArr =  dto.getClassIds().split(",");
-            classIdList = Arrays.asList(classIdArr);
+        if(StringUtils.isBlank(dto.getClassIds())){
+            throw new MyException("请选择需要征订教材的班级");
+        }
+        String[] classIdArr =  dto.getClassIds().split(",");
+        List<String> classIdList = Arrays.asList(classIdArr);
+        if(ObjectUtils.isEmpty(classIdList)){
+            throw new MyException("请选择需要征订教材的班级");
         }
-        dto.setClassIdList(classIdList);
 
         // 找到可以使用多个学期且已经征订的教材
         MPJLambdaWrapper<BaseClassCourse> subscribedTextbook = new MPJLambdaWrapper<>();
         subscribedTextbook
                 .distinct()
                 .select(BaseClassCourse::getId)
-                .innerJoin(TextbookSubscriptionClass.class, TextbookSubscriptionClass::getBaseClassId, BaseClassCourse::getClassId)
+                .innerJoin(BaseClassAdminCourse.class, BaseClassAdminCourse::getId, BaseClassCourse::getClassId)
+
+                .innerJoin(TextbookSubscriptionClass.class, TextbookSubscriptionClass::getBaseClassId, BaseClassAdminCourse::getClassId)
                 .innerJoin(TextbookSubscriptionItem.class, wrapper -> wrapper
                         .eq(TextbookSubscriptionItem::getTextbookSubscriptionId, TextbookSubscriptionClass::getTextbookSubscriptionId)
                         .eq(TextbookSubscriptionItem::getTextbookId, BaseClassCourse::getTextbookId)
                 )
 
                 .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
+
                 .gt(Textbook::getUseType, 1)
-                .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .in(BaseClassCourse::getClassId, dto.getClassIdList())
+                .eq(BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
+                .in(BaseClassAdminCourse::getClassId, classIdList)
         ;
         List<BaseClassCourse> baseClassCourses = baseClassCourseMapper.selectJoinList(BaseClassCourse.class, subscribedTextbook);
 
@@ -1077,39 +1078,86 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                 .selectAs(BaseClassCourse::getTextbookId, TextbookSubscriptionListVo::getTextbookId)
                 .selectAs(BaseCourseSubject::getName, TextbookSubscriptionListVo::getCourseName)
                 .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookSubscriptionListVo.class).contains(x.getProperty()))
+
+                .innerJoin(BaseClassAdminCourse.class, BaseClassAdminCourse::getId, BaseClassCourse::getClassId)
+
                 .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
+
                 .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
                 .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
                         wrapper -> wrapper
                                 .selectAs(DictionaryDetail::getName, TextbookSubscriptionListVo::getTextbookTypeCn)
                 )
-                .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                .in(BaseClassCourse::getClassId, dto.getClassIdList())
+
+                .eq(BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
+                .in(BaseClassAdminCourse::getClassId, classIdList)
                 .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
-                .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
+                .eq(BaseClassAdminCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
                 .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
         ;
         List<TextbookSubscriptionListVo> textbookSubscriptionListVoList = baseClassCourseMapper.selectJoinList(TextbookSubscriptionListVo.class, baseClassCourseMPJLambdaWrapper);
-//        IPage<TextbookSubscriptionListVo> page = this.baseMapper.getSubscriptionPageByClass(new Page<>(dto.getLimit(), dto.getSize()), dto);
+
+        List<String> textbookIds = textbookSubscriptionListVoList.stream()
+                .map(TextbookSubscriptionListVo::getTextbookId)
+                .distinct() // 去重操作
+                .collect(Collectors.toList());
 
         // 处理每本教材使用的人数
-        if(!classIdList.isEmpty()) {
-            for(TextbookSubscriptionListVo t : textbookSubscriptionListVoList){
-                MPJLambdaWrapper<BaseClassCourse> countNum = new MPJLambdaWrapper<>();
-                countNum
-                        .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClassCourse::getClassId)
-                        .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
-                        .eq(BaseClassCourse::getTextbookId, t.getTextbookId())
-                        .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
-                        .in(BaseClassCourse::getClassId, dto.getClassIdList())
-                        .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
-                        .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
-                ;
-                Long num = baseClassCourseMapper.selectCount(countNum);
-                t.setStudentSubscriptionNumber(num.intValue());
+        if(ObjectUtils.isNotEmpty(textbookIds)){
+            MPJLambdaWrapper<BaseClassCourse> countNum = new MPJLambdaWrapper<>();
+            countNum
+                    .selectAs(BaseClassCourse::getTextbookId, TextbookSubscriptionListVo::getTextbookId)
+                    .selectCount(BaseStudentSchoolRoll::getId, TextbookSubscriptionListVo::getStudentSubscriptionNumber)
+
+                    .innerJoin(BaseClassAdminCourse.class, BaseClassAdminCourse::getId, BaseClassCourse::getClassId)
+
+                    .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClassAdminCourse::getClassId)
+
+                    .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
+                    .in(BaseClassCourse::getTextbookId, textbookIds)
+                    .eq(BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
+                    .in(BaseClassAdminCourse::getClassId, classIdList)
+                    .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
+                    .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
+                    .groupBy(BaseClassCourse::getTextbookId)
+            ;
 
-                t.setClassIds(dto.getClassIds());
+            List<TextbookSubscriptionListVo> countStuNumList = baseClassCourseMapper.selectJoinList(TextbookSubscriptionListVo.class, countNum);
+
+            Map<String, Integer> countStuNumMap = countStuNumList.stream()
+                    .collect(Collectors.toMap(TextbookSubscriptionListVo::getTextbookId, TextbookSubscriptionListVo::getStudentSubscriptionNumber, (t1, t2) -> t1));
+
+            if(ObjectUtils.isNotEmpty(countStuNumMap)){
+                for(TextbookSubscriptionListVo t : textbookSubscriptionListVoList){
+                    Integer num = countStuNumMap.get(t.getTextbookId());
+                    if(ObjectUtils.isNotEmpty(num)){
+                        t.setStudentSubscriptionNumber(num);
+                    }else {
+                        t.setStudentSubscriptionNumber(0);
+                    }
+                    t.setClassIds(dto.getClassIds());
+                }
             }
+
+//        for(TextbookSubscriptionListVo t : textbookSubscriptionListVoList){
+//            MPJLambdaWrapper<BaseClassAdminCourse> countNum = new MPJLambdaWrapper<>();
+//            countNum
+//                    .innerJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClassAdminCourse::getId)
+//
+//                    .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClassAdminCourse::getClassId)
+//
+//                    .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
+//                    .eq(BaseClassCourse::getTextbookId, t.getTextbookId())
+//                    .eq(BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
+//                    .in(BaseClassAdminCourse::getClassId, dto.getClassIdList())
+//                    .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
+//                    .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
+//            ;
+//            Long num = baseClassCourseMapper.selectCount(countNum);
+//            t.setStudentSubscriptionNumber(num.intValue());
+//
+//            t.setClassIds(dto.getClassIds());
+//        }
         }
 
         return textbookSubscriptionListVoList;

+ 20 - 17
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookSubscriptionServiceImpl.java

@@ -247,11 +247,12 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
         // 处理征订表
         int sum = 0;
         for (TextbookSubscriptionItem textbookSubscriptionItem : textbookSubscription.getTextbookSubscriptionItemList()) {
-            textbookSubscriptionItem.setStudentNum(ObjectUtil.isNull(textbookSubscriptionItem.getStudentNum()) ? 0 : textbookSubscriptionItem.getStudentNum());
-            textbookSubscriptionItem.setTeacherNum(ObjectUtil.isNull(textbookSubscriptionItem.getTeacherNum()) ? 0 : textbookSubscriptionItem.getTeacherNum());
+            textbookSubscriptionItem.setStudentNum(ObjectUtils.isEmpty(textbookSubscriptionItem.getStudentNum()) ? 0 : textbookSubscriptionItem.getStudentNum());
+            textbookSubscriptionItem.setTeacherNum(ObjectUtils.isEmpty(textbookSubscriptionItem.getTeacherNum()) ? 0 : textbookSubscriptionItem.getTeacherNum());
 
             sum += textbookSubscriptionItem.getStudentNum() + textbookSubscriptionItem.getTeacherNum();
         }
+        textbookSubscription.setSum(sum);
         textbookSubscriptionTextbookSubscriptionMapper.insert(textbookSubscription);
 
         // 处理征订和班级关联表
@@ -260,9 +261,9 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
                 && StringUtils.isNotBlank(textbookSubscription.getBaseClassIds())
         ) {
             String[] classIdArr = textbookSubscription.getBaseClassIds().split(",");
-            List<String> classIdList = Arrays.asList(classIdArr);
-            for (String str : classIdList) {
-                TextbookSubscriptionClass textbookSubscriptionClass = new TextbookSubscriptionClass();
+            TextbookSubscriptionClass textbookSubscriptionClass;
+            for (String str : classIdArr) {
+                textbookSubscriptionClass = new TextbookSubscriptionClass();
                 textbookSubscriptionClass.setTextbookSubscriptionId(textbookSubscription.getId());
                 textbookSubscriptionClass.setBaseClassId(Long.parseLong(str));
                 textbookSubscriptionClassMapper.insert(textbookSubscriptionClass);
@@ -416,7 +417,7 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean update(TextbookSubscription textbookSubscription) {
-        textbookSubscriptionTextbookSubscriptionMapper.updateById(textbookSubscription);
+        int sum = 0;
         //********************************* TextbookSubscriptionItem  增删改  开始 *******************************************/
         {
             // 查出所有子级的id
@@ -427,30 +428,32 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
             List<Long> textbookSubscriptionItemIds = textbookSubscriptionItemList.stream()
                     .map(TextbookSubscriptionItem::getId)
                     .collect(Collectors.toList());
-            //原有子表单 没有被删除的主键
+            // 原有子表单 没有被删除的主键
             List<Long> textbookSubscriptionItemOldIds = textbookSubscription.getTextbookSubscriptionItemList().stream()
                     .map(TextbookSubscriptionItem::getId)
                     .filter(Objects::nonNull)
                     .collect(Collectors.toList());
-            //找到需要删除的id
+            // 找到需要删除的id
             List<Long> textbookSubscriptionItemRemoveIds = textbookSubscriptionItemIds.stream()
                     .filter(item -> !textbookSubscriptionItemOldIds.contains(item))
                     .collect(Collectors.toList());
 
             for (TextbookSubscriptionItem textbookSubscriptionItem : textbookSubscription.getTextbookSubscriptionItemList()) {
-                //如果不等于空则修改
+                // 如果不等于空则修改
                 if (textbookSubscriptionItem.getId() != null) {
                     textbookSubscriptionTextbookSubscriptionItemMapper.updateById(textbookSubscriptionItem);
-                }
-                //如果等于空 则新增
-                else {
-                    //已经不存在的id 删除
+                } else {
+                    // 如果等于空 则新增
                     textbookSubscriptionItem.setTextbookSubscriptionId(textbookSubscription.getId());
                     textbookSubscriptionTextbookSubscriptionItemMapper.insert(textbookSubscriptionItem);
                 }
+                textbookSubscriptionItem.setStudentNum(ObjectUtils.isEmpty(textbookSubscriptionItem.getStudentNum()) ? 0 : textbookSubscriptionItem.getStudentNum());
+                textbookSubscriptionItem.setTeacherNum(ObjectUtils.isEmpty(textbookSubscriptionItem.getTeacherNum()) ? 0 : textbookSubscriptionItem.getTeacherNum());
+
+                sum += textbookSubscriptionItem.getStudentNum() + textbookSubscriptionItem.getTeacherNum();
             }
-            //已经不存在的id 删除
-            if (textbookSubscriptionItemRemoveIds.size() > 0) {
+            // 已经不存在的id 删除
+            if (ObjectUtils.isNotEmpty(textbookSubscriptionItemRemoveIds.isEmpty())) {
                 textbookSubscriptionTextbookSubscriptionItemMapper.deleteBatchIds(textbookSubscriptionItemRemoveIds);
             }
         }
@@ -468,8 +471,7 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
                 && StringUtils.isNotBlank(textbookSubscription.getBaseClassIds())
         ) {
             String[] classIdArr = textbookSubscription.getBaseClassIds().split(",");
-            List<String> classIdList = Arrays.asList(classIdArr);
-            for (String str : classIdList) {
+            for (String str : classIdArr) {
                 TextbookSubscriptionClass textbookSubscriptionClass = new TextbookSubscriptionClass();
                 textbookSubscriptionClass.setTextbookSubscriptionId(textbookSubscription.getId());
                 textbookSubscriptionClass.setBaseClassId(Long.parseLong(str));
@@ -478,6 +480,7 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
         }
         //********************************* TextbookSubscriptionClass  增删改  结束 *******************************************/
 
+        textbookSubscriptionTextbookSubscriptionMapper.updateById(textbookSubscription);
         return true;
     }
 

+ 37 - 33
src/main/resources/mapper/base/BaseClassCourse.xml

@@ -5,41 +5,47 @@
 <mapper namespace="com.xjrsoft.module.base.mapper.BaseClassCourseMapper">
     <select id="getPage" parameterType="com.xjrsoft.module.base.dto.BaseClassCoursePageDto" resultType="com.xjrsoft.module.base.vo.BaseClassCoursePageVo">
         SELECT
-        t.id AS class_id,
-        t.name AS class_name,
+        t.id as id,
+        t.class_id AS class_id,
+        t9.name AS class_name,
         t1.name AS teacher_name,
         t3.name AS major_name,
         t4.name AS dept_name,
         GROUP_CONCAT(DISTINCT t6.name SEPARATOR '、') AS course_name,
         GROUP_CONCAT(DISTINCT t7.book_name SEPARATOR '、') AS textbook_name,
-        SUM(t8.price) AS amount,
-        SUM(t8.discount_price) AS count
-        FROM base_class t
-        LEFT JOIN xjr_user t1 ON t1.id = t.teacher_id
-        LEFT JOIN base_class_major_set t2 ON t2.class_id = t.id
+        SUM(t7.price) AS amount,
+        SUM(t7.discount_price) AS count
+        FROM base_class_admin_course t
+        inner JOIN base_class t9 ON t9.id = t.class_id
+
+        LEFT JOIN xjr_user t1 ON t1.id = t9.teacher_id
+
+        LEFT JOIN base_class_major_set t2 ON t2.class_id = t.class_id
         LEFT JOIN base_major_set t3 ON t3.id = t2.major_set_id
-        LEFT JOIN xjr_department t4 ON t4.id = t.org_id
-        LEFT JOIN base_class_course t5 ON t5.class_id = t.id AND t5.delete_mark = 0
-        LEFT JOIN base_course_subject t6 ON t6.id = t5.course_id AND t6.delete_mark = 0
-        LEFT JOIN textbook t7 ON t7.id = t5.textbook_id AND t7.delete_mark = 0
-        LEFT JOIN textbook t8 ON t8.id = t5.textbook_id AND t8.delete_mark = 0
+
+        LEFT JOIN xjr_department t4 ON t4.id = t9.org_id
+
+        LEFT JOIN base_class_course t5 ON t5.class_id = t.id and t5.delete_mark = 0
+        LEFT JOIN base_course_subject t6 ON t6.id = t5.course_id
+
+        LEFT JOIN textbook t7 ON t7.id = t5.textbook_id
         WHERE t.delete_mark = 0
         <if test="dto.semester != null">
-            AND t5.base_semester_id = #{dto.semester}
+            AND t.base_semester_id = #{dto.semester}
         </if>
         <if test="dto.className != null and dto.className != ''">
-            AND t.name LIKE CONCAT('%', #{dto.className}, '%')
+            AND t9.name LIKE CONCAT('%', #{dto.className}, '%')
         </if>
         <if test="dto.deptId != null">
-            AND t4.id = #{dto.deptId}
+            AND t9.org_id = #{dto.deptId}
         </if>
-        GROUP BY t.id, t.name, t1.name, t3.name, t4.name
+        GROUP BY t.id, t.class_id, t9.name, t1.name, t3.name, t4.name
         <choose>
             <when test="dto.courseSet == 1">
-                HAVING LENGTH(course_name) > 0
+                HAVING course_name is not null
             </when>
             <when test="dto.courseSet == 2">
-                HAVING LENGTH(course_name) = 0
+                HAVING course_name is null
             </when>
         </choose>
     </select>
@@ -74,18 +80,19 @@
 
     <select id="getSelectedCourseBook" resultType="com.xjrsoft.module.base.entity.CourseBookInfo">
         select
-            distinct
-            t.course_id as courseId,
-            t2.name as courseName,
-            t1.book_name as bookName,
-            t.textbook_id as bookId,
-            concat(t.course_id, '_', t.textbook_id) AS id,
-            t1.issn,
-            t1.editor_in_chief,
-            t1.version
-        from base_class_course t
-        left join textbook t1 on t1.id = t.textbook_id
-        left join base_course_subject t2 on t.course_id = t2.id
+        distinct
+        t3.course_id as courseId,
+        t2.name as courseName,
+        t1.book_name as bookName,
+        t3.textbook_id as bookId,
+        concat(t3.course_id, '_', t3.textbook_id) AS id,
+        t1.issn,
+        t1.editor_in_chief,
+        t1.version
+        from tl.base_class_admin_course t
+        left join base_class_course t3 on t3.class_id = t.id
+        left join textbook t1 on t1.id = t3.textbook_id
+        left join base_course_subject t2 on t3.course_id = t2.id
         where t.delete_mark = 0
         <if test="classIds != null">
             AND t.class_id in
@@ -96,9 +103,6 @@
         <if test="semester != null">
             and t.base_semester_id = #{semester}
         </if>
-<!--        <if test="subjectGroupId != null">-->
-<!--            AND-->
-<!--        </if>-->
     </select>
 
     <insert id="updateAddClassCourseTextbooks">

+ 32 - 1
src/main/resources/sqlScript/20250120_sql.sql

@@ -1,3 +1,34 @@
+-- ----------------------------
+-- 2025-01-20 10:36
+-- 需要进行课程管理的班级
+-- ----------------------------
+drop table if exists base_class_admin_course;
+create table `base_class_admin_course`
+(
+    id                  bigint        not null comment '主键编号'
+        primary key,
+    create_user_id      bigint        null comment '创建人',
+    create_date         datetime      null comment '创建时间',
+    modify_user_id      bigint        null comment '修改人',
+    modify_date         datetime      null comment '修改时间',
+    delete_mark         int           not null comment '删除标记',
+    enabled_mark        int           not null comment '有效标志',
+    sort_code           int           null comment '序号',
+    remark              varchar(1000) null comment '备注',
+
+    class_id         bigint      null comment '班级id(base_class)',
+    base_semester_id bigint      null comment '学期id'
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='需要进行课程管理的班级';
+
+alter table base_class_course
+    modify class_id bigint null comment '需要进行课程管理的班级id(base_class_admin_course)(原有班级主键id字段)';
+
+
+
+
+
 DROP TABLE IF EXISTS student_change_record;
 CREATE TABLE `student_change_record`  (
   `id` BIGINT NOT NULL COMMENT '主键',
@@ -52,5 +83,5 @@ CREATE TABLE `student_report_plan_class_relation`  (
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = INNODB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '学生报到计划-班级';
 
-ALTER TABLE `student_report_record`   
+ALTER TABLE `student_report_record`
   ADD COLUMN `student_report_plan_id` BIGINT NULL   COMMENT '报到计划id' AFTER `base_semester_id`;

+ 24 - 0
src/main/resources/sqlScript/textbook_sql.sql

@@ -1,3 +1,27 @@
+-- ----------------------------
+-- 2025-01-20 10:36
+-- 需要进行课程管理的班级
+-- ----------------------------
+drop table if exists base_class_admin_course;
+create table `base_class_admin_course`
+(
+    id                  bigint        not null comment '主键编号'
+        primary key,
+    create_user_id      bigint        null comment '创建人',
+    create_date         datetime      null comment '创建时间',
+    modify_user_id      bigint        null comment '修改人',
+    modify_date         datetime      null comment '修改时间',
+    delete_mark         int           not null comment '删除标记',
+    enabled_mark        int           not null comment '有效标志',
+    sort_code           int           null comment '序号',
+    remark              varchar(1000) null comment '备注',
+
+    class_id         bigint      null comment '班级id(base_class)',
+    base_semester_id bigint      null comment '学期id'
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='需要进行课程管理的班级';
+
 -- ----------------------------
 -- 2024-12-13 14:36
 -- 教材基础信息表

+ 25 - 0
src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

@@ -4223,6 +4223,31 @@ public class FreeMarkerGeneratorTest {
         apiGeneratorService.generateCodes(params);
     }
 
+    @Test
+    public void gcBaseClassAdminCourse() throws IOException {
+        List<TableConfig> tableConfigs = new ArrayList<>();
+        TableConfig mainTable = new TableConfig();
+        mainTable.setTableName("base_class_admin_course");//init_sql中的表名
+        mainTable.setIsMain(true);//是否是主表,一般默认为true
+        mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
+        mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
+        tableConfigs.add(mainTable);
+
+        ApiGenerateCodesDto params = new ApiGenerateCodesDto();
+        params.setAuthor("phoenix");//作者名称
+        params.setPackageName("base");//包名
+        params.setTableConfigs(tableConfigs);
+        params.setPage(true);//是否生成分页接口
+        params.setImport(true);//是否生成导入接口
+        params.setExport(true);//是否生成导出接口
+        params.setOutMainDir(false);//是否生成在主目录,前期测试可设置成false
+        params.setDs(ds);
+
+        IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
+
+        apiGeneratorService.generateCodes(params);
+    }
+
 
     @Test
     public void gcStudentChangeRecord() throws IOException {