|
@@ -224,6 +224,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
}
|
|
|
//存班级和学生的关系
|
|
|
Map<Long, Long> studentClassMap = new HashMap<>();
|
|
|
+ Map<Long, List<String>> classNameMap = new HashMap<>();
|
|
|
//4、开始分班
|
|
|
for (BandingTaskClass taskClass : classList) {
|
|
|
Integer number = taskClass.getNumber();//班级总人数
|
|
@@ -250,8 +251,9 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
}
|
|
|
}
|
|
|
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<>();
|
|
|
studentList.addAll(baseNewStudents);
|
|
|
if(ruleCodes.contains("BR0002") && classStudentMap.get(taskClass.getMajorSetId()) != null && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()){
|
|
@@ -320,7 +322,78 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
}
|
|
|
nameList.add(newStudent.getName());
|
|
|
}
|
|
|
+ classNameMap.put(taskClass.getId(), nameList);
|
|
|
}
|
|
|
+ // 4.1、二次循环班级,对没有设置排序的班级进行分班,
|
|
|
+ for (BandingTaskClass taskClass : classList) {
|
|
|
+ if(taskClass.getSortCode() != null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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<>();
|
|
|
Date createDate = new Date();
|
|
|
for (Long studentId : studentClassMap.keySet()) {
|