差旅报销单扣除餐补天数计算逻辑调整

This commit is contained in:
zhangzhiguo 2025-05-30 08:50:33 +08:00
parent 06ffd9292d
commit 6359429d47
1 changed files with 19 additions and 1 deletions

View File

@ -185,7 +185,7 @@ public class TriprAutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements
Date startdate = dynamicObject.getDate("startdate");
Date enddate = dynamicObject.getDate("enddate");
if(startdate!=null && enddate!=null){
Set<LocalDate> datesExcludingWeekends = getStartAndEnd(dateToLocalDate(startdate), dateToLocalDate(enddate));
Set<LocalDate> datesExcludingWeekends = getWorkingDays(dateToLocalDate(startdate), dateToLocalDate(enddate));
addDateSet.addAll(datesExcludingWeekends);
}
}
@ -228,6 +228,24 @@ public class TriprAutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements
return result;
}
public static Set<LocalDate> getWorkingDays(LocalDate startDate, LocalDate endDate) {
if (startDate.isAfter(endDate)) {
throw new IllegalArgumentException("开始日期不能晚于结束日期");
}
Set<LocalDate> workingDays = new HashSet<>();
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
if (!isWeekend(currentDate)) {
workingDays.add(currentDate);
}
currentDate = currentDate.plusDays(1);
}
return workingDays;
}
private static boolean isWeekend(LocalDate date) {
return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
}