|
@@ -2147,22 +2147,44 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, BigDecimal> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
|
|
|
|
- List<Map<String, BigDecimal>> monthIncomeMapList = courseScheduleTeacherSalaryDao.teacherIncomeStat(teacherId, year, month);
|
|
|
|
- Map<String, BigDecimal> monthIncomeMap = MapUtil.convertIntegerMap(monthIncomeMapList);
|
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
|
- DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
|
|
+ public List<LocalDateBigDecimalMapDto> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
|
|
|
|
+ List<LocalDateBigDecimalMapDto> monthIncomeMapList = courseScheduleTeacherSalaryDao.teacherIncomeStat(teacherId, year, month);
|
|
|
|
+ if(CollectionUtils.isEmpty(monthIncomeMapList)){
|
|
|
|
+ return monthIncomeMapList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(Objects.isNull(month)){
|
|
|
|
+ Set<String> months = monthIncomeMapList.stream().map(e -> DateUtil.dateToString(e.getDate(), "yyyy-MM")).collect(Collectors.toSet());
|
|
|
|
|
|
- LocalDate startDate = LocalDate.of(year, 1, 1);
|
|
|
|
- while (startDate.compareTo(now)<=0&&year.equals(startDate.get(ChronoField.YEAR))){
|
|
|
|
- String monthStr = dateFormatter.format(startDate);
|
|
|
|
- if(!monthIncomeMap.containsKey(monthStr)){
|
|
|
|
- monthIncomeMap.put(monthStr, BigDecimal.ZERO);
|
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
+
|
|
|
|
+ LocalDate startDate = LocalDate.of(year, Objects.isNull(month)?1:month, 1);
|
|
|
|
+ while (startDate.compareTo(now)<=0&&year.equals(startDate.get(ChronoField.YEAR))){
|
|
|
|
+ String dateStr = dateFormatter.format(startDate);
|
|
|
|
+ if(!months.contains(dateStr)){
|
|
|
|
+ monthIncomeMapList.add(new LocalDateBigDecimalMapDto(Date.from(startDate.atStartOfDay(DateUtil.zoneId).toInstant()), dateStr, BigDecimal.ZERO));
|
|
|
|
+ }
|
|
|
|
+ startDate = startDate.plusMonths(1);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ Set<String> dates = monthIncomeMapList.stream().map(e -> DateUtil.dateToString(e.getDate(), "yyyy-MM-dd")).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+
|
|
|
|
+ LocalDate startDate = LocalDate.of(year, Objects.isNull(month)?1:month, 1);
|
|
|
|
+ while (startDate.compareTo(now)<=0&&year.equals(startDate.get(ChronoField.YEAR))){
|
|
|
|
+ String dateStr = DateUtil.dateFormatter.format(startDate);
|
|
|
|
+ if(!dates.contains(dateStr)){
|
|
|
|
+ monthIncomeMapList.add(new LocalDateBigDecimalMapDto(Date.from(startDate.atStartOfDay(DateUtil.zoneId).toInstant()), dateStr, BigDecimal.ZERO));
|
|
|
|
+ }
|
|
|
|
+ startDate = startDate.plusDays(1);
|
|
}
|
|
}
|
|
- startDate = startDate.plusMonths(1);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return monthIncomeMap;
|
|
|
|
|
|
+ monthIncomeMapList.sort(Comparator.comparing(LocalDateBigDecimalMapDto::getDate));
|
|
|
|
+
|
|
|
|
+ return monthIncomeMapList;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|