This commit is contained in:
ls
2025-01-06 15:40:27 +08:00
parent 2f2e86ff4c
commit 8025e2e3d9
2 changed files with 10 additions and 13 deletions

View File

@@ -410,6 +410,9 @@ public class DateUtils extends PropertyEditorSupport {
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Date date) {
if (Objects.isNull(date)) {
return "";
}
return date_sdf.get().format(date);
}
@@ -452,6 +455,9 @@ public class DateUtils extends PropertyEditorSupport {
* @return 指定日期按指定格式显示
*/
public static String formatDate(Date date, String pattern) {
if (Objects.isNull(date)) {
return "";
}
return getSdFormat(pattern).format(date);
}
@@ -821,8 +827,7 @@ public class DateUtils extends PropertyEditorSupport {
}
return timeRanges.stream()
//过滤掉start或end为null 的数据
.filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null)
.flatMap(timeRange -> {
.filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null).flatMap(timeRange -> {
List<Date> dates = new ArrayList<>();
if (timeRange.getStartTime() != null) {
dates.add(timeRange.getStartTime());
@@ -831,9 +836,7 @@ public class DateUtils extends PropertyEditorSupport {
dates.add(timeRange.getEndTime());
}
return dates.stream();
})
.min(Date::compareTo)
.orElse(null);
}).min(Date::compareTo).orElse(null);
}
/**
@@ -848,8 +851,7 @@ public class DateUtils extends PropertyEditorSupport {
}
return timeRanges.stream()
//过滤掉start或end为null 的数据
.filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null)
.flatMap(timeRange -> {
.filter(timeRange -> timeRange.getStartTime() != null || timeRange.getEndTime() != null).flatMap(timeRange -> {
List<Date> dates = new ArrayList<>();
if (timeRange.getStartTime() != null) {
dates.add(timeRange.getStartTime());
@@ -858,8 +860,6 @@ public class DateUtils extends PropertyEditorSupport {
dates.add(timeRange.getEndTime());
}
return dates.stream();
})
.max(Date::compareTo)
.orElse(null);
}).max(Date::compareTo).orElse(null);
}
}

View File

@@ -88,11 +88,8 @@ public class ExperimentRadiationProcessServiceImpl extends ServiceImpl<Experimen
}));
}
}
log.warn("TimeRange:" + list);
Date earliestTime = DateUtils.findEarliestTime(list);
Date latestTime = DateUtils.findLatestTime(list);
log.warn("earliestTime:" + earliestTime);
log.warn("latestTime:" + latestTime);
List<ExperimentIrradiationBoard> irradiationBoardList = experimentIrradiationBoardService.getByExperimentId(
experimentRadiationProcess.getExperimentId());
String mv = DateUtils.formatDate(earliestTime, "yyyy-MM-dd") + "" + DateUtils.formatDate(latestTime, "yyyy-MM-dd");