Commit ea6385f4 authored by 张晓彤's avatar 张晓彤

固定派车问题修复

parent 89d68c1a
...@@ -144,7 +144,7 @@ class DispatchInfo: ...@@ -144,7 +144,7 @@ class DispatchInfo:
logger = get_logger("zxt.update_device_group_structure") logger = get_logger("zxt.update_device_group_structure")
# update excavator_id <-> load_area_id # update excavator_id <-> load_area_id
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).all():
cls.load_excavator_dict[item.load_area_id] = item.exactor_id cls.load_excavator_dict[item.load_area_id] = item.exactor_id
cls.excavator_load_dict[item.exactor_id] = item.load_area_id cls.excavator_load_dict[item.exactor_id] = item.load_area_id
...@@ -157,7 +157,7 @@ class DispatchInfo: ...@@ -157,7 +157,7 @@ class DispatchInfo:
# update dump_id <-> unload_area_id # update dump_id <-> unload_area_id
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).all():
cls.unload_area_dump_dict[item.unload_area_id] = item.dump_id cls.unload_area_dump_dict[item.unload_area_id] = item.dump_id
cls.dump_unload_area_dict[item.dump_id] = item.unload_area_id cls.dump_unload_area_dict[item.dump_id] = item.unload_area_id
...@@ -170,7 +170,7 @@ class DispatchInfo: ...@@ -170,7 +170,7 @@ class DispatchInfo:
# update exactor_id <-> truck_id # update exactor_id <-> truck_id
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).all():
if item.exactor_id not in cls.exactor_truck_dict.keys(): if item.exactor_id not in cls.exactor_truck_dict.keys():
cls.exactor_truck_dict[item.exactor_id] = [item.truck_id] cls.exactor_truck_dict[item.exactor_id] = [item.truck_id]
else: else:
...@@ -183,7 +183,7 @@ class DispatchInfo: ...@@ -183,7 +183,7 @@ class DispatchInfo:
# update exactor_id <-> unload_area_id # update exactor_id <-> unload_area_id
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).all():
if item.exactor_id not in cls.exactor_unload_dict.keys(): if item.exactor_id not in cls.exactor_unload_dict.keys():
cls.exactor_unload_dict[item.exactor_id] = [item.unload_area_id] cls.exactor_unload_dict[item.exactor_id] = [item.unload_area_id]
else: else:
...@@ -195,7 +195,7 @@ class DispatchInfo: ...@@ -195,7 +195,7 @@ class DispatchInfo:
# update unload_area_id -> rate # update unload_area_id -> rate
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).all():
cls.unload_rate_dict[item.unload_area_id] = item.rate cls.unload_rate_dict[item.unload_area_id] = item.rate
except Exception as es: except Exception as es:
logger.error("卸载区和比例值关系更新异常") logger.error("卸载区和比例值关系更新异常")
...@@ -203,7 +203,7 @@ class DispatchInfo: ...@@ -203,7 +203,7 @@ class DispatchInfo:
# update excavator_id <-> group_id && unload_area_id <-> group_id && truck_id <-> group_id # update excavator_id <-> group_id && unload_area_id <-> group_id && truck_id <-> group_id
try: try:
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0).all():
# add excavator # add excavator
if item.group_id not in cls.group_excavator_dict.keys(): if item.group_id not in cls.group_excavator_dict.keys():
cls.group_excavator_dict[item.group_id] = [item.exactor_id] cls.group_excavator_dict[item.group_id] = [item.exactor_id]
...@@ -254,8 +254,8 @@ class DispatchInfo: ...@@ -254,8 +254,8 @@ class DispatchInfo:
try: try:
trucks = cls.truck_group_dict.keys() trucks = cls.truck_group_dict.keys()
for i in trucks: for i in trucks:
match_excavator = session_mysql.query(DispatchSetting).filter_by(truck_id=i).first().exactor_id match_excavator = session_mysql.query(DispatchSetting).filter_by(truck_id=i, isdeleted=0, ).first().exactor_id
match_unload_area = session_mysql.query(DispatchSetting).filter_by(truck_id=i).first().unload_area_id match_unload_area = session_mysql.query(DispatchSetting).filter_by(truck_id=i, isdeleted=0, ).first().unload_area_id
cls.truck_match_dict[i] = [match_excavator, match_unload_area] cls.truck_match_dict[i] = [match_excavator, match_unload_area]
except Exception as es: except Exception as es:
logger.error(es) logger.error(es)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -35,7 +35,7 @@ def direct2redis(): ...@@ -35,7 +35,7 @@ def direct2redis():
try: try:
truck_disp = {} truck_disp = {}
for item in session_mysql.query(DispatchSetting).all(): for item in session_mysql.query(DispatchSetting).filter_by(isdeleted=0, ).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["dispatchId"] = item.id record["dispatchId"] = item.id
......
# from graph.topo_graph import *
# import networkx as nx
# import matplotlib.pyplot as plt
#
# topo = Topo()
# topo.generate_topo_graph()
# load_G = topo.get_load_G()
# pos = nx.shell_layout(load_G)
# nx.draw(load_G, pos, with_labels=True, node_color='red', edge_color='blue', font_size=18, width=5, node_size=600,
# alpha=0.5)
# # topo.get_unload_target_node_real()
# plt.show()
# import numpy as np
#
# arrival_truck_set = ['309705a0-5ddf-4559-b6c4-ee17a57677ad', '899705a0-5ddf-4559-b6c4-ee17a57677ad']
#
# arrival_truck_reach_time = [8.04, 6.05]
# #
# # arrival_truck_set = ['309705a0-5ddf-4559-b6c4-ee17a57677ad']
# #
# # arrival_truck_reach_time = [8.04]
#
# arrival_truck_list = list(zip(np.array(arrival_truck_set), np.array(arrival_truck_reach_time)))
#
# print(arrival_truck_list)
#
# arrival_truck_list = sorted(arrival_truck_list, key=lambda item: item[1])
#
# # print(arrival_truck_list)
# #
# # print(zip(*arrival_truck_list))
#
# for x1, x2 in arrival_truck_list:
# print(x1, x2)
# A = [['309705a0-5ddf-4559-b6c4-ee17a57677ad', 9.04], ['899705a0-5ddf-4559-b6c4-ee17a57677ad', 6.05]]
# A = sorted(A, key=lambda item: item[1])
# print(A)
from graph.topo_graph import *
import networkx as nx
import matplotlib.pyplot as plt
import sqlite3
conn = sqlite3.connect('test.db')
c = conn.cursor()
cursor = c.execute("SELECT * FROM GRAPH_NODE")
node_label = {}
for row in cursor:
node_label[row[1]] = row[2]
print(node_label)
load_G = nx.Graph()
unload_G = nx.Graph()
cursor = c.execute("SELECT * FROM GRAPH_EDGE")
for row in cursor:
# 处理边包含路段
lanes = row[5].split(" ")
lane_info = {}
for item in lanes:
try:
# print(item)
distance = session_postgre.query(Lane).filter_by(Id=item).first().Length
lane_info[item] = list([distance, distance])
except Exception as es:
print(es)
session_postgre.rollback()
# 重构卸载路径拓扑图
if row[4] == 1:
load_G.add_node(row[1], name=node_label[row[1]])
load_G.add_node(row[2], name=node_label[row[2]])
load_G.add_edge(str(row[1]), str(row[2]), real_distance=row[3], lane=lane_info)
# 重构装载路径拓扑图
else:
unload_G.add_node(row[1], name=node_label[row[1]])
unload_G.add_node(row[2], name=node_label[row[2]])
unload_G.add_edge(str(row[1]), str(row[2]), real_distance=row[3], lane=lane_info)
print("数据操作成功")
node_label_load = {}
node_label_unload = {}
for node in load_G.nodes:
if node in node_label:
if node_label[node] == "None":
node_label_load[node] = ''
else:
node_label_load[node] = node_label[node]
else:
node_label_load[node] = ''
for node in unload_G.nodes:
if node in node_label:
if node_label[node] == "None":
node_label_unload[node] = ''
else:
node_label_unload[node] = node_label[node]
else:
node_label_unload[node] = ''
pos1 = nx.spring_layout(load_G)
# nx.draw(load_G, pos1, with_labels=False, node_color='red', edge_color='blue', font_size=30, width=3, node_size=200,
# alpha=0.5)
nx.draw_networkx(load_G, pos=pos1, labels=node_label_load, with_labels=True, node_color='red', \
edge_color='blue', font_size=10, width=1.5, node_size=100, alpha=0.5)
plt.show()
pos2 = nx.spring_layout(unload_G)
# pos2 = nx.shell_layout(unload_G)
# nx.draw(load_G, pos1, with_labels=False, node_color='red', edge_color='blue', font_size=30, width=3, node_size=200,
# alpha=0.5)
nx.draw_networkx(unload_G, pos=pos2, labels=node_label_unload, with_labels=True, node_color='red', \
edge_color='blue', font_size=15, width=3, node_size=200, alpha=0.5)
plt.show()
# topo = Topo()
# topo.load_G = load_G
# topo.unload_G = unload_G
#
# print(topo.load_G.nodes.data('None'))
# print(topo.get_load_target_node_real("6b417083-83b0-4eec-a8bd-2f85f96cb029", "1010cbfe-b134-3ef1-91bb-d746241c975a"))
\ No newline at end of file
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