Explorar o código

Merge branch 'master' of http://gogs.gisvg.com/YDM/graduate

47 hai 3 meses
pai
achega
78c849ae2d

+ 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());
         AdminUserDO student  =adminUserService.getUser(createReqVO.getStudentId());
-
         LocalDateTime dateTime =LocalDateTime.now();
         LocalDateTime dateTime =LocalDateTime.now();
         Integer lastYear =dateTime.getYear()-1 ;
         Integer lastYear =dateTime.getYear()-1 ;
         studentSelectionProjectSaveReqVO project =new studentSelectionProjectSaveReqVO();
         studentSelectionProjectSaveReqVO project =new studentSelectionProjectSaveReqVO();
@@ -169,9 +168,10 @@ public class StudentSelectSupervisorRecordController {
         if (project==null) {
         if (project==null) {
             return error(1,"找不到互选项目");
             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());
             supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(createReqVO.getSupervisorId(), project.getId());
 
 
             if (supervisorSelectionSetting == null || (supervisorSelectionSetting.getAcademicSlots() == null && supervisorSelectionSetting.getProfessionalSlots() == null)) {
             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) {
             if (record1 != null) {
                 return error(1, "请求已通过了");
                 return error(1, "请求已通过了");
             } else if (record2 != null) {
             } else if (record2 != null) {
@@ -198,7 +198,7 @@ public class StudentSelectSupervisorRecordController {
             UserSaveReqVO saveReqVO = new UserSaveReqVO();
             UserSaveReqVO saveReqVO = new UserSaveReqVO();
             saveReqVO.setId(createReqVO.getStudentId());
             saveReqVO.setId(createReqVO.getStudentId());
 
 
-    //            设置导师id和校外导师id
+            //            设置导师id和校外导师id
             if (createReqVO.getSupervisorId() != null) {
             if (createReqVO.getSupervisorId() != null) {
                 AdminUserDO supervisor = adminUserService.getUser(createReqVO.getSupervisorId());
                 AdminUserDO supervisor = adminUserService.getUser(createReqVO.getSupervisorId());
                 if (supervisor != null) {
                 if (supervisor != null) {
@@ -218,7 +218,15 @@ public class StudentSelectSupervisorRecordController {
 
 
             adminUserService.updateUser(saveReqVO);
             adminUserService.updateUser(saveReqVO);
             studentSelectSupervisorRecordService.createStudentSelectSupervisorRecord(createReqVO);
             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.setStudentSignDate(null);////学生签名日期
                 record.setSupervisorSignature(null);//导师签名
                 record.setSupervisorSignature(null);//导师签名
                 record.setSupervisorSignDate(null);//导师签名日期
                 record.setSupervisorSignDate(null);//导师签名日期
-            } else if (record.getSelectType() == 1) {//待处理的
+          } else if (record.getSelectType() == 1) {//待处理的
                 record.setStudentSignature(null);//学生签名
                 record.setStudentSignature(null);//学生签名
                 record.setStudentSignDate(null);
                 record.setStudentSignDate(null);
             }
             }
             record.setSelectType(4);//同意
             record.setSelectType(4);//同意
             adminUserService.updateUser(saveReqVO);
             adminUserService.updateUser(saveReqVO);
             studentSelectSupervisorRecordService.updateRecordNull(BeanUtils.toBean(record, StudentSelectSupervisorRecordSaveReqVO.class));
             studentSelectSupervisorRecordService.updateRecordNull(BeanUtils.toBean(record, StudentSelectSupervisorRecordSaveReqVO.class));
+
         return success("志愿修改成功");
         return success("志愿修改成功");
     }
     }
 
 
@@ -341,57 +350,67 @@ public class StudentSelectSupervisorRecordController {
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(updateReqVO.getProjectId()), studentSelectionProjectSaveReqVO.class);
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(updateReqVO.getProjectId()), studentSelectionProjectSaveReqVO.class);
         if (updateReqVO.getId() != null) {
         if (updateReqVO.getId() != null) {
             studentSelectSupervisorRecordDO record = studentSelectSupervisorRecordService.getStudentSelectSupervisorRecord(updateReqVO.getId());
             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)) {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
             return error(1, "该项目已过截至日期");
         }else {
         }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,志愿填报那撤回(没用了暂时)
     //在导师设置那传导师id,志愿填报那撤回(没用了暂时)
@@ -425,13 +456,22 @@ public class StudentSelectSupervisorRecordController {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
             return error(1, "该项目已过截至日期");
         }else {
         }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)) {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
             return error(1, "该项目已过截至日期");
         }else {
         }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,"更新失败");
     }
     }
 
 
 
 

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

