Jelajahi Sumber

1.11,校验补充

Crazy 3 bulan lalu
induk
melakukan
3f4eb7cc9a

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

@@ -159,7 +159,6 @@ public class StudentSelectSupervisorRecordController {
         }
 
         AdminUserDO student  =adminUserService.getUser(createReqVO.getStudentId());
-
         LocalDateTime dateTime =LocalDateTime.now();
         Integer lastYear =dateTime.getYear()-1 ;
         studentSelectionProjectSaveReqVO project =new studentSelectionProjectSaveReqVO();
@@ -169,9 +168,10 @@ public class StudentSelectSupervisorRecordController {
         if (project==null) {
             return error(1,"找不到互选项目");
         }
-
-            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),createReqVO.getSupervisorId(), 1);//占用学硕
-            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),createReqVO.getSupervisorId(), 2);//占用专硕
+        Integer selectStatus =adminUserService.getUserSelectStatus(createReqVO.getStudentId(),project.getId());
+        if (selectStatus==0) {//未提交的
+            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(), createReqVO.getSupervisorId(), 1);//占用学硕
+            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(), createReqVO.getSupervisorId(), 2);//占用专硕
             supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(createReqVO.getSupervisorId(), project.getId());
 
             if (supervisorSelectionSetting == null || (supervisorSelectionSetting.getAcademicSlots() == null && supervisorSelectionSetting.getProfessionalSlots() == null)) {
@@ -187,8 +187,8 @@ public class StudentSelectSupervisorRecordController {
                 }
             }
 
-            studentSelectSupervisorRecordDO record1 = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(),student.getId(), null, 2);//同意
-            studentSelectSupervisorRecordDO record2 = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(),student.getId(), null, 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) {
@@ -198,7 +198,7 @@ public class StudentSelectSupervisorRecordController {
             UserSaveReqVO saveReqVO = new UserSaveReqVO();
             saveReqVO.setId(createReqVO.getStudentId());
 
-    //            设置导师id和校外导师id
+            //            设置导师id和校外导师id
             if (createReqVO.getSupervisorId() != null) {
                 AdminUserDO supervisor = adminUserService.getUser(createReqVO.getSupervisorId());
                 if (supervisor != null) {
@@ -218,7 +218,15 @@ public class StudentSelectSupervisorRecordController {
 
             adminUserService.updateUser(saveReqVO);
             studentSelectSupervisorRecordService.createStudentSelectSupervisorRecord(createReqVO);
-        return success("请求提交成功");
+            return success("请求提交成功");
+        }else if (selectStatus==1){
+            return error(1,"还有请求在待处理中");
+        }else if (selectStatus==2){
+            return error(1,"请求已经通过了");
+        }else if (selectStatus==4){
+            return error(1,"您已经分配过了");
+        }
+        return error(1,"提交申请失败");
     }
 
 
@@ -280,13 +288,14 @@ public class StudentSelectSupervisorRecordController {
                 record.setStudentSignDate(null);////学生签名日期
                 record.setSupervisorSignature(null);//导师签名
                 record.setSupervisorSignDate(null);//导师签名日期
-            } else if (record.getSelectType() == 1) {//待处理的
+          } else if (record.getSelectType() == 1) {//待处理的
                 record.setStudentSignature(null);//学生签名
                 record.setStudentSignDate(null);
             }
             record.setSelectType(4);//同意
             adminUserService.updateUser(saveReqVO);
             studentSelectSupervisorRecordService.updateRecordNull(BeanUtils.toBean(record, StudentSelectSupervisorRecordSaveReqVO.class));
+
         return success("志愿修改成功");
     }
 
@@ -341,57 +350,67 @@ public class StudentSelectSupervisorRecordController {
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(updateReqVO.getProjectId()), studentSelectionProjectSaveReqVO.class);
         if (updateReqVO.getId() != null) {
             studentSelectSupervisorRecordDO record = studentSelectSupervisorRecordService.getStudentSelectSupervisorRecord(updateReqVO.getId());
-            AdminUserDO student = adminUserService.getUser(record.getStudentId());
-
-            Long loginId = SecurityFrameworkUtils.getLoginUserId();
-            Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
-
-            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),loginId, 1);//占用学硕名额
-            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),loginId, 2);//占用专硕名额
-
-            supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(loginId, project.getId());
-            // 检查导师是否有名额设置
-
-            if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
-                return error(1, "该项目已过截至日期");
-            } else {
-                if (student.getMasterType() == 1) {
-                    if (supervisorSelectionSetting.getAcademicSlots() != null && supervisorSelectionSetting.getAcademicSlots().equals(occupiedAcademicSlots)) {
-                        return error(1, "您的学硕名额已经满了");
+            if (record.getSelectType() == 0) {//
+                return error(1, "该学生申请已经撤回");
+            } else if (record.getSelectType() == 2) {
+                return error(1, "该学生申请已经通过");
+            } else if (record.getSelectType() == 3) {
+                return error(1, "该学生申请已经退回");
+            }else if (record.getSelectType() == 4) {
+                return error(1, "该学生申请已经被学院进行分配");
+            }else if (record.getSelectType() == 1) {//只有待处理可以通过
+                AdminUserDO student = adminUserService.getUser(record.getStudentId());
+
+                Long loginId = SecurityFrameworkUtils.getLoginUserId();
+                Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
+
+                Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(), loginId, 1);//占用学硕名额
+                Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(), loginId, 2);//占用专硕名额
+
+                supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(loginId, project.getId());
+                // 检查导师是否有名额设置
+
+                if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
+                    return error(1, "该项目已过截至日期");
+                } else {
+                    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, "您的专硕名额已经满了");
+                        }
                     }
-                } else if (student.getMasterType() == 2) {
-                    if (supervisorSelectionSetting.getProfessionalSlots() != null && supervisorSelectionSetting.getProfessionalSlots().equals(occupiedProfessionalSlots)) {
-                        return error(1, "您的专硕名额已经满了");
+                    //提交导师签名
+                    updateReqVO.setSelectType(2);
+                    updateReqVO.setSupervisorApproveTime(dateTime);
+                    if (updateReqVO.getStudentSignature() != null && !updateReqVO.getStudentSignature().isEmpty()) {
+                        updateReqVO.setSupervisorSignDate(dateTime.toLocalDate());//导师日期
                     }
-                }
-                //提交导师签名
-                updateReqVO.setSelectType(2);
-                updateReqVO.setSupervisorApproveTime(dateTime);
-                if (updateReqVO.getStudentSignature()!=null&&!updateReqVO.getStudentSignature().isEmpty()) {
-                    updateReqVO.setSupervisorSignDate(dateTime.toLocalDate());//导师日期
-                }
-                studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
-
-                UserSaveReqVO saveReqVO = new UserSaveReqVO();
-                saveReqVO.setId(record.getStudentId());
-                //更新学生的supervisorId//或者externalSupervisorId
-                AdminUserDO supervisor =adminUserService.getUser(updateReqVO.getSupervisorId());
-                if (supervisor!=null) {
-                    if (supervisor.getUserType().equals("3")) {
-                        saveReqVO.setSupervisorId(updateReqVO.getSupervisorId());
-                    } else if (supervisor.getUserType().equals("5")) {
-                        saveReqVO.setExternalSupervisorId(updateReqVO.getSupervisorId());
-                        if (supervisor.getSupervisorId()!=null&&supervisor.getSupervisorId()!=0) {
-                            saveReqVO.setSupervisorId(supervisor.getSupervisorId());
+                    studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+
+                    UserSaveReqVO saveReqVO = new UserSaveReqVO();
+                    saveReqVO.setId(record.getStudentId());
+                    //更新学生的supervisorId//或者externalSupervisorId
+                    AdminUserDO supervisor = adminUserService.getUser(updateReqVO.getSupervisorId());
+                    if (supervisor != null) {
+                        if (supervisor.getUserType().equals("3")) {
+                            saveReqVO.setSupervisorId(updateReqVO.getSupervisorId());
+                        } else if (supervisor.getUserType().equals("5")) {
+                            saveReqVO.setExternalSupervisorId(updateReqVO.getSupervisorId());
+                            if (supervisor.getSupervisorId() != null && supervisor.getSupervisorId() != 0) {
+                                saveReqVO.setSupervisorId(supervisor.getSupervisorId());
+                            }
                         }
                     }
+                    adminUserService.updateUser(saveReqVO);
                 }
-
-                adminUserService.updateUser(saveReqVO);
+                return success(true);
             }
-            return success(true);
+            return error(1,"更新失败请刷新页面");
         }
-        return error(1,"更新失败");
+        return error(1,"更新失败请刷新页面");
     }
 
     // 退回,
@@ -406,11 +425,23 @@ public class StudentSelectSupervisorRecordController {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
         }else {
-        updateReqVO.setSupervisorApproveTime(dateTime);
-        updateReqVO.setSelectType(3);
-        studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
-    }
-        return success(true);
+            studentSelectSupervisorRecordDO record = studentSelectSupervisorRecordService.getStudentSelectSupervisorRecord(updateReqVO.getId());
+            if (record.getSelectType() == 0) {//
+                return error(1, "该学生申请已经撤回");
+            } else if (record.getSelectType() == 2) {
+                return error(1, "该学生申请已经通过");
+            } else if (record.getSelectType() == 3) {
+                return error(1, "该学生申请已经退回");
+            }else if (record.getSelectType() == 4) {
+                return error(1, "该学生申请已经被学院进行分配");
+            } else if (record.getSelectType() == 1) {
+                updateReqVO.setSupervisorApproveTime(dateTime);
+                updateReqVO.setSelectType(3);
+                studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+                return success(true);
+            }
+            return error(1,"更新失败");
+        }
     }
 
     //在导师设置那传导师id,志愿填报那撤回(没用了暂时)
