From c1fa2195062d9f2c6477fcbfd8cc6cc7121a16e1 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 06 三月 2026 10:40:23 +0800
Subject: [PATCH] 将CLAUDE.md文档翻译为中文

---
 Code/WCS/WIDESEAWCS_Server/CLAUDE.md |  261 +++++++++++++++++++++++++++-------------------------
 1 files changed, 135 insertions(+), 126 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/CLAUDE.md b/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
index ddc1bc4..e3c6ee7 100644
--- a/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
+++ b/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
@@ -1,89 +1,93 @@
 # CLAUDE.md
 
-This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
+鏈枃浠朵负 Claude Code (claude.ai/code) 鍦ㄦ浠g爜搴撲腑宸ヤ綔鏃舵彁渚涙寚瀵笺��
 
-## Build Commands
+## 鏋勫缓鍛戒护
 
 ```bash
-# Build entire solution
+# 鏋勫缓鏁翠釜瑙e喅鏂规
 dotnet build WIDESEAWCS_Server.sln
 
-# Build and run server
+# 鏋勫缓骞惰繍琛屾湇鍔″櫒
 cd WIDESEAWCS_Server
 dotnet run
 
-# Run tests
+# 杩愯娴嬭瘯
 cd WIDESEAWCS_Tests
 dotnet test
 ```
 
-## Architecture Overview
+## 鏋舵瀯姒傝堪
 
-This is a **WCS (Warehouse Control System)** built with ASP.NET Core 6.0, using:
-- **Autofac** for DI with automatic service discovery via `IDependency` marker interface
-- **Quartz.NET** for scheduled job execution (device communication loops)
-- **SqlSugar ORM** for database access
-- **Redis** (via `WIDESEAWCS_RedisService`) for distributed caching with L1+L2 hybrid pattern
-- **StackExchange.Redis** for Redis operations
-- **TCP Socket Server** for real-time device communication
-- **HslCommunication** library for PLC/hardware communication
+杩欐槸涓�涓熀浜� ASP.NET Core 6.0 鏋勫缓鐨� **WCS锛堜粨搴撴帶鍒剁郴缁燂級**锛屼娇鐢ㄤ互涓嬫妧鏈細
 
-## Project Structure
+- **Autofac** - 閫氳繃 `IDependency` 鏍囪鎺ュ彛瀹炵幇鑷姩鏈嶅姟鍙戠幇鐨勪緷璧栨敞鍏�
+- **Quartz.NET** - 瀹氭椂浠诲姟鎵ц锛堣澶囬�氫俊寰幆锛�
+- **SqlSugar ORM** - 鏁版嵁搴撹闂�
+- **Redis**锛堥�氳繃 `WIDESEAWCS_RedisService`锛�- 閲囩敤 L1+L2 娣峰悎妯″紡鐨勫垎甯冨紡缂撳瓨
+- **StackExchange.Redis** - Redis 鎿嶄綔
+- **TCP Socket Server** - 瀹炴椂璁惧閫氫俊
+- **HslCommunication** 搴� - PLC/纭欢閫氫俊
+
+## 椤圭洰缁撴瀯
 
 ```
-WIDESEAWCS_Server/          # Main ASP.NET Core API server
-WIDESEAWCS_Core/            # Core infrastructure: base classes, DI, extensions, middleware
-WIDESEAWCS_Model/           # Data models and DTOs
-WIDESEAWCS_Communicator/    # Hardware communication drivers (Siemens, Omron, Modbus, etc.)
-WIDESEAWCS_QuartzJob/       # Job scheduling infrastructure and device abstractions
-WIDESEAWCS_Tasks/           # Quartz job implementations (device communication loops)
-WIDESEAWCS_RedisService/    # Redis services: Cache, Lock, Counter, PubSub, etc.
-WIDESEAWCS_*Repository/     # Data access layer implementations
-WIDESEAWCS_*Service/        # Business service layer
-WIDESEAWCS_Tests/           # Unit tests
+WIDESEAWCS_Server/          # 涓� ASP.NET Core API 鏈嶅姟鍣�
+WIDESEAWCS_Core/            # 鏍稿績鍩虹璁炬柦锛氬熀绫汇�丏I銆佹墿灞曘�佷腑闂翠欢
+WIDESEAWCS_Model/           # 鏁版嵁妯″瀷鍜� DTO
+WIDESEAWCS_Communicator/    # 纭欢閫氫俊椹卞姩锛圫iemens銆丱mron銆丮odbus 绛夛級
+WIDESEAWCS_QuartzJob/       # 浠诲姟璋冨害鍩虹璁炬柦鍜岃澶囨娊璞�
+WIDESEAWCS_Tasks/           # Quartz 浠诲姟瀹炵幇锛堣澶囬�氫俊寰幆锛�
+WIDESEAWCS_RedisService/    # Redis 鏈嶅姟锛氱紦瀛樸�侀攣銆佽鏁板櫒銆佸彂甯冭闃呯瓑
+WIDESEAWCS_*Repository/     # 鏁版嵁璁块棶灞傚疄鐜�
+WIDESEAWCS_*Service/        # 涓氬姟鏈嶅姟灞�
+WIDESEAWCS_Tests/           # 鍗曞厓娴嬭瘯
 ```
 
