3 Commits 7e62e36b7d ... a78a3152f6

Author SHA1 Message Date
  Crazy a78a3152f6 1.6校外导师 3 days ago
  Crazy 7763a40edf Merge branch 'master' of http://gogs.gisvg.com/YDM/graduate 3 days ago
  Crazy 1c3d3d5292 1.6一点修改 3 days ago
11 changed files with 82 additions and 43 deletions
  1. 7 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectSupervisorRecord/StudentSelectSupervisorRecordController.java
  2. 7 8
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/supervisorSelectionSetting/supervisorSelectionSettingController.java
  3. 3 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/supervisorSelectionSetting/vo/supervisorSelectionSettingRespVO.java
  4. 9 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
  5. 3 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/supervisorSelectionSetting/supervisorSelectionSettingDO.java
  6. 1 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/supervisorSelectionSetting/supervisorSelectionSettingMapper.java
  7. 8 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java
  8. 5 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/supervisorSelectionSetting/supervisorSelectionSettingServiceImpl.java
  9. 3 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java
  10. 7 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
  11. 29 7
      yudao-module-system/yudao-module-system-biz/src/main/resources/Mapper/supervisorSelectionSetting/supervisorSelectionSettingMapper.xml

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

@@ -110,8 +110,8 @@ public class StudentSelectSupervisorRecordController {
         if ((roleIds.contains(112L) || roleIds.contains(113L)) && project.getSupervisorConfirmDeadline().isBefore(dateTime)) {
             return error(1, "该项目已过截至日期");
         }else {
-            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(Math.toIntExact(createReqVO.getSupervisorId()), 1);//占用学硕
-            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(Math.toIntExact(createReqVO.getSupervisorId()), 2);//占用专硕
+            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(createReqVO.getSupervisorId()), 1);//占用学硕
+            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(createReqVO.getSupervisorId()), 2);//占用专硕
             supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(createReqVO.getSupervisorId(), createReqVO.getProjectId());
 
             if (supervisorSelectionSetting == null || (supervisorSelectionSetting.getAcademicSlots() == null && supervisorSelectionSetting.getProfessionalSlots() == null)) {
@@ -154,9 +154,10 @@ public class StudentSelectSupervisorRecordController {
 
         studentSelectSupervisorRecordDO record =studentSelectSupervisorRecordService.getStudentSelectSupervisorRecord(updateReqVO.getId());
         //
+        studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(record.getProjectId()), studentSelectionProjectSaveReqVO.class);
         AdminUserDO user =adminUserService.getUser(record.getStudentId());
-        Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(Math.toIntExact(updateReqVO.getSupervisorId()),1);//占用学硕
-        Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(Math.toIntExact(updateReqVO.getSupervisorId()),2);//占用专硕
+        Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(updateReqVO.getSupervisorId()),1);//占用学硕
+        Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(updateReqVO.getSupervisorId()),2);//占用专硕
         supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(updateReqVO.getSupervisorId(), record.getProjectId());
         // 检查导师是否有名额设置
         if (supervisorSelectionSetting == null || (supervisorSelectionSetting.getAcademicSlots() == null && supervisorSelectionSetting.getProfessionalSlots() == null)) {
@@ -272,8 +273,8 @@ public class StudentSelectSupervisorRecordController {
             Long loginId = SecurityFrameworkUtils.getLoginUserId();
             Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
 
-            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(Math.toIntExact(loginId), 1);//占用学硕名额
-            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(Math.toIntExact(loginId), 2);//占用专硕名额
+            Integer occupiedAcademicSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(loginId), 1);//占用学硕名额
+            Integer occupiedProfessionalSlots = adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(loginId), 2);//占用专硕名额
 
             supervisorSelectionSettingDO supervisorSelectionSetting = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(loginId, project.getId());
             // 检查导师是否有名额设置

+ 7 - 8
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/supervisorSelectionSetting/supervisorSelectionSettingController.java

