Browse Source

学生报到计划

dzx 1 month ago
parent
commit
58f88f7c07
21 changed files with 1051 additions and 1 deletions
  1. 140 0
      src/main/java/com/xjrsoft/module/student/controller/StudentReportPlanController.java
  2. 32 0
      src/main/java/com/xjrsoft/module/student/dto/AddStudentReportPlanClassRelationDto.java
  3. 64 0
      src/main/java/com/xjrsoft/module/student/dto/AddStudentReportPlanDto.java
  4. 7 0
      src/main/java/com/xjrsoft/module/student/dto/BaseStudentUserPageDto.java
  5. 27 0
      src/main/java/com/xjrsoft/module/student/dto/StudentReportPlanPageDto.java
  6. 21 0
      src/main/java/com/xjrsoft/module/student/dto/StudentReportPlanStatusDto.java
  7. 24 0
      src/main/java/com/xjrsoft/module/student/dto/UpdateStudentReportPlanDto.java
  8. 118 0
      src/main/java/com/xjrsoft/module/student/entity/StudentReportPlan.java
  9. 43 0
      src/main/java/com/xjrsoft/module/student/entity/StudentReportPlanClassRelation.java
  10. 3 0
      src/main/java/com/xjrsoft/module/student/entity/StudentReportRecord.java
  11. 16 0
      src/main/java/com/xjrsoft/module/student/mapper/StudentReportPlanClassRelationMapper.java
  12. 27 0
      src/main/java/com/xjrsoft/module/student/mapper/StudentReportPlanMapper.java
  13. 1 0
      src/main/java/com/xjrsoft/module/student/service/IStudentManagerService.java
  14. 49 0
      src/main/java/com/xjrsoft/module/student/service/IStudentReportPlanService.java
  15. 183 0
      src/main/java/com/xjrsoft/module/student/service/impl/StudentReportPlanServiceImpl.java
  16. 33 0
      src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanClassRelationVo.java
  17. 118 0
      src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanPageVo.java
  18. 66 0
      src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanVo.java
  19. 7 1
      src/main/resources/mapper/student/BaseStudentMapper.xml
  20. 35 0
      src/main/resources/mapper/student/StudentReportPlanMapper.xml
  21. 37 0
      src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

+ 140 - 0
src/main/java/com/xjrsoft/module/student/controller/StudentReportPlanController.java

@@ -0,0 +1,140 @@
+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.extension.plugins.pagination.Page;
+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.module.base.entity.BaseClass;
+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.StudentReportPlanPageVo;
+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.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;
+
+    @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);
+    }
+}

+ 32 - 0
src/main/java/com/xjrsoft/module/student/dto/AddStudentReportPlanClassRelationDto.java

@@ -0,0 +1,32 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+
+/**
+* @title: 学生报到计划-班级
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class AddStudentReportPlanClassRelationDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 计划id
+    */
+    @ApiModelProperty("计划id")
+    private Long studentReportPlanId;
+    /**
+    * 班级id
+    */
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+}

+ 64 - 0
src/main/java/com/xjrsoft/module/student/dto/AddStudentReportPlanDto.java

@@ -0,0 +1,64 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class AddStudentReportPlanDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 学期id(base_semester)
+    */
+    @ApiModelProperty("学期id(base_semester)")
+    private Long semesterId;
+    /**
+    * 计划名称
+    */
+    @ApiModelProperty("计划名称")
+    private String name;
+    /**
+    * 报到开始时间
+    */
+    @ApiModelProperty("报到开始时间")
+    private Date startTime;
+    /**
+    * 报到结束时间
+    */
+    @ApiModelProperty("报到结束时间")
+    private Date endTime;
+    /**
+    * 数据修改开始时间
+    */
+    @ApiModelProperty("数据修改开始时间")
+    private Date updateStartTime;
+    /**
+    * 数据修改结束时间
+    */
+    @ApiModelProperty("数据修改结束时间")
+    private Date updateEndTime;
+    /**
+    * 状态(0:草稿 1:进行中 2:已结束)
+    */
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+
+    /**
+    * studentReportPlanClassRelation
+    */
+    @ApiModelProperty("studentReportPlanClassRelation子表")
+    private List<AddStudentReportPlanClassRelationDto> studentReportPlanClassRelationList;
+}

