zouxuan пре 10 месеци
родитељ
комит
2ac49dbf3e

+ 4 - 6
mec-application/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java

@@ -3,6 +3,7 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.wrapper.StudentWrapper;
 import com.ym.mec.biz.service.ClassGroupStudentMapperService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -12,10 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.io.IOException;
@@ -44,8 +42,8 @@ public class ClassGroupStudentController extends BaseController {
     @PostMapping("/findAllStudent")
     @PreAuthorize("@pcs.hasPermissions('classGroupStudent/findAllStudent')")
     @ApiImplicitParams({@ApiImplicitParam(name = "classGroupId", value = "班级id", required = true, dataType = "int")})
-    public HttpResponseResult<List<StudentRegistration>> findAllStudent(Integer classGroupId) throws Exception {
-        return succeed(classGroupStudentMapperService.findClassStudentList(classGroupId, ClassGroupStudentStatusEnum.NORMAL));
+    public HttpResponseResult<List<StudentWrapper.ClassStudentDto>> findAllStudent(@RequestBody StudentWrapper.ClassStudentQuery query) throws Exception {
+        return succeed(classGroupStudentMapperService.findAllStudent(query));
     }
 
     @ApiOperation(value = "调整班级(小班课)")

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -6,6 +6,7 @@ import java.util.Map;
 import java.util.Set;
 
 import com.ym.mec.biz.dal.wrapper.LiveGroupWrapper;
+import com.ym.mec.biz.dal.wrapper.StudentWrapper;
 import org.apache.ibatis.annotations.Param;
 
 import com.ym.mec.biz.dal.dto.BaseMapDto;
@@ -230,6 +231,8 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      */
     List<StudentRegistration> findClassStudentList(@Param("classGroupId") Integer classGroupId, @Param("status") ClassGroupStudentStatusEnum status);
 
+    List<StudentWrapper.ClassStudentDto> findAllStudent(@Param("query") StudentWrapper.ClassStudentQuery query);
+
     /**
      * 查询学生是否已报小班课
      *

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
+import com.ym.mec.biz.dal.wrapper.StudentWrapper;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -102,4 +103,8 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
     void delByIds(@Param("courseDetailIds") List<Long> courseDetailIds);
 
     List<MusicGroupPaymentStudentCourseDetail> findByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
+
+    List<StudentWrapper.ClassStudentDto> findStudentCourseDetail(@Param("musicGroupId") String musicGroupId,
+                                                                 @Param("studentIds") List<Integer> studentIds,
+                                                                 @Param("query") StudentWrapper.ClassStudentQuery query);
 }

+ 73 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/StudentWrapper.java

@@ -2,10 +2,8 @@ package com.ym.mec.biz.dal.wrapper;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
-import com.ym.mec.biz.dal.enums.EInGroupStatus;
-import com.ym.mec.biz.dal.enums.ELessonTrainingType;
-import com.ym.mec.biz.dal.enums.StandardEnum;
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.enums.*;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
@@ -13,6 +11,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -228,6 +227,76 @@ public class StudentWrapper {
 
         @ApiModelProperty(value = "合作机构ID")
         private Integer cooperationOrganId;
+    }
+
+    @Data
+    @ApiModel("班级在读学员列表")
+    public static class ClassStudentQuery {
+
+        @ApiModelProperty(value = "班级编号", required = false)
+        private Integer classGroupId;
+
+        @ApiModelProperty(value = "模糊匹配", required = false)
+        private String search;
+
+        @ApiModelProperty(value = "声部", required = false)
+        private Integer subjectId;
+
+        @ApiModelProperty(value = "有剩余时长的课程类型,(classroom,comprehensive,high,high_online,mix,single,training_mix,training_single,no_course)", required = false)
+        private String courseType;
+
+        @ApiModelProperty(value = "排序字段", required = false)
+        private String sortField;
+
+        @ApiModelProperty(value = "排序方式,ASC,DESC", required = false)
+        private String sortType;
+
+    }
+
+    @Data
+    @ApiModel("班级在读学员列表")
+    public static class ClassStudentDto {
+
+        @ApiModelProperty(value = "学生编号", required = false)
+        private Integer userId;
+
+        @ApiModelProperty(value = "学生姓名", required = false)
+        private String name;
+
+        @ApiModelProperty(value = "性别(0,女  1,男", required = false)
+        private Integer gender;
+
+        @ApiModelProperty(value = "实际科目名称", required = false)
+        private String subjectName;
+
+        @ApiModelProperty(value = "家长电话", required = false)
+        private String parentsPhone;
+
+        @ApiModelProperty(value = "乐团编号", required = false)
+        private String musicGroupId;
+
+        @ApiModelProperty(value = "声部课剩余时长", required = false)
+        private Integer single;
+
+        @ApiModelProperty(value = "合奏课剩余时长", required = false)
+        private Integer mix;
+
+        @ApiModelProperty(value = "课堂课剩余时长", required = false)
+        private Integer classroom;
+
+        @ApiModelProperty(value = "综合课剩余时长", required = false)
+        private Integer comprehensive;
+
+        @ApiModelProperty(value = "基础技能课剩余时长", required = false)
+        private Integer high;
+
+        @ApiModelProperty(value = "线上基础技能课剩余时长", required = false)
+        private Integer highOnline;
+
+        @ApiModelProperty(value = "集训声部课剩余时长", required = false)
+        private Integer trainingSingle;
 
+        @ApiModelProperty(value = "集训合奏课剩余时长", required = false)
+        private Integer trainingMix;
     }
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.wrapper.StudentWrapper;
 import com.ym.mec.common.service.BaseService;
 
 import java.io.IOException;
@@ -42,7 +43,7 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      * @param status
      * @return
      */
-    List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status);
+    List<StudentWrapper.ClassStudentDto> findAllStudent(StudentWrapper.ClassStudentQuery query);
 
     /**
      * 调整班级

+ 46 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -3,8 +3,10 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto;
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.wrapper.StudentWrapper;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
@@ -15,7 +17,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
+import javax.annotation.Resource;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
@@ -24,42 +28,42 @@ import java.util.stream.Collectors;
 @Service
 public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
 
-    @Autowired
+    @Resource
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
-    @Autowired
+    @Resource
     private CourseScheduleService courseScheduleService;
-    @Autowired
+    @Resource
     private StudentRegistrationService studentRegistrationService;
-    @Autowired
+    @Resource
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
-    @Autowired
+    @Resource
     private ClassGroupService classGroupService;
-    @Autowired
+    @Resource
     private ClassGroupRelationService classGroupRelationService;
-    @Autowired
+    @Resource
     private ImGroupMemberService imGroupMemberService;
-    @Autowired
+    @Resource
     private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
-    @Autowired
+    @Resource
     private ClassGroupTeacherMapperService classGroupTeacherMapperService;
-    @Autowired
+    @Resource
     private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
-    @Autowired
+    @Resource
     private TeacherDefaultMusicGroupSalaryService teacherDefaultMusicGroupSalaryService;
-    @Autowired
+    @Resource
     private StudentDao studentDao;
-    @Autowired
+    @Resource
     private CourseScheduleDao courseScheduleDao;
-    @Autowired
+    @Resource
     private ClassGroupDao classGroupDao;
-    @Autowired
+    @Resource
     private MusicGroupDao musicGroupDao;
-
-    @Autowired
+    @Resource
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
-
-    @Autowired
+    @Resource
     private ImUserFriendService imUserFriendService;
+    @Resource
+    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 
     private static String holidayUrl = "http://tool.bitefu.net/jiari/?d=";
 
@@ -197,8 +201,29 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     }
 
     @Override
-    public List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status) {
-        return classGroupStudentMapperDao.findClassStudentList(classGroupId, status);
+    public List<StudentWrapper.ClassStudentDto> findAllStudent(StudentWrapper.ClassStudentQuery query) {
+        List<StudentWrapper.ClassStudentDto> studentDtos = classGroupStudentMapperDao.findAllStudent(query);
+        if(CollectionUtils.isEmpty(studentDtos)){
+            return studentDtos;
+        }
+        //获取乐团学员剩余排课时长
+        String musicGroupId = studentDtos.get(0).getMusicGroupId();
+        List<Integer> studentIds = studentDtos.stream().map(StudentWrapper.ClassStudentDto::getUserId).collect(Collectors.toList());
+        List<StudentWrapper.ClassStudentDto> studentCourseDetails =
+                musicGroupPaymentStudentCourseDetailDao.findStudentCourseDetail(musicGroupId, studentIds,query);
+        if (CollectionUtils.isEmpty(studentCourseDetails)){
+            return new ArrayList<>();
+        }
+        Map<Integer,StudentWrapper.ClassStudentDto> studentDtoMap = studentDtos.stream()
+                .collect(Collectors.toMap(StudentWrapper.ClassStudentDto::getUserId, s -> s, (s1, s2) -> s1));
+        for (StudentWrapper.ClassStudentDto studentCourseDetail : studentCourseDetails) {
+            StudentWrapper.ClassStudentDto classStudentDto = studentDtoMap.get(studentCourseDetail.getUserId());
+            studentCourseDetail.setName(classStudentDto.getName());
+            studentCourseDetail.setGender(classStudentDto.getGender());
+            studentCourseDetail.setSubjectName(classStudentDto.getSubjectName());
+            studentCourseDetail.setParentsPhone(classStudentDto.getParentsPhone());
+        }
+        return classGroupStudentMapperDao.findAllStudent(query);
     }
 
     @Override

+ 16 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -305,6 +305,22 @@
         AND cgsm.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
 
+    <select id="findAllStudent" resultType="com.ym.mec.biz.dal.wrapper.StudentWrapper$ClassStudentDto">
+        SELECT sr.user_id_ userId,sr.name_ name,sr.parents_phone_ parentsPhone,
+               s.subject_name_ subjectName,su.gender_ gender,sr.music_group_id_ musicGroupId
+        FROM class_group_student_mapper cgsm
+        LEFT JOIN student_registration sr ON (sr.user_id_ = cgsm.user_id_ AND sr.music_group_id_ = cgsm.music_group_id_)
+        LEFT JOIN sys_user su on sr.user_id_ = su.id_
+        LEFT JOIN subject s ON sr.actual_subject_id_ = s.id_
+        WHERE cgsm.class_group_id_ = #{query.classGroupId} AND sr.music_group_status_ != 'QUIT' AND cgsm.status_ = 'NORMAL'
+        <if test="query.subjectId != null">
+            AND sr.actual_subject_id_ = #{query.subjectId}
+        </if>
+        <if test="query.search != null and query.search != ''">
+            AND (sr.name_ LIKE CONCAT('%',#{search},'%') OR sr.parents_phone_ LIKE CONCAT('%',#{search},'%'))
+        </if>
+    </select>
+
     <select id="findHighClassGroupHasUser" resultMap="ClassGroupStudentMapper">
         SELECT cgsm.* FROM class_group_student_mapper cgsm
         LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_

+ 29 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -362,6 +362,35 @@
             #{studentId}
         </foreach>)c
     </select>
+    <select id="findStudentCourseDetail"
+            resultType="com.ym.mec.biz.dal.wrapper.StudentWrapper$ClassStudentDto">
+        select
+         mgpscd.user_id_ userId,
+         SUM(CASE WHEN mgpscd.course_type_ = 'CLASSROOM' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'classroom'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'COMPREHENSIVE' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'comprehensive'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'HIGH' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'high'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'HIGH_ONLINE' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'highOnline'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'MIX' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'mix'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'SINGLE' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'single'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'TRAINING_MIX' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'trainingMix'
+        ,SUM(CASE WHEN mgpscd.course_type_ = 'TRAINING_SINGLE' THEN mgpscd.total_course_minutes_ ELSE 0 END) AS 'trainingSingle'
+        from music_group_payment_student_course_detail mgpscd
+        where mgpscd.music_group_id_ = #{musicGroupId}
+        and mgpscd.user_id_ IN
+        <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
+            #{studentId}
+        </foreach>
+        <if test="query.courseType != null and query.courseType == 'no_course'">
+            and mgpscd.sub_course_minutes_ = 0
+        </if>
+        group by user_id_
+        <if test="query.courseType != null and query.courseType != '' and query.courseType != 'no_course'">
+            HAVING ${query.courseType} > 0
+        </if>
+        <if test="query.sortField != null">
+            order by ${query.sortField} ${query.sortType}
+        </if>
+    </select>
 
     <update id="clearRemainCourseMinutesByMusicGroupId">
     	update music_group_payment_student_course_detail set sub_course_minutes_ = 0 WHERE sub_course_minutes_ > 0 and music_group_id_ = #{musicGroupId}