Selaa lähdekoodia

添加学员列表 修改老师请假记录

肖玮 5 vuotta sitten
vanhempi
commit
99c49c3152

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

@@ -2,6 +2,7 @@ package com.ym.mec.education.controller;
 
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.service.IClassGroupStudentMapperService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -33,4 +34,10 @@ public class StudentController {
         return groupStudentMapperService.getPage(classGroupReq);
     }
 
+    @PostMapping("/listByTeacher")
+    @ApiOperation("根据当前登录人查询对应学员名单列表")
+    public PageResponse listByTeacher(@RequestBody TeacherReq teacherReq) {
+        return groupStudentMapperService.getPageByTeacher(teacherReq);
+    }
+
 }

+ 2 - 0
mec-education/src/main/java/com/ym/mec/education/req/TeacherReq.java

@@ -1,6 +1,7 @@
 package com.ym.mec.education.req;
 
 import com.ym.mec.education.base.BaseQuery;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.ToString;
 
@@ -15,5 +16,6 @@ public class TeacherReq extends BaseQuery {
 
     private String name;
 
+    @ApiModelProperty(value = "老师编号")
     private Integer userId;
 }

+ 9 - 2
mec-education/src/main/java/com/ym/mec/education/resp/StudentListResp.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @program: mec
@@ -17,9 +18,15 @@ import java.io.Serializable;
 @Accessors(chain = true)
 public class StudentListResp implements Serializable {
 
-    @ApiModelProperty(value = "学员名称",required = true)
+    @ApiModelProperty(value = "学员名称")
     private String studentName;
 
-    @ApiModelProperty(value = "学员连续迟到情况",required = true)
+    @ApiModelProperty(value = "学员连续迟到情况")
     private String studentAttendance;
+
+    @ApiModelProperty(value = "乐团名称")
+    private String musicGroupName;
+
+    @ApiModelProperty(value = "声部")
+    private List<String> subjectName;
 }

+ 19 - 9
mec-education/src/main/java/com/ym/mec/education/resp/TeacherLeaveRecordResp.java

@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 import java.io.Serializable;
-import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -31,15 +30,26 @@ public class TeacherLeaveRecordResp implements Serializable {
     @ApiModelProperty(value = "请假类别")
     private String leaveCategory;
 
-    @ApiModelProperty(value = "上课时间")
-    private String classDate;
+    @ApiModelProperty(value = "调整的课程")
+    private List<AdjustCourse> adjustCourseList;
 
-    @ApiModelProperty(value = "调整后上课时间")
-    private String classAdjustDate;
+    @Data
+    public static class AdjustCourse{
+        @ApiModelProperty(value = "调整前上课时间")
+        private String classDate;
 
-    @ApiModelProperty(value = "课程类型")
-    private String courseType;
+        @ApiModelProperty(value = "调整后上课时间")
+        private String classAdjustDate;
+
+        @ApiModelProperty(value = "课程类型")
+        private String courseType;
+
+        @ApiModelProperty(value = "课程名称")
+        private String courseName;
+    }
+
+    public AdjustCourse getAdjustCourse(){
+        return new AdjustCourse();
+    }
 
-    @ApiModelProperty(value = "课程名称")
-    private String courseName;
 }

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.education.base.PageResponse;
 import com.ym.mec.education.entity.ClassGroupStudentMapper;
 import com.ym.mec.education.req.ClassGroupReq;
+import com.ym.mec.education.req.TeacherReq;
 import com.ym.mec.education.resp.ClassStudentResp;
 import java.util.List;
 
@@ -25,4 +26,6 @@ public interface IClassGroupStudentMapperService extends IService<ClassGroupStud
     int selectStudentPageCount(ClassGroupReq classGroupReq);
 
     Page<ClassGroupStudentMapper> selectPageByCondition(ClassGroupReq classGroupReq);
+
+    PageResponse getPageByTeacher(TeacherReq teacherReq);
 }

+ 122 - 10
mec-education/src/main/java/com/ym/mec/education/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -5,24 +5,23 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 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.education.base.PageResponse;
-import com.ym.mec.education.entity.ClassGroup;
-import com.ym.mec.education.entity.ClassGroupStudentMapper;
-import com.ym.mec.education.entity.MusicGroupStudentFee;
-import com.ym.mec.education.entity.SysUser;
+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.TeacherReq;
 import com.ym.mec.education.resp.ClassStudentResp;
 import com.ym.mec.education.resp.StudentListResp;
-import com.ym.mec.education.service.IClassGroupService;
-import com.ym.mec.education.service.IClassGroupStudentMapperService;
-import com.ym.mec.education.service.IMusicGroupStudentFeeService;
-import com.ym.mec.education.service.ISysUserService;
+import com.ym.mec.education.service.*;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import java.util.List;
-import java.util.Objects;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -41,6 +40,16 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
     private IClassGroupService classGroupService;
     @Autowired
     private IMusicGroupStudentFeeService musicGroupStudentFeeService;
+    @Autowired
+    private ITeacherService teacherService;
+    @Autowired
+    private IMusicGroupService musicGroupService;
+    @Autowired
+    private IClassGroupStudentMapperService classGroupStudentMapperService;
+    @Autowired
+    private ISubjectService subjectService;
+    @Autowired
+    private IClassGroupTeacherMapperService classGroupTeacherMapperService;
 
 
     @Override
@@ -94,4 +103,107 @@ public class ClassGroupStudentMapperServiceImpl extends ServiceImpl<ClassGroupSt
         Page<ClassGroupStudentMapper> classGroupStudentMapperPage = new Page(classGroupReq.getPageNo(), classGroupReq.getPageSize());
         return baseMapper.selectPageByCondition(classGroupStudentMapperPage, classGroupReq);
     }
+
+    @Override
+    public PageResponse getPageByTeacher(TeacherReq teacherReq) {
+        if (Objects.isNull(teacherReq.getUserId())) {
+            return PageResponse.errorParam();
+        }
+        //判断当前登录人角色
+        Teacher teacher = teacherService.getById(teacherReq.getUserId());
+        if (Objects.nonNull(teacher)) {
+            //教学主管
+            QueryWrapper<MusicGroup> musicGroupQueryWrapper = new QueryWrapper<>();
+            if (JobTypeEnum.TEACHING.getCode().equals(teacher.getJobType())) {
+                musicGroupQueryWrapper.lambda().eq(MusicGroup::getOrganId, teacher.getOrganId())
+                        .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());
+            }
+            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()));
+                List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
+                if (!CollectionUtils.isEmpty(classGroupList)) {
+                    return PageResponse.success(getPage(classGroupList, teacherReq, musicGroupList));
+                }
+            }
+            //指导老师 助教老师
+            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());
+            } else if (JobTypeEnum.ASSISTANT.getCode().equals(teacher.getJobType())) {
+                classGroupTeacherMapperQueryWrapper.lambda().eq(ClassGroupTeacherMapper::getTeacherRole, TeachTypeEnum.TEACHING.getCode())
+                        .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()));
+                List<ClassGroup> classGroupList = classGroupService.list(classGroupQueryWrapper);
+                if (!CollectionUtils.isEmpty(classGroupList)) {
+                    musicGroupQueryWrapper.lambda().in(MusicGroup::getId, classGroupList.stream().map(ClassGroup::getMusicGroupId).collect(Collectors.toList()));
+                    musicGroupList = musicGroupService.list(musicGroupQueryWrapper);
+                    return PageResponse.success(getPage(classGroupList, teacherReq, musicGroupList));
+                }
+            }
+        }
+        return PageResponse.noDataExists();
+    }
+
+    private IPage<StudentListResp> getPage(List<ClassGroup> classGroupList, TeacherReq teacherReq, 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()));
+        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()));
+            Page<SysUser> sysUserPage = new Page<>(teacherReq.getPageNo(), teacherReq.getPageSize());
+            IPage<SysUser> page = sysUserService.page(sysUserPage, sysUserQueryWrapper);
+            if (!CollectionUtils.isEmpty(page.getRecords())) {
+                BeanUtils.copyProperties(page, pageResult);
+                List<MusicGroup> finalMusicGroupList = musicGroupList;
+                page.getRecords().forEach(sysUser -> {
+                    StudentListResp studentListResp = new StudentListResp();
+                    studentListResp.setStudentName(sysUser.getRealName());
+                    classGroupStudentMapperList.stream().filter
+                            (classGroupStudentMapper -> classGroupStudentMapper.getUserId().
+                                    equals(sysUser.getId())).findFirst().ifPresent(classGroupStudentMapper -> {
+                        Integer classGroupId = classGroupStudentMapper.getClassGroupId();
+                        classGroupList.stream().filter(classGroup -> classGroup.getId().equals(classGroupId)).
+                                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());
+                            MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeService.getOne(musicGroupStudentFeeQueryWrapper);
+                            if (Objects.nonNull(musicGroupStudentFee)) {
+                                studentListResp.setStudentAttendance("连续旷课" + musicGroupStudentFee.getContinuousAbsenteeismTimes() + "次");
+                            }
+                            List<Subject> subjectList = subjectService.getSubjectList(classGroup.getSubjectIdList());
+                            if (!CollectionUtils.isEmpty(subjectList)) {
+                                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()));
+                        });
+                    });
+                    resultList.add(studentListResp);
+                });
+            }
+        }
+        pageResult.setRecords(resultList);
+        return pageResult;
+    }
 }

