From fd18eaba5e1c086a588509371f91310e7aafff9c Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 08 四月 2026 22:06:59 +0800
Subject: [PATCH] refactor: 升级多个项目目标框架至.NET 8.0

---
 Code/WCS/WIDESEAWCS_Server/CLAUDE.md |  228 +++++++++++++++++++++++---------------------------------
 1 files changed, 94 insertions(+), 134 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/CLAUDE.md b/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
index e2e08a3..9518b9c 100644
--- a/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
+++ b/Code/WCS/WIDESEAWCS_Server/CLAUDE.md
@@ -2,171 +2,131 @@
 
 This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
 
-## Build Commands
+## 椤圭洰姒傝堪
+
+**WIDESEAWCS** 鏄竴涓粨搴撴帶鍒剁郴缁燂紝鍩轰簬 ASP.NET Core 6.0 鏋勫缓銆傜敤浜庣鐞嗚嚜鍔ㄥ寲鐗╂枡澶勭悊璁惧锛堝爢鍨涙満銆佽緭閫佺嚎銆佹満鍣ㄤ汉銆佺┛姊溅绛夛級鐨勫伐涓氫粨鍌ㄧ幆澧冦��
+
+## 鏋勫缓涓庤繍琛屽懡浠�
 
 ```bash
-# Build entire solution
+# 鏋勫缓鏁翠釜瑙e喅鏂规
 dotnet build WIDESEAWCS_Server.sln
 
-# Build and run server
-cd WIDESEAWCS_Server
-dotnet run
+# 杩愯鏈嶅姟鍣紙绔彛 9292锛�
+dotnet run --project WIDESEAWCS_Server/WIDESEAWCS_Server.csproj
 
-# Run tests
-cd WIDESEAWCS_Tests
-dotnet test
+# 杩愯娴嬭瘯
+dotnet test WIDESEAWCS_Tests/WIDESEAWCS_Tests.csproj
 ```
 
-## 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
+### 椤圭洰缁撴瀯
 
-## Project Structure
+| 椤圭洰                        | 鐢ㄩ��                                  |
+| ------------------------- | ----------------------------------- |
+| `WIDESEAWCS_Server`       | 涓� Web API 鍏ュ彛锛堢鍙� 9292锛�               |
+| `WIDESEAWCS_Core`         | 妗嗘灦宸ュ叿锛堟暟鎹簱銆佺紦瀛樸�佷緷璧栨敞鍏ャ�佹棩蹇椼�佽璇侊級             |
+| `WIDESEAWCS_Common`       | 甯搁噺銆佹灇涓俱�丷edis 閿畾涔�                     |
+| `WIDESEAWCS_Model`        | 鏁版嵁搴撳疄浣撴ā鍨�                             |
+| `WIDESEAWCS_DTO`          | 鏁版嵁浼犺緭瀵硅薄                              |
+| `WIDESEAWCS_Communicator` | 宸ヤ笟璁惧閫氫俊鍗忚锛圡odbus銆丼iemens S7銆丱mron 绛夛級 |
+| `WIDESEAWCS_Tasks`        | 鍚庡彴璁惧鎺у埗浣滀笟                            |
+| `WIDESEAWCS_QuartzJob`    | Quartz.NET 璋冨害鍜屾淳鍙戦�昏緫                  |
+| `WIDESEAWCS_RedisService` | L1+L2 娣峰悎缂撳瓨鏈嶅姟                        |
 
-```
-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
-```
+### 鍏抽敭璁捐妯″紡
 
-## Dependency Injection - IDependency Pattern
+- **浠撳偍妯″紡**锛氭暟鎹闂娊璞★紙`WIDESEAWCS_*Repository` 椤圭洰锛�
+- **鏈嶅姟灞�**锛氫笟鍔¢�昏緫灏佽锛坄WIDESEAWCS_*Service` 椤圭洰锛�
+- **Autofac 渚濊禆娉ㄥ叆**锛氶�氳繃 `AutofacModuleRegister` 妯″潡娉ㄥ唽
+- **AOP 鎷︽埅**锛氶�氳繃 `UseServiceDIAttribute` 瀹炵幇缂撳瓨鍜屾棩蹇楀垏闈�
+- **SqlSugar ORM**锛氭敮鎸� MySQL銆丼QL Server銆丼QLite銆丱racle銆丳ostgreSQL
 
-Services are **automatically registered** with Autofac by implementing the empty `IDependency` marker interface:
+### 鏁版嵁娴佸悜
 
-```csharp
-// In WIDESEAWCS_Core/IDependency.cs
-public interface IDependency { }
+1. API Controllers 鈫� Services 鈫� Repositories 鈫� SqlSugar 鈫� SQL Server
+2. Quartz Jobs锛堝畾鏃惰皟搴︼級 鈫� 璁惧鎺у埗浣滀笟 鈫� Communicators 鈫� 鐗╃悊璁惧
+3. Redis L1锛堝唴瀛橈級 + L2锛圧edis锛夌紦瀛樺眰浣嶄簬鏁版嵁搴撳墠鏂�
 