@@ -1,12 +1,11 @@
 package cn.iocoder.yudao.module.system.controller.admin.supervisorSelectionSetting;
 
-import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.system.controller.admin.studentSelectionProject.vo.studentSelectionProjectSaveReqVO;
-import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
+
 import cn.iocoder.yudao.module.system.service.permission.PermissionService;
 import cn.iocoder.yudao.module.system.service.studentSelectionProject.studentSelectionProjectService;
 import cn.iocoder.yudao.module.system.service.user.AdminUserService;
-import org.apache.ibatis.annotations.Param;
+
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
@@ -15,11 +14,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Operation;
 
-import javax.validation.constraints.*;
 import javax.validation.*;
 import javax.servlet.http.*;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
+
 import java.util.*;
 import java.io.IOException;
 
@@ -69,8 +66,10 @@ public class supervisorSelectionSettingController {
 
         supervisorSelectionSettingDO setting = supervisorSelectionSettingService.getSupervisorSelectionSetting(updateReqVO.getId());
 
-        Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(Math.toIntExact(setting.getSupervisorId()),1);//占用学硕
-        Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(Math.toIntExact(setting.getSupervisorId()),2);//占用专硕
+        studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(setting.getProjectId()), studentSelectionProjectSaveReqVO.class);
+
+        Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(setting.getSupervisorId()),1);//占用学硕
+        Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),Math.toIntExact(setting.getSupervisorId()),2);//占用专硕
 
         if (updateReqVO.getAcademicSlots()<occupiedAcademicSlots){
             return error(1,"占用学硕名额大于更新学硕名额");

+ 3 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/supervisorSelectionSetting/vo/supervisorSelectionSettingRespVO.java

@@ -65,6 +65,9 @@ public class supervisorSelectionSettingRespVO {
     @Schema(description = "选择状态")
     private  Integer selectType;
 
+    @Schema(description = "合作导师")
+    private String workSupervisor;
+
 
 
 }

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

@@ -260,8 +260,15 @@ public class UserController {
     @GetMapping("/supervisor")
     @Operation(summary = "获得所有导师")
     public CommonResult<List<AdminUserDO>> getSupervisor() {
-        List<AdminUserDO> deptUser = userService.getSupervisor();
-        return success(deptUser);
+        List<AdminUserDO> user = userService.getSupervisor();
+        return success(user);
+    }
+
+    @GetMapping("/getExternalSupervisor")
+    @Operation(summary = "获得所有校外导师")
+    public CommonResult<List<AdminUserDO>> getExternalSupervisor() {
+        List<AdminUserDO> User = userService.getExternalSupervisor();
+        return success(User);
     }
 
     //工作间详情

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

@@ -88,4 +88,7 @@ public class supervisorSelectionSettingDO extends BaseDO {
     @TableField(exist = false)
     private  Integer selectType;
 
+    @TableField(exist = false)
+    private String workSupervisor;
+
 }

+ 1 - 13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/supervisorSelectionSetting/supervisorSelectionSettingMapper.java

@@ -44,19 +44,7 @@ public interface supervisorSelectionSettingMapper extends BaseMapperX<supervisor
         return selectPage(reqVO,mpjLambdaWrapperX);
     }
 
-    default supervisorSelectionSettingDO getSettingBySupervisorIdAndProjectId(@Param("supervisorId") Long supervisorId,@Param("projectId") Integer projectId){
-        MPJLambdaWrapperX<supervisorSelectionSettingDO> mpjLambdaWrapperX = new MPJLambdaWrapperX<>();
-        mpjLambdaWrapperX
-                .selectAll(supervisorSelectionSettingDO.class)
-                .leftJoin(AdminUserDO.class, AdminUserDO::getId, supervisorSelectionSettingDO::getSupervisorId)
-                .selectAs(AdminUserDO::getNickname,supervisorSelectionSettingDO::getSupervisorName)//导师姓名
-                .selectAs(AdminUserDO::getUserType,supervisorSelectionSettingDO::getUserType)//导师类型
-                .selectAs(AdminUserDO::getTitle,supervisorSelectionSettingDO::getTitle)//导师职称
-                .selectAs(AdminUserDO::getMajor,supervisorSelectionSettingDO::getMajor)//导师研究方向
-                .eqIfExists(supervisorSelectionSettingDO::getSupervisorId,supervisorId)
-                .eqIfExists(supervisorSelectionSettingDO::getProjectId,projectId);
-        return selectOne(mpjLambdaWrapperX);
-    }
+     supervisorSelectionSettingDO getSettingBySupervisorIdAndProjectId(@Param("supervisorId") Long supervisorId,@Param("projectId") Integer projectId);
 
 //    @Select("SELECT * FROM supervisor_selection_setting WHERE supervisor_id = #{supervisorId} AND project_id = #{projectId} AND deleted =0")
 //    supervisorSelectionSettingDO getSettingBySupervisorIdAndProjectId(@Param("supervisorId") Long supervisorId,@Param("projectId") Integer projectId);

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

@@ -291,6 +291,12 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
         return selectList(queryWrapper);
     }
 
