瀏覽代碼

自动分班接口

dzx 1 年之前
父節點
當前提交
a76256f8a6

+ 5 - 0
src/main/java/com/xjrsoft/common/enums/GenderDictionaryEnum.java

@@ -44,5 +44,10 @@ public enum GenderDictionaryEnum {
         return null;
     }
 
+    public static String[] getCodes() {
+        String[] genders = {"SB10001", "SB10002"};
+        return genders;
+    }
+
 
 }

+ 3 - 6
src/main/java/com/xjrsoft/module/banding/controller/BandingTaskController.java

@@ -11,6 +11,7 @@ import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.banding.dto.AddBandingTaskDto;
 import com.xjrsoft.module.banding.dto.AddBandingTaskRuleDto;
+import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
 import com.xjrsoft.module.banding.dto.BandingTaskPageDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
 import com.xjrsoft.module.banding.dto.UpdateBandingTaskDto;
@@ -170,12 +171,8 @@ public class BandingTaskController {
     @PostMapping("/automatic-banding")
     @ApiOperation(value = "自动分班")
     @SaCheckPermission("bandingTaskClass:automatic-banding")
-    public RT<Boolean> automaticBanding(@Valid @RequestBody SureBandingTaskDto dto){
-        BandingTask bandingTask = bandingTaskService.getById(dto.getId());
-        bandingTask.setStatus(1);
-        bandingTask.setModifyDate(new Date());
-        Boolean isSuccess = bandingTaskService.update(bandingTask);
-        return RT.ok(isSuccess);
+    public RT<Boolean> automaticBanding(@Valid @RequestBody AutomaticBandingTaskDto dto){
+        return RT.ok();
     }
 
 }

+ 27 - 0
src/main/java/com/xjrsoft/module/banding/dto/AutomaticBandingTaskDto.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.banding.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+/**
+* @title: 新生分班任务
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
+@Data
+public class AutomaticBandingTaskDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("任务id")
+    private Long bandingTaskId;
+
+    @ApiModelProperty("各个班级条件")
+    private List<BandingTaskClassConditionDto> classInfo;
+
+}

+ 28 - 0
src/main/java/com/xjrsoft/module/banding/dto/BandingTaskClassConditionDto.java

@@ -0,0 +1,28 @@
+package com.xjrsoft.module.banding.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+
+/**
+* @title: 新生分班任务分页查询入参
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class BandingTaskClassConditionDto {
+
+    @ApiModelProperty("班级id")
+    private Long bandingTaskCassId;
+
+    @ApiModelProperty("身高限制")
+    private BigDecimal height;
+
+    @ApiModelProperty("分数限制")
+    private BigDecimal score;
+}

+ 5 - 1
src/main/java/com/xjrsoft/module/banding/mapper/BandingTaskClassMapper.java

@@ -1,11 +1,11 @@
 package com.xjrsoft.module.banding.mapper;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
 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.outint.vo.IdCountVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,4 +22,8 @@ public interface BandingTaskClassMapper extends MPJBaseMapper<BandingTaskClass>
     List<BandingTaskClassPageVo> getList(@Param("dto")BandingTaskClassPageDto dto);
 
     List<BandingTaskClassPageVo> getClassStudent(@Param("dto") BandingTaskClassStudentPageDto dto);
+
+    List<IdCountVo> getMajorClassCount(@Param("id") Long bandingTaskId);
+    List<IdCountVo> getMajorClassStudentCount(@Param("id") Long bandingTaskId);
+
 }

+ 2 - 1
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskService.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.banding.service;
 
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
 import com.xjrsoft.module.banding.entity.BandingTask;
 
@@ -38,7 +39,7 @@ public interface IBandingTaskService extends MPJBaseService<BandingTask> {
     */
     Boolean delete(List<Long> ids);
 
-    Boolean automaticBanding(SureBandingTaskDto dto);
+    Boolean automaticBanding(AutomaticBandingTaskDto dto);
 
 
     Boolean sure(SureBandingTaskDto dto);

+ 177 - 21
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java

@@ -4,17 +4,24 @@ 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.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.BandingTaskClassConditionDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
+import com.xjrsoft.module.banding.entity.BandingRule;
 import com.xjrsoft.module.banding.entity.BandingTask;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
 import com.xjrsoft.module.banding.entity.BandingTaskRule;
+import com.xjrsoft.module.banding.mapper.BandingRuleMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassMapper;
-import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskRuleMapper;
+import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.entity.EnrollmentPlan;
 import com.xjrsoft.module.student.service.IBaseNewStudentService;
@@ -24,7 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Random;
 import java.util.stream.Collectors;
 
 /**
@@ -37,11 +47,11 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper, BandingTask> implements IBandingTaskService {
     private final BandingTaskMapper bandingTaskMapper;
-
+    private final BandingRuleMapper ruleMapper;
     private final BandingTaskRuleMapper taskRuleMapper;
     private final BandingTaskClassMapper taskClassMapper;
-    private final BandingTaskClassStudentMapper classStudentMapper;
     private final IBaseNewStudentService newStudentService;
+    private final IBandingTaskClassStudentService classStudentService;
 
 
     @Override
@@ -77,13 +87,16 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
      * 3、查询该任务使用的规则
      * 4、执行自动分班
      * 5、完成后,将分好班的信息存到banding_task_class_student表中
-     * @param dto
-     * @return
      */
     @Override
-    public Boolean automaticBanding(SureBandingTaskDto dto) {
-        BandingTask bandingTask = this.getById(dto.getId());
-        //查询需要分班的学生信息
+    public Boolean automaticBanding(AutomaticBandingTaskDto dto) {
+        BandingTask bandingTask = this.getById(dto.getBandingTaskId());
+        if(bandingTask == null){
+            throw new MyException("未能查询到该任务,无法自动分班");
+        }
+        //1、查询需要分班的学生信息
+        List<String> orderColumn = new ArrayList();
+        orderColumn.add("height");orderColumn.add("score");
         List<BaseNewStudent> baseNewStudents = newStudentService.selectJoinList(BaseNewStudent.class,
                 new MPJLambdaWrapper<BaseNewStudent>()
                         .select(BaseNewStudent::getId)
@@ -92,31 +105,174 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                         .eq(EnrollmentPlan::getGradeId, bandingTask.getGradeId())
                         .eq(EnrollmentPlan::getEnrollType, bandingTask.getEnrollType())
                         .eq(BaseNewStudent::getStatus, 0)
+                        .orderByDescStr(orderColumn)
         );
-        //查询所有班级信息
+        //2、查询所有班级信息
         List<BandingTaskClass> classList = taskClassMapper.selectList(
                 new QueryWrapper<BandingTaskClass>().lambda()
                         .select(BandingTaskClass::getId)
                         .select(BandingTaskClass.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClass.class).contains(x.getProperty()))
-                        .eq(BandingTaskClass::getBandingTaskId, dto.getId())
+                        .eq(BandingTaskClass::getBandingTaskId, bandingTask.getId())
                         .orderByAsc(BandingTaskClass::getSortCode)
         );
-        //查询所用到的规则
-        taskRuleMapper.selectJoinList(BandingTaskRule.class,
-                new MPJLambdaWrapper<BandingTaskRule>()
-                        .select(BandingTaskRule::getId)
-                        .select(BandingTaskRule.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskRule.class).contains(x.getProperty()))
-                        .leftJoin(EnrollmentPlan.class, EnrollmentPlan::getId, BaseNewStudent::getEnrollmentPlanId)
-                        .eq(EnrollmentPlan::getGradeId, bandingTask.getGradeId())
-                        .eq(EnrollmentPlan::getEnrollType, bandingTask.getEnrollType())
-                        .eq(BaseNewStudent::getStatus, 0)
+
+        //3、查询所用到的规则
+        List<BandingRule> ruleList = ruleMapper.selectJoinList(BandingRule.class,
+                new MPJLambdaWrapper<BandingRule>()
+                        .select(BandingRule::getId)
+                        .select(BandingRule.class, x -> VoToColumnUtil.fieldsToColumns(BandingRule.class).contains(x.getProperty()))
+                        .innerJoin(BandingTaskRule.class, BandingTaskRule::getBandingRuleId, BandingRule::getId)
+                        .eq(BandingTaskRule::getBandingTaskId, bandingTask.getId())
         );
-        return null;
+        List<String> ruleCodes = ruleList.stream().map(BandingRule::getCode).collect(Collectors.toList());
+
+        //包含下面个条件,则需要计算每个班级应该分配的人数
+        Map<Long, Integer> classLimitMap = new HashMap<>();
+        if(ruleCodes.contains("BR0004")){
+            //查询每个专业下面的班级人数
+            Map<Long, Integer> majorClassStudentCount = taskClassMapper.getMajorClassStudentCount(bandingTask.getId())
+                    .stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
+            //查询每个专业下面有多少个班级
+            Map<Long, Integer> majorClassCount = taskClassMapper.getMajorClassCount(bandingTask.getId())
+                    .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> majorLimitMap = new HashMap<>();
+            for (Long majorSetId : majorClassStudentCount.keySet()) {
+                Integer majorClassNumber = majorClassStudentCount.get(majorSetId);
+                Integer majorStudentNumber = majorStudentCount.get(majorSetId);
+                Integer classCount = majorClassCount.get(majorSetId);
+                if(majorStudentNumber < majorClassNumber){//报名人数小于班级人数
+                    Integer classLimtCount = majorStudentNumber / classCount;
+                    majorLimitMap.put(majorSetId, classLimtCount);
+                }else{
+                    Integer classLimtCount = majorClassNumber / classCount;
+                    majorLimitMap.put(majorSetId, classLimtCount);
+                }
+            }
+
+            for (BandingTaskClass bandingTaskClass : classList) {
+                classLimitMap.put(bandingTaskClass.getId(), majorLimitMap.get(bandingTaskClass.getMajorSetId()));
+            }
+
+        }
+
+
+        Map<Long, BandingTaskClassConditionDto> classConditionMap = new HashMap<>();
+        for (BandingTaskClassConditionDto classConditionDto : dto.getClassInfo()) {
+            classConditionMap.put(classConditionDto.getBandingTaskCassId(), classConditionDto);
+        }
+        //存班级和学生的关系
+        Map<Long, Long> studentClassMap = new HashMap<>();
+        //4、开始分班
+        for (BandingTaskClass taskClass : classList) {
+            Integer number = taskClass.getNumber();//班级总人数
+            if(classLimitMap.get(taskClass.getId()) != null){
+                number = classLimitMap.get(taskClass.getId());
+            }
+            Integer maleCount = 0, femaleCount = 0;
+            if(ruleCodes.contains("BR0001")){
+                maleCount = number / 2;
+                femaleCount = number / 2;
+                //如果班级人数是奇数,随机分配一个名额
+                if(number % 2 != 0){
+                    Random random = new Random();
+                    int randomIndex = random.nextInt(GenderDictionaryEnum.getCodes().length);
+
+                    String randomGender = GenderDictionaryEnum.getCodes()[randomIndex];
+                    if(GenderDictionaryEnum.MALE.getCode().equals(randomGender)){
+                        maleCount ++;
+                    }else if(GenderDictionaryEnum.FEMALE.getCode().equals(randomGender)){
+                        femaleCount ++ ;
+                    }
+                }
+            }
+            List<String> nameList = new ArrayList<>();
+            List<BaseNewStudent> maleList = new ArrayList();
+            List<BaseNewStudent> femaleList = new ArrayList();
+
+            for (BaseNewStudent newStudent : baseNewStudents) {
+                //人数已满,进行下一个班级的的循环
+                if(nameList.size() == number){
+                    break;
+                }
+                //该学生已被分配
+                if(studentClassMap.containsKey(newStudent.getId())){
+                    continue;
+                }
+                if(ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())){
+                    continue;
+                }
+                //专业不匹配,直接跳过
+                if(taskClass.getMajorSetId() != newStudent.getFirstAmbitionId() && taskClass.getMajorSetId() != newStudent.getSecondAmbitionId()){
+                    continue;
+                }
+                //判断该班性别是否已满
+                if(ruleCodes.contains("BR0001")){
+                    if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender()) && maleList.size() == maleCount){
+                        continue;
+                    }else if(GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender()) && femaleList.size() == femaleCount){
+                        continue;
+                    }
+                }
+
+                List<Boolean> conditionList = new ArrayList<>();
+                BandingTaskClassConditionDto condition = classConditionMap.get(taskClass.getId());
+                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());
+                if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender())){
+                    maleList.add(newStudent);
+                }else if(GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender())){
+                    femaleList.add(newStudent);
+                }
+                nameList.add(newStudent.getName());
+
+                //清除已经被分班的学生
+                baseNewStudents.remove(newStudent);
+            }
+        }
+        List<BandingTaskClassStudent> dataList = new ArrayList<>();
+        Date createDate = new Date();
+        for (Long studentId : studentClassMap.keySet()) {
+            dataList.add(
+                    new BandingTaskClassStudent(){{
+                        setBandingTaskClassId(studentClassMap.get(studentId));
+                        setNewStudentId(studentId);
+                        setStatus(0);
+                        setCreateDate(createDate);
+                    }}
+            );
+        }
+        if(!dataList.isEmpty()){
+            classStudentService.saveBatch(dataList);
+        }
+
+        return true;
     }
 
     @Override
     public Boolean sure(SureBandingTaskDto dto) {
-        List<BandingTaskClassStudent> classStudents = classStudentMapper.selectJoinList(BandingTaskClassStudent.class,
+        List<BandingTaskClassStudent> classStudents = classStudentService.selectJoinList(BandingTaskClassStudent.class,
                 new MPJLambdaWrapper<BandingTaskClassStudent>()
                         .select(BandingTaskClassStudent::getId)
                         .select(BandingTaskClassStudent.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClassStudent.class).contains(x.getProperty()))

+ 8 - 0
src/main/java/com/xjrsoft/module/student/mapper/BaseNewStudentMapper.java

@@ -2,12 +2,14 @@ package com.xjrsoft.module.student.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
 import com.xjrsoft.module.student.vo.EnrollmentPlanGradeVo;
 import com.xjrsoft.module.student.vo.EnrollmentPlanTreeVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -25,4 +27,10 @@ public interface BaseNewStudentMapper extends MPJBaseMapper<BaseNewStudent> {
     List<EnrollmentPlanTreeVo> getEnrollmentPlanList();
 
     List<EnrollmentPlanGradeVo> getGradeList();
+
+    List<IdCountVo> getFirstAmbitionStudentCount(@Param("gradeId") Long gradeId, @Param("enrollType") String enrollType);
+
+    List<IdCountVo> getSecondAmbitionStudentCount(@Param("gradeId") Long gradeId, @Param("enrollType") String enrollType);
+
+    List<IdCountVo> getMajorStudentCount();
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseNewStudentService.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.student.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
@@ -33,4 +34,8 @@ public interface IBaseNewStudentService extends MPJBaseService<BaseNewStudent> {
     List<Map<Integer, Object>> importData(Long treeId, MultipartFile file) throws IOException;
 
     List<BaseNewStudentScoreExcelVo> scoreImport(MultipartFile file) throws IOException;
+
+    List<IdCountVo> getMajorStudent(Long gradeId, String enrollType, Integer index);
+
+    List<IdCountVo> getMajorStudentCount();
 }

+ 16 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseNewStudentServiceImpl.java

@@ -12,6 +12,7 @@ import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseMajorSet;
 import com.xjrsoft.module.base.service.IBaseMajorSetService;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
+import com.xjrsoft.module.outint.vo.IdCountVo;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.mapper.BaseNewStudentMapper;
@@ -224,6 +225,21 @@ public class BaseNewStudentServiceImpl extends MPJBaseServiceImpl<BaseNewStudent
         return errorList;
     }
 
+    @Override
+    public List<IdCountVo> getMajorStudent(Long gradeId, String enrollType, Integer index) {
+        if(index == 1){
+            return this.baseMapper.getFirstAmbitionStudentCount(gradeId, enrollType);
+        }else if(index == 2){
+            return this.baseMapper.getSecondAmbitionStudentCount(gradeId, enrollType);
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
+    public List<IdCountVo> getMajorStudentCount() {
+        return this.baseMapper.getMajorStudentCount();
+    }
+
     /**
      * 检查必填字段是否为空
      */

+ 7 - 0
src/main/resources/mapper/banding/BandingTaskClassMapper.xml

@@ -61,6 +61,13 @@
         <if test="dto.className != null and dto.className != ''">
             AND t3.name like concat('%', #{dto.className}, '%')
         </if>
+    </select>
+
+    <select id="getMajorClassCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT major_set_id,COUNT(*) FROM banding_task_class WHERE banding_task_id = #{id} AND delete_mark = 0 GROUP BY major_set_id
+    </select>
 
+    <select id="getMajorClassStudentCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT major_set_id,sum(number) FROM banding_task_class WHERE banding_task_id = #{id} AND delete_mark = 0 GROUP BY major_set_id
     </select>
 </mapper>

+ 20 - 0
src/main/resources/mapper/student/BaseNewStudentMapper.xml

@@ -67,4 +67,24 @@
         WHERE t1.delete_mark = 0
     </select>
 
+    <select id="getFirstAmbitionStudentCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.first_ambition_id,COUNT(t1.id) FROM base_new_student t1
+        INNER JOIN enrollment_plan t2 ON t1.enrollment_plan_id = t2.id
+        WHERE t1.delete_mark = 0 AND t2.grade_id = #{gradeId} AND t2.enroll_type = #{enrollType}
+        GROUP BY t1.first_ambition_id
+    </select>
+
+    <select id="getSecondAmbitionStudentCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.second_ambition_id,COUNT(t1.id) FROM base_new_student t1
+        INNER JOIN enrollment_plan t2 ON t1.enrollment_plan_id = t2.id
+        WHERE t1.delete_mark = 0 AND t2.grade_id = #{gradeId} AND t2.enroll_type = #{enrollType}
+        GROUP BY t1.second_ambition_id
+    </select>
+    <select id="getMajorStudentCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
+        SELECT t1.id,(
+        SELECT COUNT(id) FROM base_new_student WHERE delete_mark = 0
+        AND (first_ambition_id = t1.id OR second_ambition_id = t1.id)
+        ) FROM base_major_set t1 WHERE delete_mark = 0
+    </select>
+
 </mapper>