2 Commits c037dd65e3 ... 4cdd1d1edc

Auteur SHA1 Message Date
  Crazy 4cdd1d1edc 1.9 il y a 22 heures
  Crazy b7537a8dc0 1.9 il y a 22 heures

+ 55 - 13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectSupervisorRecord/StudentSelectSupervisorRecordController.java

@@ -149,17 +149,68 @@ public class StudentSelectSupervisorRecordController {
         return success("请求提交成功");
     }
 
-    //    学院志愿编辑,
+    //
+    @PostMapping("/collegeCreate")
+    @Operation(summary = "学院创建师生互选记录")
+    @PreAuthorize("@ss.hasPermission('system:student-select-supervisor-record:collegeCreate')")
+    public CommonResult<String> collegeCreateRecord(@Valid @RequestBody StudentSelectSupervisorRecordSaveReqVO createReqVO) {
+
+        AdminUserDO student  =adminUserService.getUser(createReqVO.getStudentId());
+
+        LocalDateTime dateTime =LocalDateTime.now();
+        Integer nextYear =dateTime.getYear()+1 ;
+        studentSelectionProjectSaveReqVO project =new studentSelectionProjectSaveReqVO();
+        studentSelectionProjectSaveReqVO project1 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(nextYear),studentSelectionProjectSaveReqVO.class);
+        studentSelectionProjectSaveReqVO project2 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(dateTime.getYear()),studentSelectionProjectSaveReqVO.class);
+        project =project1==null?project2:project1;
+        if (project==null) {
+            return error(1,"今年还没有创建互选项目");
+        }
+
+            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),createReqVO.getSupervisorId(), 1);//占用学硕
+            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),createReqVO.getSupervisorId(), 2);//占用专硕
+            supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(createReqVO.getSupervisorId(), createReqVO.getProjectId());
+
+            if (supervisorSelectionSetting == null || (supervisorSelectionSetting.getAcademicSlots() == null && supervisorSelectionSetting.getProfessionalSlots() == null)) {
+                return error(1, "该导师无名额");
+            }
+            if (student.getMasterType() == 1) {
+                if (supervisorSelectionSetting.getAcademicSlots() != null && supervisorSelectionSetting.getAcademicSlots().equals(occupiedAcademicSlots)) {
+                    return error(1, "学硕名额已经满了");
+                }
+            } else if (student.getMasterType() == 2) {
+                if (supervisorSelectionSetting.getProfessionalSlots() != null && supervisorSelectionSetting.getProfessionalSlots().equals(occupiedProfessionalSlots)) {
+                    return error(1, "专硕名额已经满了");
+                }
+            }
+
+            studentSelectSupervisorRecordDO record1 = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(),student.getId(), null, 2);//同意
+            studentSelectSupervisorRecordDO record2 = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(),student.getId(), null, 1);//待处理
+            if (record1 != null) {
+                return error(1, "请求已通过了");
+            } else if (record2 != null) {
+                return error(1, "还有请求在待处理中");
+            }
+
+            createReqVO.setSelectType(2);//同意
+
+            studentSelectSupervisorRecordService.createStudentSelectSupervisorRecord(createReqVO);
+        return success("请求提交成功");
+    }
+
+
+    // 学院志愿编辑,
     @PutMapping("/update")
     @Operation(summary = "更新师生互选记录")
     @PreAuthorize("@ss.hasPermission('system:student-select-supervisor-record:update')")
     public CommonResult<String> updateStudentSelectSupervisorRecord(@Valid @RequestBody StudentSelectSupervisorRecordSaveReqVO updateReqVO) {
-
+        if (updateReqVO.getId()==null){
+            return error(1,"没有传互选记录id");
+        }
         studentSelectSupervisorRecordDO record =studentSelectSupervisorRecordService.getStudentSelectSupervisorRecord(updateReqVO.getId());
         //
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(record.getProjectId()), studentSelectionProjectSaveReqVO.class);
-        AdminUserDO student =adminUserService.getUser(updateReqVO.getStudentId());
-        Integer selectStatus =adminUserService.getUserSelectStatus(updateReqVO.getStudentId(),project.getId());
+        
         AdminUserDO user =adminUserService.getUser(record.getStudentId());
         Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),updateReqVO.getSupervisorId(),1);//占用学硕
         Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),updateReqVO.getSupervisorId(),2);//占用专硕
@@ -178,14 +229,6 @@ public class StudentSelectSupervisorRecordController {
                 return error(1, "该老师专硕名额已经满了");
             }
         }
