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 27bcdacf
authored
Sep 28, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 调整算法工具
1 parent
42a53b83
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
31 deletions
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
View file @
27bcdac
package
com
.
dituhui
.
pea
.
dispatch
.
scheduler
;
package
com
.
dituhui
.
pea
.
dispatch
.
scheduler
;
import
com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider
;
import
java.io.File
;
import
com.dituhui.pea.dispatch.entity.DispatchBatch
;
import
java.time.LocalDate
;
import
com.dituhui.pea.dispatch.pojo.Customer
;
import
java.time.format.DateTimeFormatter
;
import
com.dituhui.pea.dispatch.pojo.DispatchSolution
;
import
java.util.UUID
;
import
com.dituhui.pea.dispatch.pojo.Technician
;
import
com.dituhui.pea.dispatch.service.BatchService
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
com.dituhui.pea.dispatch.service.SolveService
;
import
com.dituhui.pea.dispatch.utils.DispatchSolutionUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.optaplanner.core.api.solver.Solver
;
import
org.optaplanner.core.api.solver.Solver
;
import
org.optaplanner.core.api.solver.SolverFactory
;
import
org.optaplanner.core.impl.solver.DefaultSolverFactory
;
import
org.optaplanner.core.config.solver.SolverConfig
;
import
org.optaplanner.persistence.jackson.impl.domain.solution.JacksonSolutionFileIO
;
import
org.optaplanner.persistence.jackson.impl.domain.solution.JacksonSolutionFileIO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
com.dituhui.pea.dispatch.pojo.DispatchSolution
;
import
java.time.Duration
;
import
com.dituhui.pea.dispatch.service.BatchService
;
import
java.time.LocalDate
;
import
com.dituhui.pea.dispatch.service.ExtractService
;
import
java.time.LocalDateTime
;
import
com.dituhui.pea.dispatch.service.SolveService
;
import
java.time.LocalTime
;
import
com.dituhui.pea.dispatch.utils.DispatchSolutionUtils
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Arrays
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.UUID
;
@Slf4j
@Slf4j
@Component
@Component
...
@@ -49,17 +41,11 @@ public class BatchScheduler {
...
@@ -49,17 +41,11 @@ public class BatchScheduler {
@Autowired
@Autowired
ExtractService
extractService
;
ExtractService
extractService
;
private
SolverFactory
<
DispatchSolution
>
solverFactory
;
private
Default
SolverFactory
<
DispatchSolution
>
solverFactory
;
private
Solver
<
DispatchSolution
>
solver
;
private
Solver
<
DispatchSolution
>
solver
;
public
BatchScheduler
()
{
public
BatchScheduler
()
{
solverFactory
=
DispatchSolutionUtils
.
getSolverFactory
(
30
,
60
*
5
);
SolverConfig
solverConfig
=
new
SolverConfig
().
withSolutionClass
(
DispatchSolution
.
class
);
solverConfig
.
withEntityClassList
(
Arrays
.
asList
(
Technician
.
class
,
Customer
.
class
));
// 这里不能漏掉,否则约束不生效
solverConfig
.
withConstraintProviderClass
(
DispatchConstraintProvider
.
class
);
solverConfig
.
withTerminationSpentLimit
(
Duration
.
ofSeconds
(
60
*
5
));
solverFactory
=
SolverFactory
.
create
(
solverConfig
);
solver
=
solverFactory
.
buildSolver
();
solver
=
solverFactory
.
buildSolver
();
}
}
...
@@ -74,8 +60,8 @@ public class BatchScheduler {
...
@@ -74,8 +60,8 @@ public class BatchScheduler {
String
currDay
=
LocalDate
.
now
().
plusDays
(
i
).
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
);
String
currDay
=
LocalDate
.
now
().
plusDays
(
i
).
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
);
log
.
info
(
"dispatchRun begin----- group:{}, day:{}"
,
groupId
,
currDay
);
log
.
info
(
"dispatchRun begin----- group:{}, day:{}"
,
groupId
,
currDay
);
LocalTime
currentTime
=
LocalTime
.
now
();
//
LocalTime currentTime = LocalTime.now();
LocalTime
cutoffTime
=
LocalTime
.
parse
(
"18:00:00"
,
DateTimeFormatter
.
ISO_LOCAL_TIME
);
//
LocalTime cutoffTime = LocalTime.parse("18:00:00", DateTimeFormatter.ISO_LOCAL_TIME);
// 明天单才有cutoff
// 明天单才有cutoff
...
...
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