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 6b2a36a7
authored
Oct 30, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(容量对外接口): 添加多线程执行单日任务
1 parent
9bd7c8d6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
1 deletions
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/DateSplit.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
View file @
6b2a36a
package
com
.
dituhui
.
pea
.
order
.
common
;
package
com
.
dituhui
.
pea
.
order
.
common
;
import
com.dituhui.pea.order.common.jackson.DateUtil
;
import
com.dituhui.pea.order.dao.MapBlockInfoDao
;
import
com.dituhui.pea.order.dao.MapBlockInfoDao
;
import
com.dituhui.pea.order.dao.SkillInfoDao
;
import
com.dituhui.pea.order.dao.SkillInfoDao
;
import
com.dituhui.pea.order.dto.param.CapacityQueryDTO
;
import
com.dituhui.pea.order.entity.CapacityEngineerSliceUsedEntity
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
com.dituhui.pea.order.entity.TimeSliceEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.OptionalLong
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
@Component
...
@@ -58,4 +67,58 @@ public class CapacityUtils {
...
@@ -58,4 +67,58 @@ public class CapacityUtils {
return
layers
;
return
layers
;
}
}
public
static
List
<
CapacityQueryDTO
.
Segment
>
getEngineerTypeDay
(
List
<
TimeSliceEntity
>
typeTimeSlice
,
List
<
CapacityEngineerSliceUsedEntity
>
engineerTimeSlice
,
LocalDate
date
,
int
totalTakeTime
)
{
ArrayList
<
CapacityQueryDTO
.
Segment
>
segments
=
new
ArrayList
<>();
//半天容量
for
(
TimeSliceEntity
targetTimeSlice
:
typeTimeSlice
)
{
final
LocalTime
targetStartTime
=
LocalTime
.
parse
(
targetTimeSlice
.
getStart
(),
DateUtil
.
TIME_FORMATTER
);
final
LocalTime
targetEndTime
=
LocalTime
.
parse
(
targetTimeSlice
.
getEnd
(),
DateUtil
.
TIME_FORMATTER
);
CapacityQueryDTO
.
Segment
segment
=
caculateTargetTimeSlice
(
totalTakeTime
,
targetTimeSlice
.
getName
(),
engineerTimeSlice
,
targetStartTime
,
targetEndTime
,
date
);
segments
.
add
(
segment
);
}
return
segments
;
}
public
static
CapacityQueryDTO
.
Segment
caculateTargetTimeSlice
(
int
totalTakeTime
,
String
timeSliceName
,
List
<
CapacityEngineerSliceUsedEntity
>
engineerTimeSlice
,
LocalTime
targetStartTime
,
LocalTime
targetEndTime
,
LocalDate
targetDate
)
{
List
<
CapacityEngineerSliceUsedEntity
>
collect
=
engineerTimeSlice
.
stream
().
filter
(
t
->
{
TimeSliceEntity
timeSlice
=
t
.
getTimmeSlice
();
LocalTime
sliceStartHour
=
LocalTime
.
parse
(
timeSlice
.
getStart
(),
DateUtil
.
TIME_FORMATTER
);
LocalTime
sliceEndHour
=
LocalTime
.
parse
(
timeSlice
.
getEnd
(),
DateUtil
.
TIME_FORMATTER
);
return
(
targetStartTime
.
isAfter
(
sliceStartHour
)
&&
targetEndTime
.
isBefore
(
sliceEndHour
))
||
(
targetStartTime
.
equals
(
sliceStartHour
)
||
targetEndTime
.
equals
(
sliceEndHour
));
}).
collect
(
Collectors
.
toList
());
CapacityQueryDTO
.
Segment
segment
=
new
CapacityQueryDTO
.
Segment
();
segment
.
setName
(
timeSliceName
);
segment
.
setEndTime
(
DateUtil
.
toDate
(
LocalDateTime
.
of
(
targetDate
,
targetEndTime
)));
segment
.
setBeginTime
(
DateUtil
.
toDate
(
LocalDateTime
.
of
(
targetDate
,
targetStartTime
)));
if
(!
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isEmpty
(
collect
))
{
OptionalLong
optionalLong
=
collect
.
stream
().
mapToLong
(
t
->
{
Long
maxDuration
=
t
.
getMaxDuration
();
return
Objects
.
isNull
(
maxDuration
)
?
0L
:
maxDuration
;
}).
max
();
long
maxDuration
=
optionalLong
.
isEmpty
()
?
0
:
optionalLong
.
getAsLong
();
segment
.
setMaxDuration
(
maxDuration
);
long
remain
=
collect
.
stream
().
mapToLong
(
CapacityEngineerSliceUsedEntity:
:
getCapLeft
).
sum
();
segment
.
setRemain
(
remain
);
segment
.
setStatus
(
totalTakeTime
<=
maxDuration
?
1
:
0
);
}
else
{
segment
.
setMaxDuration
(
0
);
segment
.
setRemain
(
0
);
segment
.
setStatus
(
0
);
}
return
segment
;
}
}
}
project-order/src/main/java/com/dituhui/pea/order/common/DateSplit.java
View file @
6b2a36a
...
@@ -31,7 +31,7 @@ public class DateSplit {
...
@@ -31,7 +31,7 @@ public class DateSplit {
}
}
public
LocalDateTime
getLocalEndDateTime
()
{
public
LocalDateTime
getLocalEndDateTime
()
{
return
DateUtil
.
fromDate
(
this
.
start
DateTime
);
return
DateUtil
.
fromDate
(
this
.
end
DateTime
);
}
}
/**
/**
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
6b2a36a
This diff is collapsed.
Click to expand it.
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