Commit Graph

24 Commits

Author SHA1 Message Date
Misaka
3b7c00377f style: format all Python files with Black
Apply Black formatter to the entire codebase for consistent code style.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 22:44:03 +08:00
Misaka
1b16842a2c refactor: move action buttons to right panel for User mode in material validation
Move the four action buttons (全选, 取消全选, 确认删除, 执行删除) from the
top control panel to the right-side panel below 显示全部 for User mode.
Admin users continue to see these buttons in the top control panel.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 22:40:44 +08:00
Misaka
18f784f067 refactor: extract common tab functionality to BaseTab and add decorators
- Add BaseTab base class for common tab initialization and logging
- Add constants module for shared GUI constants
- Move CheckboxTreeview to separate widget file
- Add admin_only and require_session decorators to utils.py
- Refactor DataExtractionTab and MaterialValidationTab to inherit BaseTab
- Remove duplicate _update_log method from tab classes

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 21:17:37 +08:00
Misaka_Company
3a9c6f0978 feat: add hide/show filter buttons for User mode in material validation
Add two buttons (隐藏勾选/显示全部) on the right side of the result
table for non-admin users to hide checked items or show all items.
- Buttons are disabled until validation completes
- Hidden items are tracked and can be restored
- Admin users see the original layout without these buttons

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 17:57:11 +08:00
Misaka_Company
b318856394 refactor: simplify UI layout using grid instead of pack for admin controls
Restructure the Production ID source controls to use grid layout for
better alignment. Simplify manager filter section by removing
canvas/scrollbar complexity in favor of a straightforward two-column
layout with buttons on the left.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 17:20:49 +08:00
Misaka_Company
c76ea31fcb fix: hide Production ID source controls when admin selects full table validation
When admin user selects "database_full" mode, the Production ID source
selection controls should be hidden since full table validation doesn't
need Production IDs. Changed source_frame from local variable to instance
attribute to enable proper show/hide functionality.

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 15:52:54 +08:00
Misaka_Company
8d51c5b368 feat: add delete execution feature with progress tracking and dryrun mode
- Add ExecutionConfig for dryrun settings in config schema
- Create DeleteProgressWindow widget for real-time progress display
- Integrate delete execution flow in MaterialValidationTab with threading
- Add dryrun checkbox for admin users in settings
- Add progress callback support to DiscreteMaterialPlanCleaner
- Add markdown report generation with statistics
- Include tkinterweb and markdown2 dependencies for report rendering

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-02-26 13:02:48 +08:00
Misaka
f2bbcfc426 Merge branch 'mysql' into dev
Resolved merge conflict in utils/material_status_validator.py by keeping
both deduplication statistics and error messages for empty results.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-24 20:44:52 +08:00
Misaka
24053c6a3b 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>
2026-02-24 20:31:59 +08:00
Misaka_Company
0644bdfb11 feat: add column sorting functionality to material validation table
Add sorting capability for "选择" and "材料名称" columns in the CheckboxTreeview:
- Click column header to cycle through: asc (↑) → desc (↓) → unsort
- Sort "选择" column by checkbox state (checked/unchecked)
- Sort "材料名称" column alphabetically
- Preserve checkbox states during sorting using move() instead of delete+insert
- Separate event handlers for cell clicks and heading clicks

