编辑 | blame | 历史 | 原始文档
Error: failed to parse markup
# 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` (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.