-## Dependency Injection - IDependency Pattern
+## 渚濊禆娉ㄥ叆 - IDependency 妯″紡
 
-Services are **automatically registered** with Autofac by implementing the empty `IDependency` marker interface:
+鏈嶅姟閫氳繃瀹炵幇绌虹殑 `IDependency` 鏍囪鎺ュ彛琚� Autofac **鑷姩娉ㄥ唽**锛�
 
 ```csharp
-// In WIDESEAWCS_Core/IDependency.cs
+// 鍦� WIDESEAWCS_Core/IDependency.cs 涓�
 public interface IDependency { }
 
-// Your service gets auto-registered
-public class MyService : IDependency  // Automatically registered as scoped
+// 鎮ㄧ殑鏈嶅姟浼氳鑷姩娉ㄥ唽
+public class MyService : IDependency  // 鑷姩娉ㄥ唽涓� scoped
 {
     // ...
 }
 ```
 
-Registration happens in `AutofacModuleRegister` which scans all project assemblies for `IDependency` implementations.
+娉ㄥ唽鍦� `AutofacModuleRegister` 涓繘琛岋紝瀹冧細鎵弿鎵�鏈夐」鐩▼搴忛泦鏌ユ壘 `IDependency` 瀹炵幇銆�
 
-**Important**: When adding services to `IServiceCollection` (e.g., in `Program.cs`), they can be overridden by Autofac's registrations. Use `Remove()` to replace existing registrations:
+**閲嶈鎻愮ず**锛氬悜 `IServiceCollection` 娣诲姞鏈嶅姟鏃讹紙渚嬪鍦� `Program.cs` 涓級锛屽畠浠彲鑳戒細琚� Autofac 鐨勬敞鍐岃鐩栥�備娇鐢� `Remove()` 鏉ユ浛鎹㈢幇鏈夋敞鍐岋細
 
 ```csharp
-// In RedisServiceSetup.cs - removes MemoryCacheService before adding HybridCacheService
+// 鍦� RedisServiceSetup.cs 涓� - 娣诲姞 HybridCacheService 涔嬪墠绉婚櫎 MemoryCacheService
 var existing = services.FirstOrDefault(d => d.ServiceType == typeof(ICacheService));
 if (existing != null) services.Remove(existing);
 ```
 
-## Caching - ICacheService
+## 缂撳瓨 - ICacheService
 
-The system uses a **hybrid L1 (Memory) + L2 (Redis)** cache pattern via `ICacheService`. Three implementations exist:
-- `MemoryCacheService` - Memory only
-- `RedisCacheService` - Redis only
-- `HybridCacheService` - L1+L2 with fallback (default when Redis enabled)
+绯荤粺閫氳繃 `ICacheService` 浣跨敤 **L1锛堝唴瀛橈級+ L2锛圧edis锛夋贩鍚堢紦瀛�**妯″紡銆傚瓨鍦ㄤ笁绉嶅疄鐜帮細
 
