Selaa lähdekoodia

添加学生详情

肖玮 5 vuotta sitten
vanhempi
commit
30e20d507c

+ 7 - 1
mec-education/src/main/java/com/ym/mec/education/controller/StudentController.java

@@ -1,9 +1,9 @@
 package com.ym.mec.education.controller;
 
+import com.ym.mec.education.base.BaseResponse;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.req.ClassGroupReq;
 import com.ym.mec.education.req.StudentReq;
-import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.service.IClassGroupStudentMapperService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -41,4 +41,10 @@ public class StudentController {
         return groupStudentMapperService.getPageByTeacher(studentReq);
     }
 
+    @PostMapping("/info")
+    @ApiOperation("根据学员id查询详情")
+    public BaseResponse info(@RequestBody StudentReq studentReq) {
+        return groupStudentMapperService.getInfo(studentReq);
+    }
+
 }

+ 3 - 3
mec-education/src/main/java/com/ym/mec/education/entity/SysUser.java

@@ -87,7 +87,7 @@ public class SysUser extends Model<SysUser> {
      * 性别(0,女  1,男)
      */
     @TableField("gender_")
-    private String gender;
+    private Integer gender;
     /**
      * 民族
      */
@@ -255,11 +255,11 @@ public class SysUser extends Model<SysUser> {
         return this;
     }
 
-    public String getGender() {
+    public Integer getGender() {
         return gender;
     }
 
-    public SysUser setGender(String gender) {
+    public SysUser setGender(Integer gender) {
         this.gender = gender;
         return this;
     }

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/mapper/SchoolMapper.java

@@ -1,7 +1,7 @@
 package com.ym.mec.education.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ym.mec.education.entity.School;
-import com.baomidou.mybatisplus.mapper.BaseMapper;
 
 /**
  * <p>

+ 23 - 0
mec-education/src/main/java/com/ym/mec/education/req/StudentReq.java

@@ -0,0 +1,23 @@
+package com.ym.mec.education.req;
+
+import com.ym.mec.education.base.BaseQuery;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @program: mec
+ * @description: 学员入参
+ * @author: xw
+ * @create: 2019-10-06 17:51
+ */
+@Data
+@ApiModel(description = "学员入参")
+public class StudentReq extends BaseQuery {
+
+    @ApiModelProperty(value = "学员姓名")
+    private String studentName;
+
+    @ApiModelProperty(value = "学员编号")
+    private String studentId;
+}

+ 35 - 0
mec-education/src/main/java/com/ym/mec/education/resp/StudentResp.java

@@ -0,0 +1,35 @@
+package com.ym.mec.education.resp;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @program: mec
+ * @description: 学员出参
+ * @author: xw
+ * @create: 2019-10-06 19:24
+ */
+@Data
+@ApiModel(description = "学员出参")
+@Accessors(chain = true)
+public class StudentResp implements Serializable {
+
+    @ApiModelProperty(value = "学员姓名")
+    private String studentName;
+    @ApiModelProperty(value = "学员性别")
+    private String studentGender;
+    @ApiModelProperty(value = "授课科目")
+    private List<String> subjectName;
+    @ApiModelProperty(value = "学校")
+    private String studentSchool;
+    @ApiModelProperty(value = "学员年级")
+    private String studentGrade;
+    @ApiModelProperty(value = "手机号(父母)")
+    private String parentsPhone;
+    @ApiModelProperty(value = "备注")
+    private String remark;
+}

+ 3 - 0
mec-education/src/main/java/com/ym/mec/education/service/IClassGroupStudentMapperService.java

@@ -2,6 +2,7 @@ package com.ym.mec.education.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.education.base.BaseResponse;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.ClassGroupStudentMapper;
 import com.ym.mec.education.req.ClassGroupReq;
@@ -29,4 +30,6 @@ public interface IClassGroupStudentMapperService extends IService<ClassGroupStud
     Page<ClassGroupStudentMapper> selectPageByCondition(ClassGroupReq classGroupReq);
 
     PageResponse getPageByTeacher(StudentReq studentReq);
+
+    BaseResponse getInfo(StudentReq studentReq);
 }

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/service/ISchoolService.java

@@ -1,7 +1,7 @@
 package com.ym.mec.education.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.education.entity.School;
-import com.baomidou.mybatisplus.service.IService;
 
 /**
  * <p>

+ 72 - 19
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -6,22 +6,23 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.ym.mec.biz.dal.enums.JobTypeEnum;
+import com.ym.mec.common.enums.UserGenderEnum;
 import com.ym.mec.common.security.SecurityUtils;
+import com.ym.mec.education.base.BaseResponse;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.*;
 import com.ym.mec.education.enums.TeachTypeEnum;
 import com.ym.mec.education.mapper.ClassGroupStudentMapperMapper;
 import com.ym.mec.education.req.ClassGroupReq;
 import com.ym.mec.education.req.StudentReq;
-import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.resp.ClassStudentResp;
 import com.ym.mec.education.resp.StudentListResp;
+import com.ym.mec.education.resp.StudentResp;
 import com.ym.mec.education.service.*;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -52,7 +53,10 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
     private ISubjectService subjectService;
     @Autowired
     private IClassGroupTeacherMapperService classGroupTeacherMapperService;
-
+    @Autowired
+    private IStudentRegistrationService studentRegistrationService;
+    @Autowired
+    private ISchoolService schoolService;
 
     @Override
     public PageResponse getPage(ClassGroupReq classGroupReq) {
@@ -70,11 +74,11 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
         page.getRecords().forEach(item -> {
             SysUser sysUser = sysUserService.getById(item.getUserId());
             StudentListResp studentRegistrationResp = new StudentListResp()
-                    .setStudentName(sysUser.getRealName());
+                .setStudentName(sysUser.getRealName());
             if (Objects.nonNull(classGroup) && Objects.nonNull(classGroup.getMusicGroupId())) {
                 QueryWrapper<MusicGroupStudentFee> musicGroupStudentFeeQueryWrapper = new QueryWrapper<MusicGroupStudentFee>();
                 musicGroupStudentFeeQueryWrapper.lambda().eq(true, MusicGroupStudentFee::getMusicGroupId, classGroup.getMusicGroupId())
-                        .eq(true, MusicGroupStudentFee::getUserId, item.getUserId());
+                    .eq(true, MusicGroupStudentFee::getUserId, item.getUserId());
                 MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeService.getOne(musicGroupStudentFeeQueryWrapper);
                 if (Objects.nonNull(musicGroupStudentFee) && Objects.nonNull(musicGroupStudentFee.getContinuousAbsenteeismTimes())) {
                     studentRegistrationResp.setStudentAttendance("连续缺到" + musicGroupStudentFee.getContinuousAbsenteeismTimes() + "次");
@@ -115,17 +119,17 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
             QueryWrapper<MusicGroup> musicGroupQueryWrapper = new QueryWrapper<>();
             if (JobTypeEnum.TEACHING.getCode().equals(teacher.getJobType())) {
                 musicGroupQueryWrapper.lambda().eq(MusicGroup::getOrganId, teacher.getOrganId())
-                        .eq(MusicGroup::getEducationalTeacherId, teacher.getId());
+                    .eq(MusicGroup::getEducationalTeacherId, teacher.getId());
             } else if (JobTypeEnum.ACADEMIC.getCode().equals(teacher.getJobType())) {
                 //教务老师
                 musicGroupQueryWrapper.lambda().eq(MusicGroup::getOrganId, teacher.getOrganId())
-                        .eq(MusicGroup::getTeamTeacherId, teacher.getId());
+                    .eq(MusicGroup::getTeamTeacherId, teacher.getId());
             }
             List<MusicGroup> musicGroupList = musicGroupService.list(musicGroupQueryWrapper);
             if (!CollectionUtils.isEmpty(musicGroupList)) {
                 QueryWrapper<ClassGroup> classGroupQueryWrapper = new QueryWrapper<>();
                 classGroupQueryWrapper.lambda().in(ClassGroup::getMusicGroupId,
-                        musicGroupList.stream().map(MusicGroup::getId).collect(Collectors.toList()));
+                    musicGroupList.stream().map(MusicGroup::getId).collect(Collectors.toList()));
                 List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
                 if (!CollectionUtils.isEmpty(classGroupList)) {
                     return PageResponse.success(getPage(classGroupList, studentReq, musicGroupList));
@@ -135,16 +139,16 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
             QueryWrapper<ClassGroupTeacherMapper> classGroupTeacherMapperQueryWrapper = new QueryWrapper<>();
             if (JobTypeEnum.ADVISER.getCode().equals(teacher.getJobType())) {
                 classGroupTeacherMapperQueryWrapper.lambda().eq(ClassGroupTeacherMapper::getTeacherRole, TeachTypeEnum.BISHOP.getCode())
-                        .eq(ClassGroupTeacherMapper::getUserId, teacher.getId());
+                    .eq(ClassGroupTeacherMapper::getUserId, teacher.getId());
             } else if (JobTypeEnum.ASSISTANT.getCode().equals(teacher.getJobType())) {
                 classGroupTeacherMapperQueryWrapper.lambda().eq(ClassGroupTeacherMapper::getTeacherRole, TeachTypeEnum.TEACHING.getCode())
-                        .eq(ClassGroupTeacherMapper::getUserId, teacher.getId());
+                    .eq(ClassGroupTeacherMapper::getUserId, teacher.getId());
             }
             List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupTeacherMapperService.list(classGroupTeacherMapperQueryWrapper);
             if (!CollectionUtils.isEmpty(classGroupTeacherMapperList)) {
                 QueryWrapper<ClassGroup> classGroupQueryWrapper = new QueryWrapper<>();
                 classGroupQueryWrapper.lambda().in(ClassGroup::getMusicGroupId, classGroupTeacherMapperList.stream().
-                        map(ClassGroupTeacherMapper::getMusicGroupId).collect(Collectors.toList()));
+                    map(ClassGroupTeacherMapper::getMusicGroupId).collect(Collectors.toList()));
                 List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
                 if (!CollectionUtils.isEmpty(classGroupList)) {
                     musicGroupQueryWrapper.lambda().in(MusicGroup::getId, classGroupList.stream().map(ClassGroup::getMusicGroupId).collect(Collectors.toList()));
@@ -156,18 +160,67 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
         return PageResponse.noDataExists();
     }
 
+    @Override
+    public BaseResponse getInfo(StudentReq studentReq) {
+        if (Objects.isNull(studentReq.getStudentId())) {
+            return BaseResponse.errorParam();
+        }
+        SysUser user = sysUserService.getById(studentReq.getStudentId());
+        StudentResp studentResp = new StudentResp();
+        List<String> subjectNameList = Lists.newArrayList();
+        if (Objects.nonNull(user)) {
+            studentResp.setStudentName(user.getRealName())
+                .setStudentGender(UserGenderEnum.get(user.getGender()).getDescription());
+        }
+        QueryWrapper<StudentRegistration> studentRegistrationQueryWrapper = new QueryWrapper<>();
+        studentRegistrationQueryWrapper.lambda().eq(StudentRegistration::getUserId, studentReq.getStudentId());
+        studentRegistrationService.list(studentRegistrationQueryWrapper).stream().findFirst().
+            ifPresent(studentRegistration -> studentResp.setParentsPhone(studentRegistration.getParentsPhone())
+                .setStudentGrade(studentRegistration.getCurrentGrade())
+                .setRemark(studentRegistration.getRemark()));
+        QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
+        classGroupStudentMapperQueryWrapper.lambda().eq(ClassGroupStudentMapper::getUserId, studentReq.getStudentId());
+        List<ClassGroupStudentMapper> classGroupStudentMapperList = list(classGroupStudentMapperQueryWrapper);
+        if (!CollectionUtils.isEmpty(classGroupStudentMapperList)) {
+            QueryWrapper<ClassGroup> classGroupQueryWrapper = new QueryWrapper<>();
+            classGroupQueryWrapper.lambda().in(ClassGroup::getId, classGroupStudentMapperList.stream().
+                map(ClassGroupStudentMapper::getClassGroupId).collect(Collectors.toList()));
+            List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
+            if (!CollectionUtils.isEmpty(classGroupList)) {
+                classGroupList.forEach(classGroup -> {
+                    List<Subject> subjectList = subjectService.getSubjectList(classGroup.getSubjectIdList());
+                    if (!CollectionUtils.isEmpty(subjectList)) {
+                        subjectNameList.addAll(subjectList.stream().map(Subject::getName).collect(Collectors.toList()));
+                    }
+                });
+                //学校
+                classGroupList.stream().findFirst().ifPresent(group -> {
+                    MusicGroup musicGroup = musicGroupService.getById(group.getMusicGroupId());
+                    if (Objects.nonNull(musicGroup) && Objects.nonNull(musicGroup.getSchoolId())) {
+                        School school = schoolService.getById(musicGroup.getSchoolId());
+                        if (Objects.nonNull(school)) {
+                            studentResp.setStudentSchool(school.getName());
+                        }
+                    }
+                });
+            }
+        }
+        studentResp.setSubjectName(subjectNameList);
+        return BaseResponse.success(studentResp);
+    }
+
     private IPage<StudentListResp> getPage(List<ClassGroup> classGroupList, StudentReq studentReq, List<MusicGroup> musicGroupList) {
         Page<StudentListResp> pageResult = new Page<>();
         ArrayList<StudentListResp> resultList = Lists.newArrayList();
         QueryWrapper<ClassGroupStudentMapper> classGroupStudentMapperQueryWrapper = new QueryWrapper<>();
         classGroupStudentMapperQueryWrapper.lambda().in(ClassGroupStudentMapper::getClassGroupId,
-                classGroupList.stream().map(ClassGroup::getId).collect(Collectors.toList()));
+            classGroupList.stream().map(ClassGroup::getId).collect(Collectors.toList()));
         List<ClassGroupStudentMapper> classGroupStudentMapperList = classGroupStudentMapperService.list(classGroupStudentMapperQueryWrapper);
         if (!CollectionUtils.isEmpty(classGroupStudentMapperList)) {
             QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
             sysUserQueryWrapper.lambda().in(SysUser::getId,
-                    classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toList()))
-                    .like(SysUser::getRealName, studentReq.getStudentName());
+                classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserId).collect(Collectors.toList()))
+                .like(SysUser::getRealName, studentReq.getStudentName());
             Page<SysUser> sysUserPage = new Page<>(studentReq.getPageNo(), studentReq.getPageSize());
             IPage<SysUser> page = sysUserService.page(sysUserPage, sysUserQueryWrapper);
             if (!CollectionUtils.isEmpty(page.getRecords())) {
@@ -178,16 +231,16 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
                     studentListResp.setStudentId(sysUser.getId());
                     studentListResp.setStudentName(sysUser.getRealName());
                     classGroupStudentMapperList.stream().filter
-                            (classGroupStudentMapper -> classGroupStudentMapper.getUserId().
-                                    equals(sysUser.getId())).findFirst().ifPresent(classGroupStudentMapper -> {
+                        (classGroupStudentMapper -> classGroupStudentMapper.getUserId().
+                            equals(sysUser.getId())).findFirst().ifPresent(classGroupStudentMapper -> {
                         Integer classGroupId = classGroupStudentMapper.getClassGroupId();
                         classGroupList.stream().filter(classGroup -> classGroup.getId().equals(classGroupId)).
-                                findFirst().ifPresent(classGroup -> {
+                            findFirst().ifPresent(classGroup -> {
                             Integer musicGroupId = classGroup.getMusicGroupId();
                             //连续迟到
                             QueryWrapper<MusicGroupStudentFee> musicGroupStudentFeeQueryWrapper = new QueryWrapper<MusicGroupStudentFee>();
                             musicGroupStudentFeeQueryWrapper.lambda().eq(true, MusicGroupStudentFee::getMusicGroupId, musicGroupId)
-                                    .eq(true, MusicGroupStudentFee::getUserId, sysUser.getId());
+                                .eq(true, MusicGroupStudentFee::getUserId, sysUser.getId());
                             MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeService.getOne(musicGroupStudentFeeQueryWrapper);
                             if (Objects.nonNull(musicGroupStudentFee)) {
                                 studentListResp.setStudentAttendance("连续旷课" + musicGroupStudentFee.getContinuousAbsenteeismTimes() + "次");
@@ -197,7 +250,7 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
                                 studentListResp.setSubjectName(subjectList.stream().map(Subject::getName).collect(Collectors.toList()));
                             }
                             finalMusicGroupList.stream().filter(musicGroup -> musicGroup.getId().equals(musicGroupId)).
-                                    findFirst().ifPresent(musicGroup -> studentListResp.setMusicGroupName(musicGroup.getName()));
+                                findFirst().ifPresent(musicGroup -> studentListResp.setMusicGroupName(musicGroup.getName()));
                         });
                     });
                     resultList.add(studentListResp);

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/service/impl/SchoolServiceImpl.java

@@ -1,9 +1,9 @@
 package com.ym.mec.education.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ym.mec.education.entity.School;
 import com.ym.mec.education.mapper.SchoolMapper;
 import com.ym.mec.education.service.ISchoolService;
-import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
 /**