|
|
|
|
@ -158,8 +158,34 @@ public class JobExtUtil { |
|
|
|
|
} |
|
|
|
|
} else if (type == YEAR) { |
|
|
|
|
String config = je.getJobTypeYearValue(); |
|
|
|
|
|
|
|
|
|
// 获取当月最后一天
|
|
|
|
|
LocalDate lastLD = LocalDate.of(today.getYear(), today.getMonth(), 1) |
|
|
|
|
.with(TemporalAdjusters.lastDayOfMonth()); |
|
|
|
|
log.info("当月最后一天:{}", lastLD); |
|
|
|
|
// 当月最多多少天
|
|
|
|
|
Integer maxDay = lastLD.getDayOfMonth(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果超了就设置为最后一天
|
|
|
|
|
List<String> list = Arrays.asList(config.split(",")); |
|
|
|
|
String str = ""; |
|
|
|
|
for(String one : list){ |
|
|
|
|
|
|
|
|
|
String m = one.substring(0, 2); |
|
|
|
|
String d = one.substring(2); |
|
|
|
|
|
|
|
|
|
int month = Integer.parseInt(one.substring(0, 2)); |
|
|
|
|
int day = Integer.parseInt(one.substring(2)); |
|
|
|
|
if(day>maxDay){ |
|
|
|
|
day = maxDay; |
|
|
|
|
d = day+""; |
|
|
|
|
} |
|
|
|
|
str = str+m+""+d+","; |
|
|
|
|
} |
|
|
|
|
str = str.substring(0,str.length()-1); |
|
|
|
|
// 解析配置为年度目标日期(MonthDay 仅存月+日,不关联年份)
|
|
|
|
|
Set<MonthDay> targetMonthDays = Arrays.stream(config.split(",")) |
|
|
|
|
Set<MonthDay> targetMonthDays = Arrays.stream(str.split(",")) |
|
|
|
|
.map(String::trim) |
|
|
|
|
.map(dateStr -> { |
|
|
|
|
// 解析 0201 → 月=2,日=1;1020 → 月=10,日=20
|
|
|
|
|
@ -176,6 +202,7 @@ public class JobExtUtil { |
|
|
|
|
if (targetMonthDays.contains(futureMonthDay)) { |
|
|
|
|
return futureMonthDay; |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
MonthDay leapDay = MonthDay.of(2, 29); |
|
|
|
|
if (targetMonthDays.contains(leapDay)) { // 有配置0229
|
|
|
|
|
if (!Year.now().isLeap()) { // 不是闰年 特殊情况
|
|
|
|
|
|