+ 7 - 0
src/main/java/com/xjrsoft/module/student/dto/BaseStudentUserPageDto.java

@@ -5,6 +5,9 @@ import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
 @Data
 @EqualsAndHashCode(callSuper = false)
 public class BaseStudentUserPageDto extends PageInput {
@@ -60,4 +63,8 @@ public class BaseStudentUserPageDto extends PageInput {
     @JsonIgnore
     private Long teacherId;
 
+
+    @JsonIgnore
+    private List<Long> classIds;
+
 }

+ 27 - 0
src/main/java/com/xjrsoft/module/student/dto/StudentReportPlanPageDto.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.student.dto;
+
+import com.xjrsoft.common.page.PageInput;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+/**
+* @title: 学生报到计划分页查询入参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class StudentReportPlanPageDto extends PageInput {
+
+    @ApiModelProperty("计划名称")
+    private String name;
+
+    @ApiModelProperty("学期id")
+    private Long semesterId;
+
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+}

+ 21 - 0
src/main/java/com/xjrsoft/module/student/dto/StudentReportPlanStatusDto.java

@@ -0,0 +1,21 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 学生报到计划分页查询入参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class StudentReportPlanStatusDto{
+
+    @ApiModelProperty("主键id")
+    private Long id;
+
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+}

+ 24 - 0
src/main/java/com/xjrsoft/module/student/dto/UpdateStudentReportPlanDto.java

@@ -0,0 +1,24 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class UpdateStudentReportPlanDto extends AddStudentReportPlanDto {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键
+    */
+    @ApiModelProperty("主键")
+    private Long id;
+}

+ 118 - 0
src/main/java/com/xjrsoft/module/student/entity/StudentReportPlan.java

@@ -0,0 +1,118 @@
+package com.xjrsoft.module.student.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.yulichang.annotation.EntityMapping;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+@TableName("student_report_plan")
+@ApiModel(value = "student_report_plan", description = "学生报到计划")
+public class StudentReportPlan implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键
+    */
+    @ApiModelProperty("主键")
+    @TableId
+    private Long id;
+    /**
+    * 创建人
+    */
+    @ApiModelProperty("创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private Long createUserId;
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty("创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createDate;
+    /**
+    * 修改人id
+    */
+    @ApiModelProperty("修改人id")
+    @TableField(fill = FieldFill.UPDATE)
+    private Long modifyUserId;
+    /**
+    * 修改日期
+    */
+    @ApiModelProperty("修改日期")
+    @TableField(fill = FieldFill.UPDATE)
+    private Date modifyDate;
+    /**
+    * 删除标记(0:未删除 1:已删除)
+    */
+    @ApiModelProperty("删除标记(0:未删除 1:已删除)")
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Object deleteMark;
+    /**
+    * 有效标记(0:未启用 1:已启用)
+    */
+    @ApiModelProperty("有效标记(0:未启用 1:已启用)")
+    @TableField(fill = FieldFill.INSERT)
+    private Object enabledMark;
+    /**
+    * 学期id(base_semester)
+    */
+    @ApiModelProperty("学期id(base_semester)")
+    private Long semesterId;
+    /**
+    * 计划名称
+    */
+    @ApiModelProperty("计划名称")
+    private String name;
+    /**
+    * 报到开始时间
+    */
+    @ApiModelProperty("报到开始时间")
+    private Date startTime;
+    /**
+    * 报到结束时间
+    */
+    @ApiModelProperty("报到结束时间")
+    private Date endTime;
+    /**
+    * 数据修改开始时间
+    */
+    @ApiModelProperty("数据修改开始时间")
+    private Date updateStartTime;
+    /**
+    * 数据修改结束时间
+    */
+    @ApiModelProperty("数据修改结束时间")
+    private Date updateEndTime;
+    /**
+    * 状态(0:草稿 1:进行中 2:已结束)
+    */
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+
+    /**
+    * studentReportPlanClassRelation
+    */
+    @ApiModelProperty("studentReportPlanClassRelation子表")
+    @TableField(exist = false)
+    @EntityMapping(thisField = "id", joinField = "studentReportPlanId")
+    private List<StudentReportPlanClassRelation> studentReportPlanClassRelationList;
+
+}

+ 43 - 0
src/main/java/com/xjrsoft/module/student/entity/StudentReportPlanClassRelation.java

@@ -0,0 +1,43 @@
+package com.xjrsoft.module.student.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+* @title: 学生报到计划-班级
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+@TableName("student_report_plan_class_relation")
+@ApiModel(value = "student_report_plan_class_relation", description = "学生报到计划-班级")
+public class StudentReportPlanClassRelation implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+    * 主键
+    */
+    @ApiModelProperty("主键")
+    @TableId
+    private Long id;
+    /**
+    * 计划id
+    */
+    @ApiModelProperty("计划id")
+    private Long studentReportPlanId;
+    /**
+    * 班级id
+    */
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+
+}

