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 1d704a34
authored
Jul 10, 2023
by
张晓
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-dispatch-zx' into develop
2 parents
6025ee0c
e16f06dc
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
18 deletions
project-dispatch/Dockerfile
project-dispatch/src/main/java/com/dituhui/pea/dispatch/DispatchServiceApplication.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/controller/BatchController.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/BatchService.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/BatchServiceImpl.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SolveServiceImpl.java
project-dispatch/src/main/resources/application-dev.yaml
project-dispatch/src/main/resources/application.yaml
project-dispatch/Dockerfile
View file @
1d704a3
...
...
@@ -3,6 +3,9 @@ FROM openjdk:11-jdk-slim as builder
LABEL author="yuluo" \
email="yuluo829@aliyun.com"
ENV
TZ=Asia/Shanghai
RUN
echo
-e
"
${
TZ
}
"
> /etc/timezone
&&
ln -sf /usr/share/zoneinfo/
${
TZ
}
/etc/localtime
ADD
./project-dispatch/target/project-dispatch-*.jar /app.jar
ADD
./project-dispatch/src/main/resources/data /data
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/DispatchServiceApplication.java
View file @
1d704a3
...
...
@@ -24,7 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author gpzhang
*/
@SpringBootApplication
//
@EnableScheduling
@EnableScheduling
public
class
DispatchServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/controller/BatchController.java
View file @
1d704a3
...
...
@@ -95,7 +95,7 @@ public class BatchController {
public
Result
<?>
buildBatch
(
@PathVariable
String
groupId
,
@PathVariable
String
day
)
{
log
.
info
(
"buildBatch, groupId:{}, day:{}"
,
groupId
,
day
);
try
{
String
batchNo
=
batchService
.
buildBatch
No
(
groupId
,
day
);
String
batchNo
=
batchService
.
buildBatch
Data
(
groupId
,
day
);
DispatchBatch
batch
=
batchService
.
queryBatch
(
groupId
,
batchNo
);
DispatchBatchDTO
batchDTO
=
new
DispatchBatchDTO
();
BeanUtil
.
copyProperties
(
batch
,
batchDTO
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
View file @
1d704a3
...
...
@@ -10,12 +10,10 @@ import com.dituhui.pea.dispatch.service.SolveService;
import
lombok.extern.slf4j.Slf4j
;
import
org.optaplanner.core.api.solver.Solver
;
import
org.optaplanner.core.api.solver.SolverFactory
;
import
org.optaplanner.core.api.solver.SolverJob
;
import
org.optaplanner.core.api.solver.SolverManager
;
import
org.optaplanner.core.config.solver.SolverConfig
;
import
org.optaplanner.core.config.solver.SolverManagerConfig
;
import
org.optaplanner.persistence.jackson.impl.domain.solution.JacksonSolutionFileIO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -23,7 +21,6 @@ import java.io.File;
import
java.sql.SQLException
;
import
java.time.Duration
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Arrays
;
import
java.util.UUID
;
...
...
@@ -34,7 +31,10 @@ public class BatchScheduler {
String
groupId
=
"gsuzhou"
;
int
nextDays
=
3
;
@Value
(
"${dispatch.cron.next-day-limit}"
)
int
nextDaysLimit
=
3
;
@Autowired
BatchService
batchService
;
...
...
@@ -65,11 +65,11 @@ public class BatchScheduler {
public
void
dispatchRun
()
{
log
.
info
(
"dispatchRun group:{}"
,
groupId
);
try
{
for
(
int
i
=
0
;
i
<=
2
;
i
++)
{
for
(
int
i
=
0
;
i
<=
nextDaysLimit
;
i
++)
{
String
currDay
=
LocalDate
.
now
().
plusDays
(
i
).
format
(
DateTimeFormatter
.
ISO_LOCAL_DATE
);
log
.
info
(
"dispatchRun begin----- group:{}, day:{}"
,
groupId
,
currDay
);
String
batchNo
=
batchService
.
buildBatch
No
(
groupId
,
currDay
);
String
batchNo
=
batchService
.
buildBatch
Data
(
groupId
,
currDay
);
UUID
problemId
=
solveService
.
generateProblemId
(
groupId
,
batchNo
);
log
.
info
(
"dispatchRun group:{}, day:{}, batch:{}, problemId:{}"
,
groupId
,
currDay
,
batchNo
,
problemId
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/BatchService.java
View file @
1d704a3
...
...
@@ -17,7 +17,7 @@ public interface BatchService {
// 检查指定日期的小组是否有在运行的批次任务,有则返回,没有则创建后返回批次码
@Transactional
String
buildBatch
No
(
String
groupId
,
String
day
)
throws
SQLException
;
String
buildBatch
Data
(
String
groupId
,
String
day
)
throws
SQLException
;
DispatchBatch
queryBatch
(
String
groupId
,
String
day
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/BatchServiceImpl.java
View file @
1d704a3
...
...
@@ -56,7 +56,7 @@ public class BatchServiceImpl implements BatchService {
// 检查给定小组、日期是否有在运行的批次任务,没则返回,没有则创建
@Transactional
@Override
public
String
buildBatch
No
(
String
groupId
,
String
day
)
{
public
String
buildBatch
Data
(
String
groupId
,
String
day
)
{
log
.
info
(
"准备批次数据, groupId:{}, day:{}"
,
groupId
,
day
);
String
batchNo
=
""
;
String
batchDay
=
""
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SolveServiceImpl.java
View file @
1d704a3
...
...
@@ -76,7 +76,7 @@ public class SolveServiceImpl implements SolveService {
Depot
oneDepot
;
Optional
<
OrgGroup
>
optional
=
groupRepository
.
findByGroupId
(
groupId
);
if
(!
optional
.
isPresent
())
{
log
.
error
(
"组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}"
);
log
.
error
(
"组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
throw
new
RuntimeException
(
String
.
format
(
"组织问题对象, 未查询到组织信息 ,groupId:%s, batchNo:%s"
,
groupId
,
batchNo
));
}
...
...
@@ -118,10 +118,10 @@ public class SolveServiceImpl implements SolveService {
Depot
depot
=
new
Depot
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
location
,
60
*
8
,
60
*
18
);
depotList
.
add
(
depot
);
log
.
info
(
"组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{}"
,
groupId
,
batchNo
,
engineer
.
getEngineerCode
());
// log.debug
("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{}", groupId, batchNo, engineer.getEngineerCode());
List
<
String
>
skillList
=
queryEngineerSkills
(
engineer
.
getEngineerCode
());
log
.
info
(
"组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}"
,
groupId
,
batchNo
,
engineer
.
getEngineerCode
(),
String
.
join
(
";"
,
skillList
));
// log.debug
("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}", groupId, batchNo, engineer.getEngineerCode(), String.join(";", skillList));
// 距离偏好map
Map
<
String
,
Long
>
preferedLoctionDistanceMap
=
new
HashMap
<
String
,
Long
>();
...
...
@@ -136,8 +136,8 @@ public class SolveServiceImpl implements SolveService {
technicianList
.
add
(
vehicle
);
});
log
.
info
(
"组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}"
,
groupId
,
batchNo
,
depotList
);
log
.
info
(
"组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}"
,
groupId
,
batchNo
,
technicianList
);
log
.
info
(
"组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}"
,
groupId
,
batchNo
,
depotList
.
size
()
);
log
.
info
(
"组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}"
,
groupId
,
batchNo
,
technicianList
.
size
()
);
//locationlist
List
<
Location
>
locationList
=
Stream
.
concat
(
depotList
.
stream
().
map
(
Depot:
:
getLocation
),
customerList
.
stream
().
map
(
Customer:
:
getLocation
)).
collect
(
Collectors
.
toList
());
...
...
@@ -180,7 +180,8 @@ public class SolveServiceImpl implements SolveService {
DispatchSolution
.
class
);
// Set the output file.
exporter
.
write
(
solution
,
new
File
(
"dispatchSolution.json"
));
String
fileName
=
String
.
format
(
"dispatchSolution-%s-%s.json"
,
groupId
,
batchNo
);
exporter
.
write
(
solution
,
new
File
(
fileName
));
return
solution
;
}
...
...
project-dispatch/src/main/resources/application-dev.yaml
View file @
1d704a3
...
...
@@ -3,7 +3,8 @@ server:
dispatch
:
cron
:
expr
:
0 45 8-18 * * ?
expr
:
0 36 8-18 * * ?
next-day-limit
:
3
# expr: 0 */10 8-18 * * ?
spring
:
...
...
project-dispatch/src/main/resources/application.yaml
View file @
1d704a3
...
...
@@ -4,6 +4,7 @@ server:
dispatch
:
cron
:
expr
:
0 */30 8-18 * * ?
next-day-limit
:
3
spring
:
application
:
...
...
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