-// Your service gets auto-registered
-public class MyService : IDependency  // Automatically registered as scoped
-{
-    // ...
-}
-```
+## 鍏抽敭閰嶇疆锛坅ppsettings.json锛�
 
-Registration happens in `AutofacModuleRegister` which scans all project assemblies for `IDependency` implementations.
+- **Web API锛�** `http://*:9292`
+- **WebSocket锛�** `http://localhost:9296`
+- **TCP Socket 鏈嶅姟鍣細** `0.0.0.0:2000`
+- **鏁版嵁搴擄細** SQL Server锛屽疄渚� `.\WIDESEAWCS_ShanMei`
+- **Redis锛�** `127.0.0.1:6379`锛屽瘑鐮� `P@ssw0rd`
+- **JWT 杩囨湡鏃堕棿锛�** 120 鍒嗛挓
+- **Quartz锛�** 鑷姩鍚姩
 
-**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:
+## 璁惧閫氫俊
 
-```csharp
-// In RedisServiceSetup.cs - removes MemoryCacheService before adding HybridCacheService
-var existing = services.FirstOrDefault(d => d.ServiceType == typeof(ICacheService));
-if (existing != null) services.Remove(existing);
-```
+`WIDESEAWCS_Communicator` 椤圭洰瀹炵幇浜嗗绉嶅伐涓氬崗璁細
 
-## Caching - ICacheService
+- `ModbusTcpCommunicator`
+- `SiemensS7Communicator`銆乣SiemensS7200SmartCommunicator`
+- `OmronEtherNetCommunicator`
+- `AllenBrandlyEtherNetCommunicator`
+- `InovanceTcpCommunicator`銆乣InovanceAMTcp`
+- `SerialPortCommunicator`
 
-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)
+鍩虹鎺ュ彛锛歚IBaseCommunicator`
 
-**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
+## 鍚庡彴浣滀笟
 
-**Configuration** in `appsettings.json`:
-```json
-"RedisConfig": {
-  "Enabled": true,
-  "ConnectionString": "127.0.0.1:6379,password=P@ssw0rd,...",
-  "KeyPrefix": "wcs:"
-}
-```
+璁惧鎺у埗浣滀笟浣嶄簬 `WIDESEAWCS_Tasks/`锛�
 
-## Quartz Jobs - Device Communication
+- `StackerCraneJob` - 鍫嗗灈鏈烘帶鍒�
+- `ConveyorLineJob`銆乣ConveyorLineNewJob` - 杈撻�佺嚎绠$悊
+- `RobotJob` - 鏈烘鎵嬫帶鍒�
+- `ShuttleCarJob` - 绌挎杞︽帶鍒�
+- `SocketServer` - 璁惧閫氫俊 TCP 鏈嶅姟鍣�
 
-Jobs inherit from `JobBase` and implement Quartz's `IJob`:
+## API 缁撴瀯
 
-```csharp
-public class MyDeviceJob : JobBase, IJob
-{
-    public async Task Execute(IJobExecutionContext context)
-    {
-        ExecuteJob(context, async () => {
-            // Job logic here
-            WriteDebug("MyDevice", "Debug message");
-            WriteInfo("MyDevice", "Info message");
-        });
-    }
-}
-```
+- `QuartzJob/Controllers/` - 璁惧淇℃伅銆佸崗璁�佹淳鍙戙�佽皟搴﹀櫒
+- `System/Controllers/` - 鐢ㄦ埛銆佽鑹层�佽彍鍗曘�佸瓧鍏搞�佹棩蹇�
+- `Task/Controllers/` - 浠诲姟绠$悊鍜屾満鍣ㄤ汉浠诲姟
+- `BasicInfo/Controllers/` - 璺敱閰嶇疆
 
-Jobs are registered dynamically via `SchedulerCenterServer` using device info from `Dt_DeviceInfo` table.
+## 鏃ュ織
 
-**Device types**:
-- `IStackerCrane` - Stacker cranes
-- `IConveyorLine` - Conveyor lines
-- `IShuttleCar` - Shuttle cars
-- `IRobot` - Robot cranes
+浣跨敤 Serilog锛屾寜澶╂粴鍔ㄤ繚鐣� 30 澶╂棩蹇楁枃浠讹紝鍚屾椂闆嗘垚 Seq锛坄http://localhost:5341`锛夈��
 