Implementation details:
- Added 6 new helper methods to CheckboxTreeview class
- Store original headings to properly display sort arrows
- Use identify_region() to distinguish between cell and heading clicks
- Column index conversion (#1/#2) to column identifiers

The sorting is a pure frontend feature with no database changes.
Available to all users without permission restrictions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-24 15:45:55 +08:00
Misaka
3b491d7b36 refactor: optimize settings and validation tabs for User users
Material Validation Tab:
- Remove file selection area (file_group and related frames)
- Move output file path configuration to settings
- For User users: hide data source selection, only show shared production IDs

Settings Tab:
- Add "validation output file" configuration to path settings group
- Show "save settings" button for User users
- Add User-only mode to only show path settings group

Changes:
- material_validation_tab.py: Restructure control panel, update export_paths
- settings_tab.py: Add validation output filename, add save button for users

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 22:40:07 +08:00
Misaka
6f8df2f2e6 feat: add Production ID input widget and UI configuration
- Add ProductionIdInput widget with placeholder and multi-line support
- Add UIConfig class for font family, font size, and input width settings
- Refactor data extraction tab to use horizontal PanedWindow layout
  - Left panel: Production ID text input (draggable width)
  - Right panel: control panel and log output
- Share Production IDs between data extraction and material validation tabs
- Add UI settings group in settings page (font selection, size, input width)
- For User users: automatically use shared Production IDs, simplified UI
- Apply font settings to input and log widgets
- Use sashpos() to set initial pane width correctly

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 21:47:17 +08:00
Misaka
b9184bbe3e fix: handle material validation filter for non-admin users
- Fix _get_selected_managers() to return current username for non-admin users
- Fix _restore_manager_filter_state() to skip checkbox operations for non-admin users
- Initialize filter_frame attribute for non-admin users to avoid AttributeError

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 20:59:08 +08:00
Misaka_Company
d18bedcd77 feat: implement user type-based UI access control
Restrict settings interface and material validation features based on user type:

- SettingsTab: User type only sees "Test ERP Connection" and "Test Database Connection" buttons; Admin sees full configuration interface
- MaterialValidationTab: Hide manager filter and data source options from non-admin users; default to database_filtered mode
- test_db_connection(): Read from config directly to support User type without UI variables
- Add backward compatibility: no session_manager defaults to full interface

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 17:30:26 +08:00
Misaka_Company
04b99292ad feat: implement user authentication and permission-based data filtering
Add user login system with role-based access control:
- Admin users see all data and can filter by any manager
- Regular users only see records where ManagerName matches their username

New components:
- BIPUsersDAO: user authentication and management
- SessionManager: singleton session state management
- LoginDialog: modal login UI for app startup
- init_users.sql: initial user setup script

Permission enforcement:
- Material validation tab: hide manager filter for non-admin, force filter by current user
- Material type management: hide filter UI for non-admin, filter at database level
- Window title and status bar display current user info

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 18:17:31 +08:00
Misaka_Company
57c23f4608 feat: add manager filter to material validation tab
Add checkbox-based manager filter functionality to material validation page:
- Canvas-based filter UI with 6-column grid layout for manager checkboxes
- Select All / Deselect All quick action buttons
- Filter source: union of MaterialsToBeDeleted and MaterialsTypeToBeDeleted tables
- Auto-include records with empty manager field for editing
- Preserve filter state across validation runs
- Support for MaterialValidationResult dataclass objects
- Refresh filter and results after confirm deletion operation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 17:32:59 +08:00
Misaka_Company
2fb44a2a9b feat: add material type management dialog with checkbox filter
- Add MaterialTypeManagementDialog for managing MaterialsTypeToBeDeleted table
- Implement checkbox-based filtering by manager name with dynamic manager list
- Support CRUD operations: create, read, update, delete with local caching
- Add "类型管理" button in material validation tab to open the dialog
- Include select all/deselect all functionality for manager filters
- Track pending changes and show unsaved changes warning

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 13:17:25 +08:00
Misaka_Company
13d6c20383 refactor: sync all rows with database on confirmation
Changed "确认删除" button to process ALL table rows (both checked and unchecked):
- Checked rows (☑): Upsert MaterialCode and ManagerName to database
- Unchecked rows (☐): Delete MaterialCode from database
- Validation: Checked rows must have ManagerName

This replaces the previous behavior that only processed checked items.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 17:42:32 +08:00
Misaka_Company
cd21e54abf feat: add material deletion confirmation with checkbox UI
- Add MaterialsToBeDeletedDAO for managing material deletion records by MaterialCode
- Add MaterialValidationResult dataclass for enhanced validation results
- Add CheckboxTreeview component with selectable checkbox functionality
- Refactor material validation UI with new columns: select, material name, code, spec, model, manager
- Add double-click to edit manager name functionality
- Add select all/deselect all buttons
- Add confirm deletion button to write selected records to database
- Prioritize MaterialsToBeDeleted.ManagerName over type-based matching when displaying
- Export results to Excel with selection state

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 16:40:28 +08:00
Misaka_Company
ca1a1f3219 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>
2026-02-06 13:38:48 +08:00
Misaka_Company
2096a51f55 feat: add database-driven material validation with multi-mode support
This commit enhances the material validation functionality to support
database-driven workflows alongside the existing Excel-based approach.

## New Features

### DAO Layer
- Add ProductionContractDataDAO for querying production contract data
- Add MaterialsToBeDeletedDAO with full CRUD operations
- Enhance DiscreteMaterialPlanDAO with query_all(), query_by_source_numbers(),
  and get_unique_material_names() methods

### Validation Modes
Support for 4 validation modes in MaterialValidationTab:
1. Database Full - Query all materials from DiscreteMaterialPlanData
2. Database Filtered - Query by ProductionID.txt file
3. Excel Existing - Validate from existing Excel file
4. Excel Full - Complete workflow with ERP extraction

### Configuration
- Add ValidationConfig dataclass with data_source, batch_size, match_mode,
  enable_crud_operations, and default_manager fields
- Update ConfigLoader to support validation configuration
- Add validation settings section in SettingsTab GUI

### Query Chain
Implementation of full query chain:
ProductionID.txt (总排号) → productionContractData (生产订单号) →
DiscreteMaterialPlanData (SourceNumber) → MaterialName →
MaterialsToBeDeleted comparison

## Backward Compatibility
All existing Excel-based validation methods remain unchanged, ensuring
no breaking changes for existing workflows.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 13:08:31 +08:00
Misaka_Company
2ca53f6a55 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>
2026-02-05 14:56:35 +08:00
Misaka_Company
13bc4520bf refactor: centralize configuration management with type-safe schema
Major changes:
- Add dataclass-based configuration schema with validation (config/schema.py)
- Create centralized config loader and default values (config/defaults.py, config/loader.py)
- Remove duplicate database_config.py, merge into unified structure
- Consolidate browser settings into ERP config
- Add batch_size parameter support to extractor

Bug fixes:
- Fix settings save error by updating config paths (browser.* → erp.*)
- Fix batch_size not being applied in data extraction

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 14:27:28 +08:00
Misaka_Company
71621dc8a0 feat: add Tkinter GUI application for ERP automation tools
Implement a comprehensive GUI application with the following features:
- Data Extraction tab: Extract material plan data from ERP system
- Material Validation tab: Validate material status and match deletions
- Data Query tab: Query database for production order information
- Settings tab: Manage ERP, database, browser, and path configurations

Key components:
- MainWindow: Tabbed interface with status bar
- ConfigManager: JSON-based configuration management
- LogText: Custom read-only text widget with colored logging
- FileSelector: Reusable file/directory selection component
- ProgressDialog: Modal progress dialog for long operations

Technical details:
- Thread-safe UI updates using root.after()
- Stdout capture for legacy script integration
- Event-based readonly mode allowing copy/select operations
- Custom widget composition to avoid Tkinter ScrolledText issues

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 13:33:23 +08:00