+    default List<AdminUserDO> getExternalSupervisor() {
+        LambdaQueryWrapperX<AdminUserDO> queryWrapper = (LambdaQueryWrapperX<AdminUserDO>) new LambdaQueryWrapperX<AdminUserDO>()
+                .eqIfPresent(AdminUserDO::getUserType,5);
+        return selectList(queryWrapper);
+    }
+
     //  查登录工作间下的用户列表
     default List<AdminUserDO> selectDeptUser(UserPageReqVO reqVO) {
         Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
@@ -349,8 +355,8 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
             "HAVING COUNT(sa.id) > 2;")
     List<AdminUserDO> getStudentErrorAttendance();
 
-    @Select("SELECT COUNT(*) FROM system_users WHERE supervisor_id = #{supervisorId} AND master_type = #{masterType} AND user_type = '1' AND deleted = 0")
-    Integer countStudentListBySupervisorId(@Param("supervisorId") Integer supervisorId, @Param("masterType") Integer masterType);
+    @Select("SELECT COUNT(*) FROM system_users WHERE grade =#{grade} AND supervisor_id = #{supervisorId} AND master_type = #{masterType} AND user_type = '1' AND deleted = 0")
+    Integer countStudentListBySupervisorId(@Param("grade") String grade,@Param("supervisorId") Integer supervisorId, @Param("masterType") Integer masterType);
 
 
     //弹窗值

+ 5 - 2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/supervisorSelectionSetting/supervisorSelectionSettingServiceImpl.java

@@ -43,6 +43,8 @@ public class supervisorSelectionSettingServiceImpl implements supervisorSelectio
     private studentSelectSupervisorRecordService studentSelectSupervisorRecordService;
     @Resource
     private PermissionService permissionService;