+ 3 - 0
src/main/java/com/xjrsoft/module/student/entity/StudentReportRecord.java

@@ -85,5 +85,8 @@ public class StudentReportRecord implements Serializable {
     @ApiModelProperty("所属学期")
     private Long baseSemesterId;
 
+    @ApiModelProperty("报到计划id")
+    private Long studentReportPlanId;
+
 
 }

+ 16 - 0
src/main/java/com/xjrsoft/module/student/mapper/StudentReportPlanClassRelationMapper.java

@@ -0,0 +1,16 @@
+package com.xjrsoft.module.student.mapper;
+
+import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.student.entity.StudentReportPlanClassRelation;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @title: 学生报到计划-班级
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Mapper
+public interface StudentReportPlanClassRelationMapper extends MPJBaseMapper<StudentReportPlanClassRelation> {
+
+}

+ 27 - 0
src/main/java/com/xjrsoft/module/student/mapper/StudentReportPlanMapper.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.student.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.student.dto.StudentReportPlanPageDto;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.vo.StudentReportPlanPageVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Mapper
+public interface StudentReportPlanMapper extends MPJBaseMapper<StudentReportPlan> {
+
+    Page<StudentReportPlanPageVo> getPage(Page<StudentReportPlanPageVo> page, @Param("dto") StudentReportPlanPageDto dto);
+
+
+    List<BaseClass> validateClass(@Param("id") Long id, @Param("classIds") List<Long> classIds);
+}

+ 1 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentManagerService.java

@@ -68,4 +68,5 @@ public interface IStudentManagerService extends MPJBaseService<BaseStudentUser>
 
      List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree(MajorGradeClassDto dto);
 
+
 }

+ 49 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentReportPlanService.java

@@ -0,0 +1,49 @@
+package com.xjrsoft.module.student.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.student.dto.StudentReportPlanPageDto;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.vo.StudentReportPlanPageVo;
+
+import java.util.List;
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+
+public interface IStudentReportPlanService extends MPJBaseService<StudentReportPlan> {
+    /**
+    * 新增
+    *
+    * @param studentReportPlan
+    * @return
+    */
+    Boolean add(StudentReportPlan studentReportPlan);
+
+    /**
+    * 更新
+    *
+    * @param studentReportPlan
+    * @return
+    */
+    Boolean update(StudentReportPlan studentReportPlan);
+
+    /**
+    * 删除
+    *
+    * @param ids
+    * @return
+    */
+    Boolean delete(List<Long> ids);
+
+    Page<StudentReportPlanPageVo> getPage(Page<StudentReportPlanPageVo> page, StudentReportPlanPageDto dto);
+
+    List<BaseClass> validateClass(Long id, List<Long> classIds);
+
+    Boolean release(StudentReportPlan studentReportPlan);
+}

