浏览代码

确认分班后,将新生数据初始化到报到表中

dzx 10 月之前
父节点
当前提交
f7a14e6299

+ 42 - 25
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java

@@ -1,7 +1,7 @@
 package com.xjrsoft.module.banding.service.impl;
 
 import cn.dev33.satoken.secure.BCrypt;
-import cn.hutool.core.util.ObjectUtil;
+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;
@@ -54,11 +54,14 @@ import com.xjrsoft.module.student.entity.BaseStudent;
 import com.xjrsoft.module.student.entity.BaseStudentFamily;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.EnrollmentPlan;
+import com.xjrsoft.module.student.entity.StudentReportRecord;
 import com.xjrsoft.module.student.mapper.BaseClassMajorSetMapper;
 import com.xjrsoft.module.student.service.IBaseNewStudentService;
 import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.student.service.IBaseStudentService;
+import com.xjrsoft.module.student.service.IStudentChangeRecordService;
+import com.xjrsoft.module.student.service.IStudentReportRecordService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -106,6 +109,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
     private final IBaseGradeService gradeService;
     private final BaseMajorSetMapper majorSetMapper;
     private final RedisUtil redisUtil;
+    private final IStudentReportRecordService reportRecordService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -721,7 +725,43 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
     @Transactional
     public Boolean sureReport(SureBandingTaskDto dto) {
         //修改新生信息中的状态
-        updateBaseNewStudentStatus(dto.getBandingTaskId(), 1, null);
+        List<BandingTaskClassStudent> classStudents = classStudentService.list(
+                new MPJLambdaWrapper<BandingTaskClassStudent>()
+                        .innerJoin(BandingTaskClass.class, BandingTaskClass::getId, BandingTaskClassStudent::getBandingTaskClassId)
+                        .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
+        );
+        List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
+        if(studentIds.isEmpty()){
+            throw new MyException("未能查询到学生,无法确认");
+        }
+        List<BaseNewStudent> list = newStudentService.list(
+                new QueryWrapper<BaseNewStudent>().lambda()
+                        .in(BaseNewStudent::getId, studentIds)
+        );
+        List<BaseNewStudent> updateList = new ArrayList<>();
+        for (BaseNewStudent student : list) {
+            student.setStatus(1);
+            student.setOperateMode(1);
+            updateList.add(student);
+        }
+
+        if(!updateList.isEmpty()){
+            newStudentService.updateBatchById(updateList);
+        }
+
+        //将新生数据初始化到报到表中
+        List<StudentReportRecord> insertList = new ArrayList<>();
+        for (BaseNewStudent student : updateList) {
+            insertList.add(
+                    new StudentReportRecord(){{
+                        setCreateDate(new Date());
+                        setCreateUserId(StpUtil.getLoginIdAsLong());
+                        setUserId(student.getId());
+                        setBandingTaskId(dto.getBandingTaskId());
+                    }}
+            );
+        }
+        reportRecordService.saveBatch(insertList);
 
         BandingTask bandingTask = this.getById(dto.getId());
         bandingTask.setStatus(1);
@@ -752,29 +792,6 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
      * @param baseNewStudentId 新生id,适合手动调整班级时调用
      */
     void updateBaseNewStudentStatus(Long bandingTaskId, Integer operateMode, Long baseNewStudentId){
-        List<BandingTaskClassStudent> classStudents = classStudentService.list(
-                new MPJLambdaWrapper<BandingTaskClassStudent>()
-                        .innerJoin(BandingTaskClass.class, BandingTaskClass::getId, BandingTaskClassStudent::getBandingTaskClassId)
-                        .eq(BandingTaskClass::getBandingTaskId, bandingTaskId)
-                        .eq(ObjectUtil.isNotNull(baseNewStudentId), BandingTaskClassStudent::getNewStudentId, baseNewStudentId)
-        );
-        List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
-        if(studentIds.isEmpty()){
-            throw new MyException("未能查询到学生,无法确认");
-        }
-        List<BaseNewStudent> list = newStudentService.list(
-                new QueryWrapper<BaseNewStudent>().lambda()
-                        .in(BaseNewStudent::getId, studentIds)
-        );
-        List<BaseNewStudent> updateList = new ArrayList<>();
-        for (BaseNewStudent student : list) {
-            student.setStatus(1);
-            student.setOperateMode(operateMode);
-            updateList.add(student);
-        }
 
-        if(!updateList.isEmpty()){
-            newStudentService.updateBatchById(updateList);
-        }
     };
 }

+ 4 - 1
src/main/java/com/xjrsoft/module/student/entity/StudentReportRecord.java

@@ -72,7 +72,7 @@ public class StudentReportRecord implements Serializable {
     /**
     * 学生id
     */
-    @ApiModelProperty("学生id")
+    @ApiModelProperty("学生id(banding_task_id不为空时则为新生id)")
     private Long userId;
     /**
     * 报到时间
@@ -88,5 +88,8 @@ public class StudentReportRecord implements Serializable {
     @ApiModelProperty("报到计划id")
     private Long studentReportPlanId;
 
+    @ApiModelProperty("分班任务id")
+    private Long bandingTaskId;
+
 
 }