feat: implement unified logging system for GUI components

Add centralized logging mechanism that simultaneously outputs to console
and GUI log components, improving code maintainability and consistency.

Changes:
- Add gui/log_config.py for centralized logging configuration
- Add gui/widgets/log_handler.py as bridge between logging and LogText
- Integrate unified logging into DataExtractionTab and MaterialValidationTab
- Initialize logging system in MainWindow on startup
- Improve error messages in material_status_validator for empty results
- Add documentation for logging mechanism and refactoring

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-02-24 20:31:59 +08:00
parent 3c45ef58d1
commit 24053c6a3b
9 changed files with 821 additions and 24 deletions

View File

@@ -466,6 +466,15 @@ class MaterialStatusValidator:
dao = DiscreteMaterialPlanDAO()
material_records = dao.query_by_source_numbers(source_numbers)
self._print(f"[INFO] 获取到 {len(material_records)} 条记录")
# 如果没有找到物料记录,给出友好提示
if not material_records:
self._print("\n[ERROR] 校验失败:未找到物料记录")
self._print("[ERROR] 可能原因:")
self._print("[ERROR] 1. 这些生产订单的物料数据还没有提取到数据库")
self._print("[ERROR] 2. 请先运行【正式备料计划数据提取】工具")
self._print("[ERROR] 3. 提取时勾选【持久化到数据库】选项")
self._print("[ERROR] 4. 将这 10 个 ProductionID 的物料数据保存到 DiscreteMaterialPlanData 表")
else:
raise ValueError("必须指定 full_table=True 或提供 production_id_file 参数")