|
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
|
|
|
+import com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto;
|
|
|
import com.ym.mec.biz.dal.dto.CourseTimeDto;
|
|
|
+import com.ym.mec.biz.dal.dto.GroupCourseTimesDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.service.CourseScheduleService;
|
|
@@ -17,9 +19,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup> implements CoursesGroupService {
|
|
@@ -44,6 +48,10 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
@Autowired
|
|
|
private TeacherAttendanceDao teacherAttendanceDao;
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, CoursesGroup> getDAO() {
|
|
@@ -171,4 +179,49 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
|
|
|
courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CourseGroupTeacherCardDto> findTeacherCourseGroups(Integer teacherId) {
|
|
|
+ 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));
|
|
|
+
|
|
|
+ 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,","));
|
|
|
+ }
|
|
|
+ groupCards.add(groupCard);
|
|
|
+ }
|
|
|
+ return groupCards;
|
|
|
+ }
|
|
|
}
|