Browse Source

手动分班后,修改新生的班级状态

dzx 4 months ago
parent
commit
ea28c319f8

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/dto/ChangeClassDto.java

@@ -26,4 +26,7 @@ public class ChangeClassDto implements Serializable {
     @ApiModelProperty("班级id")
     private Long bandingTaskClassId;
 
+    @ApiModelProperty("是否手动分班(1:是 0:否)")
+    private Integer isHandle = 0;
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskService.java

@@ -4,6 +4,8 @@ import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
 import com.xjrsoft.module.banding.entity.BandingTask;
+import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
 
 import java.util.List;
 
@@ -43,4 +45,6 @@ public interface IBandingTaskService extends MPJBaseService<BandingTask> {
 
 
     Boolean sure(SureBandingTaskDto dto);
+
+    void createStudentData(Long badingTaskId, List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList);
 }

+ 28 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -9,7 +9,10 @@ import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
+import com.xjrsoft.module.banding.service.IBandingTaskService;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -17,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
 * @title: 新生分班任务
@@ -28,6 +32,8 @@ import java.util.List;
 @AllArgsConstructor
 public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<BandingTaskClassStudentMapper, BandingTaskClassStudent> implements IBandingTaskClassStudentService {
     private final BandingTaskClassMapper taskClassMapper;
+    private final IBandingTaskService bandingTaskService;
+    private final IBaseNewStudentService newStudentService;
     @Override
     public Boolean add(BandingTaskClassStudent bandingTaskClass) {
         bandingTaskClass.setCreateDate(new Date());
@@ -64,12 +70,32 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
                         setNewStudentId(newStudentId);
                         setBandingTaskClassId(dto.getBandingTaskClassId());
                         setCreateUserId(createUserId);
+                        if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
+                            setStatus(1);
+                        }
                     }}
             );
         }
         if(!dataList.isEmpty()){
             this.saveBatch(dataList);
         }
+        if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
+            BandingTaskClass taskClass = taskClassMapper.selectById(dto.getBandingTaskClassId());
+            List<Long> studentIds = dataList.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
+            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);
+                updateList.add(student);
+            }
+            if(!updateList.isEmpty()){
+                newStudentService.updateBatchById(updateList);
+            }
+            bandingTaskService.createStudentData(taskClass.getBandingTaskId(), dataList, updateList);
+        }
         return true;
     }
 
@@ -111,6 +137,8 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         if(!dataList.isEmpty()){
            this.saveBatch(dataList);
         }
+
+
         return true;
     }
 

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

@@ -438,7 +438,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         return isSuccess;
     }
 
-    void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
+    public void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
         Date createDate = new Date();
         BandingTask bandingTask = this.getById(badingTaskId);
         List<BandingTaskClassSureListVo> classSure = taskClassMapper.getClassSure(new BandingTaskClassStudentPageDto() {{