-**Common methods**:
-- `Add/AddObject` - Add cache
-- `Get/Get<T>` - Retrieve cached values
-- `Remove` - Delete single key
-- `RemoveByPrefix/RemoveByPattern` - Bulk delete by pattern
-- `GetOrAdd<T>` - Retrieve or add with factory
-- `TryAdd/TryUpdate/TryUpdateIfChanged` - ConcurrentDictionary-style operations
+- `MemoryCacheService` - 浠呭唴瀛�
+- `RedisCacheService` - 浠� Redis
+- `HybridCacheService` - L1+L2 甯﹂檷绾э紙鍚敤 Redis 鏃剁殑榛樿閫夐」锛�
 
-**Configuration** in `appsettings.json`:
+**甯哥敤鏂规硶**锛�
+
+- `Add/AddObject` - 娣诲姞缂撳瓨
+- `Get/Get<T>` - 鑾峰彇缂撳瓨鍊�
+- `Remove` - 鍒犻櫎鍗曚釜閿�
+- `RemoveByPrefix/RemoveByPattern` - 鎸夋ā寮忔壒閲忓垹闄�
+- `GetOrAdd<T>` - 鑾峰彇鎴栨坊鍔狅紙甯﹀伐鍘傛柟娉曪級
+- `TryAdd/TryUpdate/TryUpdateIfChanged` - ConcurrentDictionary 椋庢牸鐨勬搷浣�
+
+**閰嶇疆**锛堝湪 `appsettings.json` 涓級锛�
+
 ```json
 "RedisConfig": {
   "Enabled": true,
@@ -92,9 +96,9 @@
 }
 ```
 
-## Quartz Jobs - Device Communication
+## Quartz 浠诲姟 - 璁惧閫氫俊
 
-Jobs inherit from `JobBase` and implement Quartz's `IJob`:
+浠诲姟缁ф壙 `JobBase` 骞跺疄鐜� Quartz 鐨� `IJob`锛�
 
 ```csharp
 public class MyDeviceJob : JobBase, IJob
@@ -102,121 +106,126 @@
     public async Task Execute(IJobExecutionContext context)
     {
         ExecuteJob(context, async () => {
-            // Job logic here
-            WriteDebug("MyDevice", "Debug message");
-            WriteInfo("MyDevice", "Info message");
+            // 浠诲姟閫昏緫
+            WriteDebug("MyDevice", "璋冭瘯淇℃伅");
+            WriteInfo("MyDevice", "淇℃伅");
         });
     }
 }
 ```
 
-Jobs are registered dynamically via `SchedulerCenterServer` using device info from `Dt_DeviceInfo` table.
+浠诲姟閫氳繃 `SchedulerCenterServer` 浣跨敤 `Dt_DeviceInfo` 琛ㄤ腑鐨勮澶囦俊鎭姩鎬佹敞鍐屻��
 
-**Device types**:
-- `IStackerCrane` - Stacker cranes
-- `IConveyorLine` - Conveyor lines
-- `IShuttleCar` - Shuttle cars
-- `IRobot` - Robot cranes
+**璁惧绫诲瀷**锛�
 
-## Hardware Communication
+- `IStackerCrane` - 鍫嗗灈鏈�
+- `IConveyorLine` - 杈撻�佺嚎
+- `IShuttleCar` - 绌挎杞�
+- `IRobot` - 鏈烘鎵�
 
-Communicator classes wrap the `HslCommunication` library:
-- `SiemensS7Communicator` / `SiemensS7200SmartCommunicator` - Siemens PLCs
-- `OmronEtherNetCommunicator` - Omron PLCs
+## 纭欢閫氫俊
+
+閫氫俊鍣ㄧ被灏佽 `HslCommunication` 搴擄細
+
+- `SiemensS7Communicator` / `SiemensS7200SmartCommunicator` - 瑗块棬瀛� PLC
+- `OmronEtherNetCommunicator` - 娆у榫� PLC
 - `ModbusTcpCommunicator` - Modbus TCP
