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 e16f06dc
authored
Jul 10, 2023
by
张晓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug batch
1 parent
5f0bc92b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
19 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 @
e16f06d
...
@@ -3,6 +3,9 @@ FROM openjdk:11-jdk-slim as builder
...
@@ -3,6 +3,9 @@ FROM openjdk:11-jdk-slim as builder
LABEL author="yuluo" \
LABEL author="yuluo" \
email="yuluo829@aliyun.com"
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/target/project-dispatch-*.jar /app.jar
ADD
./project-dispatch/src/main/resources/data /data
ADD
./project-dispatch/src/main/resources/data /data
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/DispatchServiceApplication.java
View file @
e16f06d
...
@@ -24,7 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
...
@@ -24,7 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author gpzhang
* @author gpzhang
*/
*/
@SpringBootApplication
@SpringBootApplication
//
@EnableScheduling
@EnableScheduling
public
class
DispatchServiceApplication
{
public
class
DispatchServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/controller/BatchController.java
View file @
e16f06d
...
@@ -95,7 +95,7 @@ public class BatchController {
...
@@ -95,7 +95,7 @@ public class BatchController {
public
Result
<?>
buildBatch
(
@PathVariable
String
groupId
,
@PathVariable
String
day
)
{
public
Result
<?>
buildBatch
(
@PathVariable
String
groupId
,
@PathVariable
String
day
)
{
log
.
info
(
"buildBatch, groupId:{}, day:{}"
,
groupId
,
day
);
log
.
info
(
"buildBatch, groupId:{}, day:{}"
,
groupId
,
day
);
try
{
try
{
String
batchNo
=
batchService
.
buildBatch
No
(
groupId
,
day
);
String
batchNo
=
batchService
.
buildBatch
Data
(
groupId
,
day
);
DispatchBatch
batch
=
batchService
.
queryBatch
(
groupId
,
batchNo
);
DispatchBatch
batch
=
batchService
.
queryBatch
(
groupId
,
batchNo
);
DispatchBatchDTO
batchDTO
=
new
DispatchBatchDTO
();
DispatchBatchDTO
batchDTO
=
new
DispatchBatchDTO
();
BeanUtil
.
copyProperties
(
batch
,
batchDTO
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
BeanUtil
.
copyProperties
(
batch
,
batchDTO
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
));
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/scheduler/BatchScheduler.java
View file @
e16f06d
...
@@ -10,12 +10,10 @@ import com.dituhui.pea.dispatch.service.SolveService;
...
@@ -10,12 +10,10 @@ import com.dituhui.pea.dispatch.service.SolveService;
import
lombok.extern.slf4j.Slf4j
;
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.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.SolverConfig
;
import
org.optaplanner.core.config.solver.SolverManagerConfig
;
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.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
@@ -23,7 +21,6 @@ import java.io.File;
...
@@ -23,7 +21,6 @@ import java.io.File;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -34,7 +31,10 @@ public class BatchScheduler {
...
@@ -34,7 +31,10 @@ public class BatchScheduler {
String
groupId
=
"gsuzhou"
;
String
groupId
=
"gsuzhou"
;
int
nextDays
=
3
;
@Value
(
"${dispatch.cron.next-day-limit}"
)
int
nextDaysLimit
=
3
;
@Autowired
@Autowired
BatchService
batchService
;
BatchService
batchService
;
...
@@ -65,11 +65,11 @@ public class BatchScheduler {
...
@@ -65,11 +65,11 @@ public class BatchScheduler {
public
void
dispatchRun
()
{
public
void
dispatchRun
()
{
log
.
info
(
"dispatchRun group:{}"
,
groupId
);
log
.
info
(
"dispatchRun group:{}"
,
groupId
);
try
{
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
);
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
);
String
batchNo
=
batchService
.
buildBatch
No
(
groupId
,
currDay
);
String
batchNo
=
batchService
.
buildBatch
Data
(
groupId
,
currDay
);
UUID
problemId
=
solveService
.
generateProblemId
(
groupId
,
batchNo
);
UUID
problemId
=
solveService
.
generateProblemId
(
groupId
,
batchNo
);
log
.
info
(
"dispatchRun group:{}, day:{}, batch:{}, problemId:{}"
,
groupId
,
currDay
,
batchNo
,
problemId
);
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 @
e16f06d
...
@@ -17,7 +17,7 @@ public interface BatchService {
...
@@ -17,7 +17,7 @@ public interface BatchService {
// 检查指定日期的小组是否有在运行的批次任务,有则返回,没有则创建后返回批次码
// 检查指定日期的小组是否有在运行的批次任务,有则返回,没有则创建后返回批次码
@Transactional
@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
);
DispatchBatch
queryBatch
(
String
groupId
,
String
day
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/BatchServiceImpl.java
View file @
e16f06d
...
@@ -56,7 +56,7 @@ public class BatchServiceImpl implements BatchService {
...
@@ -56,7 +56,7 @@ public class BatchServiceImpl implements BatchService {
// 检查给定小组、日期是否有在运行的批次任务,没则返回,没有则创建
// 检查给定小组、日期是否有在运行的批次任务,没则返回,没有则创建
@Transactional
@Transactional
@Override
@Override
public
String
buildBatch
No
(
String
groupId
,
String
day
)
{
public
String
buildBatch
Data
(
String
groupId
,
String
day
)
{
log
.
info
(
"准备批次数据, groupId:{}, day:{}"
,
groupId
,
day
);
log
.
info
(
"准备批次数据, groupId:{}, day:{}"
,
groupId
,
day
);
String
batchNo
=
""
;
String
batchNo
=
""
;
String
batchDay
=
""
;
String
batchDay
=
""
;
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SolveServiceImpl.java
View file @
e16f06d
...
@@ -76,7 +76,7 @@ public class SolveServiceImpl implements SolveService {
...
@@ -76,7 +76,7 @@ public class SolveServiceImpl implements SolveService {
Depot
oneDepot
;
Depot
oneDepot
;
Optional
<
OrgGroup
>
optional
=
groupRepository
.
findByGroupId
(
groupId
);
Optional
<
OrgGroup
>
optional
=
groupRepository
.
findByGroupId
(
groupId
);
if
(!
optional
.
isPresent
())
{
if
(!
optional
.
isPresent
())
{
log
.
error
(
"组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}"
);
log
.
error
(
"组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
throw
new
RuntimeException
(
String
.
format
(
"组织问题对象, 未查询到组织信息 ,groupId:%s, batchNo:%s"
,
groupId
,
batchNo
));
throw
new
RuntimeException
(
String
.
format
(
"组织问题对象, 未查询到组织信息 ,groupId:%s, batchNo:%s"
,
groupId
,
batchNo
));
}
}
...
@@ -118,10 +118,10 @@ public class SolveServiceImpl implements SolveService {
...
@@ -118,10 +118,10 @@ public class SolveServiceImpl implements SolveService {
Depot
depot
=
new
Depot
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
location
,
60
*
8
,
60
*
18
);
Depot
depot
=
new
Depot
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
location
,
60
*
8
,
60
*
18
);
depotList
.
add
(
depot
);
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
());
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
Map
<
String
,
Long
>
preferedLoctionDistanceMap
=
new
HashMap
<
String
,
Long
>();
Map
<
String
,
Long
>
preferedLoctionDistanceMap
=
new
HashMap
<
String
,
Long
>();
...
@@ -136,8 +136,8 @@ public class SolveServiceImpl implements SolveService {
...
@@ -136,8 +136,8 @@ public class SolveServiceImpl implements SolveService {
technicianList
.
add
(
vehicle
);
technicianList
.
add
(
vehicle
);
});
});
log
.
info
(
"组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}"
,
groupId
,
batchNo
,
depotList
);
log
.
info
(
"组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}"
,
groupId
,
batchNo
,
depotList
.
size
()
);
log
.
info
(
"组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}"
,
groupId
,
batchNo
,
technicianList
);
log
.
info
(
"组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}"
,
groupId
,
batchNo
,
technicianList
.
size
()
);
//locationlist
//locationlist
List
<
Location
>
locationList
=
Stream
.
concat
(
depotList
.
stream
().
map
(
Depot:
:
getLocation
),
customerList
.
stream
().
map
(
Customer:
:
getLocation
)).
collect
(
Collectors
.
toList
());
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 {
...
@@ -180,7 +180,8 @@ public class SolveServiceImpl implements SolveService {
DispatchSolution
.
class
);
DispatchSolution
.
class
);
// Set the output file.
// 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
;
return
solution
;
}
}
...
...
project-dispatch/src/main/resources/application-dev.yaml
View file @
e16f06d
...
@@ -3,7 +3,8 @@ server:
...
@@ -3,7 +3,8 @@ server:
dispatch
:
dispatch
:
cron
:
cron
:
expr
:
0 45 8-18 * * ?
expr
:
0 36 8-18 * * ?
next-day-limit
:
3
# expr: 0 */10 8-18 * * ?
# expr: 0 */10 8-18 * * ?
spring
:
spring
:
...
...
project-dispatch/src/main/resources/application.yaml
View file @
e16f06d
...
@@ -4,6 +4,7 @@ server:
...
@@ -4,6 +4,7 @@ server:
dispatch
:
dispatch
:
cron
:
cron
:
expr
:
0 */30 8-18 * * ?
expr
:
0 */30 8-18 * * ?
next-day-limit
:
3
spring
:
spring
:
application
:
application
:
...
@@ -26,7 +27,7 @@ spring:
...
@@ -26,7 +27,7 @@ spring:
enabled
:
false
enabled
:
false
datasource
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://10.10.0.
116
:3306/saas_aftersale_test?serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://10.10.0.
54
:3306/saas_aftersale_test?serverTimezone=Asia/Shanghai
username
:
root
username
:
root
password
:
123456
password
:
123456
type
:
com.alibaba.druid.pool.DruidDataSource
type
:
com.alibaba.druid.pool.DruidDataSource
...
...
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