|
@@ -3,9 +3,12 @@ package com.xjrsoft.module.banding.service.impl;
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
|
+import com.xjrsoft.common.enums.EnabledMark;
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
import com.xjrsoft.common.exception.MyException;
|
|
@@ -13,6 +16,7 @@ import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
|
|
import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
|
|
import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
|
|
import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
|
|
|
|
+import com.xjrsoft.module.banding.dto.BandingTaskPageDto;
|
|
import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
|
|
import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
|
|
import com.xjrsoft.module.banding.entity.BandingRule;
|
|
import com.xjrsoft.module.banding.entity.BandingRule;
|
|
import com.xjrsoft.module.banding.entity.BandingTask;
|
|
import com.xjrsoft.module.banding.entity.BandingTask;
|
|
@@ -28,7 +32,10 @@ import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
|
|
import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
|
|
import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
|
|
import com.xjrsoft.module.banding.service.IBandingTaskService;
|
|
import com.xjrsoft.module.banding.service.IBandingTaskService;
|
|
import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
|
|
import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
|
|
|
|
+import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
|
+import com.xjrsoft.module.base.entity.BaseMajorSet;
|
|
|
|
+import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
import com.xjrsoft.module.organization.entity.UserRoleRelation;
|
|
import com.xjrsoft.module.organization.entity.UserRoleRelation;
|
|
@@ -50,6 +57,8 @@ import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -88,6 +97,8 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
private final IBaseStudentService studentService;
|
|
private final IBaseStudentService studentService;
|
|
private final IBaseStudentFamilyService familyService;
|
|
private final IBaseStudentFamilyService familyService;
|
|
|
|
|
|
|
|
+ private final BaseMajorSetMapper majorSetMapper;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -131,7 +142,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
//1、查询需要分班的学生信息
|
|
//1、查询需要分班的学生信息
|
|
List<String> orderColumn = new ArrayList();
|
|
List<String> orderColumn = new ArrayList();
|
|
- orderColumn.add("height");orderColumn.add("score");
|
|
|
|
|
|
+ orderColumn.add("score");
|
|
List<BaseNewStudent> baseNewStudents = newStudentService.selectJoinList(BaseNewStudent.class,
|
|
List<BaseNewStudent> baseNewStudents = newStudentService.selectJoinList(BaseNewStudent.class,
|
|
new MPJLambdaWrapper<BaseNewStudent>()
|
|
new MPJLambdaWrapper<BaseNewStudent>()
|
|
.select(BaseNewStudent::getId)
|
|
.select(BaseNewStudent::getId)
|
|
@@ -144,6 +155,14 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
);
|
|
);
|
|
//2、查询所有班级信息
|
|
//2、查询所有班级信息
|
|
List<BandingTaskClass> classList = taskClassMapper.getListOrderByAsc(bandingTask.getId());
|
|
List<BandingTaskClass> classList = taskClassMapper.getListOrderByAsc(bandingTask.getId());
|
|
|
|
+ if(!classList.isEmpty()){
|
|
|
|
+ //清除数据
|
|
|
|
+ List<Long> classIds = classList.stream().map(BandingTaskClass::getId).collect(Collectors.toList());
|
|
|
|
+ classStudentService.remove(
|
|
|
|
+ new QueryWrapper<BandingTaskClassStudent>().lambda()
|
|
|
|
+ .in(BandingTaskClassStudent::getBandingTaskClassId, classIds)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
//3、查询所用到的规则
|
|
//3、查询所用到的规则
|
|
List<BandingRule> ruleList = ruleMapper.selectJoinList(BandingRule.class,
|
|
List<BandingRule> ruleList = ruleMapper.selectJoinList(BandingRule.class,
|
|
@@ -159,8 +178,8 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
Map<Long, Integer> classLimitMap = new HashMap<>();
|
|
Map<Long, Integer> classLimitMap = new HashMap<>();
|
|
if(ruleCodes.contains("BR0004")){
|
|
if(ruleCodes.contains("BR0004")){
|
|
//查询每个专业下面有多少个班级
|
|
//查询每个专业下面有多少个班级
|
|
- Map<Long, Integer> majorClassCount = taskClassMapper.getMajorClassCount(bandingTask.getId())
|
|
|
|
- .stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
|
|
|
|
+ List<IdCountVo> majorClassCountList = taskClassMapper.getMajorClassCount(bandingTask.getId());
|
|
|
|
+ Map<Long, Integer> majorClassCount = majorClassCountList.stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
//查询每个专业下面的班级人数
|
|
//查询每个专业下面的班级人数
|
|
Map<Long, Integer> majorClassStudentCount = taskClassMapper.getMajorClassStudentCount(bandingTask.getId())
|
|
Map<Long, Integer> majorClassStudentCount = taskClassMapper.getMajorClassStudentCount(bandingTask.getId())
|
|
.stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
.stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
@@ -170,8 +189,14 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
|
|
|
Map<Long, Integer> majorLimitMap = new HashMap<>();
|
|
Map<Long, Integer> majorLimitMap = new HashMap<>();
|
|
for (Long majorSetId : majorClassStudentCount.keySet()) {
|
|
for (Long majorSetId : majorClassStudentCount.keySet()) {
|
|
- Integer majorClassNumber = majorClassStudentCount.get(majorSetId);
|
|
|
|
- Integer majorStudentNumber = majorStudentCount.get(majorSetId);
|
|
|
|
|
|
+ int majorClassNumber = 0;
|
|
|
|
+ if(majorClassStudentCount.get(majorSetId) != null){
|
|
|
|
+ majorClassNumber = majorClassStudentCount.get(majorSetId);
|
|
|
|
+ }
|
|
|
|
+ int majorStudentNumber = 0;
|
|
|
|
+ if(majorStudentCount.get(majorSetId) != null){
|
|
|
|
+ majorStudentNumber = majorStudentCount.get(majorSetId);
|
|
|
|
+ }
|
|
Integer classCount = majorClassCount.get(majorSetId);
|
|
Integer classCount = majorClassCount.get(majorSetId);
|
|
if(majorStudentNumber < majorClassNumber){//报名人数小于班级人数
|
|
if(majorStudentNumber < majorClassNumber){//报名人数小于班级人数
|
|
Integer classLimtCount = majorStudentNumber / classCount;
|
|
Integer classLimtCount = majorStudentNumber / classCount;
|
|
@@ -202,6 +227,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
//存班级和学生的关系
|
|
//存班级和学生的关系
|
|
Map<Long, Long> studentClassMap = new HashMap<>();
|
|
Map<Long, Long> studentClassMap = new HashMap<>();
|
|
|
|
+ Map<Long, List<String>> classNameMap = new HashMap<>();
|
|
//4、开始分班
|
|
//4、开始分班
|
|
for (BandingTaskClass taskClass : classList) {
|
|
for (BandingTaskClass taskClass : classList) {
|
|
Integer number = taskClass.getNumber();//班级总人数
|
|
Integer number = taskClass.getNumber();//班级总人数
|
|
@@ -228,11 +254,12 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<String> nameList = new ArrayList<>();
|
|
List<String> nameList = new ArrayList<>();
|
|
- List<BaseNewStudent> maleList = new ArrayList();
|
|
|
|
- List<BaseNewStudent> femaleList = new ArrayList();
|
|
|
|
|
|
+ List<BaseNewStudent> maleList = new ArrayList();//男生
|
|
|
|
+ List<BaseNewStudent> femaleList = new ArrayList();//女生
|
|
|
|
+
|
|
List<BaseNewStudent> studentList = new ArrayList<>();
|
|
List<BaseNewStudent> studentList = new ArrayList<>();
|
|
studentList.addAll(baseNewStudents);
|
|
studentList.addAll(baseNewStudents);
|
|
- if(ruleCodes.contains("BR0002") && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()){
|
|
|
|
|
|
+ if(ruleCodes.contains("BR0002") && classStudentMap.get(taskClass.getMajorSetId()) != null && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()){
|
|
studentList.clear();
|
|
studentList.clear();
|
|
studentList.addAll(classStudentMap.get(taskClass.getMajorSetId()));
|
|
studentList.addAll(classStudentMap.get(taskClass.getMajorSetId()));
|
|
}
|
|
}
|
|
@@ -262,23 +289,30 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(taskClass.getSortCode() == null && !Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId())){//如果未给班级设置优先级,只匹配一志愿的学生
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
List<Boolean> conditionList = new ArrayList<>();
|
|
List<Boolean> conditionList = new ArrayList<>();
|
|
BandingTaskMajorCondition condition = classConditionMap.get(taskClass.getMajorSetId());
|
|
BandingTaskMajorCondition condition = classConditionMap.get(taskClass.getMajorSetId());
|
|
- if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
|
|
|
|
- conditionList.add(true);
|
|
|
|
- }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
|
|
|
|
- conditionList.add(false);
|
|
|
|
- }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
|
|
|
|
- conditionList.add(false);
|
|
|
|
- }
|
|
|
|
|
|
+ if(condition != null){
|
|
|
|
+ if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
|
|
|
|
+ conditionList.add(true);
|
|
|
|
+ }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }
|
|
|
|
|
|
- if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
|
|
|
|
- conditionList.add(true);
|
|
|
|
- }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
|
|
|
|
- conditionList.add(false);
|
|
|
|
- }else if(condition.getScore() !=null && newStudent.getScore() == null){
|
|
|
|
- conditionList.add(false);
|
|
|
|
|
|
+ if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
|
|
|
|
+ conditionList.add(true);
|
|
|
|
+ }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }else if(condition.getScore() !=null && newStudent.getScore() == null){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
//如果包含false,则表明不符合条件,这个学生跳过
|
|
//如果包含false,则表明不符合条件,这个学生跳过
|
|
if(conditionList.contains(false)){
|
|
if(conditionList.contains(false)){
|
|
continue;
|
|
continue;
|
|
@@ -291,7 +325,74 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
nameList.add(newStudent.getName());
|
|
nameList.add(newStudent.getName());
|
|
}
|
|
}
|
|
|
|
+ classNameMap.put(taskClass.getId(), nameList);
|
|
}
|
|
}
|
|
|
|
+ // 4.1、二次循环班级,对没有设置排序的班级进行分班,
|
|
|
|
+ for (BandingTaskClass taskClass : classList) {
|
|
|
|
+ Integer number = taskClass.getNumber();//班级总人数
|
|
|
|
+ if(classLimitMap.get(taskClass.getId()) != null){
|
|
|
|
+ if(number > classLimitMap.get(taskClass.getId())){
|
|
|
|
+ number = classLimitMap.get(taskClass.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<String> nameList = classNameMap.get(taskClass.getId());
|
|
|
|
+ if(nameList.size() == number){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ List<BaseNewStudent> studentList = new ArrayList<>();
|
|
|
|
+ studentList.addAll(baseNewStudents);
|
|
|
|
+ if(ruleCodes.contains("BR0002") && classStudentMap.get(taskClass.getMajorSetId()) != null && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()){
|
|
|
|
+ studentList.clear();
|
|
|
|
+ studentList.addAll(classStudentMap.get(taskClass.getMajorSetId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (BaseNewStudent newStudent : studentList) {
|
|
|
|
+ //人数已满,进行下一个班级的的循环
|
|
|
|
+ if(nameList.size() == number){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //该学生已被分配
|
|
|
|
+ if(studentClassMap.containsKey(newStudent.getId())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //专业不匹配,直接跳过
|
|
|
|
+ if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //判断该班性别是否已满
|
|
|
|
+ List<Boolean> conditionList = new ArrayList<>();
|
|
|
|
+ BandingTaskMajorCondition condition = classConditionMap.get(taskClass.getMajorSetId());
|
|
|
|
+ if(condition != null){
|
|
|
|
+ if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
|
|
|
|
+ conditionList.add(true);
|
|
|
|
+ }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
|
|
|
|
+ conditionList.add(true);
|
|
|
|
+ }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }else if(condition.getScore() !=null && newStudent.getScore() == null){
|
|
|
|
+ conditionList.add(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //如果包含false,则表明不符合条件,这个学生跳过
|
|
|
|
+ if(conditionList.contains(false)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ studentClassMap.put(newStudent.getId(), taskClass.getId());
|
|
|
|
+ nameList.add(newStudent.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
List<BandingTaskClassStudent> dataList = new ArrayList<>();
|
|
List<BandingTaskClassStudent> dataList = new ArrayList<>();
|
|
Date createDate = new Date();
|
|
Date createDate = new Date();
|
|
for (Long studentId : studentClassMap.keySet()) {
|
|
for (Long studentId : studentClassMap.keySet()) {
|
|
@@ -319,6 +420,15 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
List<BandingTaskClass> classList){
|
|
List<BandingTaskClass> classList){
|
|
Map<Long, List<BaseNewStudent>> classStudentMap = new HashMap<>();
|
|
Map<Long, List<BaseNewStudent>> classStudentMap = new HashMap<>();
|
|
for (Long majorSetId : classConditionMap.keySet()) {
|
|
for (Long majorSetId : classConditionMap.keySet()) {
|
|
|
|
+ //查询该专业下面有几个班级,把这部分学生按照成绩均匀分组
|
|
|
|
+ List<List<BaseNewStudent>> result = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < classList.size(); i++) {
|
|
|
|
+ result.add(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ if(result.size() == 1){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 1、先把每个专业匹配的学生分组存一起,并按照分数高低排序
|
|
// 1、先把每个专业匹配的学生分组存一起,并按照分数高低排序
|
|
List<BaseNewStudent> stuList = new ArrayList<>();
|
|
List<BaseNewStudent> stuList = new ArrayList<>();
|
|
|
|
|
|
@@ -350,17 +460,18 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
stuList.add(newStudent);
|
|
stuList.add(newStudent);
|
|
}
|
|
}
|
|
-
|
|
|
|
- Collections.sort(stuList, (s1, s2) -> (int) (s2.getScore().doubleValue() - s1.getScore().doubleValue())); //按照成绩降序排序
|
|
|
|
- //查询该专业下面有几个班级,把这部分学生按照成绩均匀分组
|
|
|
|
- List<List<BaseNewStudent>> result = new ArrayList<>();
|
|
|
|
- for (int i = 0; i < classList.size(); i++) {
|
|
|
|
- result.add(new ArrayList<>());
|
|
|
|
|
|
+ if(!stuList.isEmpty()){
|
|
|
|
+ for (BaseNewStudent student : stuList) {
|
|
|
|
+ if(student.getScore() == null){
|
|
|
|
+ student.setScore(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Collections.sort(stuList, (s1, s2) -> (int) (s2.getScore().doubleValue() - s1.getScore().doubleValue())); //按照成绩降序排序
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < stuList.size(); i++) {
|
|
for (int i = 0; i < stuList.size(); i++) {
|
|
BaseNewStudent currentStudent = stuList.get(i);
|
|
BaseNewStudent currentStudent = stuList.get(i);
|
|
- int classIndex = i % stuList.size(); //分配班级
|
|
|
|
|
|
+ int classIndex = i % result.size(); //分配班级
|
|
result.get(classIndex).add(currentStudent);
|
|
result.get(classIndex).add(currentStudent);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -381,9 +492,12 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
.select(BandingTaskClassStudent.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClassStudent.class).contains(x.getProperty()))
|
|
.select(BandingTaskClassStudent.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClassStudent.class).contains(x.getProperty()))
|
|
.leftJoin(BandingTaskClass.class, BandingTaskClass::getId, BandingTaskClassStudent::getBandingTaskClassId)
|
|
.leftJoin(BandingTaskClass.class, BandingTaskClass::getId, BandingTaskClassStudent::getBandingTaskClassId)
|
|
.eq(BandingTaskClass::getBandingTaskId, dto.getId())
|
|
.eq(BandingTaskClass::getBandingTaskId, dto.getId())
|
|
- .eq(BandingTaskClassStudent::getStatus, 1)
|
|
|
|
|
|
+ .eq(BandingTaskClassStudent::getStatus, 0)
|
|
);
|
|
);
|
|
List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
|
|
List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
|
|
|
|
+ if(studentIds.isEmpty()){
|
|
|
|
+ throw new MyException("未能查询到学生,无法确认");
|
|
|
|
+ }
|
|
List<BaseNewStudent> list = newStudentService.list(
|
|
List<BaseNewStudent> list = newStudentService.list(
|
|
new QueryWrapper<BaseNewStudent>().lambda()
|
|
new QueryWrapper<BaseNewStudent>().lambda()
|
|
.in(BaseNewStudent::getId, studentIds)
|
|
.in(BaseNewStudent::getId, studentIds)
|
|
@@ -401,7 +515,6 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
//形成学生数据
|
|
//形成学生数据
|
|
createStudentData(dto.getId(), classStudents, updateList);
|
|
createStudentData(dto.getId(), classStudents, updateList);
|
|
|
|
|
|
-
|
|
|
|
BandingTask bandingTask = this.getById(dto.getId());
|
|
BandingTask bandingTask = this.getById(dto.getId());
|
|
bandingTask.setStatus(1);
|
|
bandingTask.setStatus(1);
|
|
bandingTask.setModifyDate(new Date());
|
|
bandingTask.setModifyDate(new Date());
|
|
@@ -409,6 +522,11 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
return isSuccess;
|
|
return isSuccess;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Page<BandingTaskPageVo> getPage(Page<BandingTaskPageVo> page, BandingTaskPageDto dto) {
|
|
|
|
+ return this.baseMapper.getPage(page, dto);
|
|
|
|
+ }
|
|
|
|
+
|
|
void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
|
|
void createStudentData(Long badingTaskId,List<BandingTaskClassStudent> classStudents, List<BaseNewStudent> updateList){
|
|
Date createDate = new Date();
|
|
Date createDate = new Date();
|
|
BandingTask bandingTask = this.getById(badingTaskId);
|
|
BandingTask bandingTask = this.getById(badingTaskId);
|
|
@@ -427,15 +545,19 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
//查询出需要新增的班级信息
|
|
//查询出需要新增的班级信息
|
|
List<Long> classIds = classStudents.stream().map(BandingTaskClassStudent::getBandingTaskClassId).collect(Collectors.toList());
|
|
List<Long> classIds = classStudents.stream().map(BandingTaskClassStudent::getBandingTaskClassId).collect(Collectors.toList());
|
|
List<BandingTaskClass> classList = taskClassMapper.selectList(new QueryWrapper<BandingTaskClass>().lambda().in(BandingTaskClass::getId, classIds));
|
|
List<BandingTaskClass> classList = taskClassMapper.selectList(new QueryWrapper<BandingTaskClass>().lambda().in(BandingTaskClass::getId, classIds));
|
|
|
|
+
|
|
|
|
+ Map<Long, Long> majorDeptMap = majorSetMapper.selectList(new QueryWrapper<BaseMajorSet>()).stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
|
|
for (BandingTaskClass taskClass : classList) {
|
|
for (BandingTaskClass taskClass : classList) {
|
|
BaseClass baseClass = new BaseClass() {{
|
|
BaseClass baseClass = new BaseClass() {{
|
|
setName(taskClass.getName());
|
|
setName(taskClass.getName());
|
|
setClassroomId(taskClass.getClassroomId());
|
|
setClassroomId(taskClass.getClassroomId());
|
|
setTeacherId(taskClass.getTeacherId());
|
|
setTeacherId(taskClass.getTeacherId());
|
|
setIsGraduate(1);
|
|
setIsGraduate(1);
|
|
- setIsOrderClass(taskClass.getIsOrderClass().intValue());
|
|
|
|
|
|
+ setIsOrderClass(taskClass.getIsOrderClass()==null?0:taskClass.getIsOrderClass().intValue());
|
|
setGradeId(bandingTask.getGradeId());
|
|
setGradeId(bandingTask.getGradeId());
|
|
|
|
+ setDeleteMark(DeleteMark.NODELETE.getCode());
|
|
setEnrollType(bandingTask.getEnrollType());
|
|
setEnrollType(bandingTask.getEnrollType());
|
|
|
|
+ setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
|
|
}};
|
|
}};
|
|
|
|
|
|
classService.save(baseClass);
|
|
classService.save(baseClass);
|
|
@@ -466,7 +588,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
Map<Long, Long> studentClassRelation = classStudents.stream().collect(Collectors.toMap(BandingTaskClassStudent::getNewStudentId, BandingTaskClassStudent::getBandingTaskClassId));
|
|
Map<Long, Long> studentClassRelation = classStudents.stream().collect(Collectors.toMap(BandingTaskClassStudent::getNewStudentId, BandingTaskClassStudent::getBandingTaskClassId));
|
|
for (BaseNewStudent student : updateList) {
|
|
for (BaseNewStudent student : updateList) {
|
|
- LocalDateTime birthDate = getBirthDate(student.getCredentialNumber());
|
|
|
|
|
|
+ LocalDate birthDate = getBirthDate(student.getCredentialNumber());
|
|
User xjrUser = new User() {{
|
|
User xjrUser = new User() {{
|
|
setCreateDate(now);
|
|
setCreateDate(now);
|
|
setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
|
|
setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
|
|
@@ -475,9 +597,10 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
setCredentialNumber(student.getCredentialNumber());
|
|
setCredentialNumber(student.getCredentialNumber());
|
|
setCredentialType("ZZLS10007");
|
|
setCredentialType("ZZLS10007");
|
|
setMobile(student.getMobile());
|
|
setMobile(student.getMobile());
|
|
|
|
+ setEnabledMark(EnabledMark.DISABLED.getCode());
|
|
setGender(student.getGender());
|
|
setGender(student.getGender());
|
|
setIsChangePassword(1);
|
|
setIsChangePassword(1);
|
|
- setBirthDate(birthDate);
|
|
|
|
|
|
+ setBirthDate(birthDate.atStartOfDay());
|
|
}};
|
|
}};
|
|
userService.save(xjrUser);
|
|
userService.save(xjrUser);
|
|
|
|
|
|
@@ -498,7 +621,9 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
|
|
|
BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
|
|
BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
|
|
setUserId(xjrUser.getId());
|
|
setUserId(xjrUser.getId());
|
|
- setGraduatedScore(student.getScore().doubleValue());
|
|
|
|
|
|
+ if(student.getScore() != null){
|
|
|
|
+ setGraduatedScore(student.getScore().doubleValue());
|
|
|
|
+ }
|
|
setGraduatedUniversity(student.getGraduateSchool());
|
|
setGraduatedUniversity(student.getGraduateSchool());
|
|
setClassId(classMap.get(studentClassRelation.get(student.getId())));
|
|
setClassId(classMap.get(studentClassRelation.get(student.getId())));
|
|
setMajorSetId(taskClassMajorMap.get(studentClassRelation.get(student.getId())));
|
|
setMajorSetId(taskClassMajorMap.get(studentClassRelation.get(student.getId())));
|
|
@@ -521,12 +646,12 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- LocalDateTime getBirthDate(String idCardNumber){
|
|
|
|
|
|
+ LocalDate getBirthDate(String idCardNumber){
|
|
// 获取出生日期前6位,即yyyyMM
|
|
// 获取出生日期前6位,即yyyyMM
|
|
String birthdayString = idCardNumber.substring(6, 14);
|
|
String birthdayString = idCardNumber.substring(6, 14);
|
|
|
|
|
|
// 将字符串解析为LocalDate对象
|
|
// 将字符串解析为LocalDate对象
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
- return LocalDateTime.parse(birthdayString, formatter);
|
|
|
|
|
|
+ return LocalDate.parse(birthdayString, formatter);
|
|
}
|
|
}
|
|
}
|
|
}
|