@@ -425,13 +456,22 @@ public class StudentSelectSupervisorRecordController {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
         }else {
-            studentSelectSupervisorRecordDO record = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(),loginId, updateReqVO.getSupervisorId(), 1);//待处理的
-            updateReqVO.setId(record.getId());
-            updateReqVO.setSelectType(0);
-//        updateReqVO.setSupervisorId(0L);
-            studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+            studentSelectSupervisorRecordDO record = studentSelectSupervisorRecordService.getRecordByStudentIdAndSupervisorId(project.getId(), loginId, updateReqVO.getSupervisorId(), 1);//待处理的
+            if (record.getSelectType() == 0) {//
+                return error(1, "你的申请已经撤回");
+            } else if (record.getSelectType() == 2) {
+                return error(1, "你的申请已经通过");
+            } else if (record.getSelectType() == 3) {
+                return error(1, "你的申请已经退回");
+            } else if (record.getSelectType() == 4) {
+                return error(1, "你的申请学院进行分配");
+            } else if (record.getSelectType() == 1) {
+                updateReqVO.setId(record.getId());
+                updateReqVO.setSelectType(0);
+                studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+            }
+            return success(true);
         }
-        return success(true);
     }
 
     //在互选记录里面撤回
@@ -447,10 +487,21 @@ public class StudentSelectSupervisorRecordController {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
         }else {
-            updateReqVO.setSelectType(0);
-            studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+            if (record.getSelectType() == 0) {//
+                return error(1, "你的申请已经撤回");
+            } else if (record.getSelectType() == 2) {
+                return error(1, "你的申请已经通过");
+            } else if (record.getSelectType() == 3) {
+                return error(1, "你的申请已经退回");
+            } else if (record.getSelectType() == 4) {
+                return error(1, "你的申请学院进行分配");
+            } else if (record.getSelectType() == 1) {
+                updateReqVO.setSelectType(0);
+                studentSelectSupervisorRecordService.updateStudentSelectSupervisorRecord(updateReqVO);
+                return success(true);
+            }
         }
-        return success(true);
+        return error(1,"更新失败");
     }
 
 

+ 3 - 3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java

@@ -427,9 +427,9 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
 
      //获取用户选择状态
     @Select("SELECT COALESCE(MAX(CASE " +
-            "WHEN r.select_type = 4 THEN 4 " +
-            "WHEN r.select_type = 2 THEN 2 " +
-            "WHEN r.select_type = 1 THEN 1 " +
+            " WHEN COALESCE(MAX(CASE WHEN r.select_type = 4 THEN 1 ELSE 0 END),0) = 1 THEN 4 " +
+            " WHEN COALESCE(MAX(CASE WHEN r.select_type = 2 THEN 1 ELSE 0 END),0) = 1 THEN 2 " +
+            " WHEN COALESCE(MAX(CASE WHEN r.select_type = 1 THEN 1 ELSE 0 END),0) = 1 THEN 1 " +
             "ELSE 0 " +
             "END), 0) " +
             "FROM system_users u " +

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

@@ -428,17 +428,17 @@
         SELECT
         a.*,r.id,r.project_id,r.supervisor_id,
         CASE
-        WHEN COALESCE(MAX(CASE WHEN r.select_type = 4 THEN 1 ELSE 0 END),0) = 1 THEN 4  -- 如果有 4
-        WHEN COALESCE(MAX(CASE WHEN r.select_type = 2 THEN 1 ELSE 0 END),0) = 1 THEN 2  -- 如果有 2
-        WHEN COALESCE(MAX(CASE WHEN r.select_type = 1 THEN 1 ELSE 0 END),0) = 1 THEN 1  -- 如果没有 2,但有 1
+        WHEN COALESCE(MAX(CASE WHEN r.select_type = 4 THEN 1 ELSE 0 END),0) = 1 THEN 4  -- 如果有 4,就是4
+        WHEN COALESCE(MAX(CASE WHEN r.select_type = 2 THEN 1 ELSE 0 END),0) = 1 THEN 2  -- 如果有 2 ,就是2
+        WHEN COALESCE(MAX(CASE WHEN r.select_type = 1 THEN 1 ELSE 0 END),0) = 1 THEN 1  -- 如果没有2,但有 1
         ELSE 0  -- 其他情况
         END AS selectStatus,
 
         -- 计算 selectStatus 为 1 或 2 的记录 id
         CASE
-        WHEN COALESCE(MAX(r.select_type), null) IN (1, 2) THEN r.id
+        WHEN COALESCE(MAX(CASE WHEN r.select_type IN (1, 2, 4) THEN 1 ELSE 0 END), 0) = 1 THEN r.id
         ELSE NULL
-        END AS recordId,
+        END AS recordId
 
         COALESCE(system_dept.name, "测绘学院") AS deptName,
         supervisor_user.nickname AS supervisor,