修复路口管家巡检页面产品走查bug

This commit is contained in:
wangxu 2025-12-05 12:00:44 +08:00
parent 466e47fffd
commit 901f8b052d
5 changed files with 53 additions and 38 deletions

View File

@ -393,8 +393,6 @@ def query_cross_examine_records_detail(params):
else: else:
phase_type_dir_dict[int(item_type)].append(item_detail) phase_type_dir_dict[int(item_type)].append(item_detail)
days_records[date] = phase_type_dir_dict days_records[date] = phase_type_dir_dict
last_14_keys = list(days_records.keys())[-14:]
days_records = {k: days_records[k] for k in last_14_keys}
res = make_common_res(0, 'ok') res = make_common_res(0, 'ok')
res['data'] = { res['data'] = {
'days_records': days_records, 'days_records': days_records,

View File

@ -308,7 +308,10 @@ def query_monitor_problems(params):
else: else:
shield_info['tide'][row['crossid']].append(problem_key) shield_info['tide'][row['crossid']].append(problem_key)
elif problem_key == 'phase_error': elif problem_key == 'phase_error':
shield_info['phase'].append(row['crossid'] + '^' + row['time_range']) first_date = row['first_date']
if not first_date:
continue
shield_info['phase'].append(row['crossid'] + '^' + row['time_range'] + '^' + row['first_date'])
elif problem_key in ('sample_sch', 'sample_tp'): elif problem_key in ('sample_sch', 'sample_tp'):
key = row['crossid'] + '^' + row['weekdays'] key = row['crossid'] + '^' + row['weekdays']
if key not in shield_info['sample'].keys(): if key not in shield_info['sample'].keys():
@ -361,15 +364,21 @@ def update_cross_problem_shield_state(params):
date_type = check_param(params, 'date_type') date_type = check_param(params, 'date_type')
if not date_type: if not date_type:
return json.dumps(make_common_res(9, '缺少查询日期类型, 请刷新后重试')) return json.dumps(make_common_res(9, '缺少查询日期类型, 请刷新后重试'))
first_date = check_param(params, 'first_date')
if not first_date:
first_date = ''
if problem_key == 'phase_error':
if not first_date or first_date == '':
return json.dumps(make_common_res(10, '缺少开始时间, 请选择开始时间'))
if op_type == 'add': if op_type == 'add':
ret = db_cross.add_shield_records(crossid ,area_id, weekdays, time_range, problem_key, date_type) ret = db_cross.add_shield_records(crossid ,area_id, weekdays, time_range, problem_key, date_type, first_date)
if ret == 1: if ret == 1:
return json.dumps(make_common_res(0, 'ok')) return json.dumps(make_common_res(0, 'ok'))
else: else:
return json.dumps(make_common_res(10, '添加屏蔽信息失败')) return json.dumps(make_common_res(10, '添加屏蔽信息失败'))
elif op_type == 'del': elif op_type == 'del':
ret = db_cross.delete_shield_records(crossid, area_id, weekdays, time_range, problem_key, date_type) ret = db_cross.delete_shield_records(crossid, area_id, weekdays, time_range, problem_key, date_type, first_date)
if ret == 1: if ret == 1:
return json.dumps(make_common_res(0, 'ok')) return json.dumps(make_common_res(0, 'ok'))
else: else:

View File

@ -142,16 +142,16 @@ class CrossDbHelper(TableDbHelperBase):
""" % (area_id) """ % (area_id)
return self.do_select(sql) return self.do_select(sql)
def add_shield_records(self, crossid ,area_id, weekday, time_range, problem_key, date_type): def add_shield_records(self, crossid ,area_id, weekday, time_range, problem_key, date_type, first_date):
sql = """ sql = """
insert into cross_doctor_matedata.cross_problem_shield (crossid, area_id, weekdays, time_range, problem_key, date_type) values ('%s', %s, '%s', '%s', '%s', '%s') insert into cross_doctor_matedata.cross_problem_shield (crossid, area_id, weekdays, time_range, problem_key, date_type, first_date) values ('%s', %s, '%s', '%s', '%s', '%s', '%s')
""" % (crossid, area_id, weekday, time_range, problem_key, date_type) """ % (crossid, area_id, weekday, time_range, problem_key, date_type, first_date)
return self.do_execute(sql) return self.do_execute(sql)
def delete_shield_records(self, crossid, area_id, weekday, time_range, problem_key, date_type): def delete_shield_records(self, crossid, area_id, weekday, time_range, problem_key, date_type, first_date):
sql = """ sql = """
delete from cross_doctor_matedata.cross_problem_shield where crossid = '%s' and area_id = %s and weekdays = '%s' and time_range = '%s' and problem_key = '%s' and date_type = '%s' delete from cross_doctor_matedata.cross_problem_shield where crossid = '%s' and area_id = %s and weekdays = '%s' and time_range = '%s' and problem_key = '%s' and date_type = '%s' and first_date = '%s'
""" % (crossid, area_id, weekday, time_range, problem_key, date_type) """ % (crossid, area_id, weekday, time_range, problem_key, date_type, first_date)
return self.do_execute(sql) return self.do_execute(sql)
def query_csr_data(self, nodeid, key, crossid): def query_csr_data(self, nodeid, key, crossid):

View File

@ -139,7 +139,7 @@ def gen_monitor_overview_data(cross_report_pb, date_type, routing_crosses, speci
for cross_delay_info in cross_delay_info_list: for cross_delay_info in cross_delay_info_list:
if special_time_range != '' and not is_overlap_greater_than_one_hour(cross_delay_info.tp.start_hm, cross_delay_info.tp.end_hm, special_time_range): if special_time_range != '' and not is_overlap_greater_than_one_hour(cross_delay_info.tp.start_hm, cross_delay_info.tp.end_hm, special_time_range):
continue continue
service_level = calc_service_level(cross_delay_info.delay_info.delay_time, cross_delay_info.delay_info.stop_times) service_level = calc_service_level(cross_delay_info.delay_info.delay_time, cross_delay_info.delay_info.stop_times) if cross_delay_info.delay_info.car_num >= 10 else '-'
if service_level != '-': if service_level != '-':
overview['cross_service_levels']['total'] += 1 overview['cross_service_levels']['total'] += 1
if service_level in ('A', 'B'): if service_level in ('A', 'B'):
@ -291,7 +291,7 @@ def gen_monitor_cross_ledger_info(routing_crosses, nodeid, area_id, slc_company_
inroadid_list = [item['roadid'] for item in all_crosses_inroads] inroadid_list = [item['roadid'] for item in all_crosses_inroads]
cross_has_reverse_lane = db_tmnet.check_reverse_turn(inroadid_list) cross_has_reverse_lane = db_tmnet.check_reverse_turn(inroadid_list)
virtual_roads = db_tmnet.query_virtual_roads(crossid_list) virtual_roads = db_tmnet.query_virtual_roads(crossid_list)
has_reverse_turn = int(cross_has_reverse_lane) + int(sum([item['reverse_turn'] for item in virtual_roads])) has_reverse_turn = int(cross_has_reverse_lane) + int(sum([item['reverse_turn'] for item in virtual_roads if item['reverse_turn']]))
reversible_lane_num = db_tmnet.calc_has_reversible_lane_crosses(crossid_list)[0]['num'] reversible_lane_num = db_tmnet.calc_has_reversible_lane_crosses(crossid_list)[0]['num']
special_info = { special_info = {
'reverse_turn': has_reverse_turn, 'reverse_turn': has_reverse_turn,
@ -313,22 +313,23 @@ def gen_cross_delay_info_list(userid, area_id, nodeid, date_type, cross_report_p
all_cross_index_dict_prev = parse_cross_index_dict(cross_delay_index_list_prev, special_time_range, routing_crosses_dict, date_type, area_id, nodeid, userid) all_cross_index_dict_prev = parse_cross_index_dict(cross_delay_index_list_prev, special_time_range, routing_crosses_dict, date_type, area_id, nodeid, userid)
# print(json.dumps(all_cross_index_dict, ensure_ascii=False)) # print(json.dumps(all_cross_index_dict, ensure_ascii=False))
for crossid in all_cross_index_dict.keys(): for crossid in all_cross_index_dict.keys():
if 'udc_' in crossid: if crossid not in routing_crosses_dict.keys():
cross_ledger_info = db_tmnet.query_cross_ledger_info(crossid, nodeid, area_id) continue
else:
cross_ledger_info = db_tmnet.query_virtual_cross_info(crossid, nodeid, area_id) internet_code = routing_crosses_dict[crossid]['internet']
internet_code = cross_ledger_info[0]['internet'] if cross_ledger_info else 0 if internet_code == '0':
if internet_code == 0:
internet_name = '未配置' internet_name = '未配置'
elif internet_code == 1: elif internet_code == '1':
internet_name = '联网' internet_name = '联网'
elif internet_code == 2: elif internet_code == '2':
internet_name = '脱机' internet_name = '脱机'
else: else:
internet_name = '未联网' internet_name = '未联网'
slc_company = cross_ledger_info[0]['slc_company'] if cross_ledger_info else 0 slc_company = routing_crosses_dict[crossid]['slc_company']
if slc_company:
slc_company = int(slc_company)
slc_company_name = slc_company_dict[slc_company] if slc_company in slc_company_dict.keys() else '-' slc_company_name = slc_company_dict[slc_company] if slc_company in slc_company_dict.keys() else '-'
cross_model = cross_ledger_info[0]['cross_model'].split(',') if cross_ledger_info and cross_ledger_info[0]['cross_model'] and cross_ledger_info[0]['cross_model'] != '-' and cross_ledger_info[0]['cross_model'] != '' else ['3', '3'] cross_model = routing_crosses_dict[crossid]['cross_model'].split(',')
cross_model_dict = { cross_model_dict = {
'1': '', '1': '',
'2': '', '2': '',
@ -364,6 +365,8 @@ def gen_cross_delay_info_list(userid, area_id, nodeid, date_type, cross_report_p
elif tp_info['service_level'] > tp_info_prev['service_level']: elif tp_info['service_level'] > tp_info_prev['service_level']:
tp_info['service_level_color'] = 1 tp_info['service_level_color'] = 1
for key in ('delay_time', 'stop_times', 'high_park_percent', 'park_time', 'relative_flow_rate', 'flow', 'jam_index', 'imbalance_index'): for key in ('delay_time', 'stop_times', 'high_park_percent', 'park_time', 'relative_flow_rate', 'flow', 'jam_index', 'imbalance_index'):
if tp_info[key] == '-' or tp_info_prev[key] == '-':
continue
if tp_info_prev[key] != 0: if tp_info_prev[key] != 0:
rate = round((tp_info[key] - tp_info_prev[key]) / tp_info_prev[key] * 100, 2) rate = round((tp_info[key] - tp_info_prev[key]) / tp_info_prev[key] * 100, 2)
tp_info[key + '_rate'] = rate tp_info[key + '_rate'] = rate
@ -372,6 +375,8 @@ def gen_cross_delay_info_list(userid, area_id, nodeid, date_type, cross_report_p
elif rate < -20: elif rate < -20:
tp_info[key + '_color'] = 2 tp_info[key + '_color'] = 2
for key in ('speed', 'move_speed'): for key in ('speed', 'move_speed'):
if tp_info[key] == '-' or tp_info_prev[key] == '-':
continue
if tp_info_prev[key] != 0: if tp_info_prev[key] != 0:
rate = round((tp_info[key] - tp_info_prev[key]) / tp_info_prev[key] * 100, 2) rate = round((tp_info[key] - tp_info_prev[key]) / tp_info_prev[key] * 100, 2)
tp_info[key + '_rate'] = rate tp_info[key + '_rate'] = rate
@ -437,17 +442,17 @@ def parse_cross_index_dict(delay_index_list, special_time_range, routing_crosses
'weekdays': weekdays, 'weekdays': weekdays,
'tp_type': tp_type, # 时段类型,默认0表示普通时段,1表示小时级时段,2表示单日典型时段 'tp_type': tp_type, # 时段类型,默认0表示普通时段,1表示小时级时段,2表示单日典型时段
'weekdays_str': weekdays_str, 'weekdays_str': weekdays_str,
'service_level': calc_service_level(delay_index.delay_info.delay_time, delay_index.delay_info.stop_times), 'service_level': calc_service_level(delay_index.delay_info.delay_time, delay_index.delay_info.stop_times) if delay_index.delay_info.car_num >= 10 else '-',
'stop_times': round(delay_index.delay_info.stop_times, 2), 'stop_times': round(delay_index.delay_info.stop_times, 2) if delay_index.delay_info.car_num >= 10 else '-',
'high_park_percent': delay_index.delay_info.high_park_percent, 'high_park_percent': delay_index.delay_info.high_park_percent if delay_index.delay_info.car_num >= 10 else '-',
'park_time': delay_index.delay_info.park_time, 'park_time': delay_index.delay_info.park_time if delay_index.delay_info.car_num >= 10 else '-',
'delay_time': delay_index.delay_info.delay_time, 'delay_time': delay_index.delay_info.delay_time if delay_index.delay_info.car_num >= 10 else '-',
'speed': round(delay_index.delay_info.speed / 100, 2), 'speed': round(delay_index.delay_info.speed / 100, 2) if delay_index.delay_info.car_num >= 10 else '-',
'move_speed': round(delay_index.delay_info.move_speed / 100, 2), 'move_speed': round(delay_index.delay_info.move_speed / 100, 2) if delay_index.delay_info.car_num >= 10 else '-',
'relative_flow_rate': relative_flow_rate, 'relative_flow_rate': relative_flow_rate if delay_index.delay_info.car_num >= 10 else '-',
'flow': delay_index.delay_info.car_num, 'flow': delay_index.delay_info.car_num,
'jam_index': round(delay_index.delay_info.jam_index, 2), 'jam_index': round(delay_index.delay_info.jam_index, 2) if delay_index.delay_info.car_num >= 10 else '-',
'imbalance_index': round(delay_index.delay_info.imbalance_index, 2), 'imbalance_index': round(delay_index.delay_info.imbalance_index, 2) if delay_index.delay_info.car_num >= 10 else '-',
'service_level_color': 0, 'service_level_color': 0,
'stop_times_color': 0, 'stop_times_color': 0,
'high_park_percent_color': 0, 'high_park_percent_color': 0,
@ -1097,7 +1102,7 @@ def turn_imbalance_problems(turn_imbalance_crosses, routing_crosses, special_tim
'time_range': time_range, 'time_range': time_range,
'weekdays_str': weekdays_str, 'weekdays_str': weekdays_str,
'weekdays': weekdays, 'weekdays': weekdays,
'imbalance_index': ''.join(inroad_imbalance_index_list), 'imbalance_index': ''.join(list(set(inroad_imbalance_index_list))),
'detail': detail, 'detail': detail,
'is_new': is_new, 'is_new': is_new,
'cont_times': cont_times, 'cont_times': cont_times,
@ -1368,7 +1373,7 @@ def phase_tp_check_problems(routing_crosses, special_time_range, first_date, dat
cross_name = routing_crosses[crossid]['name'] cross_name = routing_crosses[crossid]['name']
cross_no = routing_crosses[crossid]['crossno'] cross_no = routing_crosses[crossid]['crossno']
time_range = convert_time(start_hm) + '-' + convert_time(end_hm) time_range = convert_time(start_hm) + '-' + convert_time(end_hm)
key = crossid + '^' + time_range key = crossid + '^' + time_range + '^' + first_date
shield_state = 0 shield_state = 0
if key in shield_info['phase']: if key in shield_info['phase']:
if filter_shield == 1: if filter_shield == 1:

View File

@ -345,17 +345,20 @@ class TmnetDbHelper(TableDbHelperBase):
if(t2.cross_no is not null, t2.cross_no, t1.cross_no) as crossno, if(t2.cross_no is not null, t2.cross_no, t1.cross_no) as crossno,
if(t2.company is not null, t2.company, t1.company) as company, if(t2.company is not null, t2.company, t1.company) as company,
if(t2.location is not null, t2.location, t1.location) as location, if(t2.location is not null, t2.location, t1.location) as location,
if(t2.internet is not null, t2.internet, t1.internet) as internet,
if(t2.slc_company is not null, t2.slc_company, t1.slc_company) as slc_company,
if(t2.cross_model is not null and t1.cross_model is not null and t2.cross_model != t1.cross_model, t2.cross_model, t1.cross_model) as cross_model,
t1.nodeid, t1.nodeid,
t1.area_id t1.area_id
from from
(select crossid, name, location, nodeid, area_id, cross_no, company from `cross` where nodeid = %s and area_id = %s) t1 (select crossid, name, location, nodeid, area_id, cross_no, company,internet, slc_company, cross_model from `cross` where nodeid = %s and area_id = %s) t1
left join left join
(select crossid, name, location, nodeid, area_id, cross_no, company from `cross_ledger_update_info` where nodeid = %s and area_id = %s ) t2 on t1.crossid = t2.crossid (select crossid, name, location, nodeid, area_id, cross_no, company,internet, slc_company, cross_model from `cross_ledger_update_info` where nodeid = %s and area_id = %s ) t2 on t1.crossid = t2.crossid
where t1.area_id = %s where t1.area_id = %s
and t1.nodeid = %s and t1.nodeid = %s
and t1.crossid in (select crossid from bound_crosses where area_id = %s and nodeid = %s and is_routing_inspection = 1) and t1.crossid in (select crossid from bound_crosses where area_id = %s and nodeid = %s and is_routing_inspection = 1)
union all union all
select crossid, name, location, nodeid, area_id, cross_no, company from user_defined_cross where area_id = %s and nodeid = %s and crossid in (select crossid from bound_crosses where area_id = %s and nodeid = %s and is_routing_inspection = 1) select crossid, name, location, nodeid, area_id, cross_no, company, internet, slc_company, cross_model from user_defined_cross where area_id = %s and nodeid = %s and crossid in (select crossid from bound_crosses where area_id = %s and nodeid = %s and is_routing_inspection = 1)
""" % (nodeid, area_id, nodeid, area_id, area_id, nodeid, area_id, nodeid, area_id, nodeid, area_id, nodeid) """ % (nodeid, area_id, nodeid, area_id, area_id, nodeid, area_id, nodeid, area_id, nodeid, area_id, nodeid)
return self.do_select(sql) return self.do_select(sql)