From bcb2bae4c85c5a7d576116ff9ae2a0c6d0011565 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期四, 10 七月 2025 10:07:05 +0800
Subject: [PATCH] Add project documentation and architecture guide

---
 CLAUDE.md |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..8090d24
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,107 @@
+# CLAUDE.md
+
+This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
+
+## Project Overview
+
+This is a Manufacturing Execution System (MES) built with .NET 8.0. The solution consists of two main projects:
+
+- **MES.Service**: Service layer containing business logic, data access, and DTOs
+- **MESApplication**: Web API application layer with controllers and HTTP endpoints
+
+## Database Environment
+
+Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
+
+- PL/SQL Release 11.2.0.1.0 - Production
+- CORE 11.2.0.1.0 Production
+- TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
+- NLSRTL Version 11.2.0.1.0 - Production
+
+**IMPORTANT**: All code must be compatible with Oracle 11g Release 11.2.0.1.0
+
+## Architecture
+
+### Database Layer
+- Uses **SqlSugar ORM** for data access with Oracle database
+- Connection string configured in `appsettings.json`
+- Two database contexts available:
+  - `DbContext<T>` (MES.Service/DB/DbContext.cs:10) - Generic repository pattern
+  - `SqlSugarHelper` (MES.Service/DB/SqlSugarHelper.cs:6) - Oracle-specific helper with transaction support
+
+### Service Layer Structure
+- **BasicData**: Core business entities (customers, items, suppliers, etc.)
+- **QC**: Quality control services (PCB testing, inspections)
+- **Warehouse**: Inventory management and warehouse operations
+- **Dto**: Data Transfer Objects split into:
+  - `service/`: Internal service DTOs
+  - `webApi/`: External API DTOs for ERP integration
+
+### API Layer
+- ASP.NET Core Web API with Swagger documentation
+- Controllers organized by domain (BasicData, QC, Warehouse)
+- Newtonsoft.Json for serialization with camelCase naming
+- CORS enabled for cross-origin requests
+- Custom ActionFilter for request/response handling
+
+## Common Development Commands
+
+### Build and Run
+```bash
+# Build the entire solution
+dotnet build
+
+# Build specific project
+dotnet build MESApplication/MESApplication.csproj
+dotnet build MES.Service/MES.Service.csproj
+
+# Run the web application
+dotnet run --project MESApplication
+
+# Run in specific configuration
+dotnet run --project MESApplication --configuration Release
+```
+
+### Development
+```bash
+# Restore NuGet packages
+dotnet restore
+
+# Clean build artifacts
+dotnet clean
+
+# Publish for deployment
+dotnet publish MESApplication -c Release -o ./publish
+```
+
+## Key Configuration
+
+### Database Connection
+- Oracle database connection configured in `appsettings.json`
+- Connection string: `AppSettings.DataBaseConn`
+- Database type switches between Oracle (SqlSugarHelper) and SqlServer (DbContext)
+
+### ERP Integration
+- Test URL: `AppSettings.TestErpUrl`
+- Production URL: `AppSettings.ProductionErpUrl`
+- Located in `MESApplication/appsettings.json`
+
+## Important Patterns
+
+### Repository Pattern
+Most business logic follows the Manager pattern:
+- Managers in `MES.Service/service/` handle business operations
+- Controllers in `MESApplication/Controllers/` handle HTTP requests
+- Models in `MES.Service/Modes/` represent database entities
+
+### Service Registration
+Services are manually instantiated rather than using dependency injection containers. When adding new services, follow the existing pattern in the respective Manager classes.
+
+### Error Handling
+- ActionFilter handles global request/response processing
+- SQL logging enabled via SqlSugar AOP for debugging
+- Console output for SQL query debugging
+
+## Testing
+
+No test projects are currently configured in this solution. When adding tests, create separate test projects following .NET testing conventions.
\ No newline at end of file

--
Gitblit v1.9.3