- 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>
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>
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>
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>
Track materials that are not in the delete list and display them in
a new "未处理物料" (Unmatched Materials) section in the report.
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
Wrap the order processing logic in try-finally to guarantee cleanup
of the popup page regardless of whether processing succeeds or fails.
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- 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>
Add dryrun boolean parameter to DiscreteMaterialPlanCleaner.
When dryrun=True, the save_button_locator.click() is skipped,
allowing preview of changes without actually saving.
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add get_materials_to_delete_by_managers() function in db/materials_to_delete.py
- Supports querying by single manager, multiple managers, or all managers
- Uses IN clause for multi-manager queries
- Refactor DiscreteMaterialPlanCleaner to accept manager_names parameter
- Accepts str, List[str], or None (for all managers)
- Automatically normalizes parameter types in __init__
- Updates preload_data() with appropriate log messages
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add identify_input_type() function to detect input format:
- production_id: 2-digit + 1-letter + serial (e.g., 25A1, 25A12345)
- order_number: SC + 14 digits (e.g., SC70202602120120)
- Refactor MaterialStatusValidator to intelligently handle both input
types in validate_from_database() and validate_from_database_enhanced()
- Update log messages to reflect the new dual-input capability
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This change adds robust wait mechanisms to prevent race conditions when
performing delete and save operations in the ERP system.
Changes:
- Add row number change detection after delete to confirm completion
- Add save button disappearance detection to confirm save completion
- Add row number range check (7000-8000) to skip specific rows
- Enable previously commented save button click
- Improve logging with detailed status messages
- Add timeout handling (10s for delete, 60s for save)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Apply consistent code formatting including:
- Single quotes to double quotes for string literals
- Multi-line formatting for long expressions
- Trailing whitespace cleanup
- Blank line adjustments for PEP 8 compliance
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Automatically convert SQL Server syntax to MySQL-compatible format in
execute_query() and execute_update() methods:
- Parameter placeholders: ? -> %s
- Table names: [dbo].[TableName] -> dbo_TableName
- Column names: [ColumnName] -> ColumnName
This fixes the "Not all parameters were used in the SQL statement" error
that occurred when running queries originally written for SQL Server against
MySQL database.
The conversion is transparent to existing code, allowing SQL queries
throughout the codebase to work with MySQL without modification.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
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>
Rename utility files to use English names for better cross-platform compatibility:
- utils/离散备料计划维护数据提取.py → utils/discrete_material_plan_extractor.py
- utils/离散备料计划维护数据清理.py → utils/discrete_material_plan_cleaner.py
Update all import statements across the codebase and documentation references.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Restructure conditional flow to check status before detail count
- Add handling for orders with no material plan data
- Add handling for completed orders (status=完成)
- Add warning for orders with unrecognized status
- Fix deletion condition to check for non-zero pending quantity
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement database-level deduplication using ROW_NUMBER() window function
to remove duplicate material records based on MaterialCode field.
Changes:
- Add query_all_distinct_by_material_code() to deduplicate full table results
- Add query_by_source_numbers_distinct() to deduplicate filtered results
- Update validator to use new deduplication methods with statistics logging
- Retention strategy: keep earliest record (CreateDate ASC, SequenceNumber ASC)
Benefits:
- Reduces data redundancy from 54,358 to 1,679 records (96.91% reduction)
- Improves validation result readability by removing duplicate materials
- Maintains backward compatibility with existing query methods
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
- Modified _create_widgets() to conditionally create filter area only for admin users
- Modified _create_filter_checkboxes() to return early for non-admin users
- This prevents AttributeError when accessing self.filter_frame for User users
- Admin users retain full filtering functionality
- Fixes the 'MaterialTypeManagementDialog' object has no attribute 'filter_frame' error
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Use conn.get_placeholder() instead of hardcoded '?'
- Adapt table and column names for both MySQL and SQL Server
- Load database type from config to handle dialect differences
- Fix ProgrammingError when running with MySQL database
Co-Authored-By: Gemini 2.0 Flash <gemini-cli@google.com>
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>
- Integrate tklinenums library for line number display
- Line numbers appear on the left side in black color
- Line numbers are always visible (even with placeholder)
- Line numbers sync with text scrolling
- Add tklinenums>=1.7.0 to requirements.txt
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When content overflows in the Production ID text input, the scrollbar
now automatically appears. When content fits within the visible area,
the scrollbar is hidden.
- Changed layout from pack to grid for dynamic scrollbar control
- Added yview-based overflow detection (last < 1.0 indicates overflow)
- Added debounce mechanism to prevent excessive checks
- Bound events: KeyRelease, ButtonRelease, Configure, Paste
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 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>
- Remove DataQueryTab class and data_query_tab.py file
- Remove data query tab from main window
- Update about dialog to remove data query feature description
- Update database description from "SQL Server" to generic "数据库"
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 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>
Added validation to check if cumulative pending quantity is empty before allowing material deletion, with appropriate emoji indicators for delete eligibility.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
When an Admin user logs in, display a centered dialog allowing them to
select which user identity to use for the session. The Admin adopts the
selected user's permissions and operates as that user throughout the session.
Changes:
- Add UserSelectionDialog class in gui/user_selection_dialog.py
- Add SessionManager.switch_user() method to switch user identity
- Add SessionManager.get_original_admin() method to retrieve original admin
- Update MainWindow status bar to show when Admin operates as another user
- Display format: "当前用户: {username} ({type}) - 以 {admin_username} 身份登录"
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement automatic authentication based on computer name to enable
passwordless login for registered computers with fallback to manual
authentication.
Changes:
- Add SessionManager.login_by_computer_name() for silent login attempt
- Add BIPUsersDAO.authenticate_by_computer_name() for computer name lookup
- Update BIPUsersDAO.create_user() to support optional computer_name parameter
- Update main_ui.py to try silent login before showing login dialog
- Display current computer name in login dialog for user reference
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix type conversion issues when handling DatabaseType enum values in
configuration loading and GUI updates.
- config/loader.py: Handle both enum and string types for DB_TYPE
- config/schema.py: Properly convert db_type when it's already a string
- gui/config_manager.py: Add Enum type conversion with validation in set_nested_value
These changes prevent AttributeError when accessing .value on string values
and ensure proper type handling throughout the configuration system.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix parameter mismatch error when saving discrete material plan data.
Changed placeholder count from 28 to 29 to match the 29 columns in the
INSERT statement (Factory through BOMVersion).
Resolves error: "The SQL contains 28 parameter markers, but 29 parameters were supplied"
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Change from fuzzy material name matching to exact material code matching
- Migrate from MaterialsTypeToBeDeleted to MaterialsToBeDeleted table
- Add should_delete_material() for on-demand database queries
- Remove in-memory material list loading to reduce memory footprint
- Update documentation to reflect new matching logic
- Remove main scripts from git tracking (contain user-specific config)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Create detailed database architecture documentation with Mermaid diagrams including:
- Class hierarchy and design patterns (Factory, DAO, Strategy, Template Method)
- Connection management flows and lifecycle
- Database table structures and entity relationships
- SQL dialect handling for SQL Server and MySQL
- Data flow and batch processing logic
- Code examples and best practices
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
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>
- Add ResultDialog class with green checkmark (✓) for success
- Add red X (✕) icon for failure/partial failure
- Center result dialog on screen
- Use color-coded backgrounds (green/red) for better visual feedback
- Replace standard messagebox for more intuitive result display
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add EditableTreeview class for inline cell editing
- Handle invisible cells by scrolling to view before editing
- For new rows, allow partial input without validation errors
- Only validate completeness when saving, not during editing
- Add proper exception handling in edit callbacks
- Track original values for modified records
- Use temp keys for new rows that get updated when data is complete
- Fix status update to show after new row data is entered
- Clear edit state before destroying Entry to prevent duplicate callbacks
This enables users to:
- Double-click or press F2 to edit cells directly
- Press Insert to add new rows
- Press Delete to remove selected rows
- See visual indicators (green/yellow) for new/modified rows
- Get accurate status updates for pending changes
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 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>
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>