-## Hardware Communication
+## 閲嶈瀹炵幇娉ㄦ剰浜嬮」
 
-Communicator classes wrap the `HslCommunication` library:
-- `SiemensS7Communicator` / `SiemensS7200SmartCommunicator` - Siemens PLCs
-- `OmronEtherNetCommunicator` - Omron PLCs
-- `ModbusTcpCommunicator` - Modbus TCP
-- `SerialPortCommunicator` - Serial port devices
+1. **鍚姩鍒濆鍖栭『搴忓緢閲嶈**锛歊edis 灏辩华鍚庢墠鑳借繍琛� `ApiRouteCacheWarmupHostedService`
+2. **Quartz 浠诲姟琛�** 閫氳繃 `QuartzJobDataTableHostedService` 鍦ㄥ惎鍔ㄦ椂鑷姩鍒涘缓
+3. **Socket 鏈嶅姟鍣�** 浣滀负鍗曚緥 `TcpSocketServer` 鐢辨墭绠℃湇鍔¤繍琛�
+4. **Redis 缂撳瓨鍚屾**锛氬彲閰嶇疆 `EnableAutoSync` 閫夐」锛屽畾鏈熷皢 Redis 鍚屾鍒� L1 鍐呭瓨缂撳瓨
+5. **璁惧鍗忚閰嶇疆** 瀛樺偍鍦ㄦ暟鎹簱锛坄Dt_DeviceProtocol` 琛級锛岃�岄潪閰嶇疆鏂囦欢涓�
 
-## TCP Socket Server
+## 娉ㄩ噴涓庢枃妗� (寮哄埗)
 
-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
+- **XML 鏂囨。娉ㄩ噴**: 鎵�鏈� `public` 绫汇�佹帴鍙c�佹柟娉曘�佸睘鎬�**蹇呴』**鍖呭惈 XML 鏂囨。娉ㄩ噴 (`/// <summary>...</summary>`)锛岃В閲婂叾鐢ㄩ�斻�佸弬鏁板拰杩斿洖鍊笺��
+- **琛屽唴娉ㄩ噴**: 瀵逛簬澶嶆潅鐨勪笟鍔¢�昏緫銆佺畻娉曞疄鐜版垨闈炵洿瑙傜殑浠g爜鍧楋紝**蹇呴』**娣诲姞 `//` 琛屽唴娉ㄩ噴瑙i噴鈥滀负浠�涔堣繖涔堝仛鈥濄��
+- **TODO 鏍囪**: 濡傛灉浠g爜鏈畬鎴愭垨鏈変复鏃舵柟妗堬紝蹇呴』浣跨敤 `// TODO: 璇存槑` 鏍囪銆�
 
-## 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
+- **寮傛缂栫▼**: 鎵�鏈� I/O 鎿嶄綔蹇呴』浣跨敤 `async/await`銆傚簱浠g爜璇蜂娇鐢� `ConfigureAwait(false)`銆�
+- **鍛藉悕**:
+  - 鎺ュ彛浠� "I" 寮�澶� (渚嬪: `IUserService`)銆�
+  - 绫诲悕銆佹柟娉曞悕浣跨敤 **PascalCase**銆�
+  - 绉佹湁瀛楁銆佸眬閮ㄥ彉閲忎娇鐢� **camelCase**銆�
+- **鍛藉悕绌洪棿**: 浣跨敤 **鏂囦欢浣滅敤鍩熷懡鍚嶇┖闂�** (`namespace MyApp.Api;`)銆�
 
-## Service Layer Pattern
+## 馃毇 涓ョ浜嬮」
+- **涓ョ** 鐢熸垚娌℃湁娉ㄩ噴鐨勪唬鐮� (灏ゅ叾鏄叕鍏辨柟娉�)銆�
+- **涓ョ** 浣跨敤 `Task.Result` 鎴� `Task.Wait()`銆�
+- **涓ョ** 鍦ㄥ紓姝ヤ笂涓嬫枃涓娇鐢� `.ToList()` (蹇呴』鐢� `.ToListAsync()`)銆�
+- **涓ョ** 鐩存帴鏆撮湶瀹炰綋 (Entity)锛屽繀椤讳娇鐢� DTO銆�
+- **涓ョ** 鎹曡幏 `Exception` 鑰屼笉璁板綍鏃ュ織銆�
 
-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
-
-## 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
-
-## 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
+## 馃洜 鎶�鏈爤
+- **妗嗘灦**: .NET 8.0 (LTS)
+- **璇█**: C# 12
+- **ORM**: SqlSugar
+- **鏁版嵁搴�**: SQL Server 
+- **楠岃瘉**: FluentValidation
+- **搴忓垪鍖�**: Newtonsoft.Json
\ No newline at end of file

--
Gitblit v1.9.3