|
@@ -42,6 +42,7 @@ import com.xjrsoft.module.organization.entity.UserRoleRelation;
|
|
import com.xjrsoft.module.organization.service.IUserRoleRelationService;
|
|
import com.xjrsoft.module.organization.service.IUserRoleRelationService;
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
import com.xjrsoft.module.outint.vo.IdCountVo;
|
|
import com.xjrsoft.module.outint.vo.IdCountVo;
|
|
|
|
+import com.xjrsoft.module.banding.vo.IdManyCountVo;
|
|
import com.xjrsoft.module.student.entity.BaseClassMajorSet;
|
|
import com.xjrsoft.module.student.entity.BaseClassMajorSet;
|
|
import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
@@ -174,18 +175,38 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
);
|
|
);
|
|
List<String> ruleCodes = ruleList.stream().map(BandingRule::getCode).collect(Collectors.toList());
|
|
List<String> ruleCodes = ruleList.stream().map(BandingRule::getCode).collect(Collectors.toList());
|
|
|
|
|
|
|
|
+ //查询每个专业符合限制条件的人数
|
|
|
|
+ List<IdManyCountVo> majorStudentCountList = newStudentService.getMajorStudentCount(bandingTask.getId());
|
|
|
|
+ Map<Long, IdManyCountVo> majorStudentCountMap = majorStudentCountList.stream().collect(Collectors.toMap(IdManyCountVo::getId, x -> x));
|
|
|
|
+ //查询每个专业下面有多少个班级
|
|
|
|
+ List<IdCountVo> majorClassCountList = taskClassMapper.getMajorClassCount(bandingTask.getId());
|
|
|
|
+ Map<Long, Integer> majorClassCount = majorClassCountList.stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
|
|
+ //计算每个专业平均的男女人数
|
|
|
|
+ Map<Long, Integer> majorMaleCountMap = new HashMap<>();
|
|
|
|
+ Map<Long, Integer> majorFemaleCountMap = new HashMap<>();
|
|
|
|
+ if(ruleCodes.contains("BR0001")){
|
|
|
|
+ for (Long majorSetId : majorClassCount.keySet()) {
|
|
|
|
+ int classCount = majorClassCount.get(majorSetId);
|
|
|
|
+ Integer maleCount = majorStudentCountMap.get(majorSetId).getMaleCount();
|
|
|
|
+ Integer femaleCount = majorStudentCountMap.get(majorSetId).getFemaleCount();
|
|
|
|
+ if(classCount == 1 || classCount == 0){
|
|
|
|
+ majorMaleCountMap.put(majorSetId, maleCount);
|
|
|
|
+ majorFemaleCountMap.put(majorSetId, femaleCount);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ majorMaleCountMap.put(majorSetId, maleCount / classCount);
|
|
|
|
+ majorFemaleCountMap.put(majorSetId, femaleCount / classCount);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//包含下面个条件,则需要计算每个班级应该分配的人数
|
|
//包含下面个条件,则需要计算每个班级应该分配的人数
|
|
Map<Long, Integer> classLimitMap = new HashMap<>();
|
|
Map<Long, Integer> classLimitMap = new HashMap<>();
|
|
if(ruleCodes.contains("BR0004")){
|
|
if(ruleCodes.contains("BR0004")){
|
|
- //查询每个专业下面有多少个班级
|
|
|
|
- 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));
|
|
- //查询每个专业人数
|
|
|
|
- Map<Long, Integer> majorStudentCount = newStudentService.getMajorStudentCount()
|
|
|
|
- .stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
|
|
|
|
|
|
+
|
|
|
|
+ Map<Long, Integer> majorStudentCount = majorStudentCountList.stream().collect(Collectors.toMap(IdManyCountVo::getId, IdManyCountVo::getCount));
|
|
|
|
|
|
Map<Long, Integer> majorLimitMap = new HashMap<>();
|
|
Map<Long, Integer> majorLimitMap = new HashMap<>();
|
|
for (Long majorSetId : majorClassStudentCount.keySet()) {
|
|
for (Long majorSetId : majorClassStudentCount.keySet()) {
|
|
@@ -193,6 +214,9 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
if(majorClassStudentCount.get(majorSetId) != null){
|
|
if(majorClassStudentCount.get(majorSetId) != null){
|
|
majorClassNumber = majorClassStudentCount.get(majorSetId);
|
|
majorClassNumber = majorClassStudentCount.get(majorSetId);
|
|
}
|
|
}
|
|
|
|
+ if(majorClassCount.get(majorSetId) == 1 || majorClassCount.get(majorSetId) == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
int majorStudentNumber = 0;
|
|
int majorStudentNumber = 0;
|
|
if(majorStudentCount.get(majorSetId) != null){
|
|
if(majorStudentCount.get(majorSetId) != null){
|
|
majorStudentNumber = majorStudentCount.get(majorSetId);
|
|
majorStudentNumber = majorStudentCount.get(majorSetId);
|
|
@@ -211,6 +235,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
classLimitMap.put(bandingTaskClass.getId(), majorLimitMap.get(bandingTaskClass.getMajorSetId()));
|
|
classLimitMap.put(bandingTaskClass.getId(), majorLimitMap.get(bandingTaskClass.getMajorSetId()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//查询每个专业的限制条件
|
|
//查询每个专业的限制条件
|
|
List<BandingTaskMajorCondition> list = conditionService.list(
|
|
List<BandingTaskMajorCondition> list = conditionService.list(
|
|
new QueryWrapper<BandingTaskMajorCondition>().lambda()
|
|
new QueryWrapper<BandingTaskMajorCondition>().lambda()
|
|
@@ -225,6 +250,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
if(ruleCodes.contains("BR0002")){
|
|
if(ruleCodes.contains("BR0002")){
|
|
classStudentMap.putAll(divideStudentByScore(classConditionMap, baseNewStudents, classList));
|
|
classStudentMap.putAll(divideStudentByScore(classConditionMap, baseNewStudents, classList));
|
|
}
|
|
}
|
|
|
|
+
|
|
//存班级和学生的关系
|
|
//存班级和学生的关系
|
|
Map<Long, Long> studentClassMap = new HashMap<>();
|
|
Map<Long, Long> studentClassMap = new HashMap<>();
|
|
Map<Long, List<String>> classNameMap = new HashMap<>();
|
|
Map<Long, List<String>> classNameMap = new HashMap<>();
|
|
@@ -238,6 +264,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
}
|
|
}
|
|
Integer maleCount = 0, femaleCount = 0;
|
|
Integer maleCount = 0, femaleCount = 0;
|
|
if(ruleCodes.contains("BR0001")){
|
|
if(ruleCodes.contains("BR0001")){
|
|
|
|
+ IdManyCountVo countVo = majorStudentCountMap.get(taskClass.getMajorSetId());
|
|
maleCount = number / 2;
|
|
maleCount = number / 2;
|
|
femaleCount = number / 2;
|
|
femaleCount = number / 2;
|
|
//如果班级人数是奇数,随机分配一个名额
|
|
//如果班级人数是奇数,随机分配一个名额
|
|
@@ -252,6 +279,13 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
femaleCount ++ ;
|
|
femaleCount ++ ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(majorMaleCountMap.get(taskClass.getMajorSetId()) < maleCount){
|
|
|
|
+ maleCount = countVo.getMaleCount();
|
|
|
|
+ femaleCount = number - maleCount;
|
|
|
|
+ }else if(majorFemaleCountMap.get(taskClass.getMajorSetId()) < femaleCount){
|
|
|
|
+ femaleCount = countVo.getFemaleCount();
|
|
|
|
+ maleCount = number - femaleCount;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
List<String> nameList = new ArrayList<>();
|
|
List<String> nameList = new ArrayList<>();
|
|
List<BaseNewStudent> maleList = new ArrayList();//男生
|
|
List<BaseNewStudent> maleList = new ArrayList();//男生
|
|
@@ -280,7 +314,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
|
|
if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //判断该班性别是否已满
|
|
|
|
|
|
+ //判断该班性别是否已满,如果设置了排序,即使性别满了班级人数没满继续分班
|
|
if(ruleCodes.contains("BR0001")){
|
|
if(ruleCodes.contains("BR0001")){
|
|
if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender()) && maleList.size() == maleCount){
|
|
if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender()) && maleList.size() == maleCount){
|
|
continue;
|
|
continue;
|
|
@@ -339,14 +373,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
if(nameList.size() == number){
|
|
if(nameList.size() == number){
|
|
continue;
|
|
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) {
|
|
|
|
|
|
+ for (BaseNewStudent newStudent : baseNewStudents) {
|
|
//人数已满,进行下一个班级的的循环
|
|
//人数已满,进行下一个班级的的循环
|
|
if(nameList.size() == number){
|
|
if(nameList.size() == number){
|
|
break;
|
|
break;
|
|
@@ -652,6 +679,12 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
|
|
|
|
|
|
// 将字符串解析为LocalDate对象
|
|
// 将字符串解析为LocalDate对象
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
- return LocalDate.parse(birthdayString, formatter);
|
|
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ LocalDate parse = LocalDate.parse(birthdayString, formatter);
|
|
|
|
+ return parse;
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ throw new MyException("身份证号填写错误,无法提取出生日期");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|