Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling-v3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张晓彤
integrated-scheduling-v3
Commits
c5099188
Commit
c5099188
authored
Sep 08, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二次调度调试
parent
4ef1d396
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
16 deletions
+138
-16
algorithm.py
alg/algorithm.py
+5
-5
dispatcher.py
core/dispatcher.py
+9
-2
group.py
core/group.py
+33
-9
util.py
core/util.py
+91
-0
调度系统部署说明4.1.docx
调度系统部署说明4.1.docx
+0
-0
No files found.
alg/algorithm.py
View file @
c5099188
...
...
@@ -147,7 +147,7 @@ class ExpectedTime(AlgorithmBase):
:return: travel_time_value
"""
#
try:
try
:
# truck_index = self.truck.truck_uuid_to_index_dict[truck_id]
...
...
@@ -170,10 +170,10 @@ class ExpectedTime(AlgorithmBase):
group_dynamic_excavator_num
=
len
(
self
.
group
.
excavator
)
group_dynamic_unload_area_num
=
len
(
self
.
group
.
unload_area
)
#
#
except Exception as es:
#
self.logger.error("车辆调度信息读取异常")
#
self.logger.error(es)
except
Exception
as
es
:
self
.
logger
.
error
(
"车辆调度信息读取异常"
)
self
.
logger
.
error
(
es
)
if
task
==
-
2
:
################################################ 矿卡启动 ###############################################
...
...
core/dispatcher.py
View file @
c5099188
...
...
@@ -137,6 +137,7 @@ class DispatchSubmission:
if
group_mode
==
3
:
try
:
self
.
logger
.
info
(
f
'调度0 {truck_id}'
)
item
=
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
truck_id
=
truck_id
,
isdeleted
=
0
,
)
.
first
()
record
[
"dispatchId"
]
=
item
.
id
record
[
"exactorId"
]
=
item
.
exactor_id
...
...
@@ -159,8 +160,9 @@ class DispatchSubmission:
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
else
:
if
task
in
[
1
,
2
]
or
(
task
==
3
and
state
==
2
):
# 卡车空载或在装载区出场前, 可变更卸载目的地
if
(
task
in
[
1
,
2
])
or
(
task
==
3
and
state
==
2
):
# 卡车空载或在装载区出场前, 可变更卸载目的地
self
.
logger
.
info
(
f
'调度1 {truck_id}'
)
# 查询车辆相关派车计划
try
:
dump_id
=
DispatchInfo
.
unload_area_dump_dict
[
dispatch_seq
[
1
]]
...
...
@@ -191,14 +193,16 @@ class DispatchSubmission:
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
group_id
]
self
.
logger
.
info
(
f
'redis 注入 {record}'
)
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡空载"
)
self
.
logger
.
error
(
es
)
finally
:
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
elif
task
in
[
4
,
5
]
or
(
task
==
0
and
state
==
2
):
# 卡车重载或在卸载区出场前, 可变更装载目的地
elif
(
task
in
[
4
,
5
])
or
(
task
==
0
and
state
==
2
):
# 卡车重载或在卸载区出场前, 可变更装载目的地
self
.
logger
.
info
(
f
'调度2 {truck_id}'
)
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
group_id
=
group_id
,
...
...
@@ -226,12 +230,14 @@ class DispatchSubmission:
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
group_id
]
self
.
logger
.
info
(
f
'redis 注入 {record}'
)
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡重载"
)
finally
:
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
elif
task
==
-
2
:
self
.
logger
.
info
(
f
'调度3 {truck_id}'
)
try
:
# 查询车辆相关派车计划
...
...
@@ -263,6 +269,7 @@ class DispatchSubmission:
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
group_id
]
self
.
logger
.
info
(
f
'redis 注入 {record}'
)
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
# record["createtime"] = datetime.now().strftime(
# "%b %d, %Y %I:%M:%S %p")
...
...
core/group.py
View file @
c5099188
...
...
@@ -12,6 +12,7 @@ from alg.algorithm import AlgorithmBase,DistributionRatio
import
numpy
as
np
# from settings import get_logger
from
data.para_config
import
get_value
from
core.util
import
redispatch_request
class
CurrentTruck
:
...
...
@@ -245,7 +246,6 @@ class Group:
"""
pass
def
info_update
(
self
):
"""
update group info.
...
...
@@ -281,6 +281,8 @@ class Group:
# except Exception as es:
# self.logger.error("车辆调度信息读取异常")
# self.logger.error(es)
try
:
# 全智能模式
if
self
.
group_mode
==
1
:
# 车辆停止或者车辆位于装载区内, 调度车辆前往卸载区
...
...
@@ -338,29 +340,37 @@ class Group:
except
Exception
as
es
:
self
.
logger
.
error
(
"空载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
es
.
__traceback__
.
tb_lineno
)
self
.
logger
.
error
(
es
)
truck_dispatch
[
i
]
=
[
None
,
None
]
elif
truck_task
==
0
:
try
:
truck_locate
=
self
.
truck
.
get_truck_locate_dict
()[
i
]
except
Exception
as
es
:
self
.
logger
.
error
(
"es"
)
self
.
logger
.
error
(
es
)
# 车辆当前位于交叉路口前,且排队等待
self
.
logger
.
info
(
f
'车辆位置 {truck_locate}'
)
self
.
logger
.
info
(
f
'车辆状态 {self.truck.truck_current_state[i]}'
)
if
truck_locate
in
self
.
topo
.
cross_bf_lanes
and
self
.
truck
.
truck_current_state
[
i
]
==
2
:
self
.
logger
.
info
(
"触发二次调度"
)
# 当前绑定卸载区
if
truck_trip
[
0
]
==
-
1
:
#
if truck_trip[0] == -1:
next_unload_area_id
=
session_mysql
.
query
(
EquipmentPair
)
.
filter_by
(
truck_id
=
i
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
else
:
dump_id
=
get_value
(
"dump_index_to_uuid_dict"
)[
truck_trip
[
0
]]
next_unload_area_id
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)[
dump_id
]
#
else:
#
dump_id = get_value("dump_index_to_uuid_dict")[truck_trip[0]]
#
next_unload_area_id = get_value("dump_uuid_to_unload_area_uuid_dict")[dump_id]
# 当前绑定装载区
if
truck_trip
[
-
1
]
==
-
1
:
#
if truck_trip[-1] == -1:
item
=
session_mysql
.
query
(
EquipmentPair
)
.
filter_by
(
truck_id
=
i
,
isdeleted
=
0
)
.
first
()
current_excavator_id
=
item
.
exactor_id
current_load_area_id
=
item
.
load_area_id
else
:
current_excavator_id
=
get_value
(
"excavator_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
current_load_area_id
=
DispatchInfo
.
excavator_load_dict
[
current_excavator_id
]
self
.
logger
.
info
(
f
'truck_id {i}'
)
self
.
logger
.
info
(
f
'current_load_area_id {current_load_area_id}'
)
# else:
# current_excavator_id = get_value("excavator_index_to_uuid_dict")[truck_trip[-1]]
# current_load_area_id = DispatchInfo.excavator_load_dict[current_excavator_id]
load_area_dict
=
self
.
topo
.
get_load_target_node_real
(
truck_locate
,
current_load_area_id
)
self
.
logger
.
info
(
load_area_dict
)
...
...
@@ -393,11 +403,18 @@ class Group:
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
res
=
redispatch_request
(
i
,
next_excavator_id
,
next_unload_area_id
)
self
.
logger
.
info
(
res
)
self
.
logger
.
info
(
"二次调度结果"
)
self
.
logger
.
info
(
truck_dispatch
[
i
])
elif
truck_task
==
3
:
try
:
truck_locate
=
self
.
truck
.
get_truck_locate_dict
()[
i
]
except
Exception
as
es
:
self
.
logger
.
error
(
"es"
)
self
.
logger
.
error
(
es
)
# 车辆当前位于交叉路口前,且排队等待
if
truck_locate
in
self
.
topo
.
cross_bf_lanes
and
self
.
truck
.
truck_current_state
[
i
]
==
0
:
# 当前绑定装载区
...
...
@@ -440,6 +457,9 @@ class Group:
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
res
=
redispatch_request
(
i
,
next_excavator_id
,
next_unload_area_id
)
self
.
logger
.
info
(
res
)
self
.
logger
.
info
(
"二次调度结果"
)
self
.
logger
.
info
(
truck_dispatch
[
i
])
...
...
@@ -466,6 +486,7 @@ class Group:
except
Exception
as
es
:
self
.
logger
.
error
(
"重载车辆空车智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
if
truck_task
in
[
0
,
1
,
2
]:
try
:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
...
...
@@ -530,5 +551,8 @@ class Group:
truck_dispatch
[
i
]
=
[
next_exactor_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
info
(
es
)
# return dispatch plan
return
truck_dispatch
core/util.py
0 → 100644
View file @
c5099188
#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2022/9/8 9:42
# @Author : Opfer
# @Site :
# @File : util.py
# @Software: PyCharm
import
requests
from
tables
import
*
import
uuid
def
redispatch_request
(
truck_id
,
excavator_id
,
unload_area_id
):
"""
redispatch request.
:param truck_id:
:param excavator_id:
:param unload_area_id:
:return:
"""
exactor_no
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
.
device_name
unload_area_name
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Name
truck_name
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
device_name
real_data
=
{
"exactorId"
:
excavator_id
,
"exactorNo"
:
exactor_no
,
"id"
:
str
(
uuid
.
uuid4
()),
"unloadAreaId"
:
unload_area_id
,
"unloadAreaName"
:
unload_area_name
,
"truckId"
:
truck_id
,
"truckNo"
:
truck_name
,
"isauto"
:
"true"
,
"tempChange"
:
1
,
"immediateEffect"
:
1
}
return
POST
(
real_data
)
def
POST
(
real_data
):
"""
Post.
:param real_data:
:return:
"""
# real_data = {
# "exactorId": "ddaa65cc-2658-4e35-b6ec-9deb046e0bfb",
# "exactorNo": "WJ001",
# "id": "d83f09cb-8df3-44d5-8e46-10dbaa317e19",
# "unloadAreaId": "10c75b23-4134-3ef1-9097-114bacac1982",
# "unloadAreaName": "卸载区4",
# "truckId": "de4080b3-fb89-460d-b511-c2ecd73c815c",
# "truckNo": "de4080b3-fb89-460d-b511-c2ecd73c815c",
# "isauto": "false",
# "tempChange": 1,
# "immediateEffect": 1
# }
#
# real_data = {
# 'exactorId': 'a3d09975-82d7-4a30-8c54-fe4ed8ff5a29',
# 'exactorNo': 'BI395-02',
# 'id': '76cb19a8-6541-4245-8ef6-40682aca9635',
# 'unloadAreaId': 'd4675d61-2134-8be7-fb36-fb9ef3c97f7c',
# 'unloadAreaName': '哈卸4',
# 'truckId': '7c196882-8850-4344-aff8-846a597f7792',
# 'truckNo': '7c196882-8850-4344-aff8-846a597f7792',
# 'isauto': 'true',
# 'tempChange': 1,
# 'immediateEffect': 1
# }
#
# head = {"Content-Type":"application/json; charset=UTF-8", 'Connection': 'close'}
url_d
=
"http://172.16.0.103:8020/ht/api/dispatch/update"
real_data
=
json
.
dumps
(
real_data
)
print
(
real_data
)
res_d
=
requests
.
post
(
url
=
url_d
,
data
=
real_data
)
return
res_d
.
text
#
# truck_id, excavator_id, unload_area_id = "9ce82957-b1e1-4dee-8dd1-3bbfa2a496b5", \
# "a3d09975-82d7-4a30-8c54-fe4ed8ff5a29", \
# "d4675d61-2134-8be7-fb36-fb9ef3c97f7c"
#
# res = redispatch_request(truck_id, excavator_id, unload_area_id)
#
# print(res)
\ No newline at end of file
调度系统部署说明4.1.docx
View file @
c5099188
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment