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 39c7d181
authored
Nov 07, 2023
by
Ren Ping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:自动任务优化
1 parent
83792934
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
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.yaml
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/BatchServiceImpl.java
View file @
39c7d18
...
...
@@ -214,6 +214,11 @@ public class BatchServiceImpl implements BatchService {
}
else
{
batchNo
=
optional
.
get
().
getBatchNo
();
batchDay
=
optional
.
get
().
getBatchDate
();
// 执行数据库操作
String
sqlInsert
=
"update dispatch_batch set"
+
" group_id=?, engineer_num=0, order_num=0, start_time=?, end_time=null,status='RUNNING'"
+
" where team_id=? and batch_no=?"
;
jdbcTemplate
.
update
(
sqlInsert
,
groupId
,
LocalDateTime
.
now
(),
teamId
,
batchNo
);
}
log
.
info
(
"清理原批次数据, teamId:{}, day:{}, batchNo:{}"
,
teamId
,
batchDay
,
batchNo
);
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/service/impl/SolveServiceImpl.java
View file @
39c7d18
package
com
.
dituhui
.
pea
.
dispatch
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.dituhui.pea.dispatch.common.GeoDistanceCalculator
;
import
com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider
;
...
...
@@ -260,7 +261,7 @@ public class SolveServiceImpl implements SolveService {
// technicianList
ArrayList
<
Technician
>
technicianList
=
new
ArrayList
<>();
dispatchEngineerRepo
.
findByTeamIdAndBatchNo
(
teamId
,
batchNo
).
forEach
(
engineer
->
{
Location
location
=
new
Location
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
"中心点"
,
Double
.
parseDouble
(
engineer
.
getX
()),
Double
.
parseDouble
(
engineer
.
getY
()));
Location
location
=
new
Location
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
"中心点"
,
StrUtil
.
isEmpty
(
engineer
.
getX
())
?
0
:
Double
.
parseDouble
(
engineer
.
getX
()),
StrUtil
.
isEmpty
(
engineer
.
getY
())
?
0
:
Double
.
parseDouble
(
engineer
.
getY
()));
// Depot depot = new Depot(engineer.getId(), engineer.getEngineerCode(), location, 60 * 8, 60 * 18);
// depotList.add(depot);
...
...
@@ -281,7 +282,7 @@ public class SolveServiceImpl implements SolveService {
if
(
engineer
.
getVehicleType
()
!=
null
&&
engineer
.
getVehicleType
()
==
2
)
{
maxDistance
=
40
*
1000
;
}
Technician
vehicle
=
new
Technician
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
engineer
.
getMaxNum
(),
engineer
.
getMaxMinute
(),
maxDistance
,
engineer
.
getVehicleType
()
,
oneDepot
,
60
*
8
,
60
*
18
,
Set
.
copyOf
(
skillList
),
preferedLoctionDistanceMap
);
Technician
vehicle
=
new
Technician
(
engineer
.
getId
(),
engineer
.
getEngineerCode
(),
engineer
.
getMaxNum
(),
engineer
.
getMaxMinute
(),
maxDistance
,
engineer
.
getVehicleType
()
,
oneDepot
,
60
*
8
,
60
*
18
,
Set
.
copyOf
(
skillList
),
preferedLoctionDistanceMap
);
technicianList
.
add
(
vehicle
);
});
...
...
@@ -302,7 +303,7 @@ public class SolveServiceImpl implements SolveService {
distanceCalculator
.
initDistanceMaps
(
locationList
,
vehicleTypes
);
long
time2
=
System
.
currentTimeMillis
();
log
.
info
(
"组织问题对象 done, teamId:{}, batchNo:{}, technician-size:{}, customer-size:{}, location-size:{}, 路网耗时path:{}ms"
,
teamId
,
batchNo
,
technicianList
.
size
(),
customerList
.
size
(),
locationList
.
size
(),
time2
-
time1
);
log
.
info
(
"组织问题对象 done, teamId:{}, batchNo:{}, technician-size:{}, customer-size:{}, location-size:{}, 路网耗时path:{}ms"
,
teamId
,
batchNo
,
technicianList
.
size
(),
customerList
.
size
(),
locationList
.
size
(),
time2
-
time1
);
return
solution
;
...
...
@@ -449,7 +450,7 @@ public class SolveServiceImpl implements SolveService {
log
.
info
(
"算法结果回写dispatch, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} "
,
groupId
,
batchNo
,
technician
.
getCode
(),
customer
.
getCode
(),
customer
.
getServiceDuration
());
log
.
info
(
customer
.
toString
());
LocalDateTime
customDateTime
=
LocalDateTime
.
parse
(
customer
.
getDt
()
+
" 00:00:00"
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
LocalDateTime
customDateTime
=
LocalDateTime
.
parse
(
customer
.
getDt
()
+
" 00:00:00"
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
LocalDateTime
arriveTime
=
customDateTime
.
plusMinutes
(
customer
.
getArrivalTime
());
LocalDateTime
leaveTime
=
customDateTime
.
plusMinutes
(
customer
.
getDepartureTime
());
...
...
@@ -500,7 +501,7 @@ public class SolveServiceImpl implements SolveService {
log
.
info
(
"算法结果回写dispatch, step3-逐个客户处理, teamId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} "
,
teamId
,
batchNo
,
technician
.
getCode
(),
customer
.
getCode
(),
customer
.
getServiceDuration
());
log
.
info
(
customer
.
toString
());
LocalDateTime
customDateTime
=
LocalDateTime
.
parse
(
customer
.
getDt
()
+
" 00:00:00"
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
LocalDateTime
customDateTime
=
LocalDateTime
.
parse
(
customer
.
getDt
()
+
" 00:00:00"
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
LocalDateTime
arriveTime
=
customDateTime
.
plusMinutes
(
customer
.
getArrivalTime
());
LocalDateTime
leaveTime
=
customDateTime
.
plusMinutes
(
customer
.
getDepartureTime
());
...
...
project-dispatch/src/main/resources/application.yaml
View file @
39c7d18
...
...
@@ -60,12 +60,13 @@ spring:
#调度实例失效的检查时间间隔
clusterCheckinInterval
:
10000
useProperties
:
false
misfireThreshold
:
600000
threadPool
:
class
:
org.quartz.simpl.SimpleThreadPool
# 指定在线程池里面创建的线程是否是守护线程
makeThreadsDaemons
:
false
#指定线程数,至少为1(无默认值,一般设置为1-100)
threadCount
:
5
threadCount
:
10
#设置线程的优先级(最大为java.lang.Thread.MAX_PRIORITY 10,最小为Thread.MIN_PRIORITY 1,默认为5)
threadPriority
:
5
threadsInheritContextClassLoaderOfInitializingThread
:
true
...
...
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