From 7b0ce478708653adf2895c21acb2375738ebf07d Mon Sep 17 00:00:00 2001 From: wangxu <1318272526@qq.com> Date: Tue, 11 Nov 2025 11:14:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/cross_evaluate_worker.py | 6 +++++- app/db_cross_delay.py | 6 ++++++ app/eva_common.py | 15 +++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/cross_evaluate_worker.py b/app/cross_evaluate_worker.py index 5ea1594..d88928d 100644 --- a/app/cross_evaluate_worker.py +++ b/app/cross_evaluate_worker.py @@ -342,9 +342,13 @@ def query_cross_examine_records_detail(params): time_range = check_param(params, 'time_range') if not time_range: return json.dumps(make_common_res(8, '缺少时段范围,请选择时段范围')) + start_time = check_param(params, 'start_time') + if not start_time: + return json.dumps(make_common_res(9, '缺少开始时间,请选择开始时间')) + max_date = max(date_list) min_date = min(date_list) - tp_start = int(str(time_range.split('-')[0]).split(':')[0]) * 100 + int(str(time_range.split('-')[0]).split(':')[1]) + tp_start = int(str(start_time).split(':')[0]) * 100 + int(str(start_time).split(':')[1]) cross_examine_records = db_cross.query_cross_examine_records(tp_start, max_date, crossid, min_date) prev_day = (datetime.now() - timedelta(days=1)).strftime('%Y%m%d') if not cross_examine_records: diff --git a/app/db_cross_delay.py b/app/db_cross_delay.py index 380ab0a..59ac94a 100644 --- a/app/db_cross_delay.py +++ b/app/db_cross_delay.py @@ -37,6 +37,12 @@ class CrossDbHelper(TableDbHelperBase): """ % (crossid, start_hm, first_date, end_date) return self.do_select(sql) + def query_cross_examine_records_nostarthm(self, first_date, crossid, end_date): + sql = """ + select * from cross_doctor_matedata.cross_phase_problems_record where crossid = '%s' and first_date <= %s and (end_date >= '%s' or end_date is null) + """ % (crossid, first_date, end_date) + return self.do_select(sql) + def update_cross_examine_record_state_sql(self, crossid, first_date, start_hm, state): sql = """ update cross_doctor_matedata.cross_phase_problems_record set state = '%s' where crossid = '%s' and first_date = '%s' and start_hm = %s diff --git a/app/eva_common.py b/app/eva_common.py index 6bd3271..64d668c 100644 --- a/app/eva_common.py +++ b/app/eva_common.py @@ -1464,7 +1464,7 @@ def gen_phase_problems(nodeid, area_id, crossid, time_range, date_list, min_date phase_problems_detail, err = QueryCrossPhaseDiagnosis(int(nodeid), crossid, [str(item) for item in date_list], time_range, int(area_id)) if not err and phase_problems_detail: 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) + phase_err_detail, phase_err_suggestions, phase_err_total_num = gen_err_phase_problems(max_date, crossid, min_date, time_range) if len(phase_err_suggestions) > 0: phase_problems['values'].append({ 'item': '路口方案异常', @@ -1478,8 +1478,8 @@ def gen_phase_problems(nodeid, area_id, crossid, time_range, date_list, min_date 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) +def gen_err_phase_problems(max_date, crossid, min_date, time_range): + cross_examine_records = db_cross.query_cross_examine_records_nostarthm(max_date, crossid, min_date) detail = [] suggestions, total_num = [], 0 color_dict = { @@ -1509,16 +1509,19 @@ def gen_err_phase_problems(start_hm, max_date, crossid, min_date): } ] for cross_examine_record in cross_examine_records: + start_hm = convert_time(cross_examine_record['start_hm']) + end_hm = convert_time(cross_examine_record['end_hm']) + if not time_overlap(time_range, [start_hm + '-' + end_hm]): + continue if cross_examine_record['level_color'] == 4 or cross_examine_record['final_state'] == 6: 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}时段运行的配时方案有异常变动风险,异常等级为' + 'text': f'从{first_date}起在{start_hm}-{end_hm}时段运行的配时方案有异常变动风险,异常等级为', + 'start_hm': start_hm, }, { 'level_color': color_level,