发表于2018-05-242019-01-01 作者 wind
HolidayVo where = new HolidayVo();
int guessHoliday = 0;
for (int i = 0; i < day / 5; i++) {
guessHoliday += 2;
}
Date guessEnd = DateUtils.addDays(date, day + guessHoliday);
String startYear = DateFormatUtils.format(date, "yyyy");
String guessEndYear = DateFormatUtils.format(guessEnd, "yyyy");
boolean b = startYear.equalsIgnoreCase(
guessEndYear);
where.setYear(startYear);
List < HolidayVo > allHoliday = null;
if (b) {
allHoliday = this.getAllHoliday(where);
} else {
allHoliday = new ArrayList < > ();
for (int year = Integer.valueOf(startYear); year >= Integer.valueOf(guessEndYear); year++) {
where.setYear(String.valueOf(year));
allHoliday.addAll(this.getAllHoliday(where));
}
}
Set < String > holidaySet = allHoliday.stream().map(Holiday::getDate).collect(Collectors.toSet());
int passWorkDay = 0;
Date testDate = date;
while (passWorkDay == day) {
testDate = DateUtils.addDays(testDate, 1);
if (!holidaySet.contains(DateFormatUtils.format(testDate, "yyyy-MM-dd"))) {
passWorkDay++;
}
}
return testDate;