+    @Resource
+    private studentSelectionProjectService studentSelectionProjectService;
 
     @Override
     public Integer createSupervisorSelectionSetting(supervisorSelectionSettingSaveReqVO createReqVO) {
@@ -88,11 +90,12 @@ public class supervisorSelectionSettingServiceImpl implements supervisorSelectio
         Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
         //获取项目名称
         PageResult<supervisorSelectionSettingDO> result =supervisorSelectionSettingMapper.selectPage(pageReqVO,roleIds,loginUser);
+        studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(pageReqVO.getProjectId()), studentSelectionProjectSaveReqVO.class);
 
         result.getList().forEach(re->{
             Integer supervisorId =re.getSupervisorId();
-            Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(supervisorId,1);//占用学硕
-            Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(supervisorId,2);//占用专硕
+            Integer  occupiedAcademicSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),supervisorId,1);//占用学硕
+            Integer  occupiedProfessionalSlots =adminUserService.countStudentListBySupervisorId(project.getStudentGrade(),supervisorId,2);//占用专硕
             re.setOccupiedAcademicSlots(occupiedAcademicSlots);
             re.setOccupiedProfessionalSlots(occupiedProfessionalSlots);
             if (roleIds.contains(112L)){

+ 3 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@@ -138,6 +138,8 @@ public interface AdminUserService {
     //查所有导师
     List<AdminUserDO> getSupervisor();
 
+    List<AdminUserDO> getExternalSupervisor();
+
     List<AdminUserDO> selectAllList(UserPageReqVO reqVO);
     /**
      * 通过用户 ID 查询用户
@@ -241,7 +243,7 @@ public interface AdminUserService {
     //获取三天内都缺勤的人
     List<AdminUserDO> getStudentErrorAttendance();
 
-    Integer countStudentListBySupervisorId(Integer supervisorId,Integer masterType);
+    Integer countStudentListBySupervisorId(String grade ,Integer supervisorId,Integer masterType);
 
     //是否弹窗
     PopDo getPopData();

+ 7 - 2
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -525,6 +525,11 @@ public class AdminUserServiceImpl implements AdminUserService {
         return userMapper.selectSupervisor();
     }
 
+    @Override
+    public List<AdminUserDO> getExternalSupervisor() {
+        return userMapper.getExternalSupervisor();
+    }
+
     //<>
 
     @Override
@@ -1171,8 +1176,8 @@ public class AdminUserServiceImpl implements AdminUserService {
         return userMapper.getStudentErrorAttendance();
     }
     @Override
-     public Integer countStudentListBySupervisorId(Integer supervisorId,Integer masterType){
-        return userMapper.countStudentListBySupervisorId(supervisorId,masterType);
+     public Integer countStudentListBySupervisorId(String grade ,Integer supervisorId,Integer masterType){
+        return userMapper.countStudentListBySupervisorId(grade,supervisorId,masterType);
     }
 
     //弹窗值

+ 29 - 7
yudao-module-system/yudao-module-system-biz/src/main/resources/Mapper/supervisorSelectionSetting/supervisorSelectionSettingMapper.xml

@@ -1,12 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.supervisorSelectionSetting.supervisorSelectionSettingMapper">
+    <select id="getSettingBySupervisorIdAndProjectId" resultType="cn.iocoder.yudao.module.system.dal.dataobject.supervisorSelectionSetting.supervisorSelectionSettingDO">
+        SELECT
+        s.*,
+        su_supervisor.nickname AS supervisorName,
+        su_supervisor.user_type AS userType,
+        su_supervisor.title AS title,
+        su_supervisor.major AS major,
+        CASE
+        WHEN su_supervisor.user_type = 5 AND su_supervisor.supervisor_id IS NOT NULL AND su_supervisor.supervisor_id != 0 THEN su_internalSupervisor.nickname
+        WHEN su_supervisor.user_type = 3 AND su_supervisor.external_supervisor_id IS NOT NULL AND su_supervisor.external_supervisor_id != 0 THEN su_externalSupervisor.nickname
+        ELSE NULL
+        END AS workSupervisor
+        FROM
+        supervisor_selection_setting s
+        LEFT JOIN
+        system_users su_supervisor ON s.supervisor_id = su_supervisor.id
+        --             是校外的时候,这个连接的su_internalSupervisor代表校内导师
+        LEFT JOIN system_users su_internalSupervisor ON su_supervisor.supervisor_id = su_internalSupervisor.id
+        --  --             是校内的时候,这个连接的su_externalSupervisor代表校外导师
+        LEFT JOIN system_users su_externalSupervisor ON su_supervisor.external_supervisor_id = su_externalSupervisor.id
 
-    <!--
-        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
-        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
-        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
-        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-     -->
-
+        <where>
+            <if test="supervisorId != null">
+                AND s.supervisor_id = #{supervisorId}
+            </if>
+            <if test="projectId != null">
+                AND s.project_id = #{projectId}
+            </if>
+        </where>
+    </select>
 </mapper>