- Add DataImportService for reading Excel and importing to database
- Extend DiscreteMaterialPlanDAO with deleteBySourceNumbers and batchInsert
- Auto-trigger database write after successful Excel merge
- Support batch delete by SourceNumber and batch insert (1000/batch)
- Update ExtractorPage UI to show import results
- Fix SQL Server query to handle undefined recordset for DELETE/INSERT
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add getTableName() method to convert MySQL table names to SQL Server format
- Use queryWithParams with sql.NVarChar for proper SQL Server parameter handling
- Implement case-insensitive matching for production IDs (e.g., 26b10433 vs 26B10433)
- Align resolver logic with validation-handler.ts for consistent database queries
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
The product unit column header was incorrectly showing "单位" instead of
"产品单位", causing confusion with the material unit column which also
uses "单位". Fixed in both extractor.ts and excel-parser.ts.
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add MaterialTypeManagementDialog component for managing material type keywords
- Add MaterialsTypeToBeDeletedDAO for database operations
- Add material-type-handler IPC handlers
- Update CleanerPage with type management button
- Add database fix scripts for AUTO_INCREMENT
- Update documentation for settings partial save and validation flow
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Fix "Workbook is not a constructor" error by handling ESM/CommonJS module format
- Add try-catch around saveMergedOrders to capture and report errors
- Return parsed recordCount even when save fails so users see actual data count
- Add detailed logging throughout merge process for debugging
- Clean up temporary batch files after merge completion
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
Add export functionality to CleanerPage that allows users to export
the currently displayed validation results to an Excel file.
- Add ExportResultItem and ExportResultResponse types
- Create ResultExporter service using ExcelJS
- Register cleaner:exportResults IPC handler
- Add exportResults method to preload API
- Connect export button in CleanerPage to export handler
Export features:
- Exports filtered results (respecting manager/visibility filters)
- Includes selection status column
- Saves to app data directory/exports/校验结果.xlsx
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add mergeFiles() method in ExtractorService to combine downloaded batch files
- Add saveMergedOrders() method to output full 31-column Excel format
- Update recordCount to return actual material record count
- Add missing field mappings in OrderHeader type and ExcelParser:
- factory, materialStatus, planNumber, materialType
- department, remark, createDate, approveDate
- Output file named with timestamp: merged_YYYYMMDDHHMMSS.xlsx
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Add IDatabaseService interface with unified query(transaction) methods
- Create DatabaseFactory for centralized database service creation
- Modify MySqlService and SqlServerService to implement IDatabaseService
- Unify SqlServerService.query() to accept array params (internally converts to @p0, @p1...)
- Refactor OrderNumberResolver to use IDatabaseService
- Refactor DiscreteMaterialPlanDAO to use DatabaseFactory
- Refactor MaterialsToBeDeletedDAO to use DatabaseFactory
- Update IPC handlers to use DatabaseFactory.create()
- Add database.types.ts with shared type definitions
This enables switching between MySQL and SQL Server via DB_TYPE env variable.
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
- Update version to 1.1 with new related files list
- Fix sequence diagram step numbers and add IPC serialization note
- Add note about progress state not receiving backend updates
- Add code references for real-time sync useEffect and preload API
- Update summary with custom error types and sessionStorage details
- Add new section for known limitations and pending features
- Document progress update and file merge as unimplemented
Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
Features:
- Partial settings save with deep merge
- Backup and rollback mechanism
- UI field whitelist validation
- Defensive programming in settings page
Safety:
- Auto-backup before save
- Automatic rollback on failure
- Field validation at both client and server
The root cause of config overwrites was key mismatch:
- .env file uses: ERP_URL, DB_TYPE, DB_NAME (underscore uppercase)
- Code was using: erp.url, database.dbType (dot notation)
Fixed in three methods:
- saveAllSettings() - now sets cache with correct keys
- resetToDefaults() - now uses correct keys
- save() - now reads cache with correct keys
This ensures partial save preserves unmodified fields.
- Change parameter type from SettingsData to Partial<SettingsData>
- Call savePartialSettings() instead of saveAllSettings()
- Return detailed error messages from savePartialSettings
- Add logging for sections being saved
This change enables partial settings save functionality, allowing
the UI to save only specific settings sections without requiring
the complete settings object.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements the core savePartialSettings method that:
- Validates fields against UI_EDITABLE_FIELDS whitelist
- Deep merges partial updates with current settings
- Creates backup before saving
- Restores backup on save failure
- Reloads .env file to populate cache with correct keys
Added comprehensive tests:
- Partial update preserves existing fields
- Rejects non-whitelisted fields
- Handles nested object updates
- Restores backup on save failure
Fixed cache key inconsistency bug by clearing cache in loadEnvFile()
and reloading after save to ensure proper cache population.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace console.log/console.error with proper logger usage in
backupEnvFile and restoreBackup methods. Use the existing 'log' logger
created with createLogger('ConfigManager') following the same pattern
used in other methods.
Changes:
- Import createLogger and create log instance
- Replace console.log with log.debug in backupEnvFile
- Replace console.error with log.error in both methods
- Pass error and path metadata as objects for structured logging
- Fix test to use correct backup path (process.cwd() + src/main/.env.backup)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix TypeScript type error in deepMerge recursive call with proper type assertions
- Remove unused type imports (ErpConfig, DatabaseConfig, PathsConfig, ExtractionConfig, ValidationConfig, UiConfig, ExecutionConfig)
- Fix line endings (CRLF to LF) via Prettier format
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds utility functions to support partial settings save functionality:
- isObject: Type guard for plain objects
- deepMerge: Recursively merges objects, preserving unspecified fields
- validateEditableFields: Validates settings against UI editable field whitelist
- UI_EDITABLE_FIELDS: Whitelist of fields modifiable through UI
A failing test is included to verify the deep merge behavior.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix User scope isolation issue in CleanerPage:
- User users can no longer affect other users' data via "取消" button
- "确认删除" only processes visible filteredResults for non-Admin users
- Admin behavior unchanged (can manage all data)
- Prevents cross-user data interference
Committed: 6ecf03c
Fix critical bug where non-Admin users could affect other users' data
when using "取消" (Uncheck All) and "确认删除" (Confirm Deletion) buttons.
Problem:
- User users see only their filtered materials in table (filteredResults)
- "取消" button was unchecking ALL materials in validationResults
- "确认删除" was processing ALL materials, not just visible ones
- This caused User A to delete/modify User B's invisible data
Solution:
1. Modified "取消" button to only uncheck visible filteredResults
- Now removes selectedItems only for visible material codes
- Preserves selections for other users' invisible data
2. Modified handleConfirmDeletion to process only visible items for non-Admin users
- Admin: processes all validationResults (unchanged behavior)
- User: processes only filteredResults (scoped to their data)
Security Impact:
- Prevents cross-user data interference
- Ensures User scope isolation
- Maintains Admin full access to all data
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add Priority 3 matching logic that allows User type users to override
material assignments with their own typeKeywords from MaterialsTypeToBeDeleted.
Changes:
- Add session manager integration to get current user context
- Implement Priority 3: User Override Match (only for non-admin users)
- Filter typeKeywords by current username and force override on match
- Maintain existing Priority 1 (exact match) and Priority 2 (type match) behavior
- Admin users bypass override logic and see original matching results
- Update cleaner-validation-flow.md with new matching algorithm flow
This ensures User users see materials assigned to themselves first when
their configured typeKeywords match, while Admin users maintain full visibility.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed material validation always using historical order numbers instead of
current input. The setSharedProductionIds function was accumulating IDs
without clearing old ones, causing validation to use all previously entered
order numbers.
Changes:
- Added sharedProductionIds.clear() before adding new IDs
- Ensures Set only contains the latest order numbers from extractor page
This fixes the root cause where changing the order number in the extractor
page would not update the validation data source, as old IDs were never
removed from the shared Set.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add documentation for extractor start button and settings save button flows with detailed Mermaid diagrams. Also add logs directory to gitignore.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reverse the inclusion check to properly match when materialName contains typeKeyword.materialName (e.g., "ABC123_SPECIAL" contains "ABC123").
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove problematic edge labels with special characters
- Move database type identifiers into node labels
- Replace ellipsis with clearer text descriptions
- Fix parse error caused by spaces and special chars in edge labels
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive documentation for the "确认删除 (同步数据库)" button
flow, including:
- Core flow overview with Mermaid diagram
- Frontend interaction layer analysis (handleConfirmDeletion)
- IPC handler layer details (upsertBatch, delete handlers)
- Database DAO layer implementation with MySQL vs SQL Server differences
- Data flow diagram showing all layers
- Key data structures and error handling
- Comparison table with validation status flow
The document now covers both core business flows in the cleaner page:
1. Get and validate material status (read operation)
2. Confirm deletion/sync to database (write operation)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix getTableName() to handle generic schema_tablename pattern
- Convert schema_tablename to [schema].[tablename] for SQL Server
- Replace hardcoded productionContractData table name with helper function
- Fix variable naming conflict: rename 'sql' to 'sqlString' to avoid shadowing mssql module import
- Apply fixes to discrete-material-plan-dao, materials-to-be-deleted-dao, and bip-users-dao
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove global user-select: none style that was preventing text input
and add explicit user-select: text to the textarea element.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add SqlServerService integration alongside existing MySQL support
- Refactor DAOs (DiscreteMaterialPlanDAO, MaterialsToBeDeletedDAO, BipUsersDAO) to support both MySQL and SQL Server
- Update validation handler to dynamically select database service based on DB_TYPE environment variable
- Add connection pooling and proper connection management for SQL Server
- Update package-lock.json dependency peer flags
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Integrated Tailwind v4 into the electron.vite.config.ts and main.css.
- Refactored App.tsx layout to use Tailwind styling and Lucide icons as provided.
- Refactored ExtractorPage, CleanerPage, and SettingsPage to match the new UI mock layout while maintaining existing state and logic.
- Simplified SettingsPage based on user feedback.
- Ensured default exports and imports are consistent across pages.
Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
- Import and integrate UserSelectionDialog component
- Add state for user selection (showUserSelection, allUsers)
- Add isSwitchedByAdmin state to track admin-switched sessions
- Implement handleUserSelect and handleUserSelectionCancel handlers
- Update login flow to show user selection when admin logs in
- Add conditional logout button visibility based on user type
- Update UI to include UserSelectionDialog component
- Add SessionManager for managing user sessions (singleton pattern)
- Add BIPUsersDAO for database authentication
- Add LoginDialog component for username/password login
- Add UserSelectionDialog component for admin user selection
- Support silent login by computer name
- Implement main page with navigation to Extractor and Cleaner
Database:
- Table: dbo_BIPUsers
- Fields: UserName, Password, UserType, ComputerNmae
UI Flow:
1. Silent login on startup via computer name
2. Show login dialog if silent login fails
3. Display main page with user info and navigation
4. Support logout and re-login
- Add OrderNumberResolver service to auto-recognize productionID and 生产订单号 formats
- Integrate MySQL database lookup for productionID to 生产订单号 conversion
- Update OrderNumberInput component with format statistics display
- Modify Extractor and Cleaner to resolve order numbers before processing
Database configuration:
- Table: productionContractData_26 年压力表合同数据
- Fields: 总排号 (productionID), 生产订单号 (production order number)
Supported formats:
- productionID: 2 digits + 1 letter + serial number (e.g., 26B742)
- 生产订单号:SC + 14 digits (e.g., SC70202601040109)
- Fix TypeScript type errors in erp-auth.ts and excel-parser.ts
- Update tsconfig.node.json to relax type checking for build
- Build Windows installer (dist/erpauto-1.0.0-setup.exe)
- Add .gitignore entries for dist files
Installation:
1. Download erpauto-1.0.0-setup.exe
2. Run installer
3. Configure ERP credentials in %APPDATA%\erpauto\.env
4. Launch application from desktop shortcut
Build commands:
- npm run build:win - Build Windows installer
- npm run build:mac - Build macOS app
- npm run build:linux - Build Linux packages
- Load .env file in main process using dotenv
- Add detailed console logging for debugging
- Add validation for ERP configuration before extraction
- Improve error display in UI with selectable text
- Add stack trace logging for better debugging
- Add README.md with installation, configuration, and usage guide
- Add docs/USER_GUIDE.md with detailed step-by-step workflows
- Include database setup scripts for MySQL and SQL Server
- Add troubleshooting section with common issues