Commit 3a116ab7 authored by Allvey's avatar Allvey

修复二次调度车辆走错装载区问题, 新增python库详见部署文档

parent 95606bae
......@@ -25,5 +25,8 @@
"redis": {
"host": "172.16.0.53",
"password": "Huituo@123"
},
"geom": {
"redispatch_minimal_distance": 40
}
}
......@@ -910,6 +910,13 @@ class ReDispatcher:
# 排除下一个路段阻塞的装载区
delete_congestion_load_area(congestion_lane_dict, load_area_dict,
next_lane_load_area_dict)
# 获取车辆经纬度信息
truck_prise_location = self.group.truck.truck_current_prise_location[truck_id]
if is_close_to_cross(truck_locate, truck_prise_location):
self.logger.info(f'距离过近无法触发二次调度')
return False
self.logger.info("剔除堵塞装载区")
self.logger.info(load_area_dict)
# 获取最佳挖机
......
......@@ -10,6 +10,8 @@ import requests
from tables import *
with open(json_file, encoding='UTF-8') as f:
mysql_config = json.load(f)["mysql"]
with open(json_file, encoding='UTF-8') as f:
geom_config = json.load(f)["geom"]
# def redispatch_request(truck_id, excavator_id, unload_area_id):
......@@ -68,6 +70,24 @@ def get_cross_next_lanes(truck_locate):
return next_lane_list
def is_close_to_cross(truck_locate, truck_prise_location):
"""
:return:
"""
start_node_id = session_postgre.query(Lane).filter_by(Id=truck_locate).first().EndNodeId
start_node_gemo = str(session_postgre.query(Node).filter_by(Id=start_node_id).first().geom)
coess_pos_xy = wkb.loads(start_node_gemo)
cross_pos = [coess_pos_xy.y, coess_pos_xy.x]
from haversine import haversine
truck_to_cross_point_dis = haversine(cross_pos, truck_prise_location)
if truck_to_cross_point_dis * 1000 < float(geom_config['redispatch_minimal_distance']):
return True
else:
return False
def delete_congestion_load_area(congestion_lane_dict, load_area_dict, next_lane_load_area_dict):
"""
......
......@@ -13,6 +13,8 @@ from sqlalchemy import Column, create_engine
from sqlalchemy import VARCHAR, DateTime, Float, Integer, BOOLEAN
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from geoalchemy2 import Geography
from shapely import wkb
from urllib.parse import quote
import json, os
from settings import *
......@@ -154,6 +156,16 @@ class Lane(Base):
self.Type = Type
class Node(Base):
__tablename__ = 'Geo_Node'
Id = Column(VARCHAR(36), primary_key=True)
geom = Column(Geography("Point"))
def __init__(self, Id, geom):
self.Id = Id
self.geom = geom
class Dispatch(Base):
# 表的名字:
__tablename__ = 'sys_dispatch_setting'
......@@ -528,4 +540,4 @@ class RecordTruckOutput(Base):
def __init__(self, id, unload_area_id, end_time ):
self.id = id
self.unload_area_id = unload_area_id
self.end_time = end_time
self.end_time = end_time
\ 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