+ 183 - 0
src/main/java/com/xjrsoft/module/student/service/impl/StudentReportPlanServiceImpl.java

@@ -0,0 +1,183 @@
+package com.xjrsoft.module.student.service.impl;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
+import com.xjrsoft.module.student.dto.StudentReportPlanPageDto;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.entity.StudentReportPlanClassRelation;
+import com.xjrsoft.module.student.entity.StudentReportRecord;
+import com.xjrsoft.module.student.mapper.StudentReportPlanClassRelationMapper;
+import com.xjrsoft.module.student.mapper.StudentReportPlanMapper;
+import com.xjrsoft.module.student.service.IBaseStudentService;
+import com.xjrsoft.module.student.service.IStudentReportPlanService;
+import com.xjrsoft.module.student.service.IStudentReportRecordService;
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
+import com.xjrsoft.module.student.vo.StudentReportPlanPageVo;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+* @title: 学生报到计划
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Service
+@AllArgsConstructor
+public class StudentReportPlanServiceImpl extends MPJBaseServiceImpl<StudentReportPlanMapper, StudentReportPlan> implements IStudentReportPlanService {
+    private final StudentReportPlanMapper planMapper;
+
+    private final StudentReportPlanClassRelationMapper relationMapper;
+
+    private final IBaseStudentService studentService;
+
+    private final IStudentReportRecordService reportRecordService;
+
+    private final IUserService userService;
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean add(StudentReportPlan studentReportPlan) {
+        planMapper.insert(studentReportPlan);
+        for (StudentReportPlanClassRelation studentReportPlanClassRelation : studentReportPlan.getStudentReportPlanClassRelationList()) {
+            studentReportPlanClassRelation.setStudentReportPlanId(studentReportPlan.getId());
+            relationMapper.insert(studentReportPlanClassRelation);
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean update(StudentReportPlan studentReportPlan) {
+        planMapper.updateById(studentReportPlan);
+        //********************************* StudentReportPlanClassRelation  增删改  开始 *******************************************/
+        {
+            // 查出所有子级的id
+            List<StudentReportPlanClassRelation> studentReportPlanClassRelationList = relationMapper.selectList(Wrappers.lambdaQuery(StudentReportPlanClassRelation.class).eq(StudentReportPlanClassRelation::getStudentReportPlanId, studentReportPlan.getId()).select(StudentReportPlanClassRelation::getId));
+            List<Long> studentReportPlanClassRelationIds = studentReportPlanClassRelationList.stream().map(StudentReportPlanClassRelation::getId).collect(Collectors.toList());
+            //原有子表单 没有被删除的主键
+            List<Long> studentReportPlanClassRelationOldIds = studentReportPlan.getStudentReportPlanClassRelationList().stream().map(StudentReportPlanClassRelation::getId).filter(Objects::nonNull).collect(Collectors.toList());
+            //找到需要删除的id
+            List<Long> studentReportPlanClassRelationRemoveIds = studentReportPlanClassRelationIds.stream().filter(item -> !studentReportPlanClassRelationOldIds.contains(item)).collect(Collectors.toList());
+
+            for (StudentReportPlanClassRelation studentReportPlanClassRelation : studentReportPlan.getStudentReportPlanClassRelationList()) {
+                //如果不等于空则修改
+                if (studentReportPlanClassRelation.getId() != null) {
+                    relationMapper.updateById(studentReportPlanClassRelation);
+                }
+                //如果等于空 则新增
+                else {
+                    //已经不存在的id 删除
+                    studentReportPlanClassRelation.setStudentReportPlanId(studentReportPlan.getId());
+                    relationMapper.insert(studentReportPlanClassRelation);
+                }
+            }
+            //已经不存在的id 删除
+            if(studentReportPlanClassRelationRemoveIds.size() > 0){
+                relationMapper.deleteBatchIds(studentReportPlanClassRelationRemoveIds);
+            }
+        }
+        //********************************* StudentReportPlanClassRelation  增删改  结束 *******************************************/
+
+        return true;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean delete(List<Long> ids) {
+        planMapper.deleteBatchIds(ids);
+        relationMapper.delete(Wrappers.lambdaQuery(StudentReportPlanClassRelation.class).in(StudentReportPlanClassRelation::getStudentReportPlanId, ids));
+
+        return true;
+    }
+
+    @Override
+    public Page<StudentReportPlanPageVo> getPage(Page<StudentReportPlanPageVo> page, StudentReportPlanPageDto dto) {
+        return this.baseMapper.getPage(page, dto);
+    }
+
+    @Override
+    public List<BaseClass> validateClass(Long id, List<Long> classIds) {
+        return this.baseMapper.validateClass(id, classIds);
+    }
+
+    /**
+     * 发布
+     * 发布之后,将学生初始化到报到记录表中
+     * 发布之后,将学生给禁用掉
+     * @param studentReportPlan
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean release(StudentReportPlan studentReportPlan) {
+        List<Long> classIds = studentReportPlan.getStudentReportPlanClassRelationList().stream().map(StudentReportPlanClassRelation::getClassId).collect(Collectors.toList());
+        //1、查询选择的学生
+        List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto() {{
+            setClassIds(classIds);
+        }});
+
+        Date createDate = new Date();
+        List<StudentReportRecord> insertList = new ArrayList<>();
+        for (BaseStudentUserPageVo student : studentList) {
+            insertList.add(
+                    new StudentReportRecord(){{
+                        setCreateDate(createDate);
+                        setCreateUserId(StpUtil.getLoginIdAsLong());
+                        setUserId(Long.parseLong(student.getId()));
+                        setBaseSemesterId(studentReportPlan.getSemesterId());
+                        setStudentReportPlanId(studentReportPlan.getId());
+                    }}
+            );
+        }
+
+        if(!insertList.isEmpty()){
+            reportRecordService.remove(
+                    new QueryWrapper<StudentReportRecord>().lambda()
+                            .eq(StudentReportRecord::getStudentReportPlanId, studentReportPlan.getId())
+            );
+
+            reportRecordService.saveBatch(insertList);
+            Set<String> studentUserIds = studentList.stream().map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
+            //发布后,将学生的状态改为不正常
+            List<BaseStudent> baseStudents = studentService.list(
+                    new QueryWrapper<BaseStudent>().lambda()
+                            .in(BaseStudent::getUserId, studentUserIds)
+            );
+
+            for (BaseStudent baseStudent : baseStudents) {
+                baseStudent.setIsNormal(0);
+            }
+
+            studentService.updateBatchById(baseStudents);
+
+            //修改用户的状态
+            List<User> userList = userService.listByIds(studentUserIds);
+
+            for (User user : userList) {
+                user.setEnabledMark(EnabledMark.DISABLED.getCode());
+            }
+
+            userService.saveBatch(userList);
+        }
+        return true;
+    }
+}

+ 33 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanClassRelationVo.java

@@ -0,0 +1,33 @@
+package com.xjrsoft.module.student.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 学生报到计划-班级表单出参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class StudentReportPlanClassRelationVo {
+
+    /**
+    * 主键
+    */
+    @ApiModelProperty("主键")
+    private Long id;
+    /**
+    * 计划id
+    */
+    @ApiModelProperty("计划id")
+    private Long studentReportPlanId;
+    /**
+    * 班级id
+    */
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+
+
+}

+ 118 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanPageVo.java

@@ -0,0 +1,118 @@
+package com.xjrsoft.module.student.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+* @title: 学生报到计划分页列表出参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class StudentReportPlanPageVo {
+
+    /**
+    * 主键
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("主键")
+    @ApiModelProperty("主键")
+    private String id;
+    /**
+    * 创建人
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("创建人")
+    @ApiModelProperty("创建人")
+    private Long createUserId;
+    /**
+    * 创建时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("创建时间")
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+    /**
+    * 修改人id
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("修改人id")
+    @ApiModelProperty("修改人id")
+    private Long modifyUserId;
+    /**
+    * 修改日期
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("修改日期")
+    @ApiModelProperty("修改日期")
+    private Date modifyDate;
+    /**
+    * 删除标记(0:未删除 1:已删除)
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("删除标记(0:未删除 1:已删除)")
+    @ApiModelProperty("删除标记(0:未删除 1:已删除)")
+    private Object deleteMark;
+    /**
+    * 有效标记(0:未启用 1:已启用)
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("有效标记(0:未启用 1:已启用)")
+    @ApiModelProperty("有效标记(0:未启用 1:已启用)")
+    private Object enabledMark;
+    /**
+    * 学期id(base_semester)
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学期id(base_semester)")
+    @ApiModelProperty("学期id(base_semester)")
+    private Long semesterId;
+    /**
+    * 计划名称
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("计划名称")
+    @ApiModelProperty("计划名称")
+    private String name;
+    /**
+    * 报到开始时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("报到开始时间")
+    @ApiModelProperty("报到开始时间")
+    private Date startTime;
+    /**
+    * 报到结束时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("报到结束时间")
+    @ApiModelProperty("报到结束时间")
+    private Date endTime;
+    /**
+    * 数据修改开始时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("数据修改开始时间")
+    @ApiModelProperty("数据修改开始时间")
+    private Date updateStartTime;
+    /**
+    * 数据修改结束时间
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("数据修改结束时间")
+    @ApiModelProperty("数据修改结束时间")
+    private Date updateEndTime;
+    /**
+    * 状态(0:草稿 1:进行中 2:已结束)
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+
+}

+ 66 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportPlanVo.java

@@ -0,0 +1,66 @@
+package com.xjrsoft.module.student.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+* @title: 学生报到计划表单出参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class StudentReportPlanVo {
+
+    /**
+    * 主键
+    */
+    @ApiModelProperty("主键")
+    private Long id;
+    /**
+    * 学期id(base_semester)
+    */
+    @ApiModelProperty("学期id(base_semester)")
+    private Long semesterId;
+    /**
+    * 计划名称
+    */
+    @ApiModelProperty("计划名称")
+    private String name;
+    /**
+    * 报到开始时间
+    */
+    @ApiModelProperty("报到开始时间")
+    private Date startTime;
+    /**
+    * 报到结束时间
+    */
+    @ApiModelProperty("报到结束时间")
+    private Date endTime;
+    /**
+    * 数据修改开始时间
+    */
+    @ApiModelProperty("数据修改开始时间")
+    private Date updateStartTime;
+    /**
+    * 数据修改结束时间
+    */
+    @ApiModelProperty("数据修改结束时间")
+    private Date updateEndTime;
+    /**
+    * 状态(0:草稿 1:进行中 2:已结束)
+    */
+    @ApiModelProperty("状态(0:草稿 1:进行中 2:已结束)")
+    private Integer status;
+
+
+    /**
+    * studentReportPlanClassRelation
+    */
+    @ApiModelProperty("studentReportPlanClassRelation子表")
+    private List<StudentReportPlanClassRelationVo> studentReportPlanClassRelationList;
+
+}

+ 7 - 1
src/main/resources/mapper/student/BaseStudentMapper.xml

@@ -130,7 +130,13 @@
         LEFT JOIN base_class t4 ON t4.id = t3.class_id
         LEFT JOIN xjr_user t5 ON t4.teacher_id = t5.id
         WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
-        and t3.archives_status = 'FB2901'
+        and t3.archives_status = 'FB2901' and t2.is_normal = 1
+        <if test="dto.classIds != null and dto.classIds.size() > 0">
+            and t3.class_id in
+            <foreach item="classId" index="index" collection="dto.classIds" open="(" close=")" separator=",">
+                #{classId}
+            </foreach>
+        </if>
     </select>
 
 </mapper>

+ 35 - 0
src/main/resources/mapper/student/StudentReportPlanMapper.xml

@@ -0,0 +1,35 @@
+<?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="com.xjrsoft.module.student.mapper.StudentReportPlanMapper">
+    <select id="getPage" parameterType="com.xjrsoft.module.student.dto.StudentReportPlanPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportPlanPageVo">
+        SELECT t1.id,t1.name,t3.name AS semester_name,t1.start_time,t1.end_time,
+        t1.update_end_time,t1.update_start_time,t1.status,t1.create_date,
+        t2.name AS create_user_name FROM student_report_plan t1
+        LEFT JOIN xjr_user t2 ON t1.create_user_id = t2.id
+        INNER JOIN base_semester t3 ON t1.semester_id = t3.id
+        WHERE t1.delete_mark = 0
+        <if test="dto.name != null and dto.name !=''">
+            and t1.name like concat('%', #{dto.name}, '%')
+        </if>
+        <if test="dto.semesterId != null">
+            and t1.semester_id = #{dto.semesterId}
+        </if>
+        <if test="dto.status != null">
+            and t1.status = #{dto.status}
+        </if>
+        order by t1.id desc
+    </select>
+    <select id="validateClass" resultType="com.xjrsoft.module.base.entity.BaseClass">
+        SELECT t1.* FROM base_class t1
+        INNER JOIN student_report_plan_class_relation t2 ON t1.id = t2.class_id
+        INNER JOIN student_report_plan t3 ON t2.student_report_plan_id = t3.id
+        WHERE t3.delete_mark = 0 AND NOW() BETWEEN t3.start_time AND t3.end_time
+        AND t3.id != #{id}
+        and t1.id in
+        <foreach item="classId" index="index" collection="classIds" open="(" close=")" separator=",">
+            #{classId}
+        </foreach>
+    </select>
+</mapper>

+ 37 - 0
src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

@@ -4234,6 +4234,43 @@ public class FreeMarkerGeneratorTest {
         mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
         tableConfigs.add(mainTable);
 
+        ApiGenerateCodesDto params = new ApiGenerateCodesDto();
+        params.setAuthor("dzx");//作者名称
+        params.setPackageName("student");//包名
+        params.setTableConfigs(tableConfigs);
+        params.setPage(true);//是否生成分页接口
+        params.setImport(true);//是否生成导入接口
+        params.setExport(true);//是否生成导出接口
+        params.setOutMainDir(true);//是否生成在主目录,前期测试可设置成false
+        params.setDs(ds);
+
+        IApiGeneratorService apiGeneratorService = new ApiGeneratorServiceImpl();
+
+        apiGeneratorService.generateCodes(params);
+    }
+
+
+    @Test
+    public void gcStudentReportPlan() throws IOException {
+        List<TableConfig> tableConfigs = new ArrayList<>();
+        TableConfig mainTable = new TableConfig();
+        mainTable.setTableName("student_report_plan");//init_sql中的表名
+        mainTable.setIsMain(true);//是否是主表,一般默认为true
+        mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
+        mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
+        tableConfigs.add(mainTable);
+
+
+        mainTable = new TableConfig();
+        mainTable.setTableName("student_report_plan_class_relation");//init_sql中的表名
+        mainTable.setIsMain(false);//是否是主表,一般默认为true
+        mainTable.setPkField(GlobalConstant.DEFAULT_PK);//设置主键
+        mainTable.setPkType(GlobalConstant.DEFAULT_PK_TYPE);//设置主键类型
+        mainTable.setRelationField("student_report_plan_id");//设置外键
+        mainTable.setRelationTableField(GlobalConstant.DEFAULT_PK);//设置外键
+        tableConfigs.add(mainTable);
+
+
         ApiGenerateCodesDto params = new ApiGenerateCodesDto();
         params.setAuthor("dzx");//作者名称
         params.setPackageName("student");//包名