@@ -426,14 +426,14 @@ 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 " +
-            "ELSE 0 " +
-            "END), 0) " +
-            "FROM system_users u " +
-            "LEFT JOIN student_select_supervisor_record r ON r.student_id = u.id " +
-            "WHERE u.id = #{id} AND r.project_id =#{projectId} AND r.deleted = 0 AND u.deleted = 0")
-    Integer getUserSelectStatus(@Param("id") Long id, @Param("projectId") Long projectId);
+     @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 " +
+             "ELSE 0 " +
+             "END), 0) " +
+             "FROM system_users u " +
+             "LEFT JOIN student_select_supervisor_record r ON r.student_id = u.id " +
+             "WHERE u.id = #{id} AND r.project_id =#{projectId} AND r.deleted = 0 AND u.deleted = 0")
+     Integer getUserSelectStatus(@Param("id") Long id, @Param("projectId") Long projectId);
 }
 }

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

@@ -428,15 +428,15 @@
         SELECT
         SELECT
         a.*,r.id,r.project_id,r.supervisor_id,
         a.*,r.id,r.project_id,r.supervisor_id,
         CASE
         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 = 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  -- 如果有 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 = 1 THEN 1 ELSE 0 END),0) = 1 THEN 1  -- 如果没有 2,但有 1
         ELSE 0  -- 其他情况
         ELSE 0  -- 其他情况
         END AS selectStatus,
         END AS selectStatus,
 
 
         -- 计算 selectStatus 为 1 或 2 的记录 id
         -- 计算 selectStatus 为 1 或 2 的记录 id
         CASE
         CASE
-        WHEN COALESCE(MAX(r.select_type), null) IN (1, 2) THEN r.id
+        WHEN COALESCE(MAX(r.select_type), null) IN (1,2,4) THEN r.id
         ELSE NULL
         ELSE NULL
         END AS recordId,
         END AS recordId,
 
 
@@ -460,6 +460,7 @@
         system_dept system_dept ON system_dept.id = a.dept_id
         system_dept system_dept ON system_dept.id = a.dept_id
         WHERE
         WHERE
         1=1
         1=1
+        AND a.deleted = 0
         <if test="reqVO.username != null and reqVO.username != ''">
         <if test="reqVO.username != null and reqVO.username != ''">
             AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
             AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
         </if>
         </if>
@@ -493,21 +494,20 @@
         <if test="reqVO.status != null and reqVO.status != '' ">
         <if test="reqVO.status != null and reqVO.status != '' ">
             AND a.status = #{reqVO.status}
             AND a.status = #{reqVO.status}
         </if>
         </if>
-        AND a.deleted = 0
         GROUP BY
         GROUP BY
         a.id
         a.id
 
 
         <!-- 合并 HAVING 子句 -->
         <!-- 合并 HAVING 子句 -->
         HAVING
         HAVING
         CASE
         CASE
-        WHEN COALESCE(MAX(CASE WHEN r.select_type = 4 THEN 1 ELSE 0 END),0) = 1 THEN 4  -- 如果有 2
-        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
+        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
         ELSE 0
         ELSE 0
         END
         END
         <choose>
         <choose>
             <when test="isPassed == 0">IN (0, 1)</when>
             <when test="isPassed == 0">IN (0, 1)</when>
-            <when test="isPassed == 1">in (2,4)</when>
+            <when test="isPassed == 1">IN (2, 4)</when>
         </choose>
         </choose>
 
 
         ORDER BY
         ORDER BY
@@ -568,14 +568,14 @@
         <!-- 合并 HAVING 条件 -->
         <!-- 合并 HAVING 条件 -->
         HAVING
         HAVING
         CASE
         CASE
-        WHEN COALESCE(MAX(CASE WHEN r.select_type = 4 THEN 1 ELSE 0 END),0) = 1 THEN 4  -- 如果有 2
-        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
+        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
         ELSE 0
         ELSE 0
         END
         END
         <choose>
         <choose>
             <when test="isPassed == 0">IN (0, 1)</when>
             <when test="isPassed == 0">IN (0, 1)</when>
-            <when test="isPassed == 1">in (2,4)</when>
+            <when test="isPassed == 1">IN (2, 4)</when>
         </choose>
         </choose>
         ) AS subquery;
         ) AS subquery;
     </select>
     </select>