|
@@ -1,5 +1,6 @@
|
|
package cn.iocoder.yudao.module.system.controller.admin.studentSelectionProject;
|
|
package cn.iocoder.yudao.module.system.controller.admin.studentSelectionProject;
|
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.supervisorSelectionSetting.vo.supervisorSelectionSettingPageReqVO;
|
|
import cn.iocoder.yudao.module.system.controller.admin.supervisorSelectionSetting.vo.supervisorSelectionSettingSaveReqVO;
|
|
import cn.iocoder.yudao.module.system.controller.admin.supervisorSelectionSetting.vo.supervisorSelectionSettingSaveReqVO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.supervisorSelectionSetting.supervisorSelectionSettingDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.supervisorSelectionSetting.supervisorSelectionSettingDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
@@ -45,7 +46,13 @@ import cn.iocoder.yudao.module.system.service.studentSelectionProject.studentSel
|
|
@RequestMapping("/system/student-selection-project")
|
|
@RequestMapping("/system/student-selection-project")
|
|
@Validated
|
|
@Validated
|
|
public class studentSelectionProjectController {
|
|
public class studentSelectionProjectController {
|
|
-
|
|
|
|
|
|
+ // TODO 1.删除项目时,应该同时删除对应的关联信息
|
|
|
|
+ // 2. 新增接口 ,学院 :(1) 查看所有未提交、未通过、(注意提交但是撤回的状态)的学生 (2) 查看所有已通过的学生 (3) 招生详情只展示同意的
|
|
|
|
+ // 老师: (1) 新增菜单, 待审批接口 (2)已审批
|
|
|
|
+ // 学生: (1) 操作提示 ,还有请求在待处理中 改为 已存在申请 , (2)申请表样式
|
|
|
|
+ // 3.合并菜单
|
|
|
|
+ // 4. 项目创建表单 名称和描述 年份默认
|
|
|
|
+ // TODO PDF导出
|
|
@Resource
|
|
@Resource
|
|
private studentSelectionProjectService studentSelectionProjectService;
|
|
private studentSelectionProjectService studentSelectionProjectService;
|
|
@Resource
|
|
@Resource
|
|
@@ -80,7 +87,7 @@ public class studentSelectionProjectController {
|
|
if (project!=null){
|
|
if (project!=null){
|
|
return error(1,"今年已经创建过项目了");
|
|
return error(1,"今年已经创建过项目了");
|
|
}else {
|
|
}else {
|
|
- Integer projectId = studentSelectionProjectService.createStudentSelectionProject(createReqVO);
|
|
|
|
|
|
+ Long projectId = studentSelectionProjectService.createStudentSelectionProject(createReqVO);
|
|
//创建初始化的导师名额设置
|
|
//创建初始化的导师名额设置
|
|
for (Map<String, String> entry : createReqVO.getSupervisorsWithQuota()) {
|
|
for (Map<String, String> entry : createReqVO.getSupervisorsWithQuota()) {
|
|
supervisorSelectionSettingSaveReqVO settingSaveReqVO = new supervisorSelectionSettingSaveReqVO();
|
|
supervisorSelectionSettingSaveReqVO settingSaveReqVO = new supervisorSelectionSettingSaveReqVO();
|
|
@@ -102,50 +109,102 @@ public class studentSelectionProjectController {
|
|
@PutMapping("/update")
|
|
@PutMapping("/update")
|
|
@Operation(summary = "更新师生互选项目")
|
|
@Operation(summary = "更新师生互选项目")
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:update')")
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:update')")
|
|
|
|
+ @Transactional
|
|
public CommonResult<Boolean> updateStudentSelectionProject(@Valid @RequestBody studentSelectionProjectSaveReqVO updateReqVO) {
|
|
public CommonResult<Boolean> updateStudentSelectionProject(@Valid @RequestBody studentSelectionProjectSaveReqVO updateReqVO) {
|
|
if (updateReqVO.getStudentStartTime().isAfter(updateReqVO.getSupervisorConfirmDeadline())){
|
|
if (updateReqVO.getStudentStartTime().isAfter(updateReqVO.getSupervisorConfirmDeadline())){
|
|
return error(1,"时间设置错误");
|
|
return error(1,"时间设置错误");
|
|
}
|
|
}
|
|
|
|
+ studentSelectionProjectDO currentProject = studentSelectionProjectService.getStudentSelectionProject(updateReqVO.getId());
|
|
|
|
+ if (currentProject == null) {
|
|
|
|
+ return error(1, "项目不存在");
|
|
|
|
+ }
|
|
//创建新的教师设置
|
|
//创建新的教师设置
|
|
- studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(updateReqVO.getId()),studentSelectionProjectSaveReqVO.class);
|
|
|
|
|
|
+ studentSelectionProjectSaveReqVO project = BeanUtils.toBean(currentProject,studentSelectionProjectSaveReqVO.class);
|
|
|
|
+
|
|
|
|
|
|
List<Long> originSupervisorIds = project.getSupervisorIds();
|
|
List<Long> originSupervisorIds = project.getSupervisorIds();
|
|
- List<Long> newSupervisorIds = new ArrayList<>(updateReqVO.getSupervisorIds()); // 先复制一份新的列表
|
|
|
|
|
|
+ supervisorSelectionSettingPageReqVO pageReqVO = new supervisorSelectionSettingPageReqVO();
|
|
|
|
+ pageReqVO.setPageNo(-1);
|
|
|
|
+ pageReqVO.setProjectId(updateReqVO.getId());
|
|
|
|
+ PageResult<supervisorSelectionSettingDO> pageResult
|
|
|
|
+ = supervisorSelectionSettingService.getSupervisorSelectionSettingPage(pageReqVO);
|
|
|
|
|
|
- if (!originSupervisorIds.isEmpty()){
|
|
|
|
- newSupervisorIds.removeAll(originSupervisorIds); // 从 newSupervisorIds 中移除 originSupervisorIds 中的元素
|
|
|
|
- }
|
|
|
|
- if (!newSupervisorIds.isEmpty()){
|
|
|
|
- supervisorSelectionSettingSaveReqVO settingSaveReqVO = new supervisorSelectionSettingSaveReqVO();
|
|
|
|
- newSupervisorIds.forEach(supervisorId -> {
|
|
|
|
|
|
+
|
|
|
|
+ List<Long> newSupervisorIds = new ArrayList<>(updateReqVO.getSupervisorIds()); // 新的导师ID列表
|
|
|
|
+
|
|
|
|
+ // 处理新增的导师(在新列表中存在但在原列表中不存在)
|
|
|
|
+ newSupervisorIds.removeAll(originSupervisorIds); // 移除已存在的导师
|
|
|
|
+ if (!newSupervisorIds.isEmpty()) {
|
|
|
|
+ // 批量新增导师设置
|
|
|
|
+ for (Long supervisorId : newSupervisorIds) {
|
|
|
|
+ supervisorSelectionSettingSaveReqVO settingSaveReqVO = new supervisorSelectionSettingSaveReqVO();
|
|
settingSaveReqVO.setSupervisorId(supervisorId);
|
|
settingSaveReqVO.setSupervisorId(supervisorId);
|
|
settingSaveReqVO.setProjectId(updateReqVO.getId());
|
|
settingSaveReqVO.setProjectId(updateReqVO.getId());
|
|
- supervisorSelectionSettingService.createSupervisorSelectionSetting(settingSaveReqVO);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 删除原来存在于 originSupervisorIds 中,但新设置中没有的导师
|
|
|
|
- if (!originSupervisorIds.isEmpty()) {
|
|
|
|
- List<Long> removedSupervisorIds = new ArrayList<>(originSupervisorIds);
|
|
|
|
- removedSupervisorIds.removeAll(updateReqVO.getSupervisorIds()); // 找出被移除的导师ID
|
|
|
|
|
|
+ // 根据 request 中的名额信息设置名额
|
|
|
|
+ Map<String, String> supervisorQuota = findSupervisorQuotaById(updateReqVO.getSupervisorsWithQuota(), supervisorId);
|
|
|
|
+ if (supervisorQuota != null) {
|
|
|
|
+ settingSaveReqVO.setAcademicSlots(Integer.valueOf(supervisorQuota.get("academicSlots")));
|
|
|
|
+ settingSaveReqVO.setProfessionalSlots(Integer.valueOf(supervisorQuota.get("professionalSlots")));
|
|
|
|
+
|
|
|
|
+ supervisorSelectionSettingService.createSupervisorSelectionSetting(settingSaveReqVO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if (!removedSupervisorIds.isEmpty()) {
|
|
|
|
- removedSupervisorIds.forEach(supervisorId -> {
|
|
|
|
- supervisorSelectionSettingDO settingDO = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(supervisorId,project.getId());
|
|
|
|
|
|
+ // 处理删除的导师(在原列表中存在但在新列表中不存在)
|
|
|
|
+ List<Long> removedSupervisorIds = new ArrayList<>(originSupervisorIds);
|
|
|
|
+ removedSupervisorIds.removeAll(updateReqVO.getSupervisorIds()); // 找出被移除的导师ID
|
|
|
|
+ if (!removedSupervisorIds.isEmpty()) {
|
|
|
|
+ for (Long supervisorId : removedSupervisorIds) {
|
|
|
|
+ supervisorSelectionSettingDO settingDO = supervisorSelectionSettingService.getSettingBySupervisorIdAndProjectId(supervisorId, updateReqVO.getId());
|
|
|
|
+ if (settingDO != null) {
|
|
supervisorSelectionSettingService.deleteSupervisorSelectionSetting(settingDO.getId());
|
|
supervisorSelectionSettingService.deleteSupervisorSelectionSetting(settingDO.getId());
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<supervisorSelectionSettingDO> originSupervisors = pageResult.getList().stream()
|
|
|
|
+ .filter(obj -> updateReqVO.getSupervisorIds().contains(obj.getSupervisorId())) // 正确的写法
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 更新已有的导师(名额发生变化的导师)
|
|
|
|
+ for (supervisorSelectionSettingDO supervisor : originSupervisors) {
|
|
|
|
+
|
|
|
|
+ supervisorSelectionSettingSaveReqVO settingSaveReqVO = new supervisorSelectionSettingSaveReqVO();
|
|
|
|
+ settingSaveReqVO.setId(supervisor.getId());
|
|
|
|
+ settingSaveReqVO.setSupervisorId(supervisor.getSupervisorId());
|
|
|
|
+ settingSaveReqVO.setProjectId(updateReqVO.getId());
|
|
|
|
+
|
|
|
|
+ // 根据 request 中的名额信息设置名额
|
|
|
|
+ Map<String, String> supervisorQuota = findSupervisorQuotaById(updateReqVO.getSupervisorsWithQuota(), supervisor.getSupervisorId());
|
|
|
|
+ if (supervisorQuota != null) {
|
|
|
|
+ settingSaveReqVO.setAcademicSlots(Integer.valueOf(supervisorQuota.get("academicSlots")));
|
|
|
|
+ settingSaveReqVO.setProfessionalSlots(Integer.valueOf(supervisorQuota.get("professionalSlots")));
|
|
|
|
+ supervisorSelectionSettingService.updateSupervisorSelectionSetting(settingSaveReqVO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //更新
|
|
|
|
|
|
+
|
|
|
|
+ // 更新项目
|
|
studentSelectionProjectService.updateStudentSelectionProject(updateReqVO);
|
|
studentSelectionProjectService.updateStudentSelectionProject(updateReqVO);
|
|
|
|
+
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Map<String, String> findSupervisorQuotaById(List<Map<String, String>> supervisorsWithQuota, Long supervisorId) {
|
|
|
|
+ for (Map<String, String> supervisorMap : supervisorsWithQuota) {
|
|
|
|
+ if (supervisorId.toString().equals(supervisorMap.get("id"))) {
|
|
|
|
+ return supervisorMap;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@DeleteMapping("/delete")
|
|
@DeleteMapping("/delete")
|
|
@Operation(summary = "删除师生互选项目")
|
|
@Operation(summary = "删除师生互选项目")
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:delete')")
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:delete')")
|
|
- public CommonResult<Boolean> deleteStudentSelectionProject(@RequestParam("id") Integer id) {
|
|
|
|
|
|
+ public CommonResult<Boolean> deleteStudentSelectionProject(@RequestParam("id") Long id) {
|
|
studentSelectionProjectService.deleteStudentSelectionProject(id);
|
|
studentSelectionProjectService.deleteStudentSelectionProject(id);
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
@@ -154,9 +213,34 @@ public class studentSelectionProjectController {
|
|
@Operation(summary = "获得师生互选项目")
|
|
@Operation(summary = "获得师生互选项目")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:query')")
|
|
@PreAuthorize("@ss.hasPermission('system:student-selection-project:query')")
|
|
- public CommonResult<studentSelectionProjectRespVO> getStudentSelectionProject(@RequestParam("id") Integer id) {
|
|
|
|
|
|
+ public CommonResult<studentSelectionProjectRespVO> getStudentSelectionProject(@RequestParam("id") Long id) {
|
|
studentSelectionProjectDO studentSelectionProject = studentSelectionProjectService.getStudentSelectionProject(id);
|
|
studentSelectionProjectDO studentSelectionProject = studentSelectionProjectService.getStudentSelectionProject(id);
|
|
- return success(BeanUtils.toBean(studentSelectionProject, studentSelectionProjectRespVO.class));
|
|
|
|
|
|
+
|
|
|
|
+ if (studentSelectionProject == null) {
|
|
|
|
+ return success(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ supervisorSelectionSettingPageReqVO pageReqVO = new supervisorSelectionSettingPageReqVO();
|
|
|
|
+ pageReqVO.setPageNo(-1);
|
|
|
|
+ pageReqVO.setProjectId(id);
|
|
|
|
+ PageResult<supervisorSelectionSettingDO> pageResult
|
|
|
|
+ = supervisorSelectionSettingService.getSupervisorSelectionSettingPage(pageReqVO);
|
|
|
|
+
|
|
|
|
+ // 将分页结果的内容转换为 List<Map<String, String>> 格式
|
|
|
|
+ List<Map<String, String>> supervisorsWithQuota = pageResult.getList().stream()
|
|
|
|
+ .map(setting -> {
|
|
|
|
+
|
|
|
|
+ Map<String, String> supervisorMap = new HashMap<>();
|
|
|
|
+ supervisorMap.put("id", String.valueOf(setting.getSupervisorId())); // 导师ID
|
|
|
|
+ supervisorMap.put("academicSlots", String.valueOf(setting.getAcademicSlots()));
|
|
|
|
+ supervisorMap.put("professionalSlots", String.valueOf(setting.getProfessionalSlots()));
|
|
|
|
+ supervisorMap.put("name", setting.getSupervisorName());
|
|
|
|
+ return supervisorMap;
|
|
|
|
+ })
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ studentSelectionProjectRespVO responseVO = BeanUtils.toBean(studentSelectionProject, studentSelectionProjectRespVO.class);
|
|
|
|
+ responseVO.setSupervisorsWithQuota(supervisorsWithQuota);
|
|
|
|
+ return success(responseVO);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@@ -189,7 +273,7 @@ public class studentSelectionProjectController {
|
|
|
|
|
|
@GetMapping("/getProjectSupervisors")
|
|
@GetMapping("/getProjectSupervisors")
|
|
@Operation(summary = "获取当前项目的导师")
|
|
@Operation(summary = "获取当前项目的导师")
|
|
- public CommonResult<List<AdminUserDO>> getProjectSupervisors(@RequestParam("projectId") Integer projectId) {
|
|
|
|
|
|
+ public CommonResult<List<AdminUserDO>> getProjectSupervisors(@RequestParam("projectId") Long projectId) {
|
|
// 获取项目数据并转换成相应的 VO
|
|
// 获取项目数据并转换成相应的 VO
|
|
studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(projectId), studentSelectionProjectSaveReqVO.class);
|
|
studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProject(projectId), studentSelectionProjectSaveReqVO.class);
|
|
List<Long> supervisorIds = project.getSupervisorIds();
|
|
List<Long> supervisorIds = project.getSupervisorIds();
|