|
|
|
|
@ -11,7 +11,7 @@ from google.protobuf.json_format import MessageToJson
|
|
|
|
|
|
|
|
|
|
import proto.xlcomm_pb2 as pb
|
|
|
|
|
from app.common_worker import *
|
|
|
|
|
from proto.phase_grpc import QueryCrossRunningPhase
|
|
|
|
|
from proto.phase_grpc import QueryCrossRunningPhase, QueryCrossPhaseDiagnosis
|
|
|
|
|
|
|
|
|
|
src_reverse = {'N': 'S', 'S': 'N', 'W': 'E', 'E': 'W', 'NE': 'SW', 'SW': 'NE', 'SE': 'NW', 'NW': 'SE'}
|
|
|
|
|
|
|
|
|
|
@ -501,7 +501,8 @@ def gen_road_dir_dict(cross_ledger_info_dict):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calc_inroad_imbalance_index(inroad_delay_pb_list):
|
|
|
|
|
for item in inroad_delay_pb_list:
|
|
|
|
|
tmp_list = copy.deepcopy(inroad_delay_pb_list)
|
|
|
|
|
for item in tmp_list:
|
|
|
|
|
avg_stop_times = item.delay_info.stop_times
|
|
|
|
|
max_stop_times, min_stop_times = 0, 99999
|
|
|
|
|
flow_delay_infos = item.flow_delay_infos
|
|
|
|
|
@ -512,7 +513,7 @@ def calc_inroad_imbalance_index(inroad_delay_pb_list):
|
|
|
|
|
min_stop_times = flow_delay_info.delay_info.stop_times
|
|
|
|
|
imbalance_index = round((max_stop_times - min_stop_times) / avg_stop_times, 2) if avg_stop_times > 0 and max_stop_times > 0 and min_stop_times != 99999 else 0
|
|
|
|
|
item.delay_info.imbalance_index = imbalance_index
|
|
|
|
|
return inroad_delay_pb_list
|
|
|
|
|
return tmp_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_flow_turn_rate_index(avg_cross_delay_info, roads_dir_dict):
|
|
|
|
|
@ -916,13 +917,18 @@ def parse_data2pb(data_list):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 生成路口诊断问题
|
|
|
|
|
def gen_cross_problems(crossid, nodeid, date_list, avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_phase, is_peak, cross_ledger_info):
|
|
|
|
|
def gen_cross_problems(crossid, nodeid, area_id, time_range, start_hm, date_list, avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_phase, is_peak, cross_ledger_info):
|
|
|
|
|
# 运行效率、均衡调控、配时方案、路口渠化
|
|
|
|
|
operating_efficiency_problems = gen_operating_efficiency_problems(avg_cross_delay_info, roads_dir_dict, cross_phase, is_peak)
|
|
|
|
|
balanced_control_problems = gen_balanced_control_problems(crossid, nodeid, date_list, avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_phase)
|
|
|
|
|
phase_problems = gen_phase_problems()
|
|
|
|
|
phase_problems = gen_phase_problems(nodeid, area_id, crossid, time_range, date_list, min(date_list), max(date_list), start_hm)
|
|
|
|
|
cross_channelized_problems = gen_cross_channelized_problems(avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_ledger_info)
|
|
|
|
|
problems = [operating_efficiency_problems, balanced_control_problems, phase_problems, cross_channelized_problems]
|
|
|
|
|
problems = {
|
|
|
|
|
'operating_efficiency_problems': operating_efficiency_problems,
|
|
|
|
|
'balanced_control_problems': balanced_control_problems,
|
|
|
|
|
'phase_problems': phase_problems,
|
|
|
|
|
'cross_channelized_problems': cross_channelized_problems
|
|
|
|
|
}
|
|
|
|
|
return problems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -934,8 +940,8 @@ def gen_operating_efficiency_problems(avg_cross_delay_info, roads_dir_dict, cros
|
|
|
|
|
'values': []
|
|
|
|
|
}]
|
|
|
|
|
road_delay_infos = avg_cross_delay_info.inroad_delay_infos
|
|
|
|
|
high_park_problems, high_park_suggestions = gen_high_park_problems(road_delay_infos, roads_dir_dict, cross_phase)
|
|
|
|
|
high_stop_times_problems, high_stop_times_suggestions = gen_high_stop_time_problems(avg_cross_delay_info, is_peak)
|
|
|
|
|
high_park_problems, high_park_suggestions, high_park_total_num = gen_high_park_problems(road_delay_infos, roads_dir_dict, cross_phase)
|
|
|
|
|
high_stop_times_problems, high_stop_times_suggestions, high_stop_times_total_num = gen_high_stop_time_problems(avg_cross_delay_info, is_peak)
|
|
|
|
|
operating_efficiency_problems = {
|
|
|
|
|
'item': '运行效率',
|
|
|
|
|
'values': [
|
|
|
|
|
@ -951,21 +957,16 @@ def gen_operating_efficiency_problems(avg_cross_delay_info, roads_dir_dict, cros
|
|
|
|
|
'reason': '高峰时段路口停车次数大于2次,非高峰时段停车次数大于1次',
|
|
|
|
|
'suggestions': high_stop_times_suggestions
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'total_num': high_park_total_num + high_stop_times_total_num
|
|
|
|
|
}
|
|
|
|
|
return operating_efficiency_problems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 运行效率-多次排队
|
|
|
|
|
def gen_high_park_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestion = []
|
|
|
|
|
detail = []
|
|
|
|
|
suggestion, total_num = [], 0
|
|
|
|
|
err_src_dict = {}
|
|
|
|
|
src_list = list(roads_dir_dict.keys())
|
|
|
|
|
road_delays_dict = {item.inroadid: item for item in road_delay_infos}
|
|
|
|
|
@ -987,6 +988,7 @@ def gen_high_park_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
if err_src_dict:
|
|
|
|
|
detail = []
|
|
|
|
|
for src_dir in err_src_dict.keys():
|
|
|
|
|
total_num = 1
|
|
|
|
|
src_detail, src_suggestions, turn_type_list = [], [], []
|
|
|
|
|
for turn_type in err_src_dict[src_dir]:
|
|
|
|
|
turn_type_list.append(int(turn_type.split(':')[0]))
|
|
|
|
|
@ -1017,25 +1019,20 @@ def gen_high_park_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
'child_detail': src_suggestions
|
|
|
|
|
})
|
|
|
|
|
suggestion.extend(phase_suggestions)
|
|
|
|
|
return detail, suggestion
|
|
|
|
|
return detail, suggestion, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 运行效率-停车较多
|
|
|
|
|
def gen_high_stop_time_problems(avg_cross_delay_info, is_peak):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestion = []
|
|
|
|
|
detail = []
|
|
|
|
|
suggestion, total_num = [], 0
|
|
|
|
|
desc, max_stop_times = '非高峰时段', 1
|
|
|
|
|
if is_peak:
|
|
|
|
|
# 表示为高峰时段,否则为平峰时段
|
|
|
|
|
desc, max_stop_times = '高峰时段', 2
|
|
|
|
|
if avg_cross_delay_info:
|
|
|
|
|
if avg_cross_delay_info.delay_info.stop_times > max_stop_times:
|
|
|
|
|
total_num = 1
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
@ -1057,15 +1054,15 @@ def gen_high_stop_time_problems(avg_cross_delay_info, is_peak):
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
return detail, suggestion
|
|
|
|
|
return detail, suggestion, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 均衡调控
|
|
|
|
|
def gen_balanced_control_problems(crossid, nodeid, date_list, avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_phase):
|
|
|
|
|
road_delay_infos = avg_cross_delay_info.inroad_delay_infos
|
|
|
|
|
cross_imbalance_detail, cross_imbalance_suggestions = gen_cross_imbalance_problems(road_delay_infos, roads_dir_dict, cross_phase)
|
|
|
|
|
turn_imbalance_detail, turn_imbalance_suggestions = gen_turn_imbalance_problems(road_delay_infos, roads_dir_dict, inroad_static_info_dict, cross_phase)
|
|
|
|
|
cross_tide_problems, cross_tide_suggestions = gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict)
|
|
|
|
|
cross_imbalance_detail, cross_imbalance_suggestions, cross_imbalance_total_num = gen_cross_imbalance_problems(road_delay_infos, roads_dir_dict, cross_phase)
|
|
|
|
|
turn_imbalance_detail, turn_imbalance_suggestions, turn_imbalance_total_num = gen_turn_imbalance_problems(road_delay_infos, roads_dir_dict, inroad_static_info_dict, cross_phase)
|
|
|
|
|
cross_tide_problems, cross_tide_suggestions, cross_tide_total_num = gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict)
|
|
|
|
|
balanced_control_problems = {
|
|
|
|
|
'item': '均衡调控',
|
|
|
|
|
'values': [
|
|
|
|
|
@ -1087,22 +1084,17 @@ def gen_balanced_control_problems(crossid, nodeid, date_list, avg_cross_delay_in
|
|
|
|
|
'reason': '对向进口道,早高峰其中一个方向的进口道与出口道流量比大于150%,晚高峰另一个方向进口道与出口道流量比大于150%',
|
|
|
|
|
'suggestions': cross_tide_suggestions
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'total_num': cross_imbalance_total_num + turn_imbalance_total_num + cross_tide_total_num
|
|
|
|
|
}
|
|
|
|
|
return balanced_control_problems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 均衡调控-路口失衡问题诊断
|
|
|
|
|
def gen_cross_imbalance_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestion = []
|
|
|
|
|
road_src_dict = {item['in']: item for item in roads_dir_dict}
|
|
|
|
|
detail = []
|
|
|
|
|
suggestion, total_num = [], 0
|
|
|
|
|
road_src_dict = {v['in']: k for k, v in roads_dir_dict.items()}
|
|
|
|
|
max_stop_times_road = max(road_delay_infos, key=lambda x: x.delay_info.stop_times)
|
|
|
|
|
min_stop_times_road = min(road_delay_infos, key=lambda x: x.delay_info.stop_times)
|
|
|
|
|
if max_stop_times_road.delay_info.stop_times > 1 \
|
|
|
|
|
@ -1112,7 +1104,8 @@ def gen_cross_imbalance_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
max_src = road_src_dict[max_roadid] if max_roadid in road_src_dict else None
|
|
|
|
|
min_src = road_src_dict[min_roadid] if min_roadid in road_src_dict else None
|
|
|
|
|
if max_src is None or min_src is None:
|
|
|
|
|
return detail, suggestion
|
|
|
|
|
return detail, suggestion, total_num
|
|
|
|
|
total_num = 1
|
|
|
|
|
detail = [
|
|
|
|
|
{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
@ -1149,21 +1142,15 @@ def gen_cross_imbalance_problems(road_delay_infos, roads_dir_dict, cross_phase):
|
|
|
|
|
is_tide = True
|
|
|
|
|
phase_suggestions = gen_src_dir_phase_detail(max_src, min_src, cross_phase, is_tide=is_tide)
|
|
|
|
|
suggestion.extend(phase_suggestions)
|
|
|
|
|
return detail, suggestion
|
|
|
|
|
return detail, suggestion, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 均衡调控-转向失衡问题诊断
|
|
|
|
|
def gen_turn_imbalance_problems(road_delay_infos, roads_dir_dict, inroad_static_info_dict, cross_phase):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestion = []
|
|
|
|
|
detail = []
|
|
|
|
|
suggestion, total_num = [], 0
|
|
|
|
|
err_road_dict = {}
|
|
|
|
|
road_src_dict = {item['in']: item for item in roads_dir_dict}
|
|
|
|
|
road_src_dict = {v['in']: k for k, v in roads_dir_dict.items()}
|
|
|
|
|
for road_delay_info in road_delay_infos:
|
|
|
|
|
inroadid = road_delay_info.inroadid
|
|
|
|
|
src_dir = road_src_dict[inroadid] if inroadid in road_src_dict.keys() else None
|
|
|
|
|
@ -1183,6 +1170,7 @@ def gen_turn_imbalance_problems(road_delay_infos, roads_dir_dict, inroad_static_
|
|
|
|
|
if len(err_road_dict.keys()) > 0:
|
|
|
|
|
detail, suggestion, road_num_suggestion = [], [], []
|
|
|
|
|
for src_dir in err_road_dict.keys():
|
|
|
|
|
total_num = 1
|
|
|
|
|
item_detail = [
|
|
|
|
|
{
|
|
|
|
|
'src_dir': dir_str_dict[src_dir] + '进口',
|
|
|
|
|
@ -1244,19 +1232,13 @@ def gen_turn_imbalance_problems(road_delay_infos, roads_dir_dict, inroad_static_
|
|
|
|
|
lane_num_suggestion.extend(road_num_suggestion)
|
|
|
|
|
suggestion = suggestion + lane_num_suggestion
|
|
|
|
|
|
|
|
|
|
return detail, suggestion
|
|
|
|
|
return detail, suggestion, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 均衡调控-路口潮汐问题诊断
|
|
|
|
|
def gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestions = []
|
|
|
|
|
detail = []
|
|
|
|
|
suggestions, total_num = [], 0
|
|
|
|
|
am_tp_start, am_tp_end = 't700', '900'
|
|
|
|
|
pm_tp_start, pm_tp_end = 't1700', '1900'
|
|
|
|
|
am_cross_delay_data_list = db_cross.query_cross_delay_info(crossid, nodeid, date_list, am_tp_start)
|
|
|
|
|
@ -1265,7 +1247,7 @@ def gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict):
|
|
|
|
|
pm_avg_cross_delay_info = gen_avg_cross_delay_pb(pm_cross_delay_data_list)
|
|
|
|
|
# 构建对向进口道对
|
|
|
|
|
subtend_road_pair = gen_subtend_road_pair(roads_dir_dict)
|
|
|
|
|
road_src_dict = {item['in']: item for item in roads_dir_dict}
|
|
|
|
|
road_src_dict = {v['in']: k for k, v in roads_dir_dict.items()}
|
|
|
|
|
max_am_flow, max_pm_flow, tide_index, max_am_flow_road, max_pm_flow_road = 0, 99999999999, 0, '', ''
|
|
|
|
|
am_inroad_infos = am_avg_cross_delay_info.inroad_delay_infos
|
|
|
|
|
pm_inroad_infos = pm_avg_cross_delay_info.inroad_delay_infos
|
|
|
|
|
@ -1277,10 +1259,12 @@ def gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict):
|
|
|
|
|
if am_flow > max_am_flow:
|
|
|
|
|
max_am_flow = am_flow
|
|
|
|
|
max_am_flow_road = am_inroad_info.inroadid
|
|
|
|
|
subtend_road_am_flow = am_inroad_info_dict[subtend_road_pair[max_am_flow_road]].delay_info.car_num if subtend_road_pair[max_am_flow_road] in am_inroad_info_dict.keys() else 0
|
|
|
|
|
subtend_road_am_flow = 0
|
|
|
|
|
if max_am_flow_road in subtend_road_pair.keys() and subtend_road_pair[max_am_flow_road] in am_inroad_info_dict.keys():
|
|
|
|
|
subtend_road_am_flow = am_inroad_info_dict[subtend_road_pair[max_am_flow_road]].delay_info.car_num
|
|
|
|
|
# 如果进口道流量小于20 则无意义
|
|
|
|
|
if min(subtend_road_am_flow, max_am_flow) < 20:
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
# 找出晚高峰最高流量的进口道
|
|
|
|
|
for pm_inroad_info in pm_inroad_infos:
|
|
|
|
|
pm_flow = pm_inroad_info.delay_info.car_num
|
|
|
|
|
@ -1289,13 +1273,14 @@ def gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict):
|
|
|
|
|
max_pm_flow_road = pm_inroad_info.inroadid
|
|
|
|
|
# 如果路段id为空或不在对向对里,则无意义
|
|
|
|
|
if max_pm_flow_road == '' or max_pm_flow_road not in subtend_road_pair.keys():
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
subtend_road_pm_flow = pm_inroad_info_dict[subtend_road_pair[max_pm_flow_road]].delay_info.car_num
|
|
|
|
|
if min(subtend_road_pm_flow, max_pm_flow) < 20:
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
Fam = max(max_am_flow_road, subtend_road_am_flow) / min(max_am_flow_road, subtend_road_am_flow)
|
|
|
|
|
Fpm = max(max_pm_flow_road, subtend_road_pm_flow) / min(max_pm_flow_road, subtend_road_pm_flow)
|
|
|
|
|
if Fam >= 1.5 and Fpm >= 1.5 and max_pm_flow_road == subtend_road_pair[max_am_flow_road]:
|
|
|
|
|
total_num = 1
|
|
|
|
|
src_dir = road_src_dict[max_am_flow_road]
|
|
|
|
|
full_src_dir = dir_str_dict[src_dir] + dir_str_dict[src_reverse[src_dir]] + '方向'
|
|
|
|
|
am_src_dir = dir_str_dict[src_dir] + '向' + dir_str_dict[src_reverse[src_dir]]
|
|
|
|
|
@ -1333,20 +1318,93 @@ def gen_cross_tide_problems(crossid, nodeid, date_list, roads_dir_dict):
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 配时方案
|
|
|
|
|
def gen_phase_problems():
|
|
|
|
|
def gen_phase_problems(nodeid, area_id, crossid, time_range, date_list, min_date, max_date, start_hm):
|
|
|
|
|
phase_problems = {
|
|
|
|
|
'item': '配时方案',
|
|
|
|
|
'values': [],
|
|
|
|
|
'total_num': 0
|
|
|
|
|
}
|
|
|
|
|
phase_problems_detail, err = QueryCrossPhaseDiagnosis(int(nodeid), crossid, [str(item) for item in date_list], time_range, int(area_id))
|
|
|
|
|
if not err:
|
|
|
|
|
phase_problems = phase_problems_detail
|
|
|
|
|
phase_err_detail, phase_err_suggestions, phase_err_total_num = gen_err_phase_problems(start_hm, max_date, crossid, min_date)
|
|
|
|
|
if len(phase_err_suggestions) > 0:
|
|
|
|
|
phase_problems['values'].append({
|
|
|
|
|
'item': '路口方案异常',
|
|
|
|
|
'detail': phase_err_detail,
|
|
|
|
|
'reason': '路口停车次数徒增或大数据计算方案与录入方案不一致',
|
|
|
|
|
'suggestions': phase_err_suggestions
|
|
|
|
|
})
|
|
|
|
|
total = phase_problems_detail['total'] if len(phase_problems_detail) > 0 else 0
|
|
|
|
|
phase_problems['total_num'] = total + phase_err_total_num
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
return phase_problems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_err_phase_problems(start_hm, max_date, crossid, min_date):
|
|
|
|
|
cross_examine_records = db_cross.query_cross_examine_records(start_hm, max_date, crossid, min_date)
|
|
|
|
|
detail = []
|
|
|
|
|
suggestions, total_num = [], 0
|
|
|
|
|
color_dict = {
|
|
|
|
|
1: '红色',
|
|
|
|
|
2: '橙色',
|
|
|
|
|
3: '黄色',
|
|
|
|
|
4: '绿色'
|
|
|
|
|
}
|
|
|
|
|
state_dict = {
|
|
|
|
|
1: '需核查逾期',
|
|
|
|
|
2: '需核查',
|
|
|
|
|
3: '监测中',
|
|
|
|
|
4: '核查有异常',
|
|
|
|
|
5: '核查无异常',
|
|
|
|
|
6: '自动结束'
|
|
|
|
|
}
|
|
|
|
|
if len(cross_examine_records) > 0:
|
|
|
|
|
total_num = 1
|
|
|
|
|
detail = []
|
|
|
|
|
suggestions = [
|
|
|
|
|
{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '核查该时段配时方案是否正常运行'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
for cross_examine_record in cross_examine_records:
|
|
|
|
|
if cross_examine_record['level_color'] == 4:
|
|
|
|
|
continue
|
|
|
|
|
first_date = cross_examine_record['first_date']
|
|
|
|
|
start_hm = convert_time(cross_examine_record['start_hm'])
|
|
|
|
|
end_hm = convert_time(cross_examine_record['end_hm'])
|
|
|
|
|
color_level = color_dict[cross_examine_record['level_color']]
|
|
|
|
|
final_state = state_dict[cross_examine_record['final_state']]
|
|
|
|
|
item_detail = [
|
|
|
|
|
{
|
|
|
|
|
'text': f'从{first_date}起在{start_hm}-{end_hm}时段运行的配时方案有异常变动风险,异常等级为'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'color': color_level,
|
|
|
|
|
'text': f',处理状态为',
|
|
|
|
|
'final_state': final_state
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
detail.append({
|
|
|
|
|
'child_detail': item_detail
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 路口渠化
|
|
|
|
|
def gen_cross_channelized_problems(avg_cross_delay_info, roads_dir_dict, inroad_static_info_dict, cross_ledger_info):
|
|
|
|
|
road_delay_infos = avg_cross_delay_info.inroad_delay_infos
|
|
|
|
|
inroad_num_detail, inroad_num_suggestion = gen_inroad_num_problems(road_delay_infos, inroad_static_info_dict, roads_dir_dict)
|
|
|
|
|
inout_lane_num_gap_problems, inout_lane_num_gap_suggestions = gen_in_out_lane_num_gap_problems(cross_ledger_info)
|
|
|
|
|
inroad_num_detail, inroad_num_suggestion, inroad_num_err_total_num = gen_inroad_num_problems(road_delay_infos, inroad_static_info_dict, roads_dir_dict)
|
|
|
|
|
inout_lane_num_gap_problems, inout_lane_num_gap_suggestions, inout_lane_num_gap_total_num = gen_in_out_lane_num_gap_problems(cross_ledger_info)
|
|
|
|
|
cross_channelized_problems = {
|
|
|
|
|
'item': '路口渠化',
|
|
|
|
|
'values': [
|
|
|
|
|
@ -1362,32 +1420,27 @@ def gen_cross_channelized_problems(avg_cross_delay_info, roads_dir_dict, inroad_
|
|
|
|
|
'reason': '进口道车道数比对向的出口道车道数多2',
|
|
|
|
|
'suggestions': inout_lane_num_gap_suggestions
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'total_num': inroad_num_err_total_num + inout_lane_num_gap_total_num
|
|
|
|
|
}
|
|
|
|
|
return cross_channelized_problems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 路口渠化-车道资源不匹配
|
|
|
|
|
def gen_inroad_num_problems(road_delay_infos, inroad_static_info_dict, roads_dir_dict):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestions, err_src_dirs = [], {}
|
|
|
|
|
road_src_dict = {item['in']: item for item in roads_dir_dict}
|
|
|
|
|
detail = []
|
|
|
|
|
suggestions, err_src_dirs, total_num = [], {}, 0
|
|
|
|
|
road_src_dict = {v['in']: k for k, v in roads_dir_dict.items()}
|
|
|
|
|
max_flow_car_num = 0
|
|
|
|
|
|
|
|
|
|
for road_delay in road_delay_infos:
|
|
|
|
|
inroadid = road_delay.inroadid
|
|
|
|
|
src_dir = road_src_dict[inroadid]
|
|
|
|
|
src_dir = road_src_dict[inroadid] if inroadid in road_src_dict else None
|
|
|
|
|
if src_dir is None:
|
|
|
|
|
continue
|
|
|
|
|
lane_info = inroad_static_info_dict[inroadid]['lane_turn_info']
|
|
|
|
|
flow_delay_infos = road_delay.flow_delay_infos
|
|
|
|
|
max_car_num = max([item.delay_info.car_num for item in flow_delay_infos if item.turn_type in [0, 1]]).delay_info.car_num
|
|
|
|
|
max_car_num = max([item.delay_info.car_num for item in flow_delay_infos if item.turn_type in [0, 1]])
|
|
|
|
|
if max_car_num > max_flow_car_num:
|
|
|
|
|
max_flow_car_num = max_car_num
|
|
|
|
|
road_car_num = road_delay.delay_info.car_num
|
|
|
|
|
@ -1426,6 +1479,7 @@ def gen_inroad_num_problems(road_delay_infos, inroad_static_info_dict, roads_dir
|
|
|
|
|
}]
|
|
|
|
|
if len(err_src_dirs.keys()) > 0:
|
|
|
|
|
detail = []
|
|
|
|
|
total_num = 1
|
|
|
|
|
for src_dir in err_src_dirs.keys():
|
|
|
|
|
err_road_dict = err_src_dirs[src_dir]
|
|
|
|
|
src_detail = [
|
|
|
|
|
@ -1468,19 +1522,13 @@ def gen_inroad_num_problems(road_delay_infos, inroad_static_info_dict, roads_dir
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 路口渠化-进出口道数不匹配
|
|
|
|
|
def gen_in_out_lane_num_gap_problems(cross_ledger_info):
|
|
|
|
|
detail = [{
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
'text': '未见异常'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}]
|
|
|
|
|
suggestions, err_src_dict = [], {}
|
|
|
|
|
detail = []
|
|
|
|
|
suggestions, err_src_dict, total_num = [], {}, 0
|
|
|
|
|
road_infos = cross_ledger_info['roads']
|
|
|
|
|
for src_dir in road_infos.keys():
|
|
|
|
|
entry_lane_num = road_infos[src_dir]['entry_lane_num']
|
|
|
|
|
@ -1494,6 +1542,7 @@ def gen_in_out_lane_num_gap_problems(cross_ledger_info):
|
|
|
|
|
}
|
|
|
|
|
if len(err_src_dict.keys()) > 0:
|
|
|
|
|
detail = []
|
|
|
|
|
total_num = 1
|
|
|
|
|
suggestions = {
|
|
|
|
|
'child_detail': [
|
|
|
|
|
{
|
|
|
|
|
@ -1514,7 +1563,7 @@ def gen_in_out_lane_num_gap_problems(cross_ledger_info):
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
return detail, suggestions
|
|
|
|
|
return detail, suggestions, total_num
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_is_peak_tp(time_range, area_id, nodeid):
|
|
|
|
|
@ -1527,6 +1576,8 @@ def check_is_peak_tp(time_range, area_id, nodeid):
|
|
|
|
|
|
|
|
|
|
def get_flow_phase_detail(src_dir, turn_type_list, cross_phase):
|
|
|
|
|
phase_suggestion = []
|
|
|
|
|
if not cross_phase:
|
|
|
|
|
return phase_suggestion
|
|
|
|
|
for item in cross_phase:
|
|
|
|
|
# 单个元素的含义为一个周计划
|
|
|
|
|
schedule_suggestion = []
|
|
|
|
|
@ -1691,3 +1742,17 @@ def count_lsr_half(turn_str):
|
|
|
|
|
# 返回格式化的结果,保留一位小数
|
|
|
|
|
return round(left_count, 1), round(straight_count, 1), round(right_count, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_next_cross(nodeid, area_id, roads_dir_dict):
|
|
|
|
|
src_cross = {}
|
|
|
|
|
for src_dir in roads_dir_dict.keys():
|
|
|
|
|
outroadid = roads_dir_dict[src_dir]['out']
|
|
|
|
|
if outroadid and outroadid != '-':
|
|
|
|
|
row_list = db_tmnet.query_out_cross(outroadid)
|
|
|
|
|
if len(row_list) > 0:
|
|
|
|
|
crossid = row_list[0]['to_crossid']
|
|
|
|
|
cross_info = db_tmnet.query_next_cross_info(nodeid, area_id, crossid)
|
|
|
|
|
if cross_info:
|
|
|
|
|
src_cross[src_dir] = cross_info[0]
|
|
|
|
|
return src_cross
|
|
|
|
|
|
|
|
|
|
|