refactor: remove Excel data source options from material validation UI
Simplify material validation tab by removing Excel-related data source options and associated logic, keeping only database-driven validation modes. Changes: - Remove Excel file and Excel full workflow radio buttons from UI - Remove Excel file selector components (excel_existing_frame, excel_full_frame) - Update _on_source_mode_change to handle only database modes - Simplify start_validation input validation for database modes only - Update _validation_worker to call only database validation methods The UI now presents only two data source options: 1. Database - Full table validation 2. Database - ProductionID filtered validation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,11 +4,9 @@
|
|||||||
物料校验标签页
|
物料校验标签页
|
||||||
|
|
||||||
校验物料状态并匹配待删除物料。
|
校验物料状态并匹配待删除物料。
|
||||||
支持 4 种校验模式:
|
支持 2 种校验模式:
|
||||||
1. database_full - 数据库全表校验
|
1. database_full - 数据库全表校验
|
||||||
2. database_filtered - 数据库 ProductionID 过滤校验
|
2. database_filtered - 数据库 ProductionID 过滤校验
|
||||||
3. excel_existing - Excel 现有文件校验
|
|
||||||
4. excel_full - Excel 完整工作流
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -97,23 +95,6 @@ class MaterialValidationTab(ttk.Frame):
|
|||||||
command=self._on_source_mode_change,
|
command=self._on_source_mode_change,
|
||||||
).grid(row=0, column=1, sticky="w", padx=5)
|
).grid(row=0, column=1, sticky="w", padx=5)
|
||||||
|
|
||||||
# Excel 模式
|
|
||||||
ttk.Radiobutton(
|
|
||||||
source_group,
|
|
||||||
text="Excel - 现有文件",
|
|
||||||
variable=self.source_mode,
|
|
||||||
value="excel_existing",
|
|
||||||
command=self._on_source_mode_change,
|
|
||||||
).grid(row=1, column=0, sticky="w", padx=5)
|
|
||||||
|
|
||||||
ttk.Radiobutton(
|
|
||||||
source_group,
|
|
||||||
text="Excel - 完整工作流",
|
|
||||||
variable=self.source_mode,
|
|
||||||
value="excel_full",
|
|
||||||
command=self._on_source_mode_change,
|
|
||||||
).grid(row=1, column=1, sticky="w", padx=5)
|
|
||||||
|
|
||||||
# 文件选择
|
# 文件选择
|
||||||
file_group = ttk.LabelFrame(parent, text="文件选择", padding=10)
|
file_group = ttk.LabelFrame(parent, text="文件选择", padding=10)
|
||||||
file_group.pack(fill=tk.X, pady=5)
|
file_group.pack(fill=tk.X, pady=5)
|
||||||
@@ -137,28 +118,6 @@ class MaterialValidationTab(ttk.Frame):
|
|||||||
)
|
)
|
||||||
self.db_filtered_production_id_selector.pack(fill=tk.X)
|
self.db_filtered_production_id_selector.pack(fill=tk.X)
|
||||||
|
|
||||||
# Excel 现有文件模式
|
|
||||||
self.excel_existing_frame = ttk.Frame(file_group)
|
|
||||||
self.excel_existing_selector = FileSelector(
|
|
||||||
self.excel_existing_frame,
|
|
||||||
label_text="现有 Excel 文件:",
|
|
||||||
file_type="file",
|
|
||||||
file_types=[("Excel 文件", "*.xlsx"), ("所有文件", "*.*")],
|
|
||||||
initial_dir=self.config.get("paths.data_dir", "data/"),
|
|
||||||
)
|
|
||||||
self.excel_existing_selector.pack(fill=tk.X)
|
|
||||||
|
|
||||||
# Excel 完整工作流模式
|
|
||||||
self.excel_full_frame = ttk.Frame(file_group)
|
|
||||||
self.excel_full_production_id_selector = FileSelector(
|
|
||||||
self.excel_full_frame,
|
|
||||||
label_text="ProductionID 文件:",
|
|
||||||
file_type="file",
|
|
||||||
file_types=[("文本文件", "*.txt"), ("所有文件", "*.*")],
|
|
||||||
initial_dir="D:/python/playwrite/",
|
|
||||||
)
|
|
||||||
self.excel_full_production_id_selector.pack(fill=tk.X)
|
|
||||||
|
|
||||||
# 输出文件
|
# 输出文件
|
||||||
output_frame = ttk.Frame(file_group)
|
output_frame = ttk.Frame(file_group)
|
||||||
output_frame.grid(row=1, column=0, columnspan=2, sticky="ew", pady=(10, 0))
|
output_frame.grid(row=1, column=0, columnspan=2, sticky="ew", pady=(10, 0))
|
||||||
@@ -243,18 +202,12 @@ class MaterialValidationTab(ttk.Frame):
|
|||||||
# 隐藏所有文件选择框架
|
# 隐藏所有文件选择框架
|
||||||
self.db_full_frame.grid_remove()
|
self.db_full_frame.grid_remove()
|
||||||
self.db_filtered_frame.grid_remove()
|
self.db_filtered_frame.grid_remove()
|
||||||
self.excel_existing_frame.grid_remove()
|
|
||||||
self.excel_full_frame.grid_remove()
|
|
||||||
|
|
||||||
# 根据模式显示对应的文件选择器
|
# 根据模式显示对应的文件选择器
|
||||||
if mode == "database_full":
|
if mode == "database_full":
|
||||||
self.db_full_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
self.db_full_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
||||||
elif mode == "database_filtered":
|
elif mode == "database_filtered":
|
||||||
self.db_filtered_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
self.db_filtered_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
||||||
elif mode == "excel_existing":
|
|
||||||
self.excel_existing_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
|
||||||
elif mode == "excel_full":
|
|
||||||
self.excel_full_frame.grid(row=0, column=0, columnspan=2, sticky="ew")
|
|
||||||
|
|
||||||
def start_validation(self):
|
def start_validation(self):
|
||||||
"""开始校验"""
|
"""开始校验"""
|
||||||
@@ -280,22 +233,9 @@ class MaterialValidationTab(ttk.Frame):
|
|||||||
if not os.path.exists(production_id_file):
|
if not os.path.exists(production_id_file):
|
||||||
messagebox.showerror("错误", f"文件不存在:{production_id_file}")
|
messagebox.showerror("错误", f"文件不存在:{production_id_file}")
|
||||||
return
|
return
|
||||||
elif mode == "excel_existing":
|
else:
|
||||||
input_file = self.excel_existing_selector.get()
|
messagebox.showerror("错误", f"未知的校验模式: {mode}")
|
||||||
if not input_file:
|
return
|
||||||
messagebox.showerror("错误", "请选择现有 Excel 文件")
|
|
||||||
return
|
|
||||||
if not os.path.exists(input_file):
|
|
||||||
messagebox.showerror("错误", f"文件不存在:{input_file}")
|
|
||||||
return
|
|
||||||
elif mode == "excel_full":
|
|
||||||
production_id_file = self.excel_full_production_id_selector.get()
|
|
||||||
if not production_id_file:
|
|
||||||
messagebox.showerror("错误", "请选择 ProductionID 文件")
|
|
||||||
return
|
|
||||||
if not os.path.exists(production_id_file):
|
|
||||||
messagebox.showerror("错误", f"文件不存在:{production_id_file}")
|
|
||||||
return
|
|
||||||
|
|
||||||
# 确保输出目录存在
|
# 确保输出目录存在
|
||||||
output_dir = os.path.dirname(output_file)
|
output_dir = os.path.dirname(output_file)
|
||||||
@@ -352,17 +292,6 @@ class MaterialValidationTab(ttk.Frame):
|
|||||||
full_table=False,
|
full_table=False,
|
||||||
output_file=output_file
|
output_file=output_file
|
||||||
)
|
)
|
||||||
elif mode == "excel_existing":
|
|
||||||
result = validator.validate_from_existing_excel(
|
|
||||||
excel_file=input_file,
|
|
||||||
output_file=output_file
|
|
||||||
)
|
|
||||||
elif mode == "excel_full":
|
|
||||||
result = validator.validate(
|
|
||||||
production_id_file=production_id_file,
|
|
||||||
merged_excel_file=None,
|
|
||||||
output_file=output_file,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"未知的校验模式: {mode}")
|
raise ValueError(f"未知的校验模式: {mode}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user