|
@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.*;
|
|
|
import com.ym.mec.biz.dal.school.dto.ClassesForDayDto;
|
|
|
+import com.ym.mec.biz.dal.school.dto.CourseStudentDto;
|
|
|
import com.ym.mec.biz.dal.school.dto.DailySummaryOfClassesForTheCurrentSemesterDto;
|
|
|
import com.ym.mec.biz.dal.school.dto.SummaryOfCurrentSemesterCoursesDto;
|
|
|
import com.ym.mec.biz.event.source.CourseEventSource;
|
|
@@ -33,6 +34,7 @@ import com.ym.mec.util.date.DateConvertor;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.json.JsonUtil;
|
|
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.ListUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -45,17 +47,14 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.Duration;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.LocalTime;
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.IsoFields;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -5996,30 +5995,121 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SummaryOfCurrentSemesterCoursesDto> getSummaryOfCurrentSemesterCourses(Integer schoolId) {
|
|
|
+ public List<SummaryOfCurrentSemesterCoursesDto> getSummaryOfCurrentSemesterCourses(Integer coopId) {
|
|
|
+ //获取合作单位关联的所有乐团列表
|
|
|
+ List<String> musicGroupIds = musicGroupDao.findNormalByCooperationId(coopId);
|
|
|
+ if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
|
+ return Collections.EMPTY_LIST;
|
|
|
+ }
|
|
|
//获取当前学期
|
|
|
Date date = new Date();
|
|
|
String startTerm = DateUtil.getStartTerm(date);
|
|
|
String endTerm = DateUtil.getEndTerm(date);
|
|
|
- return null;
|
|
|
+ return courseScheduleDao.getSummaryOfCurrentSemesterCourses(musicGroupIds,startTerm,endTerm);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DailySummaryOfClassesForTheCurrentSemesterDto> getDailySummaryOfClassesForTheCurrentSemester(Integer schoolId) {
|
|
|
+ public Map<Integer, List<DailySummaryOfClassesForTheCurrentSemesterDto>> getDailySummaryOfClassesForTheCurrentSemester(Integer coopId) {
|
|
|
+ //获取合作单位关联的所有乐团列表
|
|
|
+ List<String> musicGroupIds = musicGroupDao.findNormalByCooperationId(coopId);
|
|
|
//获取当前学期
|
|
|
Date date = new Date();
|
|
|
String startTerm = DateUtil.getStartTerm(date);
|
|
|
String endTerm = DateUtil.getEndTerm(date);
|
|
|
- return null;
|
|
|
+ List<DailySummaryOfClassesForTheCurrentSemesterDto> summary;
|
|
|
+ if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
|
+ summary = new ArrayList<>();
|
|
|
+ }else {
|
|
|
+ summary = courseScheduleDao.getDailySummaryOfClassesForTheCurrentSemester(musicGroupIds, startTerm, endTerm);
|
|
|
+ }
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtil.ISO_EXPANDED_DATE_FORMAT);
|
|
|
+ LocalDate startDate = LocalDate.parse(startTerm, formatter);
|
|
|
+ LocalDate endDate = LocalDate.parse(endTerm, formatter);
|
|
|
+ Map<Integer, List<DailySummaryOfClassesForTheCurrentSemesterDto>> result = new HashMap<>();
|
|
|
+ LocalDate currentWeekStart = startDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
+ while (!currentWeekStart.isAfter(endDate)) {
|
|
|
+ int currentWeekNumber = currentWeekStart.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
|
|
+ LocalDate currentWeekEnd = currentWeekStart.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
|
|
|
+ List<DailySummaryOfClassesForTheCurrentSemesterDto> currentWeekDates = new ArrayList<>();
|
|
|
+ for (DailySummaryOfClassesForTheCurrentSemesterDto dto : summary) {
|
|
|
+ if (!dto.getCourseDate().isBefore(currentWeekStart) && dto.getCourseDate().isBefore(currentWeekEnd)) {
|
|
|
+ currentWeekDates.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put(currentWeekNumber, currentWeekDates);
|
|
|
+ currentWeekStart = currentWeekEnd.plusDays(1);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ClassesForDayDto> getListClassesForDay(Integer schoolId,String classDate) {
|
|
|
- return null;
|
|
|
+ public List<ClassesForDayDto> getListClassesForDay(Integer coopId,String classDate) {
|
|
|
+ //获取合作单位关联的所有乐团列表
|
|
|
+ List<String> musicGroupIds = musicGroupDao.findNormalByCooperationId(coopId);
|
|
|
+ if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
|
+ return Collections.EMPTY_LIST;
|
|
|
+ }
|
|
|
+ List<ClassesForDayDto> listClassesForDay = courseScheduleDao.getListClassesForDay(musicGroupIds, classDate,null);
|
|
|
+ this.initClasses(listClassesForDay);
|
|
|
+ return listClassesForDay;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ClassesForDayDto getCourseDetail(Long courseId) {
|
|
|
- return null;
|
|
|
+ List<ClassesForDayDto> listClassesForDay = courseScheduleDao.getListClassesForDay(null, null,courseId);
|
|
|
+ this.initClasses(listClassesForDay);
|
|
|
+ return listClassesForDay.get(0);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CourseStudentDto> queryCourseStudentList(Long courseId) {
|
|
|
+ List<CourseStudentDto> courseStudentDtos = studentAttendanceDao.queryCourseStudentList(courseId);
|
|
|
+ if(CollectionUtils.isNotEmpty(courseStudentDtos)){
|
|
|
+ List<Integer> studentIds = courseStudentDtos.stream().map(e -> e.getStudentId()).collect(Collectors.toList());
|
|
|
+ List<SimpleUserDto> usersSimpleInfo = teacherDao.getUsersSimpleInfo(studentIds);
|
|
|
+ Map<Integer, SimpleUserDto> simpleUserDtoMap = usersSimpleInfo.stream().collect(Collectors.groupingBy(e -> e.getUserId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
|
+ for (CourseStudentDto dto : courseStudentDtos) {
|
|
|
+ SimpleUserDto userDto = simpleUserDtoMap.get(dto.getStudentId());
|
|
|
+ if(Objects.nonNull(userDto)){
|
|
|
+ dto.setStudentName(userDto.getUserName());
|
|
|
+ dto.setStudentAvatar(userDto.getAvatar());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return courseStudentDtos;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initClasses(List<ClassesForDayDto> listClassesForDay){
|
|
|
+ if(CollectionUtils.isNotEmpty(listClassesForDay)){
|
|
|
+ Set<String> musicGroupIds = listClassesForDay.stream().map(e -> e.getMusicGroupId()).collect(Collectors.toSet());
|
|
|
+ //获取乐团名称
|
|
|
+ Map<String,String> musicNameMap = MapUtil.convertIntegerMap(musicGroupDao.queryMusicGroupNameMap(musicGroupIds));
|
|
|
+ //获取老师基本信息
|
|
|
+ List<Integer> teacherIds = listClassesForDay.stream().map(e -> e.getTeacherId()).collect(Collectors.toList());
|
|
|
+ List<SimpleUserDto> usersSimpleInfo = teacherDao.getUsersSimpleInfo(teacherIds);
|
|
|
+ Map<Integer, SimpleUserDto> simpleUserDtoMap = usersSimpleInfo.stream().collect(Collectors.groupingBy(e -> e.getUserId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
|
+ //统计考勤信息
|
|
|
+ List<Long> courseIds = listClassesForDay.stream().map(e -> e.getCourseId()).collect(Collectors.toList());
|
|
|
+ List<ClassesForDayDto> dtoList = studentAttendanceDao.statisticalAttendanceInformation(courseIds);
|
|
|
+ Map<Long, ClassesForDayDto> dtoMap = dtoList.stream().collect(Collectors.groupingBy(e -> e.getCourseId(), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
|
|
|
+ for (ClassesForDayDto dto : listClassesForDay) {
|
|
|
+ SimpleUserDto userDto = simpleUserDtoMap.get(dto.getTeacherId());
|
|
|
+ if(Objects.nonNull(userDto)){
|
|
|
+ dto.setTeacherName(userDto.getRealName());
|
|
|
+ dto.setTeacherAvatar(userDto.getAvatar());
|
|
|
+ }
|
|
|
+ dto.setMusicGroupName(musicNameMap.get(dto.getMusicGroupId()));
|
|
|
+ ClassesForDayDto dayDto = dtoMap.get(dto.getCourseId());
|
|
|
+ if(Objects.nonNull(dayDto)){
|
|
|
+ dto.setStudentNum(dayDto.getStudentNum());
|
|
|
+ dto.setAttendanceNormalNum(dayDto.getAttendanceNormalNum());
|
|
|
+ dto.setAttendanceLateNum(dayDto.getAttendanceLateNum());
|
|
|
+ dto.setAttendanceLeaveNum(dayDto.getAttendanceLeaveNum());
|
|
|
+ dto.setAttendanceTruantNum(dayDto.getAttendanceTruantNum());
|
|
|
+ dto.setAttendanceDropNum(dayDto.getAttendanceDropNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|