|
@@ -14,9 +14,12 @@ import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.entity.ImGroupMember;
|
|
|
import com.ym.mec.common.entity.ImGroupModel;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
+import com.ym.mec.common.page.QueryInfo;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.im.ImFeignService;
|
|
|
+import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -211,48 +214,60 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CourseGroupTeacherCardDto> findTeacherCourseGroups(Integer teacherId) {
|
|
|
+ public PageInfo findTeacherCourseGroups(Integer teacherId, QueryInfo queryInfo) {
|
|
|
if(Objects.isNull(teacherId)){
|
|
|
throw new BizException("请指定老师");
|
|
|
}
|
|
|
- List<CoursesGroup> teacherCourseGroups = coursesGroupDao.findTeacherCourseGroups(teacherId);
|
|
|
- if (CollectionUtils.isEmpty(teacherCourseGroups)){
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
- List<String> groupIds = teacherCourseGroups.stream().map(group -> String.valueOf(group.getId())).collect(Collectors.toList());
|
|
|
-
|
|
|
- List<Integer> subjectIds = teacherCourseGroups.stream().map(CoursesGroup::getSubjectId).collect(Collectors.toList());
|
|
|
- List<Subject> subjects = subjectDao.findBySubjectIds(subjectIds);
|
|
|
- Map<Integer, Subject> idSubjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, subject -> subject));
|
|
|
|
|
|
- List<ClassGroupStudentMapper> students = classGroupStudentMapperDao.findByGroups(groupIds, GroupType.COMM);
|
|
|
- Map<String, List<ClassGroupStudentMapper>> groupStudentsMap = students.stream().collect(Collectors.groupingBy(ClassGroupStudentMapper::getMusicGroupId));
|
|
|
-
|
|
|
- List<GroupCourseTimesDto> groupsCourseTimesInfo = courseScheduleDao.findGroupsCourseTimesInfo(groupIds, GroupType.COMM);
|
|
|
- Map<String, GroupCourseTimesDto> groupCourseTimesInfoMap = groupsCourseTimesInfo.stream().collect(Collectors.toMap(GroupCourseTimesDto::getGroupId, e -> e));
|
|
|
+ PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+ params.put("teacherId", teacherId);
|
|
|
|
|
|
List<CourseGroupTeacherCardDto> groupCards=new ArrayList<>();
|
|
|
- for (CoursesGroup teacherCourseGroup : teacherCourseGroups) {
|
|
|
- CourseGroupTeacherCardDto groupCard=new CourseGroupTeacherCardDto();
|
|
|
- groupCard.setId(teacherCourseGroup.getId());
|
|
|
- groupCard.setName(teacherCourseGroup.getName());
|
|
|
- groupCard.setSingleClassMinutes(teacherCourseGroup.getSingleClassMinutes());
|
|
|
- groupCard.setCoursesStartDate(teacherCourseGroup.getCoursesStartDate());
|
|
|
- groupCard.setCoursesEndDate(teacherCourseGroup.getCoursesEndDate());
|
|
|
- groupCard.setSubjectId(teacherCourseGroup.getSubjectId());
|
|
|
- groupCard.setSubjectName(idSubjectMap.get(teacherCourseGroup.getSubjectId()).getName());
|
|
|
- GroupCourseTimesDto groupCourseTimesInfo = groupCourseTimesInfoMap.get(String.valueOf(teacherCourseGroup.getId()));
|
|
|
- groupCard.setTotalCourseTimes(groupCourseTimesInfo.getTotalCourseTimes());
|
|
|
- groupCard.setSurplusClassTimes(groupCourseTimesInfo.getSurplusClassTimes());
|
|
|
- List<ClassGroupStudentMapper> groupStudents = groupStudentsMap.get(String.valueOf(teacherCourseGroup.getId()));
|
|
|
- if(!CollectionUtils.isEmpty(groupStudentsMap)){
|
|
|
- List<String> userNames = groupStudents.stream().map(ClassGroupStudentMapper::getUserName).collect(Collectors.toList());
|
|
|
- groupCard.setStudentNames(StringUtils.join(userNames,","));
|
|
|
+ int count = coursesGroupDao.countTeacherGroups(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ List<CoursesGroup> teacherCourseGroups = coursesGroupDao.findTeacherCourseGroups(params);
|
|
|
+
|
|
|
+ List<String> groupIds = teacherCourseGroups.stream().map(group -> String.valueOf(group.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Integer> subjectIds = teacherCourseGroups.stream().map(CoursesGroup::getSubjectId).collect(Collectors.toList());
|
|
|
+ List<Subject> subjects = subjectDao.findBySubjectIds(subjectIds);
|
|
|
+ Map<Integer, Subject> idSubjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, subject -> subject));
|
|
|
+
|
|
|
+ List<ClassGroupStudentMapper> students = classGroupStudentMapperDao.findByGroups(groupIds, GroupType.COMM);
|
|
|
+ Map<String, List<ClassGroupStudentMapper>> groupStudentsMap = students.stream().collect(Collectors.groupingBy(ClassGroupStudentMapper::getMusicGroupId));
|
|
|
+
|
|
|
+ List<GroupCourseTimesDto> groupsCourseTimesInfo = courseScheduleDao.findGroupsCourseTimesInfo(groupIds, GroupType.COMM);
|
|
|
+ Map<String, GroupCourseTimesDto> groupCourseTimesInfoMap = groupsCourseTimesInfo.stream().collect(Collectors.toMap(GroupCourseTimesDto::getGroupId, e -> e));
|
|
|
+
|
|
|
+ groupCards=new ArrayList<>();
|
|
|
+ for (CoursesGroup teacherCourseGroup : teacherCourseGroups) {
|
|
|
+ CourseGroupTeacherCardDto groupCard=new CourseGroupTeacherCardDto();
|
|
|
+ groupCard.setId(teacherCourseGroup.getId());
|
|
|
+ groupCard.setGroupType(GroupType.COMM);
|
|
|
+ groupCard.setName(teacherCourseGroup.getName());
|
|
|
+ groupCard.setSingleClassMinutes(teacherCourseGroup.getSingleClassMinutes());
|
|
|
+ groupCard.setCoursesStartDate(teacherCourseGroup.getCoursesStartDate());
|
|
|
+ groupCard.setCoursesEndDate(teacherCourseGroup.getCoursesEndDate());
|
|
|
+ groupCard.setSubjectId(teacherCourseGroup.getSubjectId());
|
|
|
+ groupCard.setSubjectName(idSubjectMap.get(teacherCourseGroup.getSubjectId()).getName());
|
|
|
+ GroupCourseTimesDto groupCourseTimesInfo = groupCourseTimesInfoMap.get(String.valueOf(teacherCourseGroup.getId()));
|
|
|
+ groupCard.setTotalCourseTimes(groupCourseTimesInfo.getTotalCourseTimes());
|
|
|
+ groupCard.setSurplusClassTimes(groupCourseTimesInfo.getSurplusClassTimes());
|
|
|
+ groupCard.setCurrentClassTimes(groupCard.getTotalCourseTimes()-groupCard.getSurplusClassTimes());
|
|
|
+ List<ClassGroupStudentMapper> groupStudents = groupStudentsMap.get(String.valueOf(teacherCourseGroup.getId()));
|
|
|
+ if(!CollectionUtils.isEmpty(groupStudents)){
|
|
|
+ List<String> userNames = groupStudents.stream().map(ClassGroupStudentMapper::getUserName).collect(Collectors.toList());
|
|
|
+ groupCard.setStudentNames(StringUtils.join(userNames,","));
|
|
|
+ }
|
|
|
+ groupCards.add(groupCard);
|
|
|
}
|
|
|
- groupCards.add(groupCard);
|
|
|
}
|
|
|
- return groupCards;
|
|
|
+ pageInfo.setRows(groupCards);
|
|
|
+ return pageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|