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
b4797ca0
Commit
b4797ca0
authored
Aug 01, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分流配比现场测试版本
parent
e509f495
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
18 deletions
+92
-18
algorithm.py
alg/algorithm.py
+84
-10
group.py
core/group.py
+2
-2
dispatchInfo.py
data/dispatchInfo.py
+0
-0
truck.py
equipment/truck.py
+4
-4
realtime_dispatch.py
realtime_dispatch.py
+2
-2
No files found.
alg/algorithm.py
View file @
b4797ca0
...
@@ -331,12 +331,13 @@ class DistributionRatio(object):
...
@@ -331,12 +331,13 @@ class DistributionRatio(object):
@desc:计算分流配比模式下,卡车与卸载区的对应关系
@desc:计算分流配比模式下,卡车与卸载区的对应关系
"""
"""
def
__init__
(
self
,
exactor_id
):
def
__init__
(
self
,
exactor_id
,
truck
):
self
.
truck
=
truck
self
.
exactor_id
=
exactor_id
self
.
exactor_id
=
exactor_id
self
.
exactor_truck_num
=
DispatchInfo
.
get_exactor_truck_nums
(
exactor_id
)
# 获取该电铲下的卡车数量
self
.
exactor_truck_num
=
DispatchInfo
.
get_exactor_truck_nums
(
exactor_id
)
# 获取该电铲下的卡车数量
self
.
exactor_unload_match
=
DispatchInfo
.
get_exactor_unload_match
(
exactor_id
)
# 获取电铲对应的所有卸载区id
self
.
exactor_unload_match
=
DispatchInfo
.
get_exactor_unload_match
(
exactor_id
)
# 获取电铲对应的所有卸载区id
self
.
unload_ratio
=
{}
self
.
unload_ratio
=
{}
self
.
logger
=
get_logger
(
"
mqc
.DistributionRatio"
)
self
.
logger
=
get_logger
(
"
zxt
.DistributionRatio"
)
def
get_unload_ratio
(
self
):
def
get_unload_ratio
(
self
):
"""
"""
...
@@ -344,20 +345,60 @@ class DistributionRatio(object):
...
@@ -344,20 +345,60 @@ class DistributionRatio(object):
@author:maqc
@author:maqc
@desc:初始化卸载区的比值
@desc:初始化卸载区的比值
"""
"""
try
:
ratio
=
0
ratio
=
0
for
value
in
self
.
exactor_unload_match
:
for
value
in
self
.
exactor_unload_match
:
ratio
+=
DispatchInfo
.
unload_rate_dict
[
value
]
ratio
+=
DispatchInfo
.
unload_rate_dict
[
value
]
for
item
in
self
.
exactor_unload_match
:
for
item
in
self
.
exactor_unload_match
:
self
.
unload_ratio
[
item
]
=
DispatchInfo
.
unload_rate_dict
[
item
]
/
ratio
self
.
unload_ratio
[
item
]
=
DispatchInfo
.
unload_rate_dict
[
item
]
/
ratio
except
Exception
as
es
:
self
.
logger
.
error
(
"初始化卸载区的比值异常"
)
self
.
logger
.
error
(
es
)
def
get_unload_truck_total_num
(
self
,
exactor_id
):
"""
@date:2022/7/19 16:12
@author:maqc
@desc:计算正在驶往全部卸载区的卡车数量
"""
unload_area_truck_num
=
0
for
item
in
session_mysql
.
query
(
EquipmentPair
)
.
filter_by
(
exactor_id
=
exactor_id
,
isdeleted
=
0
)
.
all
():
try
:
truck_id
=
item
.
truck_id
task
=
self
.
truck
.
get_truck_current_task
()[
truck_id
]
if
task
in
[
3
,
4
]:
unload_area_truck_num
=
unload_area_truck_num
+
1
except
Exception
as
es
:
self
.
logger
.
error
(
"获取驶往卸载点全部车辆数量异常"
)
self
.
logger
.
error
(
es
)
# item = session_mysql.query(EquipmentPair).filter_by(unload_area_id=unload_area_id, isdeleted=0).all()
return
unload_area_truck_num
def
get_unload_truck_num
(
self
,
unload_area_id
):
def
get_unload_truck_num
(
self
,
unload_area_id
):
"""
"""
@date:2022/7/19 16:12
@date:2022/7/19 16:12
@author:maqc
@author:maqc
@desc:计算正在派往当前卸载区的卡车数量
@desc:计算正在派往当前卸载区的卡车数量
"""
"""
item
=
session_mysql
.
query
(
EquipmentPair
)
.
filter_by
(
unload_area_id
=
unload_area_id
,
isdeleted
=
0
)
.
all
()
return
len
(
item
)
unload_area_truck_num
=
0
for
item
in
session_mysql
.
query
(
EquipmentPair
)
.
filter_by
(
unload_area_id
=
unload_area_id
,
isdeleted
=
0
)
.
all
():
try
:
truck_id
=
item
.
truck_id
task
=
self
.
truck
.
get_truck_current_task
()[
truck_id
]
if
task
in
[
3
,
4
]:
unload_area_truck_num
=
unload_area_truck_num
+
1
except
Exception
as
es
:
self
.
logger
.
error
(
f
'获取驶往卸载点 {item.unload_area_id} 车辆异常'
)
self
.
logger
.
error
(
es
)
# item = session_mysql.query(EquipmentPair).filter_by(unload_area_id=unload_area_id, isdeleted=0).all()
return
unload_area_truck_num
def
get_next_unload_id
(
self
):
def
get_next_unload_id
(
self
):
"""
"""
...
@@ -365,18 +406,49 @@ class DistributionRatio(object):
...
@@ -365,18 +406,49 @@ class DistributionRatio(object):
@author:maqc
@author:maqc
@desc:计算卡车与下一个卸载区的对应关系
@desc:计算卡车与下一个卸载区的对应关系
"""
"""
# 无论当前卡车是否在备停区,下一个卸载区选择比值最大值对应的区域
next_unload_id
=
None
try
:
try
:
self
.
logger
.
info
(
"卸载设置分流配比"
)
self
.
logger
.
info
(
self
.
unload_ratio
)
# 无论当前卡车是否在备停区,下一个卸载区选择比值最大值对应的区域
for
dump_id
in
self
.
unload_ratio
.
keys
():
self
.
unload_ratio
[
dump_id
]
-=
((
self
.
get_unload_truck_num
(
dump_id
)
+
0.001
)
/
(
self
.
get_unload_truck_total_num
(
self
.
exactor_id
)
+
0.001
))
self
.
logger
.
info
(
dump_id
)
self
.
logger
.
info
(
f
'unload_truck_total_num {self.get_unload_truck_total_num(self.exactor_id)}'
)
self
.
logger
.
info
(
f
'unload_truck_num {self.get_unload_truck_num(dump_id)}'
)
self
.
logger
.
info
(
"卸载实时分流配比"
)
self
.
logger
.
info
(
self
.
unload_ratio
)
temp
=
list
(
self
.
unload_ratio
.
values
())
temp
=
list
(
self
.
unload_ratio
.
values
())
next_unload_id
=
list
(
self
.
unload_ratio
.
keys
())[
temp
.
index
(
max
(
temp
))]
next_unload_id
=
list
(
self
.
unload_ratio
.
keys
())[
temp
.
index
(
max
(
temp
))]
# 更新卸载区对应的比例值
self
.
logger
.
info
(
f
"下一个卸载区对应的id:{next_unload_id}"
)
self
.
logger
.
info
(
self
.
unload_ratio
.
keys
()
)
self
.
unload_ratio
[
next_unload_id
]
-=
self
.
get_unload_truck_num
(
self
.
logger
.
info
(
temp
)
next_unload_id
)
/
self
.
exactor_truck_num
self
.
logger
.
info
(
f
'下一个卸载区对应的id {next_unload_id}'
)
self
.
logger
.
info
(
f
"当前卸载区对应的比值:{self.unload_ratio[next_unload_id]}"
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"卡车与下一个卸载区的配对关系异常"
)
self
.
logger
.
error
(
"卡车与下一个卸载区的配对关系异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# try:
# temp = list(self.unload_ratio.values())
# next_unload_id = list(self.unload_ratio.keys())[temp.index(max(temp))]
# # 更新卸载区对应的比例值
# self.logger.info(f"下一个卸载区对应的id:{next_unload_id}")
# self.unload_ratio[next_unload_id] -= self.get_unload_truck_num(
# next_unload_id) / self.exactor_truck_num
# self.logger.info(f"当前卸载区对应的比值:{self.unload_ratio[next_unload_id]}")
# except Exception as es:
# self.logger.error("卡车与下一个卸载区的配对关系异常")
# self.logger.error(es)
return
next_unload_id
return
next_unload_id
def
ratio_main
(
self
):
def
ratio_main
(
self
):
...
@@ -387,6 +459,8 @@ class DistributionRatio(object):
...
@@ -387,6 +459,8 @@ class DistributionRatio(object):
"""
"""
try
:
try
:
self
.
get_unload_ratio
()
self
.
get_unload_ratio
()
self
.
logger
.
info
(
"卸载区分流比例"
)
self
.
logger
.
info
(
self
.
unload_ratio
)
next_unload_area_id
=
self
.
get_next_unload_id
()
next_unload_area_id
=
self
.
get_next_unload_id
()
self
.
logger
.
info
(
f
'当前卡车对应的卸载区:{next_unload_area_id}'
)
self
.
logger
.
info
(
f
'当前卡车对应的卸载区:{next_unload_area_id}'
)
except
Exception
as
es
:
except
Exception
as
es
:
...
...
core/group.py
View file @
b4797ca0
...
@@ -63,7 +63,7 @@ class Group:
...
@@ -63,7 +63,7 @@ class Group:
""" Generate a group obj.
""" Generate a group obj.
:param group_id: (uuid) group_id
:param group_id: (uuid) group_id
"""
"""
self
.
logger
=
get_logger
(
"
ga
.Group"
)
self
.
logger
=
get_logger
(
"
zxt
.Group"
)
# basic info.
# basic info.
self
.
group_id
=
group_id
self
.
group_id
=
group_id
self
.
group_mode
=
1
self
.
group_mode
=
1
...
@@ -283,7 +283,7 @@ class Group:
...
@@ -283,7 +283,7 @@ class Group:
try
:
try
:
next_unload_area_id
=
DistributionRatio
(
next_exactor_id
)
.
ratio_main
()
next_unload_area_id
=
DistributionRatio
(
next_exactor_id
,
self
.
truck
)
.
ratio_main
()
except
Exception
as
es
:
except
Exception
as
es
:
...
...
data/dispatchInfo.py
View file @
b4797ca0
equipment/truck.py
View file @
b4797ca0
...
@@ -288,7 +288,7 @@ class TruckInfo(WalkManage):
...
@@ -288,7 +288,7 @@ class TruckInfo(WalkManage):
session_mysql
.
rollback
()
session_mysql
.
rollback
()
continue
continue
#
try:
try
:
load_area_uuid_to_index_dict
=
get_value
(
"load_area_uuid_to_index_dict"
)
load_area_uuid_to_index_dict
=
get_value
(
"load_area_uuid_to_index_dict"
)
unload_area_uuid_to_index_dict
=
get_value
(
"unload_area_uuid_to_index_dict"
)
unload_area_uuid_to_index_dict
=
get_value
(
"unload_area_uuid_to_index_dict"
)
aa
=
task
aa
=
task
...
@@ -386,9 +386,9 @@ class TruckInfo(WalkManage):
...
@@ -386,9 +386,9 @@ class TruckInfo(WalkManage):
# end_eqp_index = excavator.excavator_uuid_to_index_dict[item.exactor_id]
# end_eqp_index = excavator.excavator_uuid_to_index_dict[item.exactor_id]
# self.excavator_hold_truck_num[end_eqp_index] = self.excavator_hold_truck_num[end_eqp_index] + 1
# self.excavator_hold_truck_num[end_eqp_index] = self.excavator_hold_truck_num[end_eqp_index] + 1
pass
pass
#
except Exception as es:
except
Exception
as
es
:
#
self.logger.error("矿卡行程读取异常")
self
.
logger
.
error
(
"矿卡行程读取异常"
)
#
self.logger.error(es)
self
.
logger
.
error
(
es
)
# print("self.dump_hold_truck_num")
# print("self.dump_hold_truck_num")
# print(self.dump_hold_truck_num)
# print(self.dump_hold_truck_num)
...
...
realtime_dispatch.py
View file @
b4797ca0
...
@@ -38,7 +38,7 @@ def direct2redis():
...
@@ -38,7 +38,7 @@ def direct2redis():
for
item
in
session_mysql
.
query
(
DispatchSetting
)
.
all
():
for
item
in
session_mysql
.
query
(
DispatchSetting
)
.
all
():
if
item
.
truck_id
not
in
truck_disp
:
if
item
.
truck_id
not
in
truck_disp
:
record
=
{
"truckId"
:
item
.
truck_id
}
record
=
{
"truckId"
:
item
.
truck_id
}
record
[
"
i
d"
]
=
item
.
id
record
[
"
dispatchI
d"
]
=
item
.
id
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
...
@@ -47,7 +47,7 @@ def direct2redis():
...
@@ -47,7 +47,7 @@ def direct2redis():
record
[
"isdeleted"
]
=
False
record
[
"isdeleted"
]
=
False
record
[
"isTemp"
]
=
False
record
[
"isTemp"
]
=
False
record
[
"haulFlag"
]
=
-
1
record
[
"haulFlag"
]
=
-
1
record
[
"groupName"
]
=
item
.
group_id
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
item
.
group_id
]
logger
.
info
(
"调度结果"
)
logger
.
info
(
"调度结果"
)
logger
.
info
(
record
)
logger
.
info
(
record
)
...
...
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