-        if (selectStatus==0){//未提交要新建直接同意
-            StudentSelectSupervisorRecordSaveReqVO createReqVO =new StudentSelectSupervisorRecordSaveReqVO();
-            createReqVO.setStudentId(student.getId());
-            createReqVO.setSupervisorId(updateReqVO.getSupervisorId());
-            createReqVO.setProjectId(project.getId());
-            createReqVO.setSelectType(2);
-            studentSelectSupervisorRecordService.createStudentSelectSupervisorRecord(createReqVO);
-        }else {
             //更新志愿
             UserSaveReqVO saveReqVO = new UserSaveReqVO();
             saveReqVO.setId(record.getStudentId());
@@ -218,7 +261,6 @@ public class StudentSelectSupervisorRecordController {
             }
             adminUserService.updateUser(saveReqVO);
             studentSelectSupervisorRecordService.updateRecordNull(BeanUtils.toBean(record, StudentSelectSupervisorRecordSaveReqVO.class));
-        }
         return success("志愿修改成功");
     }
 

+ 11 - 4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java

@@ -360,8 +360,10 @@ public class UserController {
         studentSelectionProjectSaveReqVO project1 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(nextYear),studentSelectionProjectSaveReqVO.class);
         studentSelectionProjectSaveReqVO project2 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
         project =project1==null?project2:project1;
-        if ((user.getGrade()!=null&&!user.getGrade().isEmpty())&&user.getGrade().equals(project.getStudentGrade())){
-            user.setSelectStatus(userService.getUserSelectStatus(id,project.getId()));
+        if (project!=null) {
+            if ((user.getGrade() != null && !user.getGrade().isEmpty()) && user.getGrade().equals(project.getStudentGrade())) {
+                user.setSelectStatus(userService.getUserSelectStatus(id, project.getId()));
+            }
         }
 
         // 拼接数据
@@ -713,7 +715,9 @@ public class UserController {
         studentSelectionProjectSaveReqVO project1 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(nextYear),studentSelectionProjectSaveReqVO.class);
         studentSelectionProjectSaveReqVO project2 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
         project =project1==null?project2:project1;
-
+        if (project==null) {
+            return error(1,"今年还没有创建互选项目");
+        }
         pageReqVO.setGrade(project.getStudentGrade());
         pageReqVO.setUserType("1");
 
@@ -722,7 +726,7 @@ public class UserController {
     }
 
     @GetMapping("/getUnPassedStudentsPage")
-    @Operation(summary = "获取今年互选项目学生未通过分页")
+    @Operation(summary = "获取今年互选项目学生未通过分页")//未提交和待处理
     @PreAuthorize("@ss.hasPermission('system:user:getUnPassedStudentsPage')")
     public CommonResult<PageResult<AdminUserDO>> getUnPassedStudentsPage(@Valid UserPageReqVO reqVO) {
         LocalDate date =LocalDate.now();
@@ -731,6 +735,9 @@ public class UserController {
         studentSelectionProjectSaveReqVO project1 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(nextYear),studentSelectionProjectSaveReqVO.class);
         studentSelectionProjectSaveReqVO project2 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
         project =project1==null?project2:project1;
+        if (project==null) {
+            return error(1,"今年还没有创建互选项目");
+        }
 
         reqVO.setGrade(project.getStudentGrade());
         reqVO.setUserType("1");

+ 4 - 2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java

@@ -90,8 +90,10 @@ public class UserProfileController {
         studentSelectionProjectSaveReqVO project1 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(nextYear),studentSelectionProjectSaveReqVO.class);
         studentSelectionProjectSaveReqVO project2 = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
         project =project1==null?project2:project1;
-        if ((user.getGrade()!=null&&!user.getGrade().isEmpty())&&user.getGrade().equals(project.getStudentGrade())){
-            user.setSelectStatus(userService.getUserSelectStatus(user.getId(),project.getId()));
+        if (project!=null) {
+            if ((user.getGrade() != null && !user.getGrade().isEmpty()) && user.getGrade().equals(project.getStudentGrade())) {
+                user.setSelectStatus(userService.getUserSelectStatus(user.getId(), project.getId()));
+            }
         }
 
         // 获得用户角色

+ 3 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java

@@ -193,4 +193,7 @@ public class AdminUserDO extends TenantBaseDO {
     @TableField(exist = false)
     private Integer selectStatus;
 
+    @TableField(exist = false)
+    private Long recordId;
+
 }

+ 7 - 1
yudao-module-system/yudao-module-system-biz/src/main/resources/Mapper/user/AdminUserMapper.xml

@@ -426,13 +426,19 @@
 
     <select id="getIsPassedStudentsPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
         SELECT
-        a.*,
+        a.*,r.id,
         CASE
         WHEN COALESCE(MAX(r.select_type), 0) = 2 THEN 2
         WHEN COALESCE(MAX(r.select_type), 0) = 1 THEN 1
         ELSE 0
         END AS selectStatus,
 
+        -- 计算 selectStatus 为 1 或 2 的记录 id
+        CASE
+        WHEN COALESCE(MAX(r.select_type), null) IN (1, 2) THEN r.id
+        ELSE NULL
+        END AS recordId,
+
         COALESCE(system_dept.name, "测绘学院") AS deptName,
         supervisor_user.nickname AS supervisor,
         supervisor_user.mobile AS supervisorMobile