浏览代码

分班后的确认列表

dzx 1 年之前
父节点
当前提交
a75f873d56

+ 3 - 2
src/main/java/com/xjrsoft/module/banding/controller/BandingTaskClassController.java

@@ -15,6 +15,7 @@ import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassVo;
 import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
@@ -71,8 +72,8 @@ public class BandingTaskClassController {
     @GetMapping(value = "/class-sure")
     @ApiOperation(value="分班确认列表")
     @SaCheckPermission("bandingtask:detail")
-    public RT<List<BandingTaskClassPageVo>> classSure(@Valid BandingTaskClassStudentPageDto dto){
-        List<BandingTaskClassPageVo> list = bandingTaskClassService.classStudent(dto);
+    public RT<List<BandingTaskClassSureListVo>> classSure(@Valid BandingTaskClassStudentPageDto dto){
+        List<BandingTaskClassSureListVo> list = bandingTaskClassService.getClassSure(dto);
         return RT.ok(list);
     }
 

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/mapper/BandingTaskClassMapper.java

@@ -5,6 +5,7 @@ import com.xjrsoft.module.banding.dto.BandingTaskClassPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.outint.vo.IdCountVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -26,4 +27,6 @@ public interface BandingTaskClassMapper extends MPJBaseMapper<BandingTaskClass>
     List<IdCountVo> getMajorClassCount(@Param("id") Long bandingTaskId);
     List<IdCountVo> getMajorClassStudentCount(@Param("id") Long bandingTaskId);
 
+    List<BandingTaskClassSureListVo> getClassSure(@Param("dto") BandingTaskClassStudentPageDto dto);
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskClassService.java

@@ -5,6 +5,8 @@ import com.xjrsoft.module.banding.dto.BandingTaskClassPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -46,4 +48,6 @@ public interface IBandingTaskClassService extends MPJBaseService<BandingTaskClas
     Boolean reset(Long bandingTaskId);
 
     List<BandingTaskClassPageVo> classStudent(BandingTaskClassStudentPageDto dto);
+
+    List<BandingTaskClassSureListVo> getClassSure(BandingTaskClassStudentPageDto dto);
 }

+ 6 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java

@@ -11,6 +11,7 @@ import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -85,4 +86,9 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
     public List<BandingTaskClassPageVo> classStudent(BandingTaskClassStudentPageDto dto) {
         return this.baseMapper.getClassStudent(dto);
     }
+
+    @Override
+    public List<BandingTaskClassSureListVo> getClassSure(BandingTaskClassStudentPageDto dto) {
+        return this.baseMapper.getClassSure(dto);
+    }
 }

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

@@ -8,7 +8,6 @@ import com.xjrsoft.common.enums.GenderDictionaryEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
-import com.xjrsoft.module.banding.dto.BandingTaskMajorConditionDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
 import com.xjrsoft.module.banding.entity.BandingRule;
 import com.xjrsoft.module.banding.entity.BandingTask;
@@ -36,6 +35,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Random;
 import java.util.stream.Collectors;
 
@@ -170,10 +170,46 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             classConditionMap.put(conditionDto.getMajorSetId(), conditionDto);
         }
 
+
+        Map<Long, List<BaseNewStudent>> majorStudentMap = new HashMap<>();
         if(ruleCodes.contains("BR0002")){
             /**
-             * 1、先把每个专业匹配的学生
+             * 1、先把每个专业匹配的学生分组存一起,并按照分数高低排序
+             *
              */
+            for (Long majorSetId : classConditionMap.keySet()) {
+                List<BaseNewStudent> stuList = new ArrayList<>();
+                for (BaseNewStudent newStudent : baseNewStudents) {
+                    if(!Objects.equals(majorSetId, newStudent.getFirstAmbitionId()) && !Objects.equals(majorSetId, newStudent.getSecondAmbitionId())){
+                        continue;
+                    }
+
+                    List<Boolean> conditionList = new ArrayList<>();
+                    BandingTaskMajorCondition condition = classConditionMap.get(majorSetId);
+                    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;
+                    }
+                    stuList.add(newStudent);
+                }
+                stuList.sort((x1, x2) -> x1.getScore().compareTo(x2.getScore()));
+                majorStudentMap.put(majorSetId, stuList);
+            }
         }
         //存班级和学生的关系
         Map<Long, Long> studentClassMap = new HashMap<>();
@@ -219,7 +255,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                     continue;
                 }
                 //专业不匹配,直接跳过
-                if(taskClass.getMajorSetId() != newStudent.getFirstAmbitionId() && taskClass.getMajorSetId() != newStudent.getSecondAmbitionId()){
+                if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
                     continue;
                 }
                 //判断该班性别是否已满

+ 1 - 1
src/main/resources/mapper/banding/BandingTaskClassMapper.xml

@@ -25,7 +25,7 @@
         WHERE t1.delete_mark = 0 and t1.banding_task_id = #{dto.bandingTaskId}
     </select>
 
-    <select id="getClassSure" parameterType="com.xjrsoft.module.banding.dto.BandingTaskClassPageDto" resultType="com.xjrsoft.module.banding.vo.BandingTaskClassPageVo">
+    <select id="getClassSure" parameterType="com.xjrsoft.module.banding.dto.BandingTaskClassPageDto" resultType="com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo">
         SELECT t1.id, t1.major_set_id,t2.name AS major_set_name, t1.name, t1.number,t1.sort_code,
         (SELECT COUNT(*) FROM base_new_student WHERE delete_mark = 0 AND gender = 'SB10001') AS male_count,
         (SELECT COUNT(*) FROM base_new_student WHERE delete_mark = 0 AND gender = 'SB10002') AS female_count,