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 049f4fd0
authored
Nov 08, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(工程师时间片容量): 时间片容量存在负值情况, 修订计算订单与休息时间时进行已用时间段并集运算,避免重复时间交叉计算
1 parent
ff5aa178
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcEngineerCapacityScheduler.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
View file @
049f4fd
...
...
@@ -93,21 +93,22 @@ public class CapacityUtils {
List
<
OccupyInfoDetail
>
configs
)
{
//工作日历使用时间片
List
<
OccupyInfo
>
calendar
=
Optional
.
ofNullable
(
configs
).
orElse
(
Collections
.
emptyList
())
List
<
OccupyInfo
Detail
>
calendar
=
Optional
.
ofNullable
(
configs
).
orElse
(
Collections
.
emptyList
())
.
stream
()
.
filter
(
t
->
DateUtil
.
checkTimesHasOverlap
(
t
.
getBeginTime
(),
t
.
getEndTime
(),
startTime
,
endTime
))
.
map
(
e
->
DateUtil
.
timesOverlap
(
e
.
getBeginTime
(),
e
.
getEndTime
(),
startTime
,
endTime
))
.
map
(
e
->
DateUtil
.
intersection
(
e
.
getBeginTime
(),
e
.
getEndTime
(),
startTime
,
endTime
))
.
collect
(
Collectors
.
toList
());
// 工单已使用的时间片
List
<
OccupyInfo
>
order
=
Optional
.
ofNullable
(
orders
).
orElse
(
Collections
.
emptyList
())
List
<
OccupyInfo
Detail
>
order
=
Optional
.
ofNullable
(
orders
).
orElse
(
Collections
.
emptyList
())
.
stream
()
.
filter
(
t
->
DateUtil
.
checkTimesHasOverlap
(
t
.
getPlanStartTime
(),
t
.
getPlanEndTime
(),
startTime
,
endTime
))
.
map
(
e
->
DateUtil
.
timesOverlap
(
e
.
getPlanStartTime
(),
e
.
getPlanEndTime
(),
startTime
,
endTime
))
.
map
(
e
->
DateUtil
.
intersection
(
e
.
getPlanStartTime
(),
e
.
getPlanEndTime
(),
startTime
,
endTime
))
.
collect
(
Collectors
.
toList
());
List
<
OccupyInfoDetail
>
resultList
=
Stream
.
of
(
calendar
,
order
).
flatMap
(
Collection:
:
stream
).
collect
(
Collectors
.
toList
());
resultList
=
calculateUnion
(
resultList
);
//存放所有的已用时间段信息
return
Stream
.
of
(
calendar
,
order
).
flatMap
(
Collection:
:
stream
)
.
sorted
(
Comparator
.
comparing
(
OccupyInfo:
:
getBeginTime
)).
collect
(
Collectors
.
toList
());
return
resultList
.
stream
().
sorted
(
Comparator
.
comparing
(
OccupyInfo:
:
getBeginTime
)).
collect
(
Collectors
.
toList
());
}
...
...
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcEngineerCapacityScheduler.java
View file @
049f4fd
...
...
@@ -86,7 +86,7 @@ public class CalcEngineerCapacityScheduler {
}
}
p
rivate
void
calcOneEngineer
(
String
date
,
String
engineerCode
)
{
p
ublic
void
calcOneEngineer
(
String
date
,
String
engineerCode
)
{
CapacityEngineerStatEntity
statEntity
=
capacityEngineerStatDao
.
getByWorkdayAndEngineerCode
(
date
,
engineerCode
);
if
(
statEntity
==
null
)
{
log
.
error
(
"错误:日期[{}]技术员[{}]容量尚未初始化,忽略退出!"
,
date
,
engineerCode
);
...
...
@@ -145,7 +145,7 @@ public class CalcEngineerCapacityScheduler {
long
totalUseTime
=
occupyInfo
.
stream
().
mapToLong
(
t
->
Duration
.
between
(
t
.
getEndTime
(),
t
.
getBeginTime
()).
abs
().
toMinutes
()).
sum
();
//最大连续时长
List
<
OccupyInfoDetail
>
durationTime
=
CapacityUtils
.
getMaxRemainBlock
(
startTime
,
endTime
,
occupyInfo
);
long
maxRemainBlock
=
durationTime
.
stream
().
mapToLong
(
OccupyInfoDetail:
:
getDuration
).
max
().
orElse
(
Duration
.
between
(
startTime
,
endTime
).
abs
().
toMinutes
()
);
long
maxRemainBlock
=
durationTime
.
stream
().
mapToLong
(
OccupyInfoDetail:
:
getDuration
).
max
().
orElse
(
0L
);
//剩余连续时间段
sliceCap
.
setDurationTime
(
durationTime
);
sliceCap
.
setCapLeft
(
sliceCap
.
getCapTotal
()
-
totalUseTime
);
...
...
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