Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

Joburgess 4 vuotta sitten
vanhempi
commit
e763df3d16

+ 29 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.common.dal.BaseDAO;
@@ -12,11 +14,11 @@ import org.apache.ibatis.annotations.Param;
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 
     /**
+     * @param musicGroupPaymentStudentCourseDetails:
+     * @return int
      * @describe 批量更新
      * @author qnc99
      * @date 2020/12/1 0001
-     * @param musicGroupPaymentStudentCourseDetails:
-     * @return int
      */
     int batchUpdate(@Param("paymentCourseDetails") List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails);
 
@@ -30,8 +32,8 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @date 2020.11.04
      */
     List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("batchNo") String batchNo,
-                                                                                          @Param("studentId") Integer studentId,
-                                                                                          @Param("courseType") CourseSchedule.CourseScheduleType courseType);
+                                                                                                @Param("studentId") Integer studentId,
+                                                                                                @Param("courseType") CourseSchedule.CourseScheduleType courseType);
 
     /**
      * @param studentId:
@@ -59,14 +61,16 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
 
     /**
      * 删除用户购买乐团课程记录
+     *
      * @param userId
      * @param musicGroupId
      * @return
      */
     int deleteByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
-    
+
     /**
      * 根据缴费编号删除信息
+     *
      * @param musicGroupPaymentCalenderId
      * @return
      */
@@ -74,15 +78,34 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
 
     /**
      * 删除信息
+     *
      * @param musicGroupPaymentCalenderDetailIdList
      * @return
      */
     int deleteByMusicGroupPaymentCalenderDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
-    
+
     /**
      * 查询对象
+     *
      * @param musicGroupPaymentCalenderDetailIdList
      * @return
      */
     List<MusicGroupPaymentStudentCourseDetail> queryByMusicGroupPaymentStudentCourseDetailId(List<Long> musicGroupPaymentCalenderDetailIdList);
+
+    /**
+     * 获取乐团学员剩余可排课时长
+     *
+     * @param studentIds
+     * @return
+     */
+    List<Map<Integer, Integer>> queryStudentSubTotalCourseTime(@Param("studentIds") Set<Integer> studentIds, @Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 获取学员关联的每种课程类型的剩余可排课时长
+     *
+     * @param userId
+     * @param musicGroupId
+     * @return
+     */
+    List<Map<Integer, Integer>> queryStudentSubTotalCourseTimes(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

+ 16 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentManageDao.java

@@ -283,16 +283,28 @@ public interface StudentManageDao {
     /**
      * 获取教务老师关联vip的学员列表
      *
-     * @param groupType
      * @return
      */
-    List<BasicUserDto> queryVipGroupStudents(@Param("userId") Integer userId);
+    List<BasicUserDto> queryVipGroupStudents(Map<String, Object> params);
+
+    /**
+     * 获取教务老师关联vip的学员列表
+     *
+     * @return
+     */
+    int countVipGroupStudents(Map<String, Object> params);
+
+    /**
+     * 获取教务老师关联网管课的学员列表
+     *
+     * @return
+     */
+    List<BasicUserDto> queryPracticeGroupStudents(Map<String, Object> params);
 
     /**
      * 获取教务老师关联网管课的学员列表
      *
-     * @param groupType
      * @return
      */
-    List<BasicUserDto> queryPracticeGroupStudents(@Param("userId") Integer userId);
+    int countPracticeGroupStudents(Map<String, Object> params);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupStudentsDto.java

@@ -63,6 +63,16 @@ public class MusicGroupStudentsDto{
     private String isNewStudentStr;
 
     private String nextPaymentDateStr;
+    @ApiModelProperty(value = "剩余可排课时长",required = false)
+    private Integer subTotalCourseTime;
+
+    public Integer getSubTotalCourseTime() {
+        return subTotalCourseTime;
+    }
+
+    public void setSubTotalCourseTime(Integer subTotalCourseTime) {
+        this.subTotalCourseTime = subTotalCourseTime;
+    }
 
     public String getPaymentPeriodList() {
         return paymentPeriodList;

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentQueryInfo.java

@@ -10,8 +10,28 @@ import java.util.List;
  */
 public class StudentQueryInfo extends QueryInfo {
 
+    private String groupType;
+
+    private Integer userId;
+
     private List<String> organIdList;
 
+    public String getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(String groupType) {
+        this.groupType = groupType;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
     public List<String> getOrganIdList() {
         return organIdList;
     }

+ 10 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/StudentManageService.java

@@ -6,15 +6,9 @@ import java.util.Map;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.Student;
-import com.ym.mec.biz.dal.page.MusicGroupStudentQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageAttendanceQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageCourseQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageVipClassQueryInfo;
-import com.ym.mec.biz.dal.page.StudentOperatingQueryInfo;
-import com.ym.mec.biz.dal.page.StudentSignQueryInfo;
-import com.ym.mec.biz.dal.page.TeacherPaymentRecordInfo;
+import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 
 /**
  * @Author Joburgess
@@ -200,5 +194,12 @@ public interface StudentManageService {
      * @param groupType
      * @return
      */
-    List<BasicUserDto> queryGroupStudents(String groupType);
+    PageInfo<BasicUserDto> queryGroupStudents(StudentQueryInfo groupType);
+
+    /**
+     * 乐团管理--乐团详情--学员列表--获取学员可排课时长
+     * @param userId
+     * @return
+     */
+    Map<Integer, Integer> queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId);
 }

+ 33 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -8,8 +8,10 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
+import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.SysConfigService;
 
+import com.ym.mec.common.page.QueryInfo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -40,14 +42,6 @@ import com.ym.mec.biz.dal.entity.SubjectChange;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
-import com.ym.mec.biz.dal.page.MusicGroupStudentQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageAttendanceQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageCourseQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageQueryInfo;
-import com.ym.mec.biz.dal.page.StudentManageVipClassQueryInfo;
-import com.ym.mec.biz.dal.page.StudentOperatingQueryInfo;
-import com.ym.mec.biz.dal.page.StudentSignQueryInfo;
-import com.ym.mec.biz.dal.page.TeacherPaymentRecordInfo;
 import com.ym.mec.biz.service.StudentManageService;
 import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -68,7 +62,7 @@ public class StudentManageServiceImpl implements StudentManageService {
     @Autowired
     private StudentManageDao studentManageDao;
     @Autowired
-    private OrganizationDao organizationDao;
+    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
     @Autowired
     private CourseScheduleStudentPaymentDao scheduleStudentPaymentDao;
     @Autowired
@@ -416,18 +410,8 @@ public class StudentManageServiceImpl implements StudentManageService {
         PageInfo<MusicGroupStudentsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
-//        if(StringUtils.isNotEmpty(queryInfo.getPaymentStatus())){
-//            List<Integer> userIds;
-//            if("NON_PAYMENT".equals(queryInfo.getPaymentStatus())){
-//                userIds = musicGroupPaymentCalenderDao.queryUserByNoPayment(queryInfo.getClassGroupId());
-//            }else {
-//                userIds = musicGroupPaymentCalenderDao.queryUserByPayment(queryInfo.getClassGroupId());
-//            }
-//            if(userIds != null && userIds.size() > 0){
-//                params.put("userIds",userIds);
-//            }
-//        }
         List<MusicGroupStudentsDto> dataList = null;
+        String musicGroupId = queryInfo.getMusicGroupId();
         int count = studentManageDao.countMusicGroupStudent(params);
         if (queryInfo.getIsExport() && count > 50000) {
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
@@ -438,25 +422,18 @@ public class StudentManageServiceImpl implements StudentManageService {
             dataList = studentManageDao.queryMusicGroupStudent(params);
             //退团的学生
             List<Integer> quitUserIds = dataList.stream().filter(e -> e.getStudentStatus().equals("QUIT")).map(MusicGroupStudentsDto::getUserId).collect(Collectors.toList());
-
+            Set<Integer> studentIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+            Map<Integer,Integer> subTotalCourseTimeMap = MapUtil.convertIntegerMap(musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTime(studentIds,musicGroupId));
             if (quitUserIds.size() > 0) {
                 List<MusicGroupQuit> quits = musicGroupQuitDao.getQuits(queryInfo.getMusicGroupId(), quitUserIds);
                 for (MusicGroupStudentsDto musicGroupStudentsDto : dataList) {
+                    musicGroupStudentsDto.setSubTotalCourseTime(subTotalCourseTimeMap.get(musicGroupStudentsDto.getUserId()));
                     for (MusicGroupQuit quit : quits) {
                         if (!quit.getUserId().equals(musicGroupStudentsDto.getUserId())) continue;
                         musicGroupStudentsDto.setQuitReason(quit.getReason());
                     }
                 }
             }
-//            Map<Integer,String> maps = MapUtil.convertIntegerMap(musicGroupStudentFeeDao.findPaymentStatusMap(queryInfo.getMusicGroupId()));
-//            dataList.forEach(e->{
-//                e.setPaymentStatus(maps.get(e.getUserId()));
-//            Set<Integer> collect = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-//            Map<Integer,String> paymentStatusMap = MapUtil.convertIntegerMap(
-//                    musicGroupPaymentCalenderDao.queryUserCoursePaymentStatus(collect,queryInfo.getMusicGroupId()));
-//            dataList.forEach(e -> {
-//                e.setPaymentStatus(paymentStatusMap.get(e.getUserId()));
-//            });
         }
         if (count == 0) {
             dataList = new ArrayList<>();
@@ -689,15 +666,37 @@ public class StudentManageServiceImpl implements StudentManageService {
     }
 
     @Override
-    public List<BasicUserDto> queryGroupStudents(String groupType) {
+    public PageInfo<BasicUserDto> queryGroupStudents(StudentQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null || sysUser.getId() == null){
             throw new BizException("用户信息获取失败");
         }
-        if("VIP".equals(groupType)){
-            return studentManageDao.queryVipGroupStudents(sysUser.getId());
+        PageInfo<BasicUserDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        queryInfo.setUserId(sysUser.getId());
+        MapUtil.populateMap(params, queryInfo);
+        params.put("offset", pageInfo.getOffset());
+        Integer count = 0;
+        if("VIP".equals(queryInfo.getGroupType())){
+            count = studentManageDao.countVipGroupStudents(params);
         }else {
-            return studentManageDao.queryPracticeGroupStudents(sysUser.getId());
+            count = studentManageDao.countPracticeGroupStudents(params);
         }
+        List<BasicUserDto> dataList = new ArrayList<>();
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            if("VIP".equals(queryInfo.getGroupType())){
+                dataList = studentManageDao.queryVipGroupStudents(params);
+            }else {
+                dataList = studentManageDao.queryPracticeGroupStudents(params);
+            }
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    public Map<Integer, Integer> queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId) {
+        return MapUtil.convertIntegerMap(musicGroupPaymentStudentCourseDetailDao.queryStudentSubTotalCourseTimes(userId,musicGroupId));
     }
 }

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

@@ -225,4 +225,21 @@
             WHERE music_group_id_ = #{musicGroupId}
         )
     </delete>
+
+    <select id="queryStudentSubTotalCourseTime" resultType="java.util.Map">
+        SELECT mgpscd.user_id_ 'key',SUM(mgpscd.total_course_minutes_) 'value' FROM music_group_payment_student_course_detail mgpscd
+        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
+        WHERE mgpscd.used_course_minutes_ = 0 AND mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.user_id_ IN
+        <foreach collection="studentIds" open="(" close=")" item="item" separator=",">
+            #{item}
+        </foreach>
+        GROUP BY mgpscd.user_id_
+    </select>
+
+    <select id="queryStudentSubTotalCourseTimes" resultType="java.util.Map">
+        SELECT mgpscd.course_type_ 'key',SUM(mgpscd.total_course_minutes_) 'value' FROM music_group_payment_student_course_detail mgpscd
+        LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
+        WHERE mgpscd.used_course_minutes_ = 0 AND mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.user_id_ = #{userId}
+        GROUP BY mgpscd.course_type_
+    </select>
 </mapper>

+ 20 - 0
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -822,6 +822,7 @@
         AND vg.educational_teacher_id_ = #{userId}
         AND vg.group_status_ IN (0,1,2,5)
         GROUP BY cgsm.user_id_
+        <include refid="global.limit"/>
     </select>
 
     <select id="queryPracticeGroupStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
@@ -833,5 +834,24 @@
         AND pg.educational_teacher_id_ = #{userId}
         AND pg.group_status_ NOT IN ('FINISH','CANCEL')
         GROUP BY cgsm.user_id_
+        <include refid="global.limit"/>
+    </select>
+
+    <select id="countVipGroupStudents" resultType="int">
+        SELECT COUNT(DISTINCT cgsm.user_id_) FROM
+        vip_group vg
+        LEFT JOIN class_group_student_mapper cgsm ON vg.id_ = cgsm.music_group_id_
+        WHERE cgsm.group_type_ = 'VIP' AND cgsm.status_ != 'QUIT'
+        AND vg.educational_teacher_id_ = #{userId}
+        AND vg.group_status_ IN (0,1,2,5)
+    </select>
+
+    <select id="countPracticeGroupStudents" resultType="int">
+        SELECT COUNT(DISTINCT cgsm.user_id_) FROM
+        practice_group pg
+        LEFT JOIN class_group_student_mapper cgsm ON pg.id_ = cgsm.music_group_id_
+        WHERE cgsm.group_type_ = 'PRACTICE' AND cgsm.status_ != 'QUIT'
+        AND pg.educational_teacher_id_ = #{userId}
+        AND pg.group_status_ NOT IN ('FINISH','CANCEL')
     </select>
 </mapper>

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentManageController.java

@@ -121,6 +121,13 @@ public class StudentManageController extends BaseController {
         return succeed(studentManageService.queryMusicGroupStudent(queryInfo));
     }
 
+    @ApiOperation(value = "乐团管理--乐团详情--学员列表--获取学员可排课时长")
+    @GetMapping("/queryStudentSubTotalCourseTimes")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/queryStudentSubTotalCourseTimes')")
+    public Object queryStudentSubTotalCourseTimes(Integer userId,String musicGroupId){
+        return succeed(studentManageService.queryStudentSubTotalCourseTimes(userId,musicGroupId));
+    }
+
     @ApiOperation(value = "乐团修改--学员缴费记录--可新增学员列表")
     @GetMapping("/queryCanAddStudent")
     @PreAuthorize("@pcs.hasPermissions('studentManage/queryCanAddStudent')")

+ 4 - 2
mec-web/src/main/java/com/ym/mec/web/controller/education/EduStudentStudentController.java

@@ -1,6 +1,8 @@
 package com.ym.mec.web.controller.education;
 
+import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.biz.service.StudentManageService;
+import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.ApiOperation;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,8 +43,8 @@ public class EduStudentStudentController extends BaseController {
 
     @ApiOperation(value = "教务老师关联的学员列表")
     @GetMapping("studentManage/queryGroupStudents")
-    public Object queryGroupStudents(String groupType){
-        return succeed(studentManageService.queryGroupStudents(groupType));
+    public Object queryGroupStudents(StudentQueryInfo queryInfo){
+        return succeed(studentManageService.queryGroupStudents(queryInfo));
     }
 
 }