style: normalize code formatting across the codebase
- Standardize quote style (single to double quotes) - Improve code formatting consistency - Apply formatting to utilities, GUI components, and tools - Update imports and docstrings for consistency Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
物料状态校验工具
|
||||
校验订单中的物料状态,匹配待删除物料
|
||||
"""
|
||||
|
||||
import os
|
||||
import pandas as pd
|
||||
from typing import List, Dict, Any
|
||||
@@ -49,8 +50,9 @@ class MaterialStatusValidator:
|
||||
material_names = [str(name) for name in material_names]
|
||||
return material_names
|
||||
|
||||
def match_materials(self, material_names: List[str],
|
||||
db_materials: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
def match_materials(
|
||||
self, material_names: List[str], db_materials: List[Dict[str, Any]]
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
匹配材料名称
|
||||
|
||||
@@ -66,22 +68,27 @@ class MaterialStatusValidator:
|
||||
matched = None
|
||||
for db_record in db_materials:
|
||||
# 如果数据库的MaterialName出现在Excel的材料名称中
|
||||
if db_record['MaterialName'] in material_name:
|
||||
if db_record["MaterialName"] in material_name:
|
||||
matched = db_record
|
||||
break
|
||||
|
||||
results.append({
|
||||
'材料名称': material_name,
|
||||
'匹配的MaterialName': matched['MaterialName'] if matched else None,
|
||||
'负责人': matched['ManagerName'] if matched else None,
|
||||
'匹配状态': '匹配成功' if matched else '未匹配'
|
||||
})
|
||||
results.append(
|
||||
{
|
||||
"材料名称": material_name,
|
||||
"匹配的MaterialName": matched["MaterialName"] if matched else None,
|
||||
"负责人": matched["ManagerName"] if matched else None,
|
||||
"匹配状态": "匹配成功" if matched else "未匹配",
|
||||
}
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
def validate(self, production_id_file: str,
|
||||
merged_excel_file: str = None,
|
||||
output_file: str = None) -> str:
|
||||
def validate(
|
||||
self,
|
||||
production_id_file: str,
|
||||
merged_excel_file: str = None,
|
||||
output_file: str = None,
|
||||
) -> str:
|
||||
"""
|
||||
执行完整的校验流程
|
||||
|
||||
@@ -106,7 +113,7 @@ class MaterialStatusValidator:
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
headless=self.headless,
|
||||
verbose=self.verbose
|
||||
verbose=self.verbose,
|
||||
)
|
||||
extractor.extract(production_id_file, output_file=merged_excel_file)
|
||||
self._print(f"数据提取完成: {merged_excel_file}")
|
||||
@@ -132,7 +139,7 @@ class MaterialStatusValidator:
|
||||
self._print(f"结果已保存: {output_file}")
|
||||
|
||||
# 打印统计信息
|
||||
matched_count = sum(1 for r in results if r['匹配状态'] == '匹配成功')
|
||||
matched_count = sum(1 for r in results if r["匹配状态"] == "匹配成功")
|
||||
self._print(f"\n统计信息:")
|
||||
self._print(f" 总材料数: {len(results)}")
|
||||
self._print(f" 匹配成功: {matched_count}")
|
||||
@@ -140,7 +147,9 @@ class MaterialStatusValidator:
|
||||
|
||||
return output_file
|
||||
|
||||
def validate_from_existing_excel(self, excel_file: str, output_file: str = None) -> str:
|
||||
def validate_from_existing_excel(
|
||||
self, excel_file: str, output_file: str = None
|
||||
) -> str:
|
||||
"""
|
||||
从已存在的Excel文件执行校验(不需要重新提取数据)
|
||||
|
||||
@@ -179,7 +188,7 @@ class MaterialStatusValidator:
|
||||
self._print(f"结果已保存: {output_file}")
|
||||
|
||||
# 打印统计信息
|
||||
matched_count = sum(1 for r in results if r['匹配状态'] == '匹配成功')
|
||||
matched_count = sum(1 for r in results if r["匹配状态"] == "匹配成功")
|
||||
self._print(f"\n统计信息:")
|
||||
self._print(f" 总材料数: {len(results)}")
|
||||
self._print(f" 匹配成功: {matched_count}")
|
||||
|
||||
Reference in New Issue
Block a user