Browse Source

学生列表查询调整

dzx 1 year ago
parent
commit
d50bed30b3

+ 2 - 35
src/main/java/com/xjrsoft/module/student/controller/StudentManagerController.java

@@ -3,12 +3,10 @@ package com.xjrsoft.module.student.controller;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.yulichang.toolkit.MPJWrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.GenderDictionaryEnum;
 import com.xjrsoft.common.model.result.R;
@@ -16,7 +14,6 @@ import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.TreeUtil;
-import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -24,8 +21,6 @@ import com.xjrsoft.module.base.service.IBaseGradeService;
 import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
-import com.xjrsoft.module.student.entity.BaseStudent;
-import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
 import com.xjrsoft.module.student.service.IStudentManagerService;
 import com.xjrsoft.module.student.vo.BaseStudentTreeVo;
@@ -68,35 +63,7 @@ public class StudentManagerController {
     @SaCheckPermission("studentmanager:detail")
     public R page(@Valid BaseStudentUserPageDto dto) {
 
-        IPage<BaseStudentUserPageVo> page = studentManagerService.selectJoinListPage(ConventPage.getPage(dto), BaseStudentUserPageVo.class,
-                MPJWrappers.<BaseStudentUser>lambdaJoin()
-                        .like(StrUtil.isNotBlank(dto.getUserName()), BaseStudentUser::getUserName, dto.getUserName())
-                        .like(StrUtil.isNotBlank(dto.getMobile()), BaseStudentUser::getMobile, dto.getMobile())
-                        .like(StrUtil.isNotBlank(dto.getName()), BaseStudentUser::getName, dto.getName())
-                        .like(StrUtil.isNotBlank(dto.getEmail()), BaseStudentUser::getEmail, dto.getEmail())
-                        .eq(ObjectUtil.isNotNull(dto.getClassId()), BaseClass::getId, dto.getClassId())
-                        .in((ObjectUtil.isNotNull(dto.getTokenType()) && dto.getTokenType() == 1), BaseClass::getTeacherId, StpUtil.getLoginIdAsLong())
-                        .orderByDesc(BaseStudentUser::getId)
-                        .select(BaseStudentUser::getId)
-                        .select(BaseStudent::getStudentId)
-                        .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentUserPageVo.class).contains(x.getProperty()))
-                        .select(BaseStudentUser.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentUserPageVo.class).contains(x.getProperty()))
-                        .select(BaseStudentSchoolRoll::getStudyYear)
-                        .select("a.`name` as grade_name")
-                        .select("b.`name` as major_set_name")
-                        .selectAs(BaseClass::getName, BaseStudentUserPageVo::getClassName)
-                        .innerJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentUser::getId)
-                        .leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, BaseStudentUser::getId)
-                        .leftJoin("base_grade a on a.id = t2.grade_id")
-                        .leftJoin("base_major_set b on b.id = t2.major_set_id")
-                        .leftJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
-//                        .select("c.`mobile` as guardianPhone")
-//                        .select("c.`name` as guardianName")
-//                        .leftJoin("base_student_family_member c on c.user_id = t2.user_id")
-                        );
-        for (BaseStudentUserPageVo record : page.getRecords()) {
-            record.setGenderCn(GenderDictionaryEnum.getValue(record.getGender()));
-        }
+        IPage<BaseStudentUserPageVo> page = studentManagerService.getStudentPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         PageOutput<BaseStudentUserPageVo> pageOutput = ConventPage.getPageOutput(page, BaseStudentUserPageVo.class);
         return R.ok(pageOutput);
     }

+ 7 - 0
src/main/java/com/xjrsoft/module/student/mapper/BaseStudentMapper.java

@@ -1,8 +1,13 @@
 package com.xjrsoft.module.student.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.room.dto.RoomPageDto;
+import com.xjrsoft.module.room.vo.RoomPageVo;
 import com.xjrsoft.module.schedule.vo.StudentJianyuekbVo;
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
 import com.xjrsoft.module.student.vo.StudentInfoVo;
 import com.xjrsoft.module.student.vo.StudentPersonalInfoVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -29,4 +34,6 @@ public interface BaseStudentMapper extends MPJBaseMapper<BaseStudent> {
     StudentPersonalInfoVo getPersonalInfo(Long userId);
 
     List<String> getCredentialNumbers();
+
+    Page<BaseStudentUserPageVo> getStudentPage(Page<BaseStudentUserPageVo> page, BaseStudentUserPageDto dto);
 }

