Commit 810043bf by 丁伟峰

list元素为空的处理

1 parent 38454d25
...@@ -105,7 +105,7 @@ public class CalcEngineerCapacityScheduler { ...@@ -105,7 +105,7 @@ public class CalcEngineerCapacityScheduler {
} }
if (occupyInfos.isEmpty()) { if (occupyInfos.isEmpty()) {
return Duration.between(startTime, endTime).toMinutes(); return Duration.between(startTime, endTime).toMinutes();
} else { }
occupyInfos.sort(Comparator.comparing(OccupyInfo::getBeginTime)); occupyInfos.sort(Comparator.comparing(OccupyInfo::getBeginTime));
// 从 occupyInfos的配置间隙中,获取最大的闲时段,理论上,上面的配置段之间,是不会交叉的,如果交叉,那是存在问题的! // 从 occupyInfos的配置间隙中,获取最大的闲时段,理论上,上面的配置段之间,是不会交叉的,如果交叉,那是存在问题的!
List<Long> idlePeriods = new ArrayList<>(); List<Long> idlePeriods = new ArrayList<>();
...@@ -119,6 +119,9 @@ public class CalcEngineerCapacityScheduler { ...@@ -119,6 +119,9 @@ public class CalcEngineerCapacityScheduler {
if (preLast.isBefore(endTime)) { if (preLast.isBefore(endTime)) {
idlePeriods.add(Duration.between(preLast, endTime).toMinutes()); idlePeriods.add(Duration.between(preLast, endTime).toMinutes());
} }
if (idlePeriods.isEmpty()) {
return Duration.between(startTime, endTime).toMinutes();
} else {
return Collections.max(idlePeriods); return Collections.max(idlePeriods);
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!