Commit 65ffbb1c by 刘鑫

feat(单时间片容量): 时间周期负值取正

1 parent 185fa736
......@@ -110,14 +110,14 @@ public class CapacityUtils {
LocalDateTime preLast = startTime;
for (OccupyInfo o : occupyInfos) {
if (o.getBeginTime().isAfter(preLast)) {
idlePeriods.add(Duration.between(startTime, o.getBeginTime()).toMinutes());
idlePeriods.add(Duration.between(startTime, o.getBeginTime()).abs().toMinutes());
}
preLast = o.getEndTime();
}
if (preLast.isBefore(endTime)) {
idlePeriods.add(Duration.between(preLast, endTime).toMinutes());
idlePeriods.add(Duration.between(preLast, endTime).abs().toMinutes());
}
return org.springframework.util.CollectionUtils.isEmpty(idlePeriods) ? Duration.between(startTime, endTime).toMinutes() : Collections.max(idlePeriods);
return org.springframework.util.CollectionUtils.isEmpty(idlePeriods) ? Duration.between(startTime, endTime).abs().toMinutes() : Collections.max(idlePeriods);
}
......
......@@ -138,7 +138,7 @@ public class CalcEngineerCapacityScheduler {
List<OccupyInfo> occupyInfo = CapacityUtils.caculate(startTime, endTime, orders, configs);
//已用容量
long totalUseTime = occupyInfo.stream().mapToLong(t -> Duration.between(t.getEndTime(), t.getBeginTime()).toMinutes()).sum();
long totalUseTime = occupyInfo.stream().mapToLong(t -> Duration.between(t.getEndTime(), t.getBeginTime()).abs().toMinutes()).sum();
//最大连续时长
Long maxRemainBlock = CapacityUtils.getMaxRemainBlock(startTime, endTime, occupyInfo);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!