From 428b83774603ea2c7bf1eb70c4d6c4f2925474f1 Mon Sep 17 00:00:00 2001 From: panxiang <1275280643@qq.com> Date: Sat, 7 Feb 2026 12:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=20=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=88=B0=20=20log=E4=B8=AD=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../htmlReportProcess_cmd_pV1.py | 72 ++++++++++++++----- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/htmlProcess/htmlReportProcess_cmd_p/htmlReportProcess_cmd_pV1.py b/htmlProcess/htmlReportProcess_cmd_p/htmlReportProcess_cmd_pV1.py index f81a4d1..c587cf3 100644 --- a/htmlProcess/htmlReportProcess_cmd_p/htmlReportProcess_cmd_pV1.py +++ b/htmlProcess/htmlReportProcess_cmd_p/htmlReportProcess_cmd_pV1.py @@ -88,25 +88,61 @@ class LogManager: fail_items = [] if fail_details: # 按失败次数排序,取前5个 - sorted_fail_items = sorted(fail_details.items(), key=lambda x: x[1], reverse=True)[:5] + sorted_fail_items = sorted(fail_details.items(), key=lambda x: x[1], reverse=True)[:10] for test_name, count in sorted_fail_items: fail_items.append(f"{test_name}({count}次)") + if len (sorted_fail_items)>10: + lastitems = sorted(fail_details.items(), key=lambda x: x[1], reverse=True)[10:] + messageappend ='' + for test_name, count in lastitems: + messageappend +=f"{test_name}({count}次)|" + fail_items.append(f"{messageappend})") # 写入Cell统计信息 f.write(f"Cell {cell}: 文件数={file_count}, SN:{sn_list}, FAIL数={fail_count}\n") # 如果有失败项,写入失败详情 if fail_items: - f.write(f" FAIL项: {', '.join(fail_items)}\n") + f.write(f" FAIL项:\n{'\n'.join(fail_items)}\n") - # SN统计 + # SN统计(优化后的格式) if statistics_data.get('sn_statistics'): f.write("\n=== SN统计 ===\n") sn_stats = statistics_data['sn_statistics'] - for sn, stats in sn_stats.items(): - f.write(f"SN {sn}: 文件数={stats.get('file_count', 0)}, " - f"Cell数={len(stats.get('cells', []))}, " - f"FAIL数={stats.get('fail_count', 0)}\n") + + # 按SN排序(按字母顺序) + sorted_sns = sorted(sn_stats.keys()) + + for sn in sorted_sns: + stats = sn_stats[sn] + file_count = stats.get('file_count', 0) + cells = stats.get('cells', []) + fail_count = stats.get('fail_count', 0) + fail_details = stats.get('fail_details', {}) + + # Cell列表(逗号分隔) + cell_list = ','.join(sorted(cells, key=lambda x: int(x) if x.isdigit() else x)) + + # 失败项详情 + fail_items = [] + if fail_details: + # 按失败次数排序,取前5个 + sorted_fail_items = sorted(fail_details.items(), key=lambda x: x[1], reverse=True)[:10] + for test_name, count in sorted_fail_items: + fail_items.append(f"{test_name}({count}次)") + if len (sorted_fail_items)>10: + lastitems = sorted(fail_details.items(), key=lambda x: x[1], reverse=True)[10:] + messageappend ='' + for test_name, count in lastitems: + messageappend +=f"{test_name}({count}次)|" + fail_items.append(f"{messageappend})") + + # 写入SN统计信息 + f.write(f"SN {sn}: 文件数={file_count}, Cell数={len(cells)}, FAIL数={fail_count}\n") + + # 如果有失败项,写入失败详情 + if fail_items: + f.write(f" FAIL项:\n{'\n'.join(fail_items)}\n") # 失败项统计 if statistics_data.get('failure_details'): @@ -885,7 +921,8 @@ class StatisticsCollector: 'file_count': 0, 'cells': set(), 'fail_count': 0, - 'elevation_count': 0 + 'elevation_count': 0, + 'fail_details': defaultdict(int) # 新增:SN级别的失败项详情 }) self.failure_details = { @@ -920,8 +957,8 @@ class StatisticsCollector: self.cell_statistics[cell]['sn_set'].add(sn) self.cell_statistics[cell]['fail_count'] += fail_count - # 收集失败项详情 - self._collect_fail_details(cell, rows, result.get("headers", [])) + # 收集失败项详情(同时收集SN和Cell级别的) + self._collect_fail_details(sn, cell, rows, result.get("headers", [])) else: self.failed_files += 1 @@ -929,8 +966,8 @@ class StatisticsCollector: f"{result.get('file', '未知文件')}: {result.get('error', '未知错误')}" ) - def _collect_fail_details(self, cell, rows, headers): - """收集失败项详情""" + def _collect_fail_details(self, sn, cell, rows, headers): + """收集失败项详情(包括SN和Cell级别)""" try: # 找到状态列和测试名称列的索引 status_idx = -1 @@ -958,6 +995,8 @@ class StatisticsCollector: test_name = str(row[test_name_col_idx]).strip() if 'FAIL' in status_val and test_name: + # 同时记录SN级别和Cell级别的失败项 + self.sn_statistics[sn]['fail_details'][test_name] += 1 self.cell_statistics[cell]['fail_details'][test_name] += 1 except Exception as e: @@ -1004,7 +1043,8 @@ class StatisticsCollector: 'sn_statistics': {sn: { 'file_count': stats['file_count'], 'cells': list(stats['cells']), - 'fail_count': stats['fail_count'] + 'fail_count': stats['fail_count'], + 'fail_details': dict(stats['fail_details']) # 包含失败项详情 } for sn, stats in self.sn_statistics.items()}, 'failure_details': self.failure_details, 'test_elevation_stats': self.test_elevation_stats @@ -1038,7 +1078,7 @@ class ParallelHTMLReportProcessor: self._collect_sn_distribution(all_files) # 显示文件分布 - # self._display_file_distribution() + self._display_file_distribution() # 设置工作进程数 if max_workers is None: @@ -1133,8 +1173,8 @@ class ParallelHTMLReportProcessor: if len(self.sn_file_counts) > 10: dist_info.append(f"... 还有 {len(self.sn_file_counts) - 10} 个SN") - self.log_manager.log_info(f"SN文件分布: {chr(10).join(dist_info)}") - print(f"{Fore.MAGENTA}⚫ SN文件分布:\n{Fore.CYAN}{chr(10).join(dist_info)}") + self.log_manager.log_info(f"{Fore.MAGENTA}⚫SN文件分布: \n{chr(10).join(dist_info)}") + # print(f"{Fore.MAGENTA}⚫ SN文件分布:\n{Fore.CYAN}{chr(10).join(dist_info)}") def _store_result_data(self, result): """存储处理结果"""