-- `SerialPortCommunicator` - Serial port devices
+- `SerialPortCommunicator` - 涓插彛璁惧
 
-## TCP Socket Server
+## TCP Socket 鏈嶅姟鍣�
 
-The `TcpSocketServer` (port 2000) handles real-time device communication:
-- Managed as a Singleton with `SocketServerHostedService`
-- Client connections stored in `ConcurrentDictionary<string, TcpClient>`
-- Messages handled via `OnDataReceived` event
+`TcpSocketServer`锛堢鍙� 2000锛夊鐞嗗疄鏃惰澶囬�氫俊锛�
 
-## Robot Communication System
+- 閫氳繃 `SocketServerHostedService` 浣滀负 Singleton 绠$悊
+- 瀹㈡埛绔繛鎺ュ瓨鍌ㄥ湪 `ConcurrentDictionary<string, TcpClient>` 涓�
+- 閫氳繃 `OnDataReceived` 浜嬩欢澶勭悊娑堟伅
 
-The robot crane system uses a modular architecture with specialized components.
+## 鏈烘鎵嬮�氫俊绯荤粺
 
-**Components:**
+鏈烘鎵嬬郴缁熼噰鐢ㄦā鍧楀寲鏋舵瀯锛屽寘鍚笓闂ㄧ殑缁勪欢銆�
 
-- `RobotClientManager` - Manages TCP client connections and subscriptions
-- `RobotStateManager` - Manages robot state cache with safe concurrent updates
-- `RobotMessageHandler` - Processes incoming TCP messages from robots
-- `RobotTaskProcessor` - Handles task execution and state transitions
-- `RobotBarcodeGenerator` - Generates tray/barcode identifiers
+**缁勪欢**锛�
 
-**Task Types** (from `RobotTaskTypeEnum`):
+- `RobotClientManager` - 绠$悊 TCP 瀹㈡埛绔繛鎺ュ拰璁㈤槄
+- `RobotStateManager` - 绠$悊鏈烘鎵嬬姸鎬佺紦瀛橈紝鏀寔瀹夊叏鐨勫苟鍙戞洿鏂�
+- `RobotMessageHandler` - 澶勭悊鏉ヨ嚜鏈烘鎵嬬殑 TCP 娑堟伅
+- `RobotTaskProcessor` - 澶勭悊浠诲姟鎵ц鍜岀姸鎬佽浆鎹�
+- `RobotBarcodeGenerator` - 鐢熸垚鎵樼洏/鏉$爜鏍囪瘑绗�
+
+**浠诲姟绫诲瀷**锛堟潵鑷� `RobotTaskTypeEnum`锛夛細
 
 - `GroupPallet (500)` - 缁勭洏浠诲姟
 - `ChangePallet (510)` - 鎹㈢洏浠诲姟
 - `SplitPallet (520)` - 鎷嗙洏浠诲姟
 
-**State Flow:**
+**鐘舵�佹祦杞�**锛�
 
-1. Robot connects via TCP 鈫� ClientManager tracks connection
-2. Job polls for tasks 鈫� TaskProcessor gets pending tasks
-3. Message received 鈫� MessageHandler parses and updates state
-4. State transitions 鈫� TaskProcessor sends commands back to robot
+1. 鏈烘鎵嬮�氳繃 TCP 杩炴帴 鈫� ClientManager 璺熻釜杩炴帴
+2. 浠诲姟杞鑾峰彇浠诲姟 鈫� TaskProcessor 鑾峰彇寰呭鐞嗕换鍔�
+3. 鎺ユ敹娑堟伅 鈫� MessageHandler 瑙f瀽骞舵洿鏂扮姸鎬�
+4. 鐘舵�佽浆鎹� 鈫� TaskProcessor 鍚戞満姊版墜鍙戦�佸懡浠�
 