+ 6 - 1
src/main/java/com/xjrsoft/module/student/service/IStudentManagerService.java

@@ -1,10 +1,12 @@
 package com.xjrsoft.module.student.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
 import com.xjrsoft.module.student.vo.BaseStudentClassVo;
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
 import com.xjrsoft.module.student.vo.PersonalPortraitPersonalInfoVo;
-import com.xjrsoft.module.student.vo.StudentPersonalInfoVo;
 
 import java.text.ParseException;
 import java.util.List;
@@ -52,4 +54,7 @@ public interface IStudentManagerService extends MPJBaseService<BaseStudentUser>
     PersonalPortraitPersonalInfoVo getPersonalInfo(Long userId);
 
     Boolean importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException;
+
+
+    Page<BaseStudentUserPageVo> getStudentPage(Page<BaseStudentUserPageVo> page, BaseStudentUserPageDto dto);
 }

+ 10 - 0
src/main/java/com/xjrsoft/module/student/service/impl/StudentManagerServiceImpl.java

@@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 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.DeleteMark;
@@ -22,6 +23,7 @@ import com.xjrsoft.module.base.mapper.BaseGradeMapper;
 import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.entity.BaseStudent;
 import com.xjrsoft.module.student.entity.BaseStudentContact;
 import com.xjrsoft.module.student.entity.BaseStudentFamily;
@@ -31,6 +33,7 @@ import com.xjrsoft.module.student.entity.BaseStudentSubsidize;
 import com.xjrsoft.module.student.entity.BaseStudentUser;
 import com.xjrsoft.module.student.mapper.BaseStudentFamilyMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentFamilyMemberMapper;
+import com.xjrsoft.module.student.mapper.BaseStudentMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentUserMapper;
 import com.xjrsoft.module.student.service.IBaseStudentContactService;
 import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
@@ -39,6 +42,7 @@ import com.xjrsoft.module.student.service.IBaseStudentService;
 import com.xjrsoft.module.student.service.IBaseStudentSubsidizeService;
 import com.xjrsoft.module.student.service.IStudentManagerService;
 import com.xjrsoft.module.student.vo.BaseStudentClassVo;
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
 import com.xjrsoft.module.student.vo.PersonalPortraitPersonalInfoVo;
 import com.xjrsoft.module.student.vo.StudentPersonalInfoVo;
 import com.xjrsoft.module.system.entity.Area;
@@ -87,6 +91,7 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
     private final IBaseStudentSchoolRollService schoolRollService;
     private final IBaseStudentSubsidizeService subsidizeService;
     private final IBaseStudentFamilyService familyService;
+    private final BaseStudentMapper baseStudentMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -885,6 +890,11 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
         return true;
     }
 
+    @Override
+    public Page<BaseStudentUserPageVo> getStudentPage(Page<BaseStudentUserPageVo> page, BaseStudentUserPageDto dto) {
+        return baseStudentMapper.getStudentPage(page, dto);
+    }
+
     /**
      * 初始化字典信息
      * 身份证类型、

+ 18 - 103
src/main/java/com/xjrsoft/module/student/vo/BaseStudentUserPageVo.java

@@ -6,118 +6,33 @@ import lombok.Data;
 @Data
 public class BaseStudentUserPageVo {
 
-
-    /**
-     *
-     */
     @ApiModelProperty("")
     private String id;
-    /**
-     * 账户
-     */
-    @ApiModelProperty("账户")
-    private String userName;
-    /**
-     * 姓名
-     */
+
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ApiModelProperty("班主任名字")
+    private String teacherName;
+
     @ApiModelProperty("姓名")
     private String name;
-    /**
-     * 手机号
-     */
-    @ApiModelProperty("手机号")
-    private String mobile;
-    /**
-     * 邮箱
-     */
-    @ApiModelProperty("邮箱")
-    private String email;
-    /**
-     * 学号
-     */
-    @ApiModelProperty("学号")
-    private String studentId;
-    /**
-     * 别名
-     */
-    @ApiModelProperty("别名")
-    private String asName;
-    /**
-     * 性别
-     */
-    @ApiModelProperty("性别")
-    private String gender;
 
