浏览代码

未设置班级优先级,有限按照一志愿分配

dzx 4 月之前
父节点
当前提交
8182eb42cb

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

@@ -4,8 +4,6 @@ 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;
 
@@ -46,5 +44,4 @@ public interface IBandingTaskService extends MPJBaseService<BandingTask> {
 
     Boolean sure(SureBandingTaskDto dto);
 
-    void createStudentData(Long badingTaskId, List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList);
 }

+ 162 - 3
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -1,25 +1,53 @@
 package com.xjrsoft.module.banding.service.impl;
 
+import cn.dev33.satoken.secure.BCrypt;
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.RoleEnum;
+import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.dto.ChangeClassDto;
+import com.xjrsoft.module.banding.entity.BandingTask;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 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.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
+import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
+import com.xjrsoft.module.student.entity.BaseClassMajorSet;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
+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.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 lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -32,8 +60,17 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<BandingTaskClassStudentMapper, BandingTaskClassStudent> implements IBandingTaskClassStudentService {
     private final BandingTaskClassMapper taskClassMapper;
-    private final IBandingTaskService bandingTaskService;
+    private final BandingTaskMapper bandingTaskMapper;
     private final IBaseNewStudentService newStudentService;
+
+    private final IBaseClassService classService;
+    private final BaseClassMajorSetMapper classMajorSetMapper;
+    private final CommonPropertiesConfig propertiesConfig;
+    private final IUserService userService;
+    private final IUserRoleRelationService roleRelationService;
+    private final IBaseStudentSchoolRollService schoolRollService;
+    private final IBaseStudentService studentService;
+    private final IBaseStudentFamilyService familyService;
     @Override
     public Boolean add(BandingTaskClassStudent bandingTaskClass) {
         bandingTaskClass.setCreateDate(new Date());
@@ -94,11 +131,134 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
             if(!updateList.isEmpty()){
                 newStudentService.updateBatchById(updateList);
             }
-            bandingTaskService.createStudentData(taskClass.getBandingTaskId(), dataList, updateList);
+            createStudentData(taskClass.getBandingTaskId(), dataList, updateList);
         }
         return true;
     }
 
