Commit fe375db4 authored by Allvey's avatar Allvey

Merge branch 'master' of github.com:Allvey/integrated-scheduling

# 读取装载/卸载能力,添加设备可用性 # Conflicts: # realtime_dispatch.py # settings.py # static_data_process.py # tables.py # traffic_flow_planner.py
parent 855ff7d4
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -116,7 +116,6 @@ class DumpInfo(WalkManage):
self.cur_dump_real_mass = np.zeros(self.dynamic_dump_num)
now = datetime.now().strftime('%Y-%m-%d')
for dump_id in self.dump_uuid_to_index_dict.keys():
# print(excavator_id)
for query in session_mysql.query(LoadInfo). \
join(Equipment, LoadInfo.dump_id == Equipment.equipment_id). \
filter(Equipment.id == dump_id, LoadInfo.time > now). \
......
......@@ -39,7 +39,7 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
# filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10)
filehandler = logging.handlers.RotatingFileHandler("Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
# 设置后缀名称,跟strftime的格式一样
filehandler.suffix = "%Y-%m-%d_%H-%M.log"
......
......@@ -9,9 +9,9 @@
# 静态数据处理(函数名即为注释)
from settings import *
def build_work_area_uuid_index_map():
# load_area_id <-> load_area_index
# unload_area_id <-> unload_area_index
......@@ -137,6 +137,7 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
'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 = {}
......@@ -151,22 +152,23 @@ def update_truck_uuid_index_map(dynamic_truck_set):
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)
query = np.array(session_mysql.query(Equipment).filter_by(device_type=1, isdeleted=0, disabled=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:
......@@ -190,6 +192,7 @@ def update_fixdisp_truck():
logger.error(es)
return fixed_truck_list
def update_autodisp_excavator():
# 用于动态派车的挖机集合
dynamic_excavator_list = []
......@@ -216,6 +219,7 @@ def update_autodisp_dump():
logger.warning(es)
return dynamic_dump_list
def update_load_area():
load_area_list = []
for walk_time in session_postgre.query(WalkTime).all():
......@@ -230,6 +234,7 @@ def update_unload_area():
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():
......
......@@ -295,8 +295,9 @@ class Equipment(Base):
equipment_spec = Column(VARCHAR(36))
equipment_state = Column(Integer)
isdeleted = Column(Integer)
disabled = Column(Integer)
def __init__(self, id, equipment_id, device_name, device_type, equipment_spec, equipment_state, isdeleted):
def __init__(self, id, equipment_id, device_name, device_type, equipment_spec, equipment_state, isdeleted, disabled):
self.id = id
self.equipment_id = equipment_id
self.device_name = device_name
......@@ -304,16 +305,19 @@ class Equipment(Base):
self.equipment_spec = equipment_spec
self.equipment_state = equipment_state
self.isdeleted = isdeleted
self.disabled = disabled
class EquipmentSpec(Base):
__tablename__ = 'sys_equipment_spec'
id = Column(VARCHAR(36), primary_key=True)
capacity = Column(Integer)
mining_abililty = Column(Float)
def __init__(self, id, capacity):
def __init__(self, id, capacity, mining_abililty):
self.id = id
self.capacity = capacity
self.mining_abililty = self.mining_abililty
class LoadInfo(Base):
__tablename__ = 'sys_loadinfo'
......@@ -360,3 +364,18 @@ class WrokRecord(Base):
self.load_entrance_count = load_entrance_count
self.load_exit_time = load_exit_time
self.load_exit_count = load_exit_count
class DumpArea(Base):
__tablename__ = 'Geo_DumpArea'
Id = Column(VARCHAR(50), primary_key=True)
BindList = Column(VARCHAR(1000))
UnloadAbililty = Column(Float)
Disabled = Column(Integer)
def __init__(self, Id, BindList, UnloadAbililty, Disabled):
self.Id = Id
self.BindList = BindList
self.UnloadAbililty = UnloadAbililty
self.Disabled = Disabled
\ No newline at end of file
......@@ -97,8 +97,12 @@ class Traffic_para(WalkManage):
def extract_dump_info(self):
try:
for dump_index in range(dynamic_excavator_num):
unload_area_id = unload_area_index_to_uuid_dict[self.dump_index_to_unload_area_index_dict[dump_index]]
self.dump_strength[dump_index] = 10000 # 卸载设备最大卸载能力,单位吨/小时
unload_ability = session_postgre.query(DumpArea).filter_by(Id=unload_area_id).first().UnloadAbililty
self.dump_strength[dump_index] = unload_ability # 卸载设备最大卸载能力,单位吨/小时
# self.dump_strength[dump_index] = 10000 # 卸载设备最大卸载能力,单位吨/小时
self.grade_upper_dump_array[dump_index] = 100 # 卸点品位上限
self.grade_lower_dump_array[dump_index] = 100 # 卸点品位下限
self.dump_priority_coefficient[dump_index] = 1 # 卸载设备优先级
......@@ -135,7 +139,11 @@ class Traffic_para(WalkManage):
def extract_excavator_info(self):
try:
for excavator_index in range(len(self.excavator_index_to_uuid_dict)):
self.excavator_strength[excavator_index] = 1000 # 挖机最大装载能力,单位吨/小时
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.excavator_strength[excavator_index] = load_ability.mining_abililty
# self.excavator_strength[excavator_index] = 1000 # 挖机最大装载能力,单位吨/小时
self.grade_loading_array[excavator_index] = 100 # 挖机装载物料品位
self.excavator_priority_coefficient[excavator_index] = 1 # 挖机优先级
except Exception as es:
......@@ -266,3 +274,6 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
logger.error(es)
logger.error("车流规划类比初始化异常")
return tra_para
Traffic_para_init(2, 2, 2, 2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment