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 a7a5faab
authored
Jul 03, 2023
by
张晓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充回写逻辑
1 parent
d5696b02
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
13 deletions
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/controller/PrepareController.java
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/service/PrepareService.java
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/service/impl/PrepareServiceImpl.java
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/controller/PrepareController.java
View file @
a7a5faa
...
@@ -78,7 +78,7 @@ public class PrepareController {
...
@@ -78,7 +78,7 @@ public class PrepareController {
VehicleRoutingSolution
problem
=
solveService
.
prepareSolution
(
groupId
,
batchNo
);
VehicleRoutingSolution
problem
=
solveService
.
prepareSolution
(
groupId
,
batchNo
);
solverManager
.
solveAndListen
(
problemId
,
id
->
problem
,
solverManager
.
solveAndListen
(
problemId
,
id
->
problem
,
this
.
prepareService
::
save
SolutionToDispatch
);
this
.
prepareService
::
save
AndExtractSolution
);
log
.
error
(
"调用引擎处理-异步处理, 已触发异步, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
log
.
error
(
"调用引擎处理-异步处理, 已触发异步, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
...
...
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/service/PrepareService.java
View file @
a7a5faa
...
@@ -17,9 +17,16 @@ public interface PrepareService {
...
@@ -17,9 +17,16 @@ public interface PrepareService {
/*
/*
* 将计算结果回写到dispatch2个表、以及order两个表
* 是下面两个方法的包装
* */
void
saveAndExtractSolution
(
VehicleRoutingSolution
solution
)
throws
RuntimeException
;
/*
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
* */
* */
void
saveSolutionToDispatch
(
VehicleRoutingSolution
solution
)
throws
RuntimeException
;
void
saveSolutionToDispatch
(
String
groupId
,
String
batchNo
,
VehicleRoutingSolution
solution
)
throws
RuntimeException
;
/*
/*
* 将dispath_order 中的计算结果,回写到 order_request, order_appointment
* 将dispath_order 中的计算结果,回写到 order_request, order_appointment
...
@@ -28,4 +35,6 @@ public interface PrepareService {
...
@@ -28,4 +35,6 @@ public interface PrepareService {
* */
* */
void
extractDispatchToOrder
(
String
groupId
,
String
batchNo
)
throws
SQLException
;
void
extractDispatchToOrder
(
String
groupId
,
String
batchNo
)
throws
SQLException
;
}
}
project-pre-dispatch/src/main/java/com/dituhui/pea/pre/service/impl/PrepareServiceImpl.java
View file @
a7a5faa
...
@@ -62,32 +62,46 @@ public class PrepareServiceImpl implements PrepareService {
...
@@ -62,32 +62,46 @@ public class PrepareServiceImpl implements PrepareService {
OrderAppointmentRepository
orderAppointmentRepo
;
OrderAppointmentRepository
orderAppointmentRepo
;
/*
* 将计算结果回写到dispatch2个表、以及order两个表
* */
@Override
public
void
saveAndExtractSolution
(
VehicleRoutingSolution
solution
)
throws
RuntimeException
{
String
groupId
=
solution
.
getGroupId
();
String
batchNo
=
solution
.
getBatchNo
();
log
.
info
(
"算法结果回写包装方法, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
this
.
saveSolutionToDispatch
(
groupId
,
batchNo
,
solution
);
try
{
this
.
extractDispatchToOrder
(
solution
.
getGroupId
(),
solution
.
getBatchNo
());
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
/**
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
*/
*/
@Override
@Override
public
void
saveSolutionToDispatch
(
VehicleRoutingSolution
solution
)
throws
RuntimeException
{
public
void
saveSolutionToDispatch
(
String
groupId
,
String
batchNo
,
VehicleRoutingSolution
solution
)
throws
RuntimeException
{
String
groupId
=
solution
.
getGroupId
();
log
.
info
(
"算法结果回写dispatch, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
String
batchNo
=
solution
.
getBatchNo
();
log
.
info
(
"算法结果回写, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
// 清理当前批次指派结果
// 清理当前批次指派结果
log
.
info
(
"算法结果回写, step1-清除历史, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
log
.
info
(
"算法结果回写
dispatch
, step1-清除历史, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
Object
[]
paramClear
=
{
groupId
,
batchNo
};
Object
[]
paramClear
=
{
groupId
,
batchNo
};
try
{
try
{
queryRunner
.
update
(
" update dispatch_order set engineer_code='' , seq=0, time_begin=null ,time_end=null where group_id=? and batch_no=? "
,
paramClear
);
queryRunner
.
update
(
" update dispatch_order set engineer_code='' , seq=0, time_begin=null ,time_end=null where group_id=? and batch_no=? "
,
paramClear
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
log
.
info
(
"算法结果回写, step1-清除历史异常, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
log
.
info
(
"算法结果回写
dispatch
, step1-清除历史异常, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
String
sql
=
"update dispatch_order set engineer_code=? , seq=?, time_begin=? ,time_end=? where group_id=? and batch_no=? and order_id=? "
;
String
sql
=
"update dispatch_order set engineer_code=? , seq=?, time_begin=? ,time_end=? where group_id=? and batch_no=? and order_id=? "
;
log
.
info
(
"算法结果回写, step2-开始回写, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
log
.
info
(
"算法结果回写
dispatch
, step2-开始回写, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
// 保存当前批次指派结果
// 保存当前批次指派结果
solution
.
getVehicleList
().
forEach
(
vehicle
->
{
solution
.
getVehicleList
().
forEach
(
vehicle
->
{
log
.
info
(
"算法结果回写, step2.1-按技术员逐个回写, groupId:{}, batchNo:{}, employ: {}, max-minute:{}, customlist.size:{}"
,
log
.
info
(
"算法结果回写
dispatch
, step2.1-按技术员逐个回写, groupId:{}, batchNo:{}, employ: {}, max-minute:{}, customlist.size:{}"
,
groupId
,
batchNo
,
vehicle
.
getId
(),
vehicle
.
getMaxMinute
(),
vehicle
.
getCustomerList
().
size
());
groupId
,
batchNo
,
vehicle
.
getId
(),
vehicle
.
getMaxMinute
(),
vehicle
.
getCustomerList
().
size
());
AtomicInteger
seq
=
new
AtomicInteger
();
AtomicInteger
seq
=
new
AtomicInteger
();
...
@@ -112,7 +126,7 @@ public class PrepareServiceImpl implements PrepareService {
...
@@ -112,7 +126,7 @@ public class PrepareServiceImpl implements PrepareService {
LocalDateTime
localEndTime
=
localExpectBegin
.
plusMinutes
(
dOrder
.
getTakeTime
());
LocalDateTime
localEndTime
=
localExpectBegin
.
plusMinutes
(
dOrder
.
getTakeTime
());
Date
end
=
Date
.
from
(
localEndTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
Date
end
=
Date
.
from
(
localEndTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
log
.
info
(
"算法结果回写, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, customer-duration:{} "
,
log
.
info
(
"算法结果回写
dispatch
, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, customer-duration:{} "
,
groupId
,
batchNo
,
vehicle
.
getId
(),
customer
.
getId
(),
customer
.
getDuration
());
groupId
,
batchNo
,
vehicle
.
getId
(),
customer
.
getId
(),
customer
.
getDuration
());
Object
[]
param
=
{
vehicle
.
getId
(),
idx
,
expectBegin
[
0
],
end
,
groupId
,
batchNo
,
customer
.
getId
()};
Object
[]
param
=
{
vehicle
.
getId
(),
idx
,
expectBegin
[
0
],
end
,
groupId
,
batchNo
,
customer
.
getId
()};
...
@@ -120,7 +134,7 @@ public class PrepareServiceImpl implements PrepareService {
...
@@ -120,7 +134,7 @@ public class PrepareServiceImpl implements PrepareService {
try
{
try
{
queryRunner
.
update
(
sql
,
param
);
queryRunner
.
update
(
sql
,
param
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
log
.
error
(
"算法结果回写, step3-逐个客户处理, sqlerror"
,
e
);
log
.
error
(
"算法结果回写
dispatch
, step3-逐个客户处理, sqlerror"
,
e
);
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -132,7 +146,7 @@ public class PrepareServiceImpl implements PrepareService {
...
@@ -132,7 +146,7 @@ public class PrepareServiceImpl implements PrepareService {
});
});
log
.
info
(
"算法结果回写完成, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
log
.
info
(
"算法结果回写
dispatch
完成, groupId:{}, batchNo:{}"
,
groupId
,
batchNo
);
}
}
...
...
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