|
@@ -9,11 +9,13 @@ import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
|
|
|
import com.ym.mec.biz.dal.wrapper.SchoolIndexStatWrapper;
|
|
|
import com.ym.mec.biz.service.SchoolIndexStatService;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.Collator;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -53,6 +55,12 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
Map<Integer, String> subjectMap = subjectDao.findBySubjectIds(subjectIdList).stream().collect(Collectors.toMap(Subject::getId, s -> s.getName(), (s1, s2) -> s1));
|
|
|
//年级分布
|
|
|
List<SchoolIndexStatWrapper.GradeDistribution> gradeDistributions = studentRegistrations.stream()
|
|
|
+ .map(e -> {
|
|
|
+ if (e.getCurrentGrade() == null) {
|
|
|
+ e.setCurrentGrade("一年级");
|
|
|
+ }
|
|
|
+ return e;
|
|
|
+ })
|
|
|
.collect(Collectors.groupingBy(
|
|
|
e -> e.getCurrentGrade(),
|
|
|
Collectors.collectingAndThen(
|
|
@@ -67,9 +75,10 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
distribution.setStudentNum(entry.getValue());
|
|
|
return distribution;
|
|
|
})
|
|
|
- .sorted(Comparator.comparing(SchoolIndexStatWrapper.GradeDistribution::getGrade))
|
|
|
+ .sorted(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())))
|
|
|
.collect(Collectors.toList());
|
|
|
result.setGradeDistributions(gradeDistributions);
|
|
|
+
|
|
|
//声部分布
|
|
|
List<SchoolIndexStatWrapper.SubjectDistribution> subjectDistributions = studentRegistrations.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -121,6 +130,7 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+ musicGradeDistributions.sort(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())));
|
|
|
result.setMusicGradeDistributions(musicGradeDistributions);
|
|
|
|
|
|
//声部年级分组
|
|
@@ -145,6 +155,7 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
subjectGradeDistributions.add(gradeDistribution);
|
|
|
}
|
|
|
}
|
|
|
+ subjectGradeDistributions.sort(Comparator.comparingInt(entry -> gradeOrder.indexOf(entry.getGrade())));
|
|
|
result.setSubjectGradeDistributions(subjectGradeDistributions);
|
|
|
return result;
|
|
|
}
|
|
@@ -160,6 +171,7 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
|
return new SchoolIndexStatWrapper.StudentAttendance();
|
|
|
}
|
|
|
+ this.setTime(queryDto);
|
|
|
//获取学员考勤数据
|
|
|
SchoolIndexStatWrapper.StudentAttendance studentAttendance = studentAttendanceDao.statCoopAttendance(musicGroupIds,queryDto);
|
|
|
if(Objects.nonNull(studentAttendance)){
|
|
@@ -182,6 +194,48 @@ public class SchoolIndexStatServiceImpl implements SchoolIndexStatService {
|
|
|
if(CollectionUtils.isEmpty(musicGroupIds)){
|
|
|
return new SchoolIndexStatWrapper.StudentLesson();
|
|
|
}
|
|
|
+ this.setTime(queryDto);
|
|
|
return lessonExaminationDao.schoolLessonStat(musicGroupIds,queryDto);
|
|
|
}
|
|
|
+
|
|
|
+ private void setTime(SchoolIndexStatWrapper.QueryDto queryDto){
|
|
|
+ if(StringUtils.isNotEmpty(queryDto.getPeriod())){
|
|
|
+ Date now = new Date();
|
|
|
+ if(queryDto.getPeriod().equals("week")){
|
|
|
+ queryDto.setStartTime(DateUtil.format(DateUtil.getWeekDayWithDate(now,Calendar.MONDAY),DateUtil.DEFAULT_PATTERN));
|
|
|
+ queryDto.setEndTime(DateUtil.format(DateUtil.getWeekDayWithDate(now,Calendar.SUNDAY),DateUtil.DEFAULT_PATTERN));
|
|
|
+ }
|
|
|
+ if(queryDto.getPeriod().equals("month")){
|
|
|
+ DateUtil.getFirstDayOfMonth(now);
|
|
|
+ queryDto.setStartTime(DateUtil.format(DateUtil.getFirstDayOfMonth(now),DateUtil.DEFAULT_PATTERN));
|
|
|
+ queryDto.setEndTime(DateUtil.format(DateUtil.getLastDayOfMonth(now),DateUtil.DEFAULT_PATTERN));
|
|
|
+ }
|
|
|
+ if(queryDto.getPeriod().equals("term")){
|
|
|
+ queryDto.setStartTime(DateUtil.getStartTerm(now));
|
|
|
+ queryDto.setEndTime(DateUtil.getEndTerm(now));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义自定义顺序的列表
|
|
|
+ List<String> gradeOrder = Arrays.asList(
|
|
|
+ "一年级",
|
|
|
+ "二年级",
|
|
|
+ "三年级",
|
|
|
+ "四年级",
|
|
|
+ "五年级",
|
|
|
+ "六年级",
|
|
|
+ "六年级/初一",
|
|
|
+ "七年级/初一",
|
|
|
+ "初一/七年级",
|
|
|
+ "七年级/初二",
|
|
|
+ "八年级/初二",
|
|
|
+ "初二/八年级",
|
|
|
+ "八年级/初三",
|
|
|
+ "初三/九年级",
|
|
|
+ "九年级/初三",
|
|
|
+ "高一",
|
|
|
+ "高二",
|
|
|
+ "高三"
|
|
|
+ );
|
|
|
}
|