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
c6d3e92b
Commit
c6d3e92b
authored
Jul 20, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新调度写入机制
parent
3faa8a40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
99 deletions
+59
-99
dispatcher.py
core/dispatcher.py
+59
-67
realtime_dispatch_test.py
realtime_dispatch_test.py
+0
-32
No files found.
core/dispatcher.py
View file @
c6d3e92b
...
...
@@ -110,7 +110,6 @@ class DispatchSubmission:
"""
try
:
try
:
# group_id = self.group.dispatch_truck_group[truck_id]
group_id
=
DispatchInfo
.
truck_group_dict
[
truck_id
]
record
=
{
"truckId"
:
truck_id
}
...
...
@@ -123,41 +122,37 @@ class DispatchSubmission:
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
# exactor_id=dispatch_seq[0],
# dump_id=dispatch_seq[1],
truck_id
=
truck_id
,
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
dump_id
=
DispatchInfo
.
unload_area_dump_dict
[
dispatch_seq
[
1
]]
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
dump_id
=
dump_id
,
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
if
item
is
None
:
raise
Exception
(
"调度计划配置异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
truck_id
=
truck_id
,
# group_id=group_id,
isdeleted
=
0
,
)
.
first
())
# 调度目的地写入
try
:
if
dispatch_seq
[
0
]
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
record
[
"dumpId"
]
=
DispatchInfo
.
unload_area_dump_dict
[
dispatch_seq
[
1
]]
except
Exception
as
es
:
record
[
"dumpId"
]
=
item
.
dump_id
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
self
.
logger
.
error
(
es
)
# # 调度目的地写入
# try:
# if dispatch_seq[0] is None:
# raise Exception("调度计划表与实时监控不匹配")
# record["dumpId"] = DispatchInfo.unload_area_dump_dict[dispatch_seq[1]]
# record["unloadAreaId"] = dispatch_seq[1]
# except Exception as es:
# # item = (session_mysql.query(DispatchSetting).filter_by(truck_id=truck_id, isdeleted=0, ).first())
# record["dumpId"] = item.dump_id
# record["unloadAreaId"] = item.unload_area_id
# self.logger.error(es)
# 其余调度信息写入
try
:
record
[
"dispatchId"
]
=
item
.
id
record
[
"exactorId"
]
=
item
.
exactor_id
# record["dumpId"] = DispatchInfo.unload_area_dump_dict[dispatch_seq[1]]
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"groupId"
]
=
group_id
record
[
"isdeleted"
]
=
False
...
...
@@ -176,39 +171,34 @@ class DispatchSubmission:
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
# exactor_id=dispatch_seq[0],
# dump_id=dispatch_seq[1],
truck_id
=
truck_id
,
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
if
item
is
None
:
raise
Exception
(
"调度计划配置异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
truck_id
=
truck_id
,
# group_id=group_id,
isdeleted
=
0
,
)
.
first
())
# 调度目的地写入
try
:
if
dispatch_seq
[
0
]
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
record
[
"exactorId"
]
=
dispatch_seq
[
0
]
except
Exception
as
es
:
record
[
"exactorId"
]
=
item
.
exactor_id
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
self
.
logger
.
error
(
es
)
# 其余调度信息写入
# # 调度目的地写入
# try:
# if dispatch_seq[0] is None:
# raise Exception("调度计划表与实时监控不匹配")
# record["exactorId"] = dispatch_seq[0]
# record["loadAreaId"] = DispatchInfo.excavator_load_dict[dispatch_seq[0]]
# except Exception as es:
# # item = (session_mysql.query(DispatchSetting).filter_by(truck_id=truck_id, isdeleted=0, ).first())
# record["exactorId"] = item.exactor_id
# record["loadAreaId"] = item.load_area_id
# self.logger.error(es)
# 调度信息写入
try
:
record
[
"dispatchId"
]
=
item
.
id
# record["exactorId"] = dispatch_seq[0]
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"groupId"
]
=
group_id
record
[
"isdeleted"
]
=
False
...
...
@@ -227,37 +217,39 @@ class DispatchSubmission:
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
# exactor_id=dispatch_seq[0],
truck_id
=
truck_id
,
group_id
=
group_id
,
isdeleted
=
0
)
.
first
())
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
group_id
=
group_id
,
isdeleted
=
0
)
.
first
())
if
item
is
None
:
raise
Exception
(
"调度计划配置异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
truck_id
=
truck_id
,
# group_id=group_id,
isdeleted
=
0
)
.
first
())
# 调度目的地写入
try
:
if
dispatch_seq
[
0
]
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
record
[
"exactorId"
]
=
dispatch_seq
[
0
]
except
Exception
as
es
:
record
[
"exactorId"
]
=
item
.
exactor_id
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
self
.
logger
.
error
(
es
)
# # 调度目的地写入
# try:
# if dispatch_seq[0] is None:
# raise Exception("调度计划表与实时监控不匹配")
# record["exactorId"] = dispatch_seq[0]
# record["loadAreaId"] = DispatchInfo.excavator_load_dict[dispatch_seq[0]]
# except Exception as es:
# item = (
# session_mysql.query(DispatchSetting)
# .filter_by(truck_id=truck_id,
# isdeleted=0).first())
# record["exactorId"] = item.exactor_id
# record["loadAreaId"] = item.load_area_id
# self.logger.error(es)
# 调度信息写入
try
:
record
[
"dispatchId"
]
=
item
.
id
# record["exactorId"] = dispatch_seq[0]
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"groupId"
]
=
group_id
record
[
"isdeleted"
]
=
False
...
...
realtime_dispatch_test.py
View file @
c6d3e92b
...
...
@@ -59,22 +59,12 @@ def process(dispatcher):
:return: None
"""
# # 直接读取数据库写入redis
# direct2redis()
# try:
# 更新周期参数
logger
.
info
(
"#####################################周期更新开始#####################################"
)
global_period_para_update
()
# if get_value("dynamic_dump_num") * get_value("dynamic_excavator_num") == 0:
# raise Exception("无动态派车计划可用")
# return
# if get_value("dynamic_truck_num") == 0:
# raise Exception("无动态派车可用矿卡")
# return
# 清空数据库缓存
session_mysql
.
commit
()
session_mysql
.
flush
()
...
...
@@ -96,28 +86,6 @@ def process(dispatcher):
DispatchInfo
.
update_group_name
()
# logger.info
# group_set = set()
#
# # device group structure
# load_excavator_dict = {} # 装载区id-->>电铲编号的映射
# excavator_load_dict = {} # 电铲编号->>装载区id的映射
#
# group_excavator_dict = {} # team_id -> dict {[excavator_id, excavator_id], ...}
# excavator_group_dict = {} # excavator_id -> team_id 问题:多个key值对应一个value值
#
# group_dump_dict = {} # team_id -> dict {unload_area_id, unload_area_id, ...}
# dump_group_dict = {} # unload_area_id -> team_id
#
# group_truck_dict = {} # team_id -> dict # {group_id:[truck_id,truck_id],...}
# truck_group_dict = {} # truck_id -> team_id
#
# # group feature
# group_mode = {} # 数据格式: {team_id:mode_code}
#
# # route_distance(路网距离)
# load_distance = {}
# unload_distance = {}
logger
.
info
(
"Dispatchinfo,更新后信息"
)
logger
.
info
(
"group_set"
)
logger
.
info
(
DispatchInfo
.
group_set
)
...
...
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