Browse Source

专业年级班级树调整

dzx 1 month ago
parent
commit
54e8ca53f1

+ 3 - 2
src/main/java/com/xjrsoft/module/student/controller/StudentManagerController.java

@@ -32,6 +32,7 @@ import com.xjrsoft.module.organization.service.IUserDeptRelationService;
 import com.xjrsoft.module.room.service.IRoomBedService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
+import com.xjrsoft.module.student.dto.MajorGradeClassDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
 import com.xjrsoft.module.student.entity.BaseStudent;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
@@ -204,8 +205,8 @@ public class StudentManagerController {
     @GetMapping(value = "/major-grade-class-tree")
     @ApiOperation(value = "学生部门专业年级班级树")
     @SaCheckPermission("studentmanager:detail")
-    public RT<List<BaseDepMajorGradeClassStudenTreeVo>> tree2() {
-        return RT.ok(studentManagerService.deptMajorGradeClassTree());
+    public RT<List<BaseDepMajorGradeClassStudenTreeVo>> tree2(@Valid MajorGradeClassDto dto) {
+        return RT.ok(studentManagerService.deptMajorGradeClassTree(dto));
     }
 
 

+ 17 - 0
src/main/java/com/xjrsoft/module/student/dto/MajorGradeClassDto.java

@@ -0,0 +1,17 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.simpleframework.xml.Default;
+
+/**
+ * @author dzx
+ * @date 2024/7/9
+ */
+@Data
+public class MajorGradeClassDto {
+
+    @ApiModelProperty("在读状态(1: 在读 2: 毕业)")
+    private Integer isGraduate = 1;
+
+}

+ 2 - 1
src/main/java/com/xjrsoft/module/student/service/IStudentManagerService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
+import com.xjrsoft.module.student.dto.MajorGradeClassDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
 import com.xjrsoft.module.student.vo.BaseDepMajorGradeClassStudenTreeVo;
@@ -65,6 +66,6 @@ public interface IStudentManagerService extends MPJBaseService<BaseStudentUser>
 
     Boolean uploadImage(Long userId, MultipartFile file) throws IOException;
 
-     List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree();
+     List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree(MajorGradeClassDto dto);
 
 }

+ 21 - 5
src/main/java/com/xjrsoft/module/student/service/impl/StudentManagerServiceImpl.java

@@ -41,6 +41,7 @@ import com.xjrsoft.module.organization.service.IUserDeptRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
+import com.xjrsoft.module.student.dto.MajorGradeClassDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
 import com.xjrsoft.module.student.entity.BaseClassMajorSet;
 import com.xjrsoft.module.student.entity.BaseMajor;
@@ -1051,7 +1052,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
     }
 
     @Override
-    public List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree() {
+    public List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree(MajorGradeClassDto dto) {
         List<BaseDepMajorGradeClassStudenTreeVo> voList = new ArrayList<>();
         MPJLambdaWrapper<BaseClass> baseClassMPJLambdaWrapper = new MPJLambdaWrapper<>();
         baseClassMPJLambdaWrapper
@@ -1061,20 +1062,35 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
                 .selectAs(BaseClass::getGradeId, BaseClassMajorSetVo::getGradeId)
                 .leftJoin(BaseClassMajorSet.class, BaseClassMajorSet::getClassId, BaseClass::getId)
                 .leftJoin(BaseMajorSet.class, BaseMajorSet::getId, BaseClassMajorSet::getMajorSetId)
+                .eq(dto.getIsGraduate() != null, BaseClass::getIsGraduate, dto.getIsGraduate())
         ;
 
         List<BaseClassMajorSetVo> majorSetList = baseClassService.selectJoinList(BaseClassMajorSetVo.class, baseClassMPJLambdaWrapper);
-
+        if(majorSetList.isEmpty()){
+            return new ArrayList<>();
+        }
+        List<Long> gradeIds = majorSetList.stream().map(BaseClassMajorSetVo::getGradeId).collect(Collectors.toList());
+        List<Long> majorSetIds = majorSetList.stream().map(BaseClassMajorSetVo::getMajorSetId).collect(Collectors.toList());
 
         List<BaseGrade> gradeList = baseGradeService.list(
-                new QueryWrapper<BaseGrade>().lambda().eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
+                new QueryWrapper<BaseGrade>().lambda()
+                        .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .in(!gradeIds.isEmpty(), BaseGrade::getId, gradeIds)
+                        .orderByDesc(BaseGrade::getTitle)
         );
         List<BaseMajor> majorList = baseMajorService.list(
-                new QueryWrapper<BaseMajor>().lambda().eq(BaseMajor::getDeleteMark, DeleteMark.NODELETE.getCode())
+                new QueryWrapper<BaseMajor>().lambda()
+                        .eq(BaseMajor::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .in(!majorSetIds.isEmpty(), BaseMajor::getId, majorSetIds)
         );
+
+        List<Long> deptIds = majorList.stream().map(BaseMajor::getDepartmentId).collect(Collectors.toList());
+
         List<Department> departmentList =baseDeparmentService.list(
-                new QueryWrapper<Department>().lambda().eq(Department::getDeleteMark, DeleteMark.NODELETE.getCode())
+                new QueryWrapper<Department>().lambda()
+                        .eq(Department::getDeleteMark, DeleteMark.NODELETE.getCode())
                         .eq(Department::getIsMajor,1)
+                        .in(!deptIds.isEmpty(), Department::getId, deptIds)
         );
         departmentList.forEach((node) -> {
             voList.add(new BaseDepMajorGradeClassStudenTreeVo(){{