|
|
@@ -0,0 +1,197 @@
|
|
|
+package com.xjrsoft.module.student.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.page.PageOutput;
|
|
|
+import com.xjrsoft.common.utils.TreeUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
+import com.xjrsoft.module.student.dto.AddStudentReportPlanDto;
|
|
|
+import com.xjrsoft.module.student.dto.StudentReportPlanPageDto;
|
|
|
+import com.xjrsoft.module.student.dto.StudentReportPlanStatusDto;
|
|
|
+import com.xjrsoft.module.student.dto.UpdateStudentReportPlanDto;
|
|
|
+import com.xjrsoft.module.student.entity.StudentReportPlan;
|
|
|
+import com.xjrsoft.module.student.entity.StudentReportPlanClassRelation;
|
|
|
+import com.xjrsoft.module.student.service.IStudentReportPlanService;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentTreeVo;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportPlanPageVo;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportPlanTreeVo;
|
|
|
+import com.xjrsoft.module.student.vo.StudentReportPlanVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 学生报到计划
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2025-01-21
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@RestController
|
|
|
+@RequestMapping("/student" + "/studentReportPlan")
|
|
|
+@Api(value = "/student" + "/studentReportPlan",tags = "学生报到计划代码")
|
|
|
+@AllArgsConstructor
|
|
|
+public class StudentReportPlanController {
|
|
|
+
|
|
|
+
|
|
|
+ private final IStudentReportPlanService studentReportPlanService;
|
|
|
+ private final IBaseSemesterService semesterService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/page")
|
|
|
+ @ApiOperation(value="学生报到计划列表(分页)")
|
|
|
+ @SaCheckPermission("studentreportplan:detail")
|
|
|
+ public RT<PageOutput<StudentReportPlanPageVo>> page(@Valid StudentReportPlanPageDto dto){
|
|
|
+ Page<StudentReportPlanPageVo> page = studentReportPlanService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+ PageOutput<StudentReportPlanPageVo> pageOutput = ConventPage.getPageOutput(page, StudentReportPlanPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ApiOperation(value="根据id查询学生报到计划信息")
|
|
|
+ @SaCheckPermission("studentreportplan:detail")
|
|
|
+ public RT<StudentReportPlanVo> info(@RequestParam Long id){
|
|
|
+ StudentReportPlan studentReportPlan = studentReportPlanService.getByIdDeep(id);
|
|
|
+ if (studentReportPlan == null) {
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
+ }
|
|
|
+ return RT.ok(BeanUtil.toBean(studentReportPlan, StudentReportPlanVo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增学生报到计划")
|
|
|
+ @SaCheckPermission("studentreportplan:add")
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddStudentReportPlanDto dto){
|
|
|
+ StudentReportPlan studentReportPlan = BeanUtil.toBean(dto, StudentReportPlan.class);
|
|
|
+ boolean isSuccess = studentReportPlanService.add(studentReportPlan);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation(value = "修改学生报到计划")
|
|
|
+ @SaCheckPermission("studentreportplan:edit")
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateStudentReportPlanDto dto){
|
|
|
+
|
|
|
+ StudentReportPlan studentReportPlan = BeanUtil.toBean(dto, StudentReportPlan.class);
|
|
|
+ return RT.ok(studentReportPlanService.update(studentReportPlan));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping
|
|
|
+ @ApiOperation(value = "删除学生报到计划")
|
|
|
+ @SaCheckPermission("studentreportplan:delete")
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
+ return RT.ok(studentReportPlanService.delete(ids));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/change-status")
|
|
|
+ @ApiOperation(value="修改状态")
|
|
|
+ @SaCheckPermission("classroom:detail")
|
|
|
+ public RT<Boolean> changeStatus(@Valid @RequestBody StudentReportPlanStatusDto dto) throws Exception {
|
|
|
+ StudentReportPlan reportPlan = studentReportPlanService.getByIdDeep(dto.getId());
|
|
|
+ if(reportPlan == null){
|
|
|
+ throw new MyException("未能找到计划信息");
|
|
|
+ }
|
|
|
+ //如果发布,需要先验证计划中的班级是否在其他生效的计划内
|
|
|
+ if(dto.getStatus() != null && dto.getStatus() == 1){
|
|
|
+ if(reportPlan.getStudentReportPlanClassRelationList() == null || !reportPlan.getStudentReportPlanClassRelationList().isEmpty()){
|
|
|
+ return RT.error("未选择班级,无法进行发布");
|
|
|
+ }
|
|
|
+ List<Long> classIds = reportPlan.getStudentReportPlanClassRelationList()
|
|
|
+ .stream().map(StudentReportPlanClassRelation::getClassId).collect(Collectors.toList());
|
|
|
+ List<BaseClass> classList = studentReportPlanService.validateClass(dto.getId(), classIds);
|
|
|
+ if(classList.isEmpty()){
|
|
|
+ Set<String> classNames = classList.stream().map(BaseClass::getName).collect(Collectors.toSet());
|
|
|
+ return RT.error(classNames.toString().replace("[", "").replace("]", "") + "已在其他计划中,无法发布");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(reportPlan.getStatus() == 1){
|
|
|
+ return RT.error("已发布,无法再次发布");
|
|
|
+ }
|
|
|
+
|
|
|
+ studentReportPlanService.release(reportPlan);
|
|
|
+ reportPlan.setStatus(dto.getStatus());
|
|
|
+ reportPlan.setModifyDate(new Date());
|
|
|
+ reportPlan.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ studentReportPlanService.update(reportPlan);
|
|
|
+ }else if(dto.getStatus() != null && dto.getStatus() == 2){
|
|
|
+ reportPlan.setStatus(dto.getStatus());
|
|
|
+ reportPlan.setModifyDate(new Date());
|
|
|
+ reportPlan.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ studentReportPlanService.update(reportPlan);
|
|
|
+ }
|
|
|
+ return RT.ok(true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/tree")
|
|
|
+ @ApiOperation(value="学期计划树")
|
|
|
+ @SaCheckPermission("studentreportplan:detail")
|
|
|
+ public RT<List<StudentReportPlanTreeVo>> tree(@RequestParam Long id){
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(1);statusList.add(2);
|
|
|
+ List<StudentReportPlan> list = studentReportPlanService.list(
|
|
|
+ new QueryWrapper<StudentReportPlan>().lambda()
|
|
|
+ .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .in(StudentReportPlan::getStatus, statusList)
|
|
|
+ );
|
|
|
+ Set<Long> semesterIds = list.stream().map(StudentReportPlan::getSemesterId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<BaseSemester> semesterList = semesterService.list(
|
|
|
+ new QueryWrapper<BaseSemester>().lambda()
|
|
|
+ .eq(BaseSemester::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .orderByDesc(BaseSemester::getName)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<StudentReportPlanTreeVo> resultList = new ArrayList<>();
|
|
|
+ for (BaseSemester baseSemester : semesterList) {
|
|
|
+ if(!semesterIds.contains(baseSemester.getId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ resultList.add(
|
|
|
+ new StudentReportPlanTreeVo(){{
|
|
|
+ setId(baseSemester.getId());
|
|
|
+ setName(baseSemester.getName());
|
|
|
+ }}
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ list.forEach((e->{
|
|
|
+ resultList.add(
|
|
|
+ new StudentReportPlanTreeVo(){{
|
|
|
+ setId(e.getId());
|
|
|
+ setName(e.getName());
|
|
|
+ setParentId(e.getSemesterId());
|
|
|
+ }}
|
|
|
+ );
|
|
|
+ }));
|
|
|
+
|
|
|
+
|
|
|
+ List<StudentReportPlanTreeVo> treeVoList = TreeUtil.build(resultList);
|
|
|
+ return RT.ok(treeVoList);
|
|
|
+ }
|
|
|
+}
|