+ 17 - 9
mec-education/src/main/java/com/ym/mec/education/service/impl/TeacherLeaveRecordServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.education.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -55,6 +56,7 @@ public class TeacherLeaveRecordServiceImpl extends ServiceImpl<TeacherLeaveRecor
         IPage<TeacherLeaveRecord> page = page(teacherLeaveRecordPage, recordQueryWrapper);
         Page<TeacherLeaveRecordResp> pageResult = new Page();
         List<TeacherLeaveRecordResp> list = Lists.newArrayList();
+        List<TeacherLeaveRecordResp.AdjustCourse> adjustCourseList = Lists.newArrayList();
         if (!CollectionUtils.isEmpty(page.getRecords())) {
             page.getRecords().forEach(item -> {
                 TeacherLeaveRecordResp teacherLeaveRecordResp = new TeacherLeaveRecordResp();
@@ -73,15 +75,21 @@ public class TeacherLeaveRecordServiceImpl extends ServiceImpl<TeacherLeaveRecor
                 //解析课程调整json
                 try {
                     if (StringUtils.isNotBlank(item.getCoursesScheduleJson())) {
-                        JSONObject coursesSchedule = JSON.parseObject(item.getCoursesScheduleJson());
-                        JSONObject before = coursesSchedule.getJSONObject("before");
-                        teacherLeaveRecordResp.setClassDate(before.getString("classDate").substring(5) + " " +
-                                before.getString("startClassTime").substring(0, before.getString("startClassTime").length() - 3));
-                        JSONObject after = coursesSchedule.getJSONObject("after");
-                        teacherLeaveRecordResp.setClassAdjustDate(after.getString("classDate").substring(5) + " " +
-                                before.getString("startClassTime").substring(0, before.getString("startClassTime").length() - 3));
-                        teacherLeaveRecordResp.setCourseType(CourseSchedule.CourseScheduleType.getMsgByCode(before.getString("type")));
-                        teacherLeaveRecordResp.setCourseName(before.getString("name"));
+                        JSONArray courseScheduleArray = JSON.parseArray(item.getCoursesScheduleJson());
+                        courseScheduleArray.forEach(courseSchedule ->{
+                            JSONObject coursesSchedule = (JSONObject)courseSchedule;
+                            TeacherLeaveRecordResp.AdjustCourse adjustCourse = new TeacherLeaveRecordResp.AdjustCourse();
+                            JSONObject before = coursesSchedule.getJSONObject("before");
+                            adjustCourse.setClassDate(before.getString("classDate").substring(5) + " " +
+                                    before.getString("startClassTime").substring(0, before.getString("startClassTime").length() - 3));
+                            JSONObject after = coursesSchedule.getJSONObject("after");
+                            adjustCourse.setClassAdjustDate(after.getString("classDate").substring(5) + " " +
+                                    before.getString("startClassTime").substring(0, before.getString("startClassTime").length() - 3));
+                            adjustCourse.setCourseType(CourseSchedule.CourseScheduleType.getMsgByCode(before.getString("type")));
+                            adjustCourse.setCourseName(before.getString("name"));
+                            adjustCourseList.add(adjustCourse);
+                        });
+                        teacherLeaveRecordResp.setAdjustCourseList(adjustCourseList);
                     }
                 } catch (Exception e) {
                     log.error("老师请假记录中解析课程json出现异常 {}", e.getMessage(), e);

+ 1 - 8
mec-education/src/main/resources/mapper/TeacherAttendanceMapper.xml

@@ -36,14 +36,7 @@
         where
         teacher_attendance.teacher_id_ = #{query.teacherId}
         <if test="query.courseType != null and query.courseType != ''">
-            <!--VIP课-->
-            <if test="query.courseType == 'VIP'">
-                and course_schedule.type_ = 'VIP'
-            </if>
-            <!--乐团课-->
-            <if test="query.courseType == 'GROUP'">
-                and course_schedule.type_ not in ('ENLIGHTENMENT', 'TRAINING')
-            </if>
+            and course_schedule.type_ = #{query.courseType}
         </if>
     </select>
 </mapper>