Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 810043bf
authored
Aug 11, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list元素为空的处理
1 parent
38454d25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcEngineerCapacityScheduler.java
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcEngineerCapacityScheduler.java
View file @
810043b
...
...
@@ -105,20 +105,23 @@ public class CalcEngineerCapacityScheduler {
}
if
(
occupyInfos
.
isEmpty
())
{
return
Duration
.
between
(
startTime
,
endTime
).
toMinutes
();
}
else
{
occupyInfos
.
sort
(
Comparator
.
comparing
(
OccupyInfo:
:
getBeginTime
));
// 从 occupyInfos的配置间隙中,获取最大的闲时段,理论上,上面的配置段之间,是不会交叉的,如果交叉,那是存在问题的!
List
<
Long
>
idlePeriods
=
new
ArrayList
<>();
LocalDateTime
preLast
=
startTime
;
for
(
OccupyInfo
o
:
occupyInfos
)
{
if
(
o
.
getBeginTime
().
isAfter
(
preLast
))
{
idlePeriods
.
add
(
Duration
.
between
(
startTime
,
o
.
getBeginTime
()).
toMinutes
());
}
preLast
=
o
.
getEndTime
();
}
if
(
preLast
.
isBefore
(
endTime
))
{
idlePeriods
.
add
(
Duration
.
between
(
preLast
,
endTime
).
toMinutes
());
}
occupyInfos
.
sort
(
Comparator
.
comparing
(
OccupyInfo:
:
getBeginTime
));
// 从 occupyInfos的配置间隙中,获取最大的闲时段,理论上,上面的配置段之间,是不会交叉的,如果交叉,那是存在问题的!
List
<
Long
>
idlePeriods
=
new
ArrayList
<>();
LocalDateTime
preLast
=
startTime
;
for
(
OccupyInfo
o
:
occupyInfos
)
{
if
(
o
.
getBeginTime
().
isAfter
(
preLast
))
{
idlePeriods
.
add
(
Duration
.
between
(
startTime
,
o
.
getBeginTime
()).
toMinutes
());
}
preLast
=
o
.
getEndTime
();
}
if
(
preLast
.
isBefore
(
endTime
))
{
idlePeriods
.
add
(
Duration
.
between
(
preLast
,
endTime
).
toMinutes
());
}
if
(
idlePeriods
.
isEmpty
())
{
return
Duration
.
between
(
startTime
,
endTime
).
toMinutes
();
}
else
{
return
Collections
.
max
(
idlePeriods
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment