|
|
@@ -1,13 +1,18 @@
|
|
|
package com.xjrsoft.module.banding.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.secure.BCrypt;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
+import com.xjrsoft.common.enums.RoleEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
|
|
|
+import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
|
|
|
import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
|
|
|
import com.xjrsoft.module.banding.entity.BandingRule;
|
|
|
import com.xjrsoft.module.banding.entity.BandingTask;
|
|
|
@@ -22,19 +27,35 @@ import com.xjrsoft.module.banding.mapper.BandingTaskRuleMapper;
|
|
|
import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
|
|
|
import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
|
|
|
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.outint.vo.IdCountVo;
|
|
|
+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.entity.EnrollmentPlan;
|
|
|
+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.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
@@ -58,6 +79,15 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
private final IBandingTaskClassStudentService classStudentService;
|
|
|
private final IBandingTaskMajorConditionService conditionService;
|
|
|
|
|
|
+ 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
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -206,6 +236,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
studentList.clear();
|
|
|
studentList.addAll(classStudentMap.get(taskClass.getMajorSetId()));
|
|
|
}
|
|
|
+
|
|
|
for (BaseNewStudent newStudent : studentList) {
|
|
|
//人数已满,进行下一个班级的的循环
|
|
|
if(nameList.size() == number){
|
|
|
@@ -259,9 +290,6 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
femaleList.add(newStudent);
|
|
|
}
|
|
|
nameList.add(newStudent.getName());
|
|
|
-
|
|
|
- //清除已经被分班的学生
|
|
|
- baseNewStudents.remove(newStudent);
|
|
|
}
|
|
|
}
|
|
|
List<BandingTaskClassStudent> dataList = new ArrayList<>();
|
|
|
@@ -371,7 +399,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
}
|
|
|
|
|
|
//形成学生数据
|
|
|
- createStudentData(classStudents, updateList);
|
|
|
+ createStudentData(dto.getId(), classStudents, updateList);
|
|
|
|
|
|
|
|
|
BandingTask bandingTask = this.getById(dto.getId());
|
|
|
@@ -381,7 +409,124 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
return isSuccess;
|
|
|
}
|
|
|
|
|
|
- void createStudentData(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() {{
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|