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
4f0065f8
Commit
4f0065f8
authored
Jun 14, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.static_data_process.py 路网异常修复 2.替换Dispatch 表为 DispatchSetting 表
parent
27dab62a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
401 deletions
+84
-401
dispatcher.py
core/dispatcher.py
+77
-91
dump.py
equipment/dump.py
+1
-1
excavator.py
equipment/excavator.py
+1
-1
truck.py
equipment/truck.py
+0
-1
priority_control.py
path_plan/priority_control.py
+1
-1
static_data_process.py
static_data_process.py
+4
-306
No files found.
core/dispatcher.py
View file @
4f0065f8
...
@@ -10,7 +10,7 @@ from data.dispatchInfo import DispatchInfo
...
@@ -10,7 +10,7 @@ from data.dispatchInfo import DispatchInfo
from
core.group
import
Group
from
core.group
import
Group
from
alg.algorithm
import
ExpectedTime
from
alg.algorithm
import
ExpectedTime
from
settings
import
get_logger
,
session_mysql
,
redis5
from
settings
import
get_logger
,
session_mysql
,
redis5
from
tables
import
Dispatch
,
DispatchMatch
,
DispatchEquipment
,
DispatchGroup
from
tables
import
Dispatch
,
DispatchMatch
,
DispatchEquipment
,
DispatchGroup
,
DispatchSetting
from
para_config
import
DeviceMap
,
get_value
,
global_period_para_update
from
para_config
import
DeviceMap
,
get_value
,
global_period_para_update
from
equipment
import
TruckInfo
,
ExcavatorInfo
,
DumpInfo
from
equipment
import
TruckInfo
,
ExcavatorInfo
,
DumpInfo
from
core.schedule
import
PreSchedule
from
core.schedule
import
PreSchedule
...
@@ -117,39 +117,39 @@ class DispatchSubmission:
...
@@ -117,39 +117,39 @@ class DispatchSubmission:
# group_id=group_id,
# group_id=group_id,
# isauto=1, isdeleted=0, ).first())
# isauto=1, isdeleted=0, ).first())
# item = (
# session_mysql.query(DispatchMatch)
# .filter_by(exactor_id=dispatch_seq[0],
# dump_id=dispatch_seq[1],
# truck_id=truck_id,
# group_id=group_id,
# isauto=1, isdeleted=0, ).first())
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
filter
(
DispatchMatch
.
exactor_id
==
dispatch_seq
[
0
],
dump_id
=
dispatch_seq
[
1
],
DispatchMatch
.
dump_id
==
dispatch_seq
[
1
],
truck_id
=
truck_id
,
DispatchEquipment
.
equipment_id
==
truck_id
,
group_id
=
group_id
,
DispatchMatch
.
id
==
group_id
isauto
=
1
,
isdeleted
=
0
,
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchMatch.exactor_id == dispatch_seq[0],
# DispatchMatch.dump_id == dispatch_seq[1],
# DispatchEquipment.equipment_id == truck_id,
# DispatchMatch.id == group_id
# ).first())
if
item
is
None
:
if
item
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
raise
Exception
(
"调度计划表与实时监控不匹配"
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# item = (
# session_mysql.query(DispatchMatch)
# .filter_by(truck_id=truck_id,
# # group_id=group_id,
# isauto=1, isdeleted=0, ).first())
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
truck_id
=
truck_id
,
filter
(
DispatchEquipment
.
equipment_id
==
truck_id
,
# group_id=group_id,
DispatchMatch
.
id
==
group_id
isauto
=
1
,
isdeleted
=
0
,
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchEquipment.equipment_id == truck_id,
# DispatchMatch.id == group_id
# ).first())
try
:
try
:
# record["exactorId"] = item.exactor_id
# record["exactorId"] = item.exactor_id
...
@@ -178,47 +178,40 @@ class DispatchSubmission:
...
@@ -178,47 +178,40 @@ class DispatchSubmission:
self
.
logger
.
error
(
"调度结果写入异常-矿卡空载"
)
self
.
logger
.
error
(
"调度结果写入异常-矿卡空载"
)
elif
task
in
[
3
,
4
,
5
]:
# 卡车重载或在卸载区出场前, 可变更装载目的地
elif
task
in
[
3
,
4
,
5
]:
# 卡车重载或在卸载区出场前, 可变更装载目的地
try
:
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,
# isauto=1, isdeleted=0, ).first())
# item = (
# session_mysql.query(DispatchMatch)
# .filter_by(exactor_id=dispatch_seq[0],
# dump_id=dispatch_seq[1],
# truck_id=truck_id,
# group_id=group_id,
# isauto=1, isdeleted=0, ).first())
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
filter
(
DispatchMatch
.
exactor_id
==
dispatch_seq
[
0
],
dump_id
=
dispatch_seq
[
1
],
DispatchMatch
.
dump_id
==
dispatch_seq
[
1
],
truck_id
=
truck_id
,
DispatchEquipment
.
equipment_id
==
truck_id
,
group_id
=
group_id
,
DispatchMatch
.
id
==
group_id
isauto
=
1
,
isdeleted
=
0
,
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchMatch.exactor_id == dispatch_seq[0],
# DispatchMatch.dump_id == dispatch_seq[1],
# DispatchEquipment.equipment_id == truck_id,
# DispatchMatch.id == group_id
# ).first())
if
item
is
None
:
if
item
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
raise
Exception
(
"调度计划表与实时监控不匹配"
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# item = (
# session_mysql.query(DispatchMatch)
# .filter_by(truck_id=truck_id,
# # group_id=group_id,
# isauto=1, isdeleted=0, ).first())
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
truck_id
=
truck_id
,
filter
(
DispatchEquipment
.
equipment_id
==
truck_id
,
# group_id=group_id,
DispatchMatch
.
id
==
group_id
isauto
=
1
,
isdeleted
=
0
,
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchEquipment.equipment_id == truck_id,
# DispatchMatch.id == group_id
# ).first())
try
:
try
:
# record["exactorId"] = self.excavator.excavator_index_to_uuid_dict[dispatch_seq[1]]
# record["exactorId"] = self.excavator.excavator_index_to_uuid_dict[dispatch_seq[1]]
...
@@ -248,27 +241,20 @@ class DispatchSubmission:
...
@@ -248,27 +241,20 @@ class DispatchSubmission:
elif
task
==
-
2
:
elif
task
==
-
2
:
try
:
try
:
try
:
try
:
# item = (
# session_mysql.query(Dispatch)
# .filter_by(exactor_id=dispatch_seq[0],
# truck_id=truck_id,
# group_id=group_id,
# isauto=1, isdeleted=0).first())
# load_ability = session_mysql.query(EquipmentSpec.mining_abililty). \
# join(Equipment, Equipment.equipment_spec == EquipmentSpec.id). \
# filter(Equipment.id == self.excavator_index_to_uuid_dict[excavator_index]).first()
self
.
logger
.
info
(
f
'写入矿卡 {truck_id} 调度信息'
)
self
.
logger
.
info
(
f
'挖机 {dispatch_seq[0]}'
)
self
.
logger
.
info
(
f
'分组 {group_id}'
)
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
exactor_id
=
dispatch_seq
[
0
],
filter
(
DispatchMatch
.
exactor_id
==
dispatch_seq
[
0
],
truck_id
=
truck_id
,
DispatchEquipment
.
equipment_id
==
truck_id
,
group_id
=
group_id
,
# DispatchMatch.group_code==group_id
isauto
=
1
,
isdeleted
=
0
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchMatch.exactor_id==dispatch_seq[0],
# DispatchEquipment.equipment_id==truck_id,
# # DispatchMatch.group_code==group_id
# ).first())
if
item
is
None
:
if
item
is
None
:
raise
Exception
(
"调度计划表与实时监控不匹配"
)
raise
Exception
(
"调度计划表与实时监控不匹配"
)
...
@@ -280,18 +266,18 @@ class DispatchSubmission:
...
@@ -280,18 +266,18 @@ class DispatchSubmission:
# print(item.id, item.truck_id, item.exactor_id, item.dump_id)
# print(item.id, item.truck_id, item.exactor_id, item.dump_id)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# item = (
# session_mysql.query(DispatchMatch)
# .filter_by(truck_id=truck_id,
# # group_id=group_id,
# isauto=1, isdeleted=0).first())
item
=
(
item
=
(
session_mysql
.
query
(
DispatchEquipment
.
id
,
DispatchMatch
.
load_area_id
,
DispatchMatch
.
unload_area_id
,
DispatchMatch
.
dump_id
,
DispatchEquipment
.
isdeleted
)
.
session_mysql
.
query
(
DispatchSetting
)
join
(
DispatchEquipment
,
DispatchMatch
.
match_code
==
DispatchEquipment
.
match_code
)
.
.
filter_by
(
truck_id
=
truck_id
,
filter
(
DispatchEquipment
.
equipment_id
==
truck_id
,
# group_id=group_id,
DispatchMatch
.
id
==
group_id
isauto
=
1
,
isdeleted
=
0
)
.
first
())
)
.
first
())
# item = (
# session_mysql.query(DispatchEquipment.id, DispatchMatch.load_area_id, DispatchMatch.unload_area_id, DispatchMatch.dump_id, DispatchEquipment.isdeleted).
# join(DispatchEquipment, DispatchMatch.match_code == DispatchEquipment.match_code).
# filter(DispatchEquipment.equipment_id == truck_id,
# DispatchMatch.id == group_id
# ).first())
try
:
try
:
# record["exactorId"] = item.exactor_id
# record["exactorId"] = item.exactor_id
...
...
equipment/dump.py
View file @
4f0065f8
...
@@ -118,7 +118,7 @@ class DumpInfo(WalkManage):
...
@@ -118,7 +118,7 @@ class DumpInfo(WalkManage):
self
.
dump_material
=
{}
self
.
dump_material
=
{}
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
try
:
try
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
unload_area_id
=
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Materials
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Materials
self
.
dump_material
[
dump_id
]
=
dump_material_id
self
.
dump_material
[
dump_id
]
=
dump_material_id
except
Exception
as
es
:
except
Exception
as
es
:
...
...
equipment/excavator.py
View file @
4f0065f8
...
@@ -131,7 +131,7 @@ class ExcavatorInfo(WalkManage):
...
@@ -131,7 +131,7 @@ class ExcavatorInfo(WalkManage):
self
.
logger
.
info
(
self
.
dynamic_excavator_set
)
self
.
logger
.
info
(
self
.
dynamic_excavator_set
)
for
excavator_id
in
self
.
dynamic_excavator_set
:
for
excavator_id
in
self
.
dynamic_excavator_set
:
try
:
try
:
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
load_area_id
=
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
except
Exception
as
es
:
except
Exception
as
es
:
...
...
equipment/truck.py
View file @
4f0065f8
...
@@ -273,7 +273,6 @@ class TruckInfo(WalkManage):
...
@@ -273,7 +273,6 @@ class TruckInfo(WalkManage):
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
raise
Exception
(
f
"矿卡 {truck_id} 配对关系异常"
)
raise
Exception
(
f
"矿卡 {truck_id} 配对关系异常"
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"配对关系异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
session_postgre
.
rollback
()
session_postgre
.
rollback
()
session_mysql
.
rollback
()
session_mysql
.
rollback
()
...
...
path_plan/priority_control.py
View file @
4f0065f8
...
@@ -112,7 +112,7 @@ class PriorityController:
...
@@ -112,7 +112,7 @@ class PriorityController:
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
):
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
):
try
:
try
:
item
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
exactor_id
=
excavator_id
,
isauto
=
1
,
item
=
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
(
dump_id
=
dump_id
,
exactor_id
=
excavator_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
isdeleted
=
0
)
.
first
()
except
Exception
as
es
:
except
Exception
as
es
:
session_postgre
.
rollback
()
session_postgre
.
rollback
()
...
...
static_data_process.py
View file @
4f0065f8
...
@@ -152,7 +152,7 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
...
@@ -152,7 +152,7 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
excavator_num
=
0
excavator_num
=
0
dump_num
=
0
dump_num
=
0
for
item
in
(
for
item
in
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
()
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
()
):
):
# excavator_id <-> excavator_index
# excavator_id <-> excavator_index
# dump_id <-> dump_index
# dump_id <-> dump_index
...
@@ -301,7 +301,7 @@ def update_fixdisp_truck():
...
@@ -301,7 +301,7 @@ def update_fixdisp_truck():
try
:
try
:
query
=
np
.
array
(
query
=
np
.
array
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isauto
=
0
,
isdeleted
=
0
)
.
all
()
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
(
isauto
=
0
,
isdeleted
=
0
)
.
all
()
)
)
for
item
in
query
:
for
item
in
query
:
...
@@ -338,7 +338,7 @@ def update_autodisp_excavator():
...
@@ -338,7 +338,7 @@ def update_autodisp_excavator():
dynamic_excavator_list
=
[]
dynamic_excavator_list
=
[]
try
:
try
:
for
item
in
(
for
item
in
(
session_mysql
.
query
(
Dispatch
Match
)
.
filter_by
()
.
all
()
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
()
.
all
()
):
):
dynamic_excavator_list
.
append
(
item
.
exactor_id
)
dynamic_excavator_list
.
append
(
item
.
exactor_id
)
if
len
(
dynamic_excavator_list
)
<
1
:
if
len
(
dynamic_excavator_list
)
<
1
:
...
@@ -356,7 +356,7 @@ def update_autodisp_dump():
...
@@ -356,7 +356,7 @@ def update_autodisp_dump():
dynamic_dump_list
=
[]
dynamic_dump_list
=
[]
try
:
try
:
for
item
in
(
for
item
in
(
session_mysql
.
query
(
Dispatch
Match
)
.
filter_by
()
.
all
()
session_mysql
.
query
(
Dispatch
Setting
)
.
filter_by
()
.
all
()
):
):
dynamic_dump_list
.
append
(
item
.
dump_id
)
dynamic_dump_list
.
append
(
item
.
dump_id
)
if
len
(
dynamic_dump_list
)
<
1
:
if
len
(
dynamic_dump_list
)
<
1
:
...
@@ -401,305 +401,3 @@ def update_park_area():
...
@@ -401,305 +401,3 @@ def update_park_area():
session_postgre
.
rollback
()
session_postgre
.
rollback
()
session_mysql
.
rollback
()
session_mysql
.
rollback
()
return
park_area_list
return
park_area_list
# def build_work_area_uuid_index_map():
# # load_area_id <-> load_area_index
# # unload_area_id <-> unload_area_index
# load_area_uuid_to_index_dict = {}
# unload_area_uuid_to_index_dict = {}
# load_area_index_to_uuid_dict = {}
# unload_area_index_to_uuid_dict = {}
#
# unload_area_num = 0
# load_area_num = 0
#
# try:
# for item in session_postgre.query(WalkTime).all():
# load_area = str(item.load_area_id)
# unload_area = str(item.unload_area_id)
# if load_area not in load_area_uuid_to_index_dict:
# load_area_uuid_to_index_dict[load_area] = load_area_num
# load_area_index_to_uuid_dict[load_area_num] = load_area
# load_area_num = load_area_num + 1
# if unload_area not in unload_area_uuid_to_index_dict:
# unload_area_uuid_to_index_dict[unload_area] = unload_area_num
# unload_area_index_to_uuid_dict[unload_area_num] = unload_area
# unload_area_num = unload_area_num + 1
# if unload_area_num < 1 or load_area_num < 1:
# raise Exception("无路网信息")
# except Exception as es:
# logger.error("路网读取")
# logger.error(es)
# return (
# load_area_uuid_to_index_dict,
# unload_area_uuid_to_index_dict,
# load_area_index_to_uuid_dict,
# unload_area_index_to_uuid_dict,
# )
#
#
# def build_park_uuid_index_map():
# # park_id <-> park_index
# park_uuid_to_index_dict = {}
# park_index_to_uuid_dict = {}
#
# park_num = 0
#
# try:
# for item in session_postgre.query(WalkTimePark).all():
# park = str(item.park_area_id)
# if park not in park_uuid_to_index_dict:
# park_uuid_to_index_dict[park] = park_num
# park_index_to_uuid_dict[park_num] = park
# park_num = park_num + 1
# if park_num < 1:
# raise Exception("无备停区路网信息")
# except Exception as es:
# logger.info("备停区路网读取")
# logger.error(es)
#
# return park_uuid_to_index_dict, park_index_to_uuid_dict
#
#
# def build_truck_uuid_name_map():
# # truck_id <-> truck_name
# truck_uuid_to_name_dict = {}
# truck_name_to_uuid_dict = {}
#
# try:
# for item in session_mysql.query(Equipment).filter_by(device_type=1).all():
# truck_id = item.id
# truck_name = item.equipment_id
#
# truck_name_to_uuid_dict[truck_name] = truck_id
# truck_uuid_to_name_dict[truck_id] = truck_name
# if len(truck_uuid_to_name_dict) < 1 or len(truck_name_to_uuid_dict) < 1:
# raise Exception("无矿卡设备可用-矿卡设备映射异常")
# except Exception as es:
# logger.warning(es)
# return truck_uuid_to_name_dict, truck_name_to_uuid_dict
#
#
# def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_dict):
# excavator_uuid_to_index_dict = {} # 用于将Excavator表中的area_id映射到index
# dump_uuid_to_index_dict = {} # 用于将Dump表中的area_id映射到index
# excavator_index_to_uuid_dict = {} # 用于将index映射到Excavator表中的area_id
# dump_index_to_uuid_dict = {} # 用于将index映射到Dump表中的area_id
#
# dump_uuid_to_unload_area_uuid_dict = {}
# excavator_uuid_to_load_area_uuid_dict = {}
# excavator_index_to_load_area_index_dict = {}
# dump_index_to_unload_area_index_dict = {}
#
# try:
# excavator_num = 0
# dump_num = 0
# for item in (
# session_mysql.query(Dispatch).filter_by(isdeleted=0, isauto=1).all()
# ):
# # excavator_id <-> excavator_index
# # dump_id <-> dump_index
# # excavator_id <-> load_area_id
# # dump_id <-> unload_area_id
# # excavator_index <-> load_area_index
# # dump_index <-> unload_area_index
# excavator_id = item.exactor_id
# load_area_id = item.load_area_id
# unload_area_id = item.unload_area_id
# dump_id = item.dump_id
# if dump_id not in dump_uuid_to_unload_area_uuid_dict:
# dump_uuid_to_index_dict[dump_id] = dump_num
# dump_index_to_uuid_dict[dump_num] = dump_id
# dump_uuid_to_unload_area_uuid_dict[dump_id] = unload_area_id
# dump_index_to_unload_area_index_dict[
# dump_uuid_to_index_dict[dump_id]
# ] = unload_area_uuid_to_index_dict[unload_area_id]
# dump_num = dump_num + 1
# if excavator_id not in excavator_uuid_to_index_dict:
# excavator_uuid_to_index_dict[excavator_id] = excavator_num
# excavator_index_to_uuid_dict[excavator_num] = excavator_id
# excavator_uuid_to_load_area_uuid_dict[excavator_id] = load_area_id
# excavator_index_to_load_area_index_dict[
# excavator_uuid_to_index_dict[excavator_id]
# ] = load_area_uuid_to_index_dict[load_area_id]
# excavator_num = excavator_num + 1
# if excavator_num < 1 or dump_num < 1:
# raise Exception("无动态派车计划可用-动态派车挖机/卸载设备映射失败")
# except Exception as es:
# logger.error("卸载区信息异常")
# logger.error(es)
#
# logger.info("excavator_index_to_load_area_index_dict")
# logger.info(excavator_index_to_load_area_index_dict)
#
# logger.info("load_area_uuid_to_index_dict")
# logger.info(load_area_uuid_to_index_dict)
# logger.info("static_excavator_uuid_to_index_dict")
# logger.info(excavator_uuid_to_index_dict)
#
# return {
# "excavator_uuid_to_index_dict": excavator_uuid_to_index_dict,
# "dump_uuid_to_index_dict": dump_uuid_to_index_dict,
# "excavator_index_to_uuid_dict": excavator_index_to_uuid_dict,
# "dump_index_to_uuid_dict": dump_index_to_uuid_dict,
# "dump_uuid_to_unload_area_uuid_dict": dump_uuid_to_unload_area_uuid_dict,
# "excavator_uuid_to_load_area_uuid_dict": excavator_uuid_to_load_area_uuid_dict,
# "excavator_index_to_load_area_index_dict": excavator_index_to_load_area_index_dict,
# "dump_index_to_unload_area_index_dict": dump_index_to_unload_area_index_dict,
# }
#
#
# def update_truck_uuid_index_map(dynamic_truck_set):
# truck_uuid_to_index_dict = {}
# truck_index_to_uuid_dict = {}
#
# # truck_id <-> truck_index
# truck_num = 0
# for truck_id in dynamic_truck_set:
# truck_uuid_to_index_dict[truck_id] = truck_num
# truck_index_to_uuid_dict[truck_num] = truck_id
# truck_num = truck_num + 1
#
# logger.info("static_data_process.py-truck_uuid_to_index_dict")
# logger.info(truck_uuid_to_index_dict)
#
# return {
# "truck_uuid_to_index_dict": truck_uuid_to_index_dict,
# "truck_index_to_uuid_dict": truck_index_to_uuid_dict,
# }
#
#
# def update_total_truck():
# # 矿卡集合
# truck_list = []
#
# try:
# query = np.array(
# session_mysql.query(Equipment)
# .filter_by(device_type=1, isdeleted=0)
# .all()
# )
#
# # for item in query:
# # json_value = json.loads(redis2.get(item.equipment_id))
# # is_online = json_value.get('isOnline')
# # if is_online:
# # truck_list.append(item.id)
#
# for item in query:
# truck_list.append(item.id)
#
# if len(truck_list) < 1:
# raise Exception("无矿卡设备可用-矿卡集合读取异常")
# except Exception as es:
# logger.info("矿卡读取")
# logger.error(es)
#
# return truck_list
#
#
# def update_dynamic_truck():
# dynamic_truck_list = []
#
# try:
# query = np.array(
# session_mysql.query(Dispatch).filter_by(isauto=1, isdeleted=0).all()
# )
#
# for item in query:
# if item.truck_id is not None:
# dynamic_truck_list.append(item.truck_id)
#
# except Exception as es:
# logger.error(es)
# logger.error("动态调度矿卡读取异常")
#
# return set(dynamic_truck_list)
#
#
# def update_fixdisp_truck():
# # 固定派车矿卡集合
# fixed_truck_list = []
#
# try:
# query = np.array(
# session_mysql.query(Dispatch).filter_by(isauto=0, isdeleted=0).all()
# )
#
# for item in query:
# fixed_truck_list.append(item.truck_id)
#
# rule5 = session_mysql.query(DispatchRule).filter_by(id=5).first().disabled
#
# if not rule5:
# query = np.array(
# session_mysql.query(Equipment)
# .filter_by(device_type=1, isdeleted=0, disabled=1)
# .all()
# )
#
# for item in query:
# fixed_truck_list.append(item.id)
#
# if len(fixed_truck_list) < 1:
# raise Exception("无固定派车计划可用-固定派车矿卡集合读取异常")
# except Exception as es:
# logger.info("派车计划读取")
# logger.error(es)
# return set(fixed_truck_list)
#
#
# def update_autodisp_excavator():
# # 用于动态派车的挖机集合
# dynamic_excavator_list = []
# try:
# for item in (
# session_mysql.query(Dispatch).filter_by(isdeleted=0, isauto=1).all()
# ):
# dynamic_excavator_list.append(item.exactor_id)
# if len(dynamic_excavator_list) < 1:
# raise Exception("无动态派车计划可用-动态派车挖机/卸载设备集合读取异常")
# except Exception as es:
# logger.warning(es)
#
# return set(dynamic_excavator_list)
#
#
# def update_autodisp_dump():
# # 用于动态调度的卸载点集合
# dynamic_dump_list = []
# try:
# for item in (
# session_mysql.query(Dispatch).filter_by(isdeleted=0, isauto=1).all()
# ):
# dynamic_dump_list.append(item.dump_id)
# if len(dynamic_dump_list) < 1:
# raise Exception("无动态派车计划可用-动态派车挖机/卸载设备集合读取异常")
# except Exception as es:
# logger.warning(es)
#
# print("here1")
# print(set(dynamic_dump_list))
# return set(dynamic_dump_list)
#
#
# def update_load_area():
# load_area_list = []
# for walk_time in session_postgre.query(WalkTime).all():
# load_area_list.append(walk_time.load_area_id)
#
# return load_area_list
#
#
# def update_unload_area():
# unload_area_list = []
# for walk_time in session_postgre.query(WalkTime).all():
# unload_area_list.append(walk_time.unload_area_id)
# return unload_area_list
#
#
# def update_park_area():
# park_area_list = []
# for walk_time_park in session_postgre.query(WalkTimePark).all():
# park_area_list.append(walk_time_park.park_area_id)
# return park_area_list
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