dzx 4 mēneši atpakaļ
vecāks
revīzija
86e26c15ed

+ 2 - 15
src/main/java/com/xjrsoft/module/banding/controller/BandingTaskController.java

@@ -2,14 +2,12 @@ package com.xjrsoft.module.banding.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 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;
@@ -25,8 +23,6 @@ import com.xjrsoft.module.banding.service.IBandingTaskService;
 import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
 import com.xjrsoft.module.banding.vo.BandingTaskRuleVo;
 import com.xjrsoft.module.banding.vo.BandingTaskVo;
-import com.xjrsoft.module.base.entity.BaseGrade;
-import com.xjrsoft.module.system.entity.DictionaryDetail;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -68,16 +64,7 @@ public class BandingTaskController {
     @SaCheckPermission("bandingtask:detail")
     public RT<PageOutput<BandingTaskPageVo>> page(@Valid BandingTaskPageDto dto){
 
-        IPage<BandingTaskPageVo> page = bandingTaskService.selectJoinListPage(ConventPage.getPage(dto), BandingTaskPageVo.class,
-                new MPJLambdaWrapper<BandingTask>()
-                        .select(BandingTask::getId)
-                        .select(BandingTask.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskPageVo.class).contains(x.getProperty()))
-                        .selectAs(DictionaryDetail::getName, BandingTaskPageVo::getEnrollTypeCn)
-                        .selectAs(BaseGrade::getName, BandingTaskPageVo::getGradeName)
-                        .eq(StrUtil.isNotEmpty(dto.getEnrollType()), BandingTask::getEnrollType, dto.getEnrollType())
-                        .leftJoin(BaseGrade.class, BaseGrade::getId, BandingTask::getGradeId)
-                        .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, BandingTask::getEnrollType)
-        );
+        IPage<BandingTaskPageVo> page = bandingTaskService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         PageOutput<BandingTaskPageVo> pageOutput = ConventPage.getPageOutput(page, BandingTaskPageVo.class);
         return RT.ok(pageOutput);
     }

+ 4 - 0
src/main/java/com/xjrsoft/module/banding/mapper/BandingTaskMapper.java

@@ -1,7 +1,10 @@
 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.BandingTaskPageDto;
 import com.xjrsoft.module.banding.entity.BandingTask;
+import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -13,4 +16,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface BandingTaskMapper extends MPJBaseMapper<BandingTask> {
 
+    Page<BandingTaskPageVo> getPage(Page<BandingTaskPageVo> page, BandingTaskPageDto dto);
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskService.java

@@ -1,9 +1,12 @@
 package com.xjrsoft.module.banding.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
 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.entity.BandingTask;
+import com.xjrsoft.module.banding.vo.BandingTaskPageVo;
 
 import java.util.List;
 
@@ -44,4 +47,6 @@ public interface IBandingTaskService extends MPJBaseService<BandingTask> {
 
     Boolean sure(SureBandingTaskDto dto);
 
+    Page<BandingTaskPageVo> getPage(Page<BandingTaskPageVo> page, BandingTaskPageDto dto);
+
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -21,6 +21,8 @@ import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 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.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
@@ -72,6 +74,7 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
     private final IBaseStudentSchoolRollService schoolRollService;
     private final IBaseStudentService studentService;
     private final IBaseStudentFamilyService familyService;
+    private final BaseMajorSetMapper majorSetMapper;
     @Override
     public Boolean add(BandingTaskClassStudent bandingTaskClass) {
         bandingTaskClass.setCreateDate(new Date());
@@ -155,12 +158,14 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         //查询出需要新增的班级信息
         List<Long> classIds = classStudents.stream().map(BandingTaskClassStudent::getBandingTaskClassId).collect(Collectors.toList());
         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) {
             BaseClass baseClass = new BaseClass() {{
                 setName(taskClass.getName());
                 setClassroomId(taskClass.getClassroomId());
                 setTeacherId(taskClass.getTeacherId());
                 setIsGraduate(1);
+                setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
                 setIsOrderClass(taskClass.getIsOrderClass()==null?0:taskClass.getIsOrderClass().intValue());
                 setGradeId(bandingTask.getGradeId());
                 setDeleteMark(DeleteMark.NODELETE.getCode());

+ 8 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.banding.service.impl;
 import cn.dev33.satoken.secure.BCrypt;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
@@ -15,6 +16,7 @@ import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
 import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
 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.entity.BandingRule;
 import com.xjrsoft.module.banding.entity.BandingTask;
@@ -30,6 +32,7 @@ import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskMajorConditionService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
 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.BaseMajorSet;
 import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
@@ -520,6 +523,11 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         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){
         Date createDate = new Date();
         BandingTask bandingTask = this.getById(badingTaskId);

+ 24 - 0
src/main/resources/mapper/banding/BandingTaskMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.banding.mapper.BandingTaskMapper">
+    <select id="getPage" parameterType="com.xjrsoft.module.banding.dto.BandingTaskPageDto" resultType="com.xjrsoft.module.banding.vo.BandingTaskPageVo">
+        SELECT t.id, t.sort_code, t.grade_id, t.enroll_type, t.name, t.status, t2.name AS enrollTypeCn, t1.name AS gradeName,
+        (SELECT COUNT(*) FROM base_new_student a1
+        INNER JOIN enrollment_plan a2 ON a1.enrollment_plan_id = a2.id
+        WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
+        AND a2.grade_id = t.grade_id AND a2.enroll_type = t.enroll_type
+        ) AS admissions_count,
+        (SELECT COUNT(*) FROM banding_task_class_student a1
+        INNER JOIN banding_task_class a2 ON a1.banding_task_class_id = a2.id
+        WHERE a1.delete_mark = 0 AND a2.delete_mark = 0 AND a2.banding_task_id = t.id) AS divided_count
+        FROM banding_task t
+        LEFT JOIN base_grade t1 ON (t1.id = t.grade_id)
+        LEFT JOIN xjr_dictionary_detail t2 ON (t2.code = t.enroll_type)
+        WHERE t.delete_mark = 0 AND t2.delete_mark = 0
+        <if test="dto.enrollType != null and dto.enrollType != ''">
+            and t.enroll_type = #{dto.enrollType}
+        </if>
+    </select>
+</mapper>