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
eacad5b4
Commit
eacad5b4
authored
Jul 19, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改进 redis 写入策略
parent
72525d10
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
27 deletions
+67
-27
dispatcher.py
core/dispatcher.py
+54
-24
realtime_dispatch.py
realtime_dispatch.py
+1
-1
tables.py
tables.py
+12
-2
No files found.
core/dispatcher.py
View file @
eacad5b4
...
...
@@ -120,6 +120,8 @@ class DispatchSubmission:
self
.
logger
.
error
(
es
)
if
task
in
[
0
,
1
,
2
]:
# 卡车空载或在装载区出场前, 可变更卸载目的地
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
...
...
@@ -130,8 +132,9 @@ class DispatchSubmission:
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
if
(
item
is
None
)
or
(
dispatch_seq
[
0
]
is
None
):
raise
Exception
(
"调度计划表与实时监控不匹配"
)
if
item
is
None
:
raise
Exception
(
"调度计划配置异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
...
...
@@ -139,11 +142,21 @@ class DispatchSubmission:
.
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
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["dumpId"] = DispatchInfo.unload_area_dump_dict[dispatch_seq[1]]
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"groupId"
]
=
group_id
...
...
@@ -153,13 +166,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
[
3
,
4
,
5
]:
# 卡车重载或在卸载区出场前, 可变更装载目的地
try
:
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
.
filter_by
(
...
...
@@ -168,8 +184,8 @@ class DispatchSubmission:
truck_id
=
truck_id
,
group_id
=
group_id
,
isdeleted
=
0
,
)
.
first
())
if
(
item
is
None
)
or
(
dispatch_seq
[
0
]
is
None
)
:
raise
Exception
(
"调度计划
表与实时监控不匹配
"
)
if
item
is
None
:
raise
Exception
(
"调度计划
配置异常
"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
...
...
@@ -177,9 +193,20 @@ class DispatchSubmission:
.
filter_by
(
truck_id
=
truck_id
,
# group_id=group_id,
isdeleted
=
0
,
)
.
first
())
# 调度目的地写入
try
:
record
[
"dispatchId"
]
=
item
.
id
if
dispatch_seq
[
0
]
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
record
[
"exactorId"
]
=
dispatch_seq
[
0
]
except
Exception
as
es
:
record
[
"exactorId"
]
=
item
.
exactor_id
self
.
logger
.
error
(
es
)
# 其余调度信息写入
try
:
record
[
"dispatchId"
]
=
item
.
id
# record["exactorId"] = dispatch_seq[0]
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
...
...
@@ -190,12 +217,15 @@ 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
:
try
:
# 查询车辆相关派车计划
try
:
item
=
(
session_mysql
.
query
(
DispatchSetting
)
...
...
@@ -204,15 +234,8 @@ class DispatchSubmission:
truck_id
=
truck_id
,
group_id
=
group_id
,
isdeleted
=
0
)
.
first
())
if
(
item
is
None
)
or
(
dispatch_seq
[
0
]
is
None
):
raise
Exception
(
"调度计划表与实时监控不匹配"
)
# self.logger.info(dispatch_seq[1])
# self.logger.info(DeviceMap.excavator_index_to_uuid_dict[dispatch_seq[1]])
# print("item")
# print(item.id, item.truck_id, item.exactor_id, item.dump_id)
if
item
is
None
:
raise
Exception
(
"调度计划配置异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
item
=
(
...
...
@@ -221,10 +244,18 @@ class DispatchSubmission:
# 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
self
.
logger
.
error
(
es
)
try
:
record
[
"dispatchId"
]
=
item
.
id
record
[
"exactorId"
]
=
dispatch_seq
[
0
]
#
record["exactorId"] = dispatch_seq[0]
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
...
...
@@ -238,12 +269,11 @@ class DispatchSubmission:
# record["createtime"] = datetime.now().strftime(
# "%b %d, %Y %I:%M:%S %p")
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡故障或备停区-redis写入异常"
)
self
.
logger
.
error
(
es
)
finally
:
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡故障或备停区"
)
...
...
realtime_dispatch.py
View file @
eacad5b4
...
...
@@ -142,7 +142,6 @@ def process(dispatcher):
# logger.info(DispatchInfo.dump_group_dict)
# logger.info(DispatchInfo.truck_group_dict)
# 调度生成
dispatcher
.
period_update
()
...
...
@@ -157,6 +156,7 @@ def process(dispatcher):
except
Exception
as
es
:
logger
.
error
(
"最外层异常捕获"
)
logger
.
error
(
es
)
direct2redis
()
def
perform
(
inc
,
dispatcher
):
...
...
tables.py
View file @
eacad5b4
...
...
@@ -507,8 +507,11 @@ class DumpArea(Base):
Materials
=
Column
(
VARCHAR
(
36
))
Priority
=
Column
(
Integer
)
DumpEquipmentId
=
Column
(
VARCHAR
(
36
))
EntranceNodeId
=
Column
(
VARCHAR
(
50
))
ExitNodeId
=
Column
(
VARCHAR
(
50
))
Name
=
Column
(
VARCHAR
(
36
))
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Materials
,
Priority
,
DumpEquipmentId
):
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Materials
,
Priority
,
DumpEquipmentId
,
EntranceNodeId
,
ExitNodeId
,
Name
):
self
.
Id
=
Id
self
.
BindList
=
BindList
self
.
UnloadAbililty
=
UnloadAbililty
...
...
@@ -516,6 +519,9 @@ class DumpArea(Base):
self
.
Materials
=
Materials
self
.
Priority
=
Priority
self
.
DumpEquipmentId
=
DumpEquipmentId
self
.
EntranceNodeId
=
EntranceNodeId
self
.
ExitNodeId
=
ExitNodeId
self
.
Name
=
Name
class
DiggingWorkArea
(
Base
):
...
...
@@ -525,12 +531,16 @@ class DiggingWorkArea(Base):
Material
=
Column
(
VARCHAR
(
36
))
ExactorId
=
Column
(
VARCHAR
(
36
))
ExactorUuid
=
Column
(
VARCHAR
(
50
))
EntranceNodeId
=
Column
(
VARCHAR
(
50
))
ExitNodeId
=
Column
(
VARCHAR
(
50
))
def
__init__
(
self
,
Id
,
Material
,
ExactorId
,
ExactorUuid
):
def
__init__
(
self
,
Id
,
Material
,
ExactorId
,
ExactorUuid
,
EntranceNodeId
,
ExitNodeId
):
self
.
Id
=
Id
self
.
Material
=
Material
self
.
ExactorId
=
ExactorId
self
.
ExactorUuid
=
ExactorUuid
self
.
EntranceNodeId
=
EntranceNodeId
self
.
ExitNodeId
=
ExitNodeId
class
DispatchRule
(
Base
):
...
...
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