-    /**
-     * 性别中文
-     */
     @ApiModelProperty("性别中文")
     private String genderCn;
-    /**
-     * 证件号码
-     */
-    @ApiModelProperty("证件号码")
+
+    @ApiModelProperty("身份证号")
     private String credentialNumber;
-    /**
-     * 所属组织机构
-     */
-    @ApiModelProperty("所属组织机构")
-    private String deptId;
-    /**
-     * 班级年级
-     */
-    @ApiModelProperty("班级年级")
-    private String gradeId;
-    /**
-     * 班级名称
-     */
-    @ApiModelProperty("班级名称")
-    private String gradeName;
-    /**
-     * 招生类型
-     */
-    @ApiModelProperty("招生类型")
-    private String enrollType;
-    /**
-     * 班级编号
-     */
-    @ApiModelProperty("班级编号")
-    private String classId;
-    /**
-     * 班级名称
-     */
-    @ApiModelProperty("班级名称")
-    private String className;
-    /**
-     * 专业方向
-     */
-    @ApiModelProperty("专业方向编号")
-    private String majorSetId;
-    /**
-     * 专业方向
-     */
-    @ApiModelProperty("专业方向名称")
-    private String majorSetName;
-    /**
-     * 学制
-     */
-    @ApiModelProperty("学制")
-    private String studyYear;
-    /**
-     * 学籍状态
-     */
+
+    @ApiModelProperty("手机号")
+    private String mobile;
+
     @ApiModelProperty("学籍状态")
-    private String archivesStatus;
+    private String archivesStatusCn;
 
-    /**
-     * 监护人姓名
-     */
-    @ApiModelProperty("监护人姓名")
-    private String guardianName;
+    @ApiModelProperty("就读方式")
+    private String stduyStatusCn;
 
-    /**
-     * 江湖人联系电话
-     */
-    @ApiModelProperty("监护人联系电话")
-    private String guardianPhone;
+    @ApiModelProperty("学生类别")
+    private String studentTypeCn;
 }

+ 30 - 0
src/main/resources/mapper/student/BaseStudentMapper.xml

@@ -50,4 +50,34 @@
         SELECT t1.credential_number FROM xjr_user t1
         INNER JOIN base_student t2 ON t1.id = t2.user_id
     </select>
+    <select id="getStudentPage" parameterType="com.xjrsoft.module.student.dto.BaseStudentUserPageDto" resultType="com.xjrsoft.module.student.vo.BaseStudentUserPageVo">
+        SELECT t1.id,t4.name AS class_name,t5.name AS teacher_name,t1.name,t6.name AS gender_cn,t1.credential_number,
+        t1.mobile,t7.name AS archives_status_cn ,t8.name AS stduy_status_cn,t9.name AS student_type_cn FROM xjr_user t1
+        INNER JOIN base_student t2 ON t1.id = t2.user_id
+        LEFT JOIN base_student_school_roll t3 ON t1.id = t3.user_id
+        LEFT JOIN base_class t4 ON t4.id = t3.class_id
+        LEFT JOIN xjr_user t5 ON t4.teacher_id = t5.id
+        LEFT JOIN xjr_dictionary_detail t6 ON t1.gender = t6.code AND t6.item_id = 2023000000000000004
+        LEFT JOIN xjr_dictionary_detail t7 ON t3.archives_status = t7.code AND t7.item_id = 2023000000000000029
+        LEFT JOIN xjr_dictionary_detail t8 ON t3.stduy_status = t8.code AND t8.item_id = 2023000000000000030
+        LEFT JOIN xjr_dictionary_detail t9 ON t3.student_type = t9.code AND t9.item_id = 2023000000000000028
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+        <if test="dto.name != null and dto.name != ''">
+            and t1.name like concat('%', #{dto.name},'%')
+        </if>
+        <if test="dto.userName != null and dto.userName != ''">
+            and t1.user_name like concat('%', #{dto.userName},'%')
+        </if>
+        <if test="dto.mobile != null and dto.mobile != ''">
+            and t1.mobile like concat('%', #{dto.mobile},'%')
+        </if>
+        <if test="dto.email != null and dto.email != ''">
+            and t1.email like concat('%', #{dto.email},'%')
+        </if>
+        <if test="dto.classId != null">
+            and t4.id = #{dto.classId}
+        </if>
+        order by t1.id
+    </select>
+
 </mapper>