|
@@ -21,8 +21,10 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.time.DayOfWeek;
|
|
import java.time.DayOfWeek;
|
|
|
|
+import java.time.Instant;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.ZoneId;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -341,15 +343,20 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
// return;
|
|
// return;
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
+ //查询需要生成服务指标的学员
|
|
List<StudentServeCourseDto> studentFutureCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), studentIds, tenantId);
|
|
List<StudentServeCourseDto> studentFutureCourseInfo = studentDao.getStudentFutureCourseInfo(monDayDate.toString(), DateUtil.dateToString(nextMonday, "yyyy-MM-dd"), studentIds, tenantId);
|
|
if(CollectionUtils.isEmpty(studentFutureCourseInfo)){
|
|
if(CollectionUtils.isEmpty(studentFutureCourseInfo)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId));
|
|
Map<Integer, List<StudentServeCourseDto>> studentCourseMap = studentFutureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getStudentId));
|
|
|
|
+ //有单技课或合奏课,且需要服务的学员
|
|
Set<Integer> musicCourseStudentIds = studentFutureCourseInfo.stream().filter(s -> CourseSchedule.CourseScheduleType.SINGLE.equals(s.getType()) || CourseSchedule.CourseScheduleType.MIX.equals(s.getType())).map(StudentServeCourseDto::getStudentId).collect(Collectors.toSet());
|
|
Set<Integer> musicCourseStudentIds = studentFutureCourseInfo.stream().filter(s -> CourseSchedule.CourseScheduleType.SINGLE.equals(s.getType()) || CourseSchedule.CourseScheduleType.MIX.equals(s.getType())).map(StudentServeCourseDto::getStudentId).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
+ //有课且被服务的学生
|
|
Set<Integer> haveCourseBeServeStudentIds = studentCourseMap.keySet();
|
|
Set<Integer> haveCourseBeServeStudentIds = studentCourseMap.keySet();
|
|
|
|
+ //查询所有开启了服务状态的学员
|
|
List<Integer> allServeStudentIds = studentDao.getServeStudentIds(tenantId);
|
|
List<Integer> allServeStudentIds = studentDao.getServeStudentIds(tenantId);
|
|
|
|
+ //没课但需要服务的学员
|
|
Set<Integer> noCourseServeStudentIds = allServeStudentIds.stream().filter(id -> !haveCourseBeServeStudentIds.contains(id)).collect(Collectors.toSet());
|
|
Set<Integer> noCourseServeStudentIds = allServeStudentIds.stream().filter(id -> !haveCourseBeServeStudentIds.contains(id)).collect(Collectors.toSet());
|
|
|
|
|
|
Set<Integer> musicStudentIds = new HashSet<>();
|
|
Set<Integer> musicStudentIds = new HashSet<>();
|
|
@@ -361,6 +368,7 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
}
|
|
}
|
|
List<StudentServeCourseDto> noCourseBeServeStudentInfo = new ArrayList<>();
|
|
List<StudentServeCourseDto> noCourseBeServeStudentInfo = new ArrayList<>();
|
|
if(!CollectionUtils.isEmpty(musicStudentIds)){
|
|
if(!CollectionUtils.isEmpty(musicStudentIds)){
|
|
|
|
+ //查询进行中的乐团,且需要服务的学生、老师、乐团信息
|
|
noCourseBeServeStudentInfo = studentDao.getNoCourseBeServeStudentInfo(new ArrayList<>(musicStudentIds), tenantId);
|
|
noCourseBeServeStudentInfo = studentDao.getNoCourseBeServeStudentInfo(new ArrayList<>(musicStudentIds), tenantId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -371,13 +379,19 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
|
|
|
|
for (Map.Entry<Integer, List<StudentServeCourseDto>> studentCourseMapEntry : studentCourseMap.entrySet()) {
|
|
for (Map.Entry<Integer, List<StudentServeCourseDto>> studentCourseMapEntry : studentCourseMap.entrySet()) {
|
|
Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
|
|
Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
|
|
|
|
+
|
|
|
|
+ Integer userId = studentCourseMapEntry.getKey();
|
|
|
|
|
|
|
|
+ //有未上的单技课
|
|
if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE)){
|
|
if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE)){
|
|
Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
|
|
Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
|
|
if(Objects.isNull(musicGroupIds)){
|
|
if(Objects.isNull(musicGroupIds)){
|
|
musicGroupIds = new HashSet<>();
|
|
musicGroupIds = new HashSet<>();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ List<Mapper> mapperList = courseScheduleStudentPaymentDao.queryUserMusicGroupCourseNumByClassTime(GroupType.MUSIC, musicGroupIds, userId, new Date(2019, 1, 1), LocalDateToUdate(monDayDate));
|
|
|
|
+ Map<Object, Object> map = mapperList.stream().collect(Collectors.toMap(Mapper :: getKey, Mapper :: getValue));
|
|
|
|
+
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
if(!CollectionUtils.isEmpty(weekCourseInfo)){
|
|
if(!CollectionUtils.isEmpty(weekCourseInfo)){
|
|
Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
|
|
Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
|
|
@@ -387,6 +401,12 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
if(musicGroupIds.contains(groupCourseInfoEntry.getKey())) {
|
|
if(musicGroupIds.contains(groupCourseInfoEntry.getKey())) {
|
|
musicGroupIds.remove(groupCourseInfoEntry.getKey());
|
|
musicGroupIds.remove(groupCourseInfoEntry.getKey());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //学生在当前乐团没有上过课,就不需要生成服务指标
|
|
|
|
+ if(map.get(groupCourseInfoEntry.getKey()) != null && (int)map.get(groupCourseInfoEntry.getKey()) == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
|
|
StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
|
|
if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
|
|
if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
|
|
teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
|
|
teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
|
|
@@ -443,7 +463,7 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
|
|
studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
}
|
|
}
|
|
- }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.VIP)){
|
|
|
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.VIP)){ //有未上的VIP
|
|
List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
|
|
List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP);
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.VIP).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
@@ -478,13 +498,24 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){
|
|
|
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.MIX)){//有未上的合奏课
|
|
Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
|
|
Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
|
|
if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ List<Mapper> mapperList = courseScheduleStudentPaymentDao.queryUserMusicGroupCourseNumByClassTime(GroupType.MUSIC, musicGroupIds, userId, new Date(2019, 1, 1), LocalDateToUdate(monDayDate));
|
|
|
|
+ Map<Object, Object> map = mapperList.stream().collect(Collectors.toMap(Mapper :: getKey, Mapper :: getValue));
|
|
|
|
+
|
|
|
|
+
|
|
Map<Integer, Integer> teacherNumMap = new HashMap<>();
|
|
Map<Integer, Integer> teacherNumMap = new HashMap<>();
|
|
for (String groupId : musicGroupIds) {
|
|
for (String groupId : musicGroupIds) {
|
|
|
|
+
|
|
|
|
+ //学生在当前乐团没有上过课,就不需要生成服务指标
|
|
|
|
+ if(map.get(groupId) != null && (int)map.get(groupId) == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
Integer teacherId = null;
|
|
Integer teacherId = null;
|
|
List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId);
|
|
List<BaseMapDto<Integer, Integer>> studentTeacherIdList = classGroupStudentMapperDao.getStudentClassGroupBishopTeacherMap(Arrays.asList(studentCourseMapEntry.getKey()), groupId);
|
|
if(!CollectionUtils.isEmpty(studentTeacherIdList)){
|
|
if(!CollectionUtils.isEmpty(studentTeacherIdList)){
|
|
@@ -512,7 +543,7 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
|
|
studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
results.add(studentExtracurricularExercisesSituation);
|
|
}
|
|
}
|
|
- }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.PRACTICE)){
|
|
|
|
|
|
+ }else if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.PRACTICE)){//有未上的陪练课
|
|
List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.PRACTICE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
|
|
if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
if(CollectionUtils.isEmpty(weekCourseInfo)){
|
|
@@ -1182,4 +1213,12 @@ public class StudentServeServiceImpl implements StudentServeService {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private Date LocalDateToUdate(LocalDate localDate) {
|
|
|
|
+ ZoneId zone = ZoneId.systemDefault();
|
|
|
|
+ Instant instant = localDate.atStartOfDay().atZone(zone).toInstant();
|
|
|
|
+ return Date.from(instant);
|
|
|
|
+ }
|
|
}
|
|
}
|