+    void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
+        Date createDate = new Date();
+        BandingTask bandingTask = bandingTaskMapper.selectById(badingTaskId);
+        List<BandingTaskClassSureListVo> classSure = taskClassMapper.getClassSure(new BandingTaskClassStudentPageDto() {{
+            setBandingTaskId(badingTaskId);
+        }});
+
+        Map<Long, Integer> classTotal = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getNumber));
+        Map<Long, Integer> classBoy = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getMaleCount));
+        Map<Long, Integer> classGirl = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getFemaleCount));
+
+
+        //生成班级数据
+        Map<Long, Long> classMap = new HashMap<>();
+        Map<Long, Long> taskClassMajorMap = new HashMap<>();
+        //查询出需要新增的班级信息
+        List<Long> classIds = classStudents.stream().map(BandingTaskClassStudent::getBandingTaskClassId).collect(Collectors.toList());
+        List<BandingTaskClass> classList = taskClassMapper.selectList(new QueryWrapper<BandingTaskClass>().lambda().in(BandingTaskClass::getId, classIds));
+        for (BandingTaskClass taskClass : classList) {
+            BaseClass baseClass = new BaseClass() {{
+                setName(taskClass.getName());
+                setClassroomId(taskClass.getClassroomId());
+                setTeacherId(taskClass.getTeacherId());
+                setIsGraduate(1);
+                setIsOrderClass(taskClass.getIsOrderClass().intValue());
+                setGradeId(bandingTask.getGradeId());
+                setDeleteMark(DeleteMark.NODELETE.getCode());
+                setEnrollType(bandingTask.getEnrollType());
+            }};
+
+            classService.save(baseClass);
+
+            BaseClassMajorSet majorSet = new BaseClassMajorSet() {{
+                setCreateDate(createDate);
+                setMajorSetId(taskClass.getMajorSetId());
+                setClassId(baseClass.getId());
+                setPlanTotalStudent(taskClass.getNumber());
+                setTotalStudent(classTotal.get(taskClass.getId()));
+                setBoyNum(classBoy.get(taskClass.getId()));
+                setGirlNum(classGirl.get(taskClass.getId()));
+            }};
+            classMajorSetMapper.insert(majorSet);
+
+            classMap.put(taskClass.getId(), baseClass.getId());
+            taskClassMajorMap.put(taskClass.getId(), taskClass.getMajorSetId());
+        }
+
+        /**
+         * 新增学生数据
+         * 1、新增用户xjr_user
+         * 2、新增用户与角色的关系xjr_user_role_relation
+         * 3、新增学生基本信息base_student
+         * 4、新增学籍信息表base_student_school_roll
+         * 5、新增家庭信息表base_student_family
+         */
+        LocalDateTime now = LocalDateTime.now();
+        Map<Long, Long> studentClassRelation = classStudents.stream().collect(Collectors.toMap(BandingTaskClassStudent::getNewStudentId, BandingTaskClassStudent::getBandingTaskClassId));
+        for (BaseNewStudent student : updateList) {
+            LocalDateTime birthDate = getBirthDate(student.getCredentialNumber());
+            User xjrUser = new User() {{
+                setCreateDate(now);
+                setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
+                setName(student.getName());
+                setUserName(student.getCredentialNumber());
+                setCredentialNumber(student.getCredentialNumber());
+                setCredentialType("ZZLS10007");
+                setMobile(student.getMobile());
+                setEnabledMark(EnabledMark.DISABLED.getCode());
+                setGender(student.getGender());
+                setIsChangePassword(1);
+                setBirthDate(birthDate);
+            }};
+            userService.save(xjrUser);
+
+            UserRoleRelation userRoleRelation = new UserRoleRelation() {{
+                setRoleId(RoleEnum.STUDENT.getCode());
+                setUserId(xjrUser.getId());
+            }};
+            roleRelationService.save(userRoleRelation);
+
+            BaseStudent baseStudent = new BaseStudent() {{
+                setUserId(xjrUser.getId());
+                setCreateDate(now);
+                setStudentId(student.getCredentialNumber());
+                setHeight(student.getHeight().doubleValue());
+                setWeight(student.getWeight().doubleValue());
+            }};
+            studentService.save(baseStudent);
+
+            BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
+                setUserId(xjrUser.getId());
+                setGraduatedScore(student.getScore().doubleValue());
+                setGraduatedUniversity(student.getGraduateSchool());
+                setClassId(classMap.get(studentClassRelation.get(student.getId())));
+                setMajorSetId(taskClassMajorMap.get(studentClassRelation.get(student.getId())));
+                setStduyStatus(student.getStduyStatus());
+                setEnrollType(bandingTask.getEnrollType());
+                setStudentSource(student.getSource());
+                setGradeId(bandingTask.getGradeId());
+                setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                setCreateDate(now);
+            }};
+            schoolRollService.save(schoolRoll);
+
+            BaseStudentFamily studentFamily = new BaseStudentFamily() {{
+                setCreateDate(now);
+                setUserId(xjrUser.getId());
+                setTelephone(student.getFamilyMobile());
+                setAddress(student.getFamilyAddress());
+            }};
+            familyService.save(studentFamily);
+        }
+    }
+
+    LocalDateTime getBirthDate(String idCardNumber){
+        // 获取出生日期前6位,即yyyyMM
+        String birthdayString = idCardNumber.substring(6, 14);
+
+        // 将字符串解析为LocalDate对象
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        return LocalDateTime.parse(birthdayString, formatter);
+    }
+
     @Override
     public Boolean removeStudent(ChangeClassDto dto) {
         this.baseMapper.delete(
@@ -138,7 +298,6 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
            this.saveBatch(dataList);
         }
 
-
         return true;
     }
 

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

@@ -65,8 +65,6 @@ import java.util.Objects;
 import java.util.Random;
 import java.util.stream.Collectors;
 
-import static java.util.Arrays.stream;
-
 /**
 * @title: 新生分班任务
 * @Author dzx
@@ -441,7 +439,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         return isSuccess;
     }
 
-    public void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
+    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() {{