# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview PadService is a .NET 8.0 MES (Manufacturing Execution System) backend service that manages barcode printing, work reporting, and data collection for factory production processes. The system provides RESTful APIs for frontend applications like mobile devices and tablets. ## Development Commands ### Building and Running ```bash # Build the project dotnet build # Run in development mode (launches Swagger UI at http://localhost:5106) dotnet run # Run with specific profile dotnet run --launch-profile http # Publish the application dotnet publish ``` ### Testing and Validation ```bash # Restore packages dotnet restore # Check for build errors dotnet build --verbosity normal ``` ## Architecture Overview ### Core Technologies - **Framework**: .NET 8.0 Web API - **ORM**: SqlSugar 5.1.4.169 with Oracle database - **API Documentation**: Swagger/OpenAPI - **JSON Serialization**: Newtonsoft.Json with camelCase naming - **CORS**: Enabled for cross-origin requests ### Project Structure ``` Controllers/ # API controllers for different modules ├── MesInvItemBarcodesController.cs # Barcode management ├── DeviceMetricsController.cs # Device metrics ├── MesOrderSelectController.cs # Work order management └── ... Services/ # Business logic managers ├── MesInvItemBarcodesManager.cs # Core barcode operations ├── WomdaaManager.cs # Work order management └── ... Entites/ # Data models ├── DbModels/ # Database entity models └── Dto/ # Data transfer objects DB/ # Data access layer ├── Repository.cs # Generic repository with SqlSugar └── RepositoryNoEntity.cs util/ # Utility classes ├── AppSettings.cs # Configuration model ├── ResponseResult.cs # API response wrapper └── ... ``` ### Database Architecture - **Database**: Oracle with SqlSugar ORM - **Connection**: Configured via `AppSettings.DataBaseConn` - **Key Tables**: - `MES_INV_ITEM_BARCODES`: Barcode information - `MES_REPORTING`: Work reporting records - `WOMDAA`: Work order master data - `MES_NUMERICAL`: Data collection from devices - `MES_ANCHORS`: Work order anchor points (initial values) - `MES_QA_ITEMS_DETECT_02`: Quality inspection records ### Core Business Logic #### Barcode Management (MesInvItemBarcodesManager) The central module handles: - Barcode generation with uniqueness validation - Print quantity validation against work orders - Work order status verification (must be "开工" - started) - Quality inspection status verification - Integration with work reporting system #### Key Data Flow: Barcode Printing (AddItemToBarcodes) 1. Validate work order status and quality inspection status 2. Check print quantity doesn't exceed work order quantity 3. Generate unique barcodes 4. Create barcode records and work reporting entries 5. Update work order completion quantities #### Repository Pattern - Generic `Repository` base class extends SqlSugar's `SimpleClient` - Provides transaction support via `UseTransaction` method - Common pagination support via `CommonPage` methods - SQL logging enabled in development ### Configuration - **Settings**: Managed via `AppSettings` class and `appsettings.json` - **Database**: Oracle connection string in `AppSettings.DataBaseConn` - **Environment**: Development mode enables Swagger UI at `/swagger` - **CORS**: Configured to allow all origins, headers, and standard HTTP methods ### API Conventions - RESTful API design with standard HTTP methods - Swagger documentation available in development - JSON responses with camelCase property naming - Date format: "yyyy-MM-dd HH:mm:ss" - CORS enabled for cross-platform access ### Development Notes - **Language**: Comments and documentation are in Chinese - **Error Handling**: Exceptions thrown for business rule violations - **Logging**: SQL queries logged to console in development - **Transactions**: Business operations wrapped in database transactions where needed - **Validation**: Extensive validation for work order status, quantities, and business rules