|
@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
@@ -9,10 +10,13 @@ import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
+import com.ym.mec.biz.dal.mapper.CourseSchedulePlusMapper;
|
|
|
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.dal.wrapper.TeachingPointWrapper;
|
|
|
import com.ym.mec.biz.event.source.CourseEventSource;
|
|
|
import com.ym.mec.biz.event.source.SendSeoMessageSource;
|
|
|
import com.ym.mec.biz.service.*;
|
|
@@ -33,6 +37,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 +50,15 @@ 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.ChronoUnit;
|
|
|
+import java.time.temporal.IsoFields;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -176,6 +179,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
@Autowired
|
|
|
private CourseScheduleConvertDao courseScheduleConvertDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CourseSchedulePlusMapper courseSchedulePlusMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherService teacherService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TeacherAttendanceService teacherAttendanceService;
|
|
|
+
|
|
|
private final Logger LOGGER = LoggerFactory
|
|
|
.getLogger(this.getClass());
|
|
|
|
|
@@ -450,7 +462,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if (type == CourseScheduleType.VIP) {
|
|
|
throw new BizException("暂不支持vip课加课");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(type == CourseSchedule.CourseScheduleType.HIGH){
|
|
|
type = CourseScheduleType.HIGH_ONLINE;
|
|
|
}
|
|
@@ -762,7 +774,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
//基础技能提高课
|
|
|
if(type == CourseScheduleType.HIGH_ONLINE || type == CourseScheduleType.HIGH){
|
|
|
-
|
|
|
+
|
|
|
if(StringUtils.isBlank(tdms.getSalaryRuleJson())){
|
|
|
throw new BizException("线上基础技能课课酬设置异常");
|
|
|
}
|
|
@@ -4113,10 +4125,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if(musicGroup != null){
|
|
|
musicGroup.setFirstCourseStartTime(courseSchedule.getClassDate());
|
|
|
musicGroup.setGroupMemberNum(courseScheduleStudentPaymentDao.countStudentNum(courseSchedule.getId().intValue()));
|
|
|
-
|
|
|
+
|
|
|
musicGroupDao.update(musicGroup);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
musicGroupIdList.add(courseSchedule.getMusicGroupId());
|
|
|
}
|
|
|
}
|
|
@@ -5996,30 +6008,245 @@ 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<String, 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("yyyy-MM-dd");
|
|
|
+ LocalDate startDate = LocalDate.parse(startTerm, formatter);
|
|
|
+ LocalDate endDate = LocalDate.parse(endTerm, formatter);
|
|
|
+ Map<String, List<DailySummaryOfClassesForTheCurrentSemesterDto>> result = new LinkedHashMap<>(30);
|
|
|
+ LocalDate currentWeekStart = startDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
+ StringBuffer sb;
|
|
|
+ while (!currentWeekStart.isAfter(endDate)) {
|
|
|
+ int currentWeekNumber = (int) ChronoUnit.WEEKS.between(startDate, currentWeekStart);
|
|
|
+ sb = new StringBuffer("第").append(toChineseNumber(currentWeekNumber)).append("周");
|
|
|
+ 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(sb.toString(), currentWeekDates);
|
|
|
+ currentWeekStart = currentWeekEnd.plusDays(1);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String toChineseNumber(int n) {
|
|
|
+ String[] chineseNumbers = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八",
|
|
|
+ "十九", "二十", "二十一", "二十二", "二十三", "二十四", "二十五", "二十六", "二十七", "二十八", "二十九", "三十", "三十一", "三十二", "三十三", "三十四",
|
|
|
+ "三十五", "三十六", "三十七", "三十八", "三十九", "四十", "四十一", "四十二", "四十三", "四十四", "四十五", "四十六", "四十七", "四十八", "四十九", "五十"};
|
|
|
+ if (n <= 50) {
|
|
|
+ return chineseNumbers[n];
|
|
|
+ } else {
|
|
|
+ return Integer.toString(n);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询课程信息
|
|
|
+ *
|
|
|
+ * @param queryInfo 查询条件
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public IPage<TeachingPointWrapper.CourseTeachingPoint> teachingPointCourse(TeachingPointWrapper.TeachingPointQuery queryInfo) {
|
|
|
+ IPage<TeachingPointWrapper.CourseTeachingPoint> page = com.microsvc.toolkit.common.response.paging.QueryInfo.getPage(queryInfo);
|
|
|
+ List<TeachingPointWrapper.CourseTeachingPoint> courseTeachingPoints = courseSchedulePlusMapper
|
|
|
+ .teachingPointCourse(page, queryInfo);
|
|
|
+ if (CollectionUtils.isEmpty(courseTeachingPoints)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置老师信息
|
|
|
+
|
|
|
+ // 老师ID集合
|
|
|
+ List<Integer> teacherIds = courseTeachingPoints.stream()
|
|
|
+ .map(TeachingPointWrapper.CourseTeachingPoint::getTeacherId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, Teacher> teacherMap = teacherService.getMapByIds(teacherIds);
|
|
|
+
|
|
|
+ // 设置签到/签退信息
|
|
|
+
|
|
|
+ // 课程ID集合
|
|
|
+ List<Long> courseIds = courseTeachingPoints.stream()
|
|
|
+ .map(TeachingPointWrapper.CourseTeachingPoint::getCourseId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Long, TeacherAttendance> attendanceMap = teacherAttendanceService.getMapByCourseIds(courseIds);
|
|
|
+
|
|
|
+ for (TeachingPointWrapper.CourseTeachingPoint courseTeachingPoint : courseTeachingPoints) {
|
|
|
+
|
|
|
+ // 设置老师信息
|
|
|
+ if (courseTeachingPoint.getTeacherId() != null) {
|
|
|
+ Teacher teacher = teacherMap.get(courseTeachingPoint.getTeacherId());
|
|
|
+ if (teacher != null) {
|
|
|
+ courseTeachingPoint.setTeacherName(teacher.getRealName());
|
|
|
+ courseTeachingPoint.setTeacherAvatar(teacher.getAvatar());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置签到/签退信息
|
|
|
+ TeacherAttendance attendance = attendanceMap.get(courseTeachingPoint.getCourseId());
|
|
|
+ if (attendance != null) {
|
|
|
+ courseTeachingPoint.setSignPhoto(attendance.getSignInAttachments());
|
|
|
+ courseTeachingPoint.setSignOutPhoto(attendance.getSignOutAttachments());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return page.setRecords(courseTeachingPoints);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<TeachingPointWrapper.ClassTeachingPoint> teachingPointClass(TeachingPointWrapper.TeachingPointQuery queryInfo) {
|
|
|
+ IPage<TeachingPointWrapper.ClassTeachingPoint> page = com.microsvc.toolkit.common.response.paging.QueryInfo.getPage(queryInfo);
|
|
|
+ List<TeachingPointWrapper.ClassTeachingPoint> courseTeachingPoints = courseSchedulePlusMapper
|
|
|
+ .teachingPointClass(page, queryInfo);
|
|
|
+ if (CollectionUtils.isEmpty(courseTeachingPoints)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 班级主教信息
|
|
|
+
|
|
|
+ // 班级ID集合
|
|
|
+ List<Integer> classIds = courseTeachingPoints.stream()
|
|
|
+ .map(TeachingPointWrapper.ClassTeachingPoint::getClassGroupId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Integer, Teacher> teacherMap = classGroupTeacherMapperService.getTeacherByClassIds(classIds);
|
|
|
+
|
|
|
+ for (TeachingPointWrapper.ClassTeachingPoint courseTeachingPoint : courseTeachingPoints) {
|
|
|
+
|
|
|
+ // 设置老师信息
|
|
|
+ Teacher teacher = teacherMap.get(courseTeachingPoint.getClassGroupId());
|
|
|
+ if (teacher != null) {
|
|
|
+ courseTeachingPoint.setTeacherId(teacher.getId());
|
|
|
+ courseTeachingPoint.setTeacherName(teacher.getRealName());
|
|
|
+ courseTeachingPoint.setTeacherAvatar(teacher.getAvatar());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page.setRecords(courseTeachingPoints);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置教学点
|
|
|
+ *
|
|
|
+ * @param teachingPoint 教学点信息
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Boolean teachingPoint(TeachingPointWrapper.TeachingPoint teachingPoint) {
|
|
|
+
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
+ classGroup.setId(teachingPoint.getClassGroupId());
|
|
|
+ classGroup.setTeachingPoint(teachingPoint.getTeachingPoint());
|
|
|
+ classGroupDao.updateTeachingPointById(classGroup);
|
|
|
+
|
|
|
+ // 未开始的课程修改教学点
|
|
|
+ courseScheduleDao.updateTeachingPointByClassGroupId(teachingPoint.getClassGroupId(), teachingPoint.getTeachingPoint());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|