编辑 | blame | 历史 | 原始文档

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) API application built with .NET 8, consisting of:
- MESApplication: Main Web API project with controllers and middleware
- MES.Service: Service layer containing business logic, data models, and database operations

The system manages manufacturing operations including quality control (QC), warehouse management, inventory tracking, PLM integration, and ERP connectivity.

Development Commands

Build and Run

# Build the solution
dotnet build MESApplication.sln

# Run the API (from MESApplication directory)
cd MESApplication
dotnet run

# Run with specific environment
dotnet run --environment Development

Development Server

  • API runs on: http://localhost:5184
  • Swagger UI available at: http://localhost:5184/swagger
  • IIS Express: http://localhost:10054

Project Structure Commands

# Restore NuGet packages
dotnet restore

# Clean build artifacts
dotnet clean

# Build specific project
dotnet build MESApplication/MESApplication.csproj
dotnet build MES.Service/MES.Service.csproj

Architecture

Database Layer

  • ORM: SqlSugar for Oracle database connectivity
  • Database: Oracle (connection configured in appsettings.json)
  • Patterns: Repository pattern with generic DbContext and specific managers
  • Key Classes:
  • SqlSugarHelper.cs: Database connection and transaction management
  • DbContext<T>.cs: Generic repository for CRUD operations
  • Repository.cs: Base repository implementation

Service Layer (MES.Service)

Organized by business domains:
- BasicData/: Core master data (customers, suppliers, items, departments)
- QC/: Quality control operations (inspections, testing, suspensions)
- Warehouse/: Inventory management (stock, moves, receipts, shipments)
- PLM/: Product lifecycle management integration
- SpotCheck/: Equipment maintenance and spot checking

API Layer (MESApplication)

  • Controllers/: REST endpoints organized by domain (matching service structure)
  • Filter/: Action filters for logging and error handling
  • Authentication: Not implemented (anonymous access)
  • Serialization: Newtonsoft.Json with camelCase naming

Key Configuration

  • Database: Oracle connection string in AppSettings.DataBaseConn
  • CORS: Enabled for all origins during development
  • Swagger: Auto-generated API documentation with XML comments
  • Logging: Console logging with SQL query debugging enabled

External Integrations

  • Kingdee ERP: Via WebService (configured URLs in AppSettings)
  • PLM System: Document and BOM management
  • Real-time Inventory: HTTP client for inventory queries

Domain Models

Major entity categories:
- Inventory: MesInvItem* classes for stock management
- Quality: MesQa* classes for quality control processes
- Manufacturing: Wom* classes for work orders
- Purchasing: Purd* classes for procurement
- Sales: SalesOrder* classes for order management

Data Transfer Objects (DTOs)

  • service/: Internal service communication DTOs
  • webApi/: External API integration DTOs (ERP, PLM)
  • base/: Common DTOs (pagination, login, settings)

Testing and Quality

Testing Commands

# No automated tests currently configured
# Manual testing via Swagger UI at http://localhost:5184/swagger

Common Development Tasks

Adding New API Endpoints

  1. Create model class in MES.Service/Modes/
  2. Create service manager in MES.Service/service/[Domain]/
  3. Create controller in MESApplication/Controllers/[Domain]/
  4. Register dependencies in Startup.cs if needed

Working with Database

  • All database operations use SqlSugar ORM with Oracle
  • Transaction support via SqlSugarHelper.UseTransactionWithOracle()
  • SQL queries are logged to console during development
  • Connection string configured in appsettings.json

External System Integration

  • ERP Integration: Kingdee WebService calls configured in AppSettings
  • PLM Integration: Document management via HTTP clients
  • Real-time Inventory: Dedicated service for inventory queries

Key Files to Understand

  • MES.Service/DB/SqlSugarHelper.cs: Database connection management
  • MES.Service/DB/DbContext.cs: Generic repository pattern
  • MES.Service/util/AppsettingsUtility.cs: Configuration access
  • MESApplication/Startup.cs: Application configuration and DI setup
  • MESApplication/Filter/ActionFilter.cs: Request/response logging

Dependencies and Packages

  • SqlSugarCore: ORM for Oracle database operations
  • Newtonsoft.Json: JSON serialization with camelCase naming
  • Swashbuckle.AspNetCore: API documentation generation
  • Oracle.EntityFrameworkCore: Oracle database connectivity
  • Kingdee.CDP.WebApi.SDK: ERP system integration (local DLL)

Configuration Management

  • Environment-specific settings in appsettings.json and appsettings.Development.json
  • Database connection in AppSettings.DataBaseConn
  • ERP URLs in AppSettings.TestErpUrl and AppSettings.ProductionErpUrl
  • CORS enabled for all origins in development mode