-## Common Constants
+## 閫氱敤甯搁噺
 
-**Communication Timeouts** (`CommunicationConst`):
+**閫氫俊瓒呮椂**锛坄CommunicationConst`锛夛細
 
-- `WaitIntervalMs: 500` - Device wait interval
-- `WaitTimeoutBaseMs: 6000` - Timeout base
-- `WaitTotalTimeoutMs: 60000` - Total timeout (10 脳 base)
-- `PingIntervalMs: 100` - Ping check interval
-- `HttpDefaultTimeoutSeconds: 60` - HTTP timeout
+- `WaitIntervalMs: 500` - 璁惧绛夊緟闂撮殧
+- `WaitTimeoutBaseMs: 6000` - 瓒呮椂鍩烘暟
+- `WaitTotalTimeoutMs: 60000` - 鎬昏秴鏃舵椂闂达紙10 脳 鍩烘暟锛�
+- `PingIntervalMs: 100` - Ping 妫�娴嬮棿闅�
+- `HttpDefaultTimeoutSeconds: 60` - HTTP 瓒呮椂
 
-**System Integration URLs** (`BaseAPI`):
+**绯荤粺闆嗘垚 URL**锛坄BaseAPI`锛夛細
 
-- `WMSBaseUrl: "http://localhost:9291/api/"` - WMS system
-- `WCSBaseUrl: "http://localhost:9292/api/"` - WCS system (this server)
-- `MESBaseUrl: "http://localhost:9293/api/"` - MES system
-- `ERPBaseUrl: "http://localhost:9294/api/"` - ERP system
+- `WMSBaseUrl: "http://localhost:9291/api/"` - WMS 绯荤粺
+- `WCSBaseUrl: "http://localhost:9292/api/"` - WCS 绯荤粺锛堟湰鏈嶅姟鍣級
+- `MESBaseUrl: "http://localhost:9293/api/"` - MES 绯荤粺
+- `ERPBaseUrl: "http://localhost:9294/api/"` - ERP 绯荤粺
 
