|
@@ -1642,9 +1642,9 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
|
|
|
}else{
|
|
|
List<TeacherSalaryDeductReasonDto> deductReasons = new ArrayList<>();
|
|
|
|
|
|
- BigDecimal subsidy = school.getSubsidy();
|
|
|
- if (Objects.isNull(subsidy)) {
|
|
|
- subsidy = new BigDecimal(0);
|
|
|
+ BigDecimal subsidy = new BigDecimal(0);
|
|
|
+ if (Objects.nonNull(school)&&Objects.nonNull(school.getSubsidy())) {
|
|
|
+ subsidy = school.getSubsidy();
|
|
|
}
|
|
|
teacherSalary = teacherSalary.add(subsidy);
|
|
|
|
|
@@ -2147,22 +2147,54 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
|
|
|
}
|
|
|
|
|
|
@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 Map<String, Object> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
|
|
|
+ if(Objects.isNull(year)){
|
|
|
+ year = LocalDate.now().get(ChronoField.YEAR);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("total", BigDecimal.ZERO);
|
|
|
+ result.put("salary", BigDecimal.ZERO);
|
|
|
+
|
|
|
+ List<LocalDateBigDecimalMapDto> monthIncomeMapList = courseScheduleTeacherSalaryDao.teacherIncomeStat(teacherId, year, month);
|
|
|
+
|
|
|
+ if(Objects.isNull(month)){
|
|
|
+ Set<String> months = monthIncomeMapList.stream().map(e -> DateUtil.dateToString(e.getDate(), "yyyy-MM")).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
|
|
- 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 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 startDate = LocalDate.of(year, Objects.isNull(month)?1:month, 1);
|
|
|
+ Integer oldMonth = Objects.isNull(month)?new Integer(1):month;
|
|
|
+ while (oldMonth.equals(startDate.get(ChronoField.MONTH_OF_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));
|
|
|
+
|
|
|
+ BigDecimal reduce = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ result.put("total", reduce);
|
|
|
+ result.put("salary", reduce);
|
|
|
+ result.put("data", monthIncomeMapList);
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|