-**Redis Cache Prefixes** (`RedisPrefix`):
+**Redis 缂撳瓨鍓嶇紑**锛坄RedisPrefix`锛夛細
 
-- `System: "System"` - System-level cache
-- `User: "User"` - User-specific cache
-- `Code: "Code"` - Code/configuration cache
+- `System: "System"` - 绯荤粺绾х紦瀛�
+- `User: "User"` - 鐢ㄦ埛鐗瑰畾缂撳瓨
+- `Code: "Code"` - 浠g爜/閰嶇疆缂撳瓨
 
-Use these prefixes with `ICacheService.RemoveByPrefix()` for bulk cache invalidation.
+浣跨敤杩欎簺鍓嶇紑閰嶅悎 `ICacheService.RemoveByPrefix()` 杩涜鎵归噺缂撳瓨澶辨晥銆�
 
-## Configuration Settings
+## 閰嶇疆璁剧疆
 
-Key settings in `appsettings.json`:
-- `"urls": "http://*:9292"` - Server port
-- `"QuartzJobAutoStart": true` - Auto-start scheduled jobs
-- `"SocketServer:Enabled": true` - Enable TCP server
-- `"RedisConfig:Enabled": true` - Enable Redis caching
-- `"LogAOPEnable": false` - Enable AOP logging
-- `"DBType": "SqlServer"` - Database type
+`appsettings.json` 涓殑鍏抽敭璁剧疆锛�
 
-## Service Layer Pattern
+- `"urls": "http://*:9292"` - 鏈嶅姟鍣ㄧ鍙�
+- `"QuartzJobAutoStart": true` - 鑷姩鍚姩瀹氭椂浠诲姟
+- `"SocketServer:Enabled": true` - 鍚敤 TCP 鏈嶅姟鍣�
+- `"RedisConfig:Enabled": true` - 鍚敤 Redis 缂撳瓨
+- `"LogAOPEnable": false` - 鍚敤 AOP 鏃ュ織
+- `"DBType": "SqlServer"` - 鏁版嵁搴撶被鍨�
 
-Services follow a layered pattern:
-- **Interface** in `WIDESEAWCS_IService/` (e.g., `ITaskInfoService`)
-- **Implementation** in `WIDESEAWCS_Service/` (e.g., `TaskInfoService`)
-- Both implement `IDependency` for auto-registration
+## 鏈嶅姟灞傛ā寮�
 
-## Base Classes
+鏈嶅姟閬靛惊鍒嗗眰妯″紡锛�
 
-- `ServiceBase<T, TKey>` - Base service with CRUD operations
-- `RepositoryBase<TEntity>` - Base repository with SqlSugar ORM
-- `ApiBaseController` - Base API controller with common functionality
-- `JobBase` - Base Quartz job with logging helpers
+- **鎺ュ彛**鍦� `WIDESEAWCS_IService/` 涓紙渚嬪 `ITaskInfoService`锛�
+- **瀹炵幇**鍦� `WIDESEAWCS_Service/` 涓紙渚嬪 `TaskInfoService`锛�
+- 涓よ�呴兘瀹炵幇 `IDependency` 浠ヨ繘琛岃嚜鍔ㄦ敞鍐�
 
-## Adding New Features
+## 鍩虹被
 
-1. **New Service**: Create interface in `I*Service/` and class in `*Service/`, implement `IDependency`
-2. **New Job**: Inherit from `JobBase` and `IJob` in `WIDESEAWCS_Tasks/`
-3. **New Device Type**: Add interface in `WIDESEAWCS_QuartzJob/Device/` and implement
+- `ServiceBase<T, TKey>` - 甯︽湁 CRUD 鎿嶄綔鐨勫熀纭�鏈嶅姟
+- `RepositoryBase<TEntity>` - 鍩轰簬 SqlSugar ORM 鐨勫熀纭�浠撳偍
+- `ApiBaseController` - 甯︽湁閫氱敤鍔熻兘鐨勫熀纭� API 鎺у埗鍣�
+- `JobBase` - 甯︽湁鏃ュ織杈呭姪鏂规硶鐨勫熀纭� Quartz 浠诲姟
 
-## Important Notes
+## 娣诲姞鏂板姛鑳�
 
-- The application uses **CamelCase** JSON serialization
-- All services use **scoped** lifetime by default via Autofac
-- Redis connection uses **Lazy initialization** - first access triggers connection
-- Use `ConsoleHelper.WriteSuccessLine()` / `WriteErrorLine()` for console output in jobs
-- TCP Socket server runs independently of the HTTP API
+1. **鏂版湇鍔�**锛氬湪 `I*Service/` 涓垱寤烘帴鍙o紝鍦� `*Service/` 涓垱寤虹被锛屽疄鐜� `IDependency`
+2. **鏂颁换鍔�**锛氬湪 `WIDESEAWCS_Tasks/` 涓户鎵� `JobBase` 鍜� `IJob`
+3. **鏂拌澶囩被鍨�**锛氬湪 `WIDESEAWCS_QuartzJob/Device/` 涓坊鍔犳帴鍙e苟瀹炵幇
+
+## 閲嶈璇存槑
+
+- 搴旂敤绋嬪簭浣跨敤 **CamelCase** JSON 搴忓垪鍖�
+- 鎵�鏈夋湇鍔¢粯璁ら�氳繃 Autofac 浣跨敤 **scoped** 鐢熷懡鍛ㄦ湡
+- Redis 杩炴帴浣跨敤 **寤惰繜鍒濆鍖�** - 棣栨璁块棶鏃惰Е鍙戣繛鎺�
+- 鍦ㄤ换鍔′腑浣跨敤 `ConsoleHelper.WriteSuccessLine()` / `WriteErrorLine()` 杩涜鎺у埗鍙拌緭鍑�
+- TCP Socket 鏈嶅姟鍣ㄧ嫭绔嬩簬 HTTP API 杩愯

--
Gitblit v1.9.3