From b690250002ee04f4309e6a90fd16fbfd9bd959e2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 五月 2026 23:11:23 +0800
Subject: [PATCH] feat(router): 添加托盘操作页面路由

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj          |    4 
 Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js                                          |    5 
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                          |   23 -
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs                |   85 +++--
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs                           |   75 +++-
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs |   28 +
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs           |   69 +++-
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotStateManager.cs                  |   25 +
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs                    |   24 +
 Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs                                    |   44 ++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                              |    2 
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs       |   13 
 Code/WMS/WIDESEA_WMSClient/src/api/http.js                                                 |    2 
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs           |   69 +++
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/RobotState/Dt_RobotState.cs             |   22 +
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotSimpleCommandHandler.cs |  192 +++++++++---
 Code/WMS/WIDESEA_WMSClient/src/views/taskinfo/palletOperation.vue                          |  185 ++++++++++++
 17 files changed, 677 insertions(+), 190 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/RobotState/Dt_RobotState.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/RobotState/Dt_RobotState.cs
index 615edea..c5e872d 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/RobotState/Dt_RobotState.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/RobotState/Dt_RobotState.cs
@@ -96,8 +96,18 @@
         /// <summary>
         /// 鏈�杩戜竴娆℃斁璐у畬鎴愮殑浣嶇疆鏁扮粍锛圝SON锛�
         /// </summary>
-        [SugarColumn(Length = 500, ColumnDescription = "鏀捐揣浣嶇疆鏁扮粍JSON", IsNullable = true)]
+        [SugarColumn(Length = 5000, ColumnDescription = "鏀捐揣浣嶇疆鏁扮粍JSON", IsNullable = true)]
         public string? LastPutPositionsJson { get; set; }
+
+        /// <summary>
+        /// 褰撳墠鎵规鐨勭數鑺潯鐮佸垪琛�
+        /// </summary>
+        /// <remarks>
+        /// 姣忔璇诲彇鏂版潯鐮佹椂璁剧疆涓烘湰鎵规鐨勬潯鐮侊紝浠呯敤浜� WMS 鎻愪氦鏃舵寜鎵规鎻愪氦銆�
+        /// 姣忔鏂版壒娆¤鍙栨椂瑕嗙洊锛屽湪 allputfinished 鏃舵竻绌恒��
+        /// </remarks>
+        [SugarColumn(Length = 5000, ColumnDescription = "褰撳墠鎵规鐨勭數鑺潯鐮佸垪琛�", IsNullable = true)]
+        public string? CurrentBatchBarcodes { get; set; }
 
         /// <summary>
         /// 鐢垫睜/璐т綅鏉$爜鍒楄〃锛圝SON锛�
@@ -158,5 +168,15 @@
         /// </summary>
         [SugarColumn(ColumnDescription = "鐢佃姱鏄惁鍒颁綅")]
         public bool BatteryArrived { get; set; }
+
+        /// <summary>
+        /// 褰撳墠鎵ц涓殑鏈哄櫒浜轰换鍔$紪鍙�
+        /// </summary>
+        /// <remarks>
+        /// 涓嬪彂浠诲姟鏃剁紦瀛樹换鍔$紪鍙凤紝鐢ㄤ簬 RobotJob 蹇�熸煡鎵炬墽琛屼腑鐨勪换鍔★紝
+        /// 閬垮厤姣忔杞鍏ㄨ〃鎵弿銆備换鍔″畬鎴愭椂娓呯┖涓� null銆�
+        /// </remarks>
+        [SugarColumn(ColumnDescription = "褰撳墠鎵ц涓殑鏈哄櫒浜轰换鍔$紪鍙�")]
+        public int? CurrentTaskNum { get; set; }
     }
 }
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
index 6847c0c..1ac9eae 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
@@ -112,7 +112,7 @@
   },
   "RedisConfig": {
     "Enabled": true, //鏄惁鍚敤Redis锛宖alse鏃朵粎浣跨敤鍐呭瓨缂撳瓨
-    "ConnectionString": "127.0.0.1:6379,password=,defaultDatabase=0,connectTimeout=5000,abortConnect=false", //Redis杩炴帴瀛楃涓�
+    "ConnectionString": "127.0.0.1:6379,password=P@ssw0rd,defaultDatabase=0,connectTimeout=5000,abortConnect=false", //Redis杩炴帴瀛楃涓�
     "InstanceName": "WIDESEAWCS:", //瀹炰緥鍚嶇О锛岀敤浜庡尯鍒嗕笉鍚屽簲鐢�
     "DefaultDatabase": 0, //榛樿鏁版嵁搴撶储寮曪紙0-15锛�
     "EnableSentinel": false, //鏄惁鍚敤鍝ㄥ叺妯″紡
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
index bd0ee02..26b78d3 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
@@ -48,10 +48,24 @@
         {
             newState.ModifyDate = DateTime.Now;
 
-            // 涔愯閿侊細WHERE IPAddress = @ip AND Version = @expectedVersion锛岀増鏈尮閰嶆墠鏇存柊
-            var affectedRows = Db.Updateable<Dt_RobotState>(newState)
+            // SqlSugar 鐨� Updateable(entity).Where(x => x.Version == param) 瀛樺湪鍙傛暟娣锋穯闂锛�
+            // 瀹炰綋鐨� Version 宸茶璁句负 expectedVersion+1锛�.Where() 涓� SqlSugar 鍙兘浣跨敤瀹炰綋鐨�
+            // Version 鍊硷紙expectedVersion+1锛夎�岄潪鍙傛暟鍊硷紙expectedVersion锛夛紝瀵艰嚧 WHERE 姘歌繙鍖归厤涓嶄笂銆�
+            // 淇锛氬皢鐗堟湰鏍¢獙鎷嗕负鐙珛鏌ヨ锛屾洿鏂颁粎閫氳繃涓婚敭鎵ц銆�
+
+            // 姝ラ1锛氭牎楠岀増鏈彿鏄惁涓庢湡鏈涗竴鑷�
+            var currentVersion = Db.Queryable<Dt_RobotState>()
                 .Where(x => x.IpAddress == ipAddress)
-                .ExecuteCommand();
+                .Select(x => x.Version)
+                .First();
+
+            if (currentVersion != expectedVersion)
+            {
+                return false;
+            }
+
+            // 姝ラ2锛氱増鏈尮閰嶏紝閫氳繃涓婚敭鐩存帴鏇存柊
+            var affectedRows = Db.Updateable(newState).ExecuteCommand();
 
             return affectedRows > 0;
         }
@@ -76,13 +90,19 @@
                 CurrentBatchIndex = entity.CurrentBatchIndex,
                 ChangePalletPhase = entity.ChangePalletPhase,
                 IsScanNG = entity.IsScanNG,
-                BatteryArrived = entity.BatteryArrived
+                BatteryArrived = entity.BatteryArrived,
+                CurrentTaskNum = entity.CurrentTaskNum,
             };
 
             // 鍙嶅簭鍒楀寲澶嶆潅 JSON 瀛楁
             if (!string.IsNullOrEmpty(entity.RobotCraneJson))
             {
                 state.RobotCrane = JsonConvert.DeserializeObject<RobotCraneDevice>(entity.RobotCraneJson);
+            }
+
+            if (!string.IsNullOrEmpty(entity.CurrentBatchBarcodes))
+            {
+                state.CurrentBatchBarcodes = JsonConvert.DeserializeObject<List<string>>(entity.CurrentBatchBarcodes) ?? new List<string>();
             }
 
             if (!string.IsNullOrEmpty(entity.CurrentTaskJson))
@@ -132,6 +152,8 @@
                 LastPickPositionsJson = state.LastPickPositions.ToJson(),
                 CurrentTaskJson = state.CurrentTask.ToJson(),
                 LastPutPositionsJson = state.LastPutPositions.ToJson(),
+                CurrentBatchBarcodes = state.CurrentBatchBarcodes.ToJson(),
+                CurrentTaskNum = state.CurrentTaskNum,
             };
 
             // 搴忓垪鍖栧鏉傚璞′负 JSON
@@ -140,27 +162,32 @@
                 entity.RobotCraneJson = JsonConvert.SerializeObject(state.RobotCrane);
             }
 
-            if (state.CurrentTask != null)
-            {
-                entity.CurrentTaskJson = JsonConvert.SerializeObject(state.CurrentTask);
-            }
+            //if (state.CurrentTask != null)
+            //{
+            //    entity.CurrentTaskJson = JsonConvert.SerializeObject(state.CurrentTask);
+            //}
 
-            if (state.LastPickPositions != null)
-            {
-                entity.LastPickPositionsJson = JsonConvert.SerializeObject(state.LastPickPositions);
-            }
+            //if (state.LastPickPositions != null)
+            //{
+            //    entity.LastPickPositionsJson = JsonConvert.SerializeObject(state.LastPickPositions);
+            //}
 
-            if (state.LastPutPositions != null)
-            {
-                entity.LastPutPositionsJson = JsonConvert.SerializeObject(state.LastPutPositions);
-            }
+            //if (state.LastPutPositions != null)
+            //{
+            //    entity.LastPutPositionsJson = JsonConvert.SerializeObject(state.LastPutPositions);
+            //}
 
-            if (state.CellBarcode != null && state.CellBarcode.Count > 0)
-            {
-                entity.CellBarcodeJson = JsonConvert.SerializeObject(state.CellBarcode);
-            }
+            //if (state.CellBarcode != null && state.CellBarcode.Count > 0)
+            //{
+            //    entity.CellBarcodeJson = JsonConvert.SerializeObject(state.CellBarcode);
+            //}
+
+            //if (state.CurrentBatchBarcodes != null && state.CurrentBatchBarcodes.Count > 0)
+            //{
+            //    entity.CurrentBatchBarcodes = JsonConvert.SerializeObject(state.CurrentBatchBarcodes);
+            //}
 
             return entity;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
index ecb24ae..3792119 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
@@ -203,46 +203,65 @@
                     return;
                 }
 
-                if (state.CurrentAction == "Picking" || state.CurrentAction == "Puting")
-                {
-                    return;
-                }
 
-                // 杞鑾峰彇璇ヨ澶囩殑寰呭鐞嗕换鍔�
-                // 浼樺厛閫氳繃鐘舵�佷腑缂撳瓨鐨勪换鍔$紪鍙锋煡鎵炬墽琛屼腑鐨勪换鍔�
-                Dt_RobotTask? task = null;
-                if (state.CurrentTaskNum.HasValue)
-                {
-                    task = _taskProcessor.GetTaskByNum(state.CurrentTaskNum.Value);
-                }
+                // 鑾峰彇璇ヨ澶囩殑浜掓枼閿侊紝纭繚 Job 鎵ц涓庢秷鎭鐞嗕簰鏂�
+                var robotLock = _stateManager.GetOrCreateLock(ipAddress);
 
-                // 缂撳瓨鐨勪换鍔″彿鏈壘鍒板搴斾换鍔℃椂锛屾寜璁惧缂栫爜鑾峰彇鏂颁换鍔�
-                task ??= _taskProcessor.GetTask(robotCrane);
-
-                // 濡傛灉娌℃湁鑾峰彇鍒板緟澶勭悊浠诲姟锛屼笖RobotArmObject涓�1锛堟湁鐗╂枡锛夛紝鍒欒幏鍙栬璁惧鎵ц涓殑浠诲姟
-                //if (task == null && state.RobotArmObject == 1)
+                // 閿佽娑堟伅澶勭悊鍣ㄥ崰鐢ㄦ椂鐩存帴璺宠繃鏈 tick锛岀瓑涓嬫璋冨害鍐嶆墽琛�
+                //if (!await robotLock.WaitAsync(TimeSpan.Zero))
                 //{
-                //    task = _taskProcessor.GetExecutingTask(robotCrane);
+                //    return;
                 //}
 
-                // 濡傛灉鏈夊緟澶勭悊浠诲姟
-                if (task != null)
+                // 鑾峰彇璇ヨ澶囩殑浜掓枼閿侊紝纭繚 Job 鎵ц涓庢秷鎭鐞嗕簰鏂�
+                await robotLock.WaitAsync();
+                try
                 {
-                    // 鑾峰彇鏈�鏂扮殑璁惧鐘舵��
-                    var latestState = _stateManager.GetState(ipAddress);
-                    if (latestState == null)
+                    if (state.CurrentAction == "Picking" || state.CurrentAction == "Puting")
                     {
-                        // 鐘舵�佷笉瀛樺湪锛屽彲鑳借澶囨湭鍒濆鍖�
                         return;
                     }
 
-                    // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
-                    if (latestState.RobotTaskTotalNum < RobotConst.MaxTaskTotalNum)
+                    // 杞鑾峰彇璇ヨ澶囩殑寰呭鐞嗕换鍔�
+                    // 浼樺厛閫氳繃鐘舵�佷腑缂撳瓨鐨勪换鍔$紪鍙锋煡鎵炬墽琛屼腑鐨勪换鍔�
+                    Dt_RobotTask? task = null;
+                    if (state.CurrentTaskNum.HasValue)
                     {
-                        // 璋冪敤宸ヤ綔娴佺紪鎺掑櫒鎵ц浠诲姟
-                        // 缂栨帓鍣ㄤ細鏍规嵁褰撳墠鐘舵�佸喅瀹氫笅涓�姝ュ姩浣�
-                        await _workflowOrchestrator.ExecuteAsync(latestState, task, ipAddress);
+                        task = _taskProcessor.GetTaskByNum(state.CurrentTaskNum.Value);
                     }
+
+                    // 缂撳瓨鐨勪换鍔″彿鏈壘鍒板搴斾换鍔℃椂锛屾寜璁惧缂栫爜鑾峰彇鏂颁换鍔�
+                    task ??= _taskProcessor.GetTask(robotCrane);
+
+                    // 濡傛灉娌℃湁鑾峰彇鍒板緟澶勭悊浠诲姟锛屼笖RobotArmObject涓�1锛堟湁鐗╂枡锛夛紝鍒欒幏鍙栬璁惧鎵ц涓殑浠诲姟
+                    //if (task == null && state.RobotArmObject == 1)
+                    //{
+                    //    task = _taskProcessor.GetExecutingTask(robotCrane);
+                    //}
+
+                    // 濡傛灉鏈夊緟澶勭悊浠诲姟
+                    if (task != null)
+                    {
+                        // 鑾峰彇鏈�鏂扮殑璁惧鐘舵��
+                        var latestState = _stateManager.GetState(ipAddress);
+                        if (latestState == null)
+                        {
+                            // 鐘舵�佷笉瀛樺湪锛屽彲鑳借澶囨湭鍒濆鍖�
+                            return;
+                        }
+
+                        // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
+                        if (latestState.RobotTaskTotalNum < RobotConst.MaxTaskTotalNum)
+                        {
+                            // 璋冪敤宸ヤ綔娴佺紪鎺掑櫒鎵ц浠诲姟
+                            // 缂栨帓鍣ㄤ細鏍规嵁褰撳墠鐘舵�佸喅瀹氫笅涓�姝ュ姩浣�
+                            await _workflowOrchestrator.ExecuteAsync(latestState, task, ipAddress);
+                        }
+                    }
+                }
+                finally
+                {
+                    robotLock.Release();
                 }
             }
             catch (Exception ex)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
index 3dc5a22..7a78510 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
@@ -89,47 +89,60 @@
         public async Task<string?> HandleMessageReceivedAsync(string message, bool isJson, TcpClient client)
         {
             var state = _stateManager.GetState(client.Client.RemoteEndPoint.ToString());
-            if (state.OperStatus == message)
-            {
-                // 澶勭悊鎴愬姛鍚庯紝灏嗗師娑堟伅鍥炲啓鍒板鎴风锛堜繚鎸佸師鏈夎涓猴級
-                //await _socketClientGateway.SendMessageAsync(client, message);
-            }
-            // 璁板綍鎺ユ敹鍒扮殑娑堟伅鏃ュ織
-            QuartzLogHelper.LogInfo(_logger, $"鎺ユ敹鍒板鎴风銆恵state.RobotCrane?.DeviceName}銆戝彂閫佹秷鎭�恵message}銆�", state.RobotCrane?.DeviceName);
 
-            // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
-            if (state.RobotTaskTotalNum > RobotConst.MaxTaskTotalNum)
+            // 璁惧鐘舵�佷笉瀛樺湪鏃剁洿鎺ヨ繑鍥烇紝閬垮厤鍚庣画绌哄紩鐢�
+            if (state == null)
             {
+                return null;
+            }
+
+            // 鑾峰彇璇ヨ澶囩殑浜掓枼閿侊紝纭繚娑堟伅澶勭悊涓� Job 鎵ц浜掓枼
+            // Job 鍦ㄥ鐞嗕换鍔℃椂浼氱瓑寰呮閿侀噴鏀惧悗鎵嶇户缁墽琛�
+            var robotLock = _stateManager.GetOrCreateLock(state.IPAddress);
+            await robotLock.WaitAsync();
+            try
+            {
+                // 璁板綍鎺ユ敹鍒扮殑娑堟伅鏃ュ織
                 QuartzLogHelper.LogInfo(_logger, $"鎺ユ敹鍒板鎴风銆恵state.RobotCrane?.DeviceName}銆戝彂閫佹秷鎭�恵message}銆�", state.RobotCrane?.DeviceName);
-                await _socketClientGateway.SendMessageAsync(client, message);
-                return null;
+
+                // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
+                if (state.RobotTaskTotalNum > RobotConst.MaxTaskTotalNum)
+                {
+                    QuartzLogHelper.LogInfo(_logger, $"鎺ユ敹鍒板鎴风銆恵state.RobotCrane?.DeviceName}銆戝彂閫佹秷鎭�恵message}銆�", state.RobotCrane?.DeviceName);
+                    await _socketClientGateway.SendMessageAsync(client, message);
+                    return null;
+                }
+
+                // 灏嗘秷鎭浆鎹负灏忓啓锛堢敤浜庣畝鍗曞懡浠ゅ尮閰嶏級
+                string messageLower = message.ToLowerInvariant();
+
+                // 灏濊瘯鐢ㄧ畝鍗曞懡浠ゅ鐞嗗櫒澶勭悊
+                // 绠�鍗曞懡浠ゅ寘鎷細homing銆乭omed銆乺unning銆乸ausing銆乺unmode銆乧ontrolmode 绛�
+                if (await _simpleCommandHandler.HandleAsync(messageLower, state))
+                {
+                    //if (messageLower != "batteryarrived")
+                    //{
+                    // 澶勭悊鎴愬姛鍚庯紝灏嗗師娑堟伅鍥炲啓鍒板鎴风锛堜繚鎸佸師鏈夎涓猴級
+                    //await _socketClientGateway.SendMessageAsync(client, message);
+                    QuartzLogHelper.LogInfo(_logger, $"鎺ユ敹鍒版秷鎭秷鎭�恵message}銆戯紝绾﹀畾涓嶈繑鍥炲彂閫佹秷鎭細銆恵message}銆�", state.RobotCrane?.DeviceName);
+                    //}
+
+                    //// 瀹夊叏鏇存柊鐘舵�佸埌鏁版嵁搴�
+                    //_stateManager.TryUpdateStateSafely(state.IPAddress, state);
+                    return null;
+                }
+
+                // 濡傛灉涓嶆槸绠�鍗曞懡浠わ紝妫�鏌ユ槸鍚︽槸鍓嶇紑鍛戒护
+                // 鍓嶇紑鍛戒护鍖呮嫭锛歱ickfinished銆乸utfinished锛堝悗闈㈣窡閫楀彿鍒嗛殧鐨勪綅缃弬鏁帮級
+                if (_prefixCommandHandler.IsPrefixCommand(messageLower))
+                {
+                    // 璋冪敤鍓嶇紑鍛戒护澶勭悊鍣�
+                    await _prefixCommandHandler.HandleAsync(message, state, client);
+                }
             }
-
-            // 灏嗘秷鎭浆鎹负灏忓啓锛堢敤浜庣畝鍗曞懡浠ゅ尮閰嶏級
-            string messageLower = message.ToLowerInvariant();
-
-            // 灏濊瘯鐢ㄧ畝鍗曞懡浠ゅ鐞嗗櫒澶勭悊
-            // 绠�鍗曞懡浠ゅ寘鎷細homing銆乭omed銆乺unning銆乸ausing銆乺unmode銆乧ontrolmode 绛�
-            if (await _simpleCommandHandler.HandleAsync(messageLower, state))
+            finally
             {
-                //if (messageLower != "batteryarrived")
-                //{
-                // 澶勭悊鎴愬姛鍚庯紝灏嗗師娑堟伅鍥炲啓鍒板鎴风锛堜繚鎸佸師鏈夎涓猴級
-                //await _socketClientGateway.SendMessageAsync(client, message);
-                QuartzLogHelper.LogInfo(_logger, $"鎺ユ敹鍒版秷鎭秷鎭�恵message}銆戯紝绾﹀畾涓嶈繑鍥炲彂閫佹秷鎭細銆恵message}銆�", state.RobotCrane?.DeviceName);
-                //}
-
-                // 瀹夊叏鏇存柊鐘舵�佸埌鏁版嵁搴�
-                _stateManager.TryUpdateStateSafely(state.IPAddress, state);
-                return null;
-            }
-
-            // 濡傛灉涓嶆槸绠�鍗曞懡浠わ紝妫�鏌ユ槸鍚︽槸鍓嶇紑鍛戒护
-            // 鍓嶇紑鍛戒护鍖呮嫭锛歱ickfinished銆乸utfinished锛堝悗闈㈣窡閫楀彿鍒嗛殧鐨勪綅缃弬鏁帮級
-            if (_prefixCommandHandler.IsPrefixCommand(messageLower))
-            {
-                // 璋冪敤鍓嶇紑鍛戒护澶勭悊鍣�
-                await _prefixCommandHandler.HandleAsync(message, state, client);
+                robotLock.Release();
             }
 
             return null;
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotStateManager.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotStateManager.cs
index 5c1ecba..c4bac8a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotStateManager.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotStateManager.cs
@@ -1,3 +1,4 @@
+using System.Collections.Concurrent;
 using Newtonsoft.Json;
 using Serilog;
 using WIDESEAWCS_ITaskInfoRepository;
@@ -11,6 +12,7 @@
     /// <remarks>
     /// 鏍稿績鍔熻兘鏄�氳繃 IRobotStateRepository 绠$悊鏁版嵁搴撲腑鐨勬満姊版墜鐘舵�併��
     /// 鎻愪緵涔愯骞跺彂鎺у埗锛岄�氳繃 Version 瀛楁闃叉骞跺彂鏇存柊鏃剁殑鏁版嵁瑕嗙洊闂銆�
+    /// 鍚屾椂鎻愪緵鍩轰簬 SemaphoreSlim 鐨勪簰鏂ラ攣锛岀‘淇濇秷鎭鐞嗕笌 Job 鎵ц涓嶄細骞跺彂鎿嶄綔鍚屼竴璁惧鐘舵�併��
     /// </remarks>
     public class RobotStateManager
     {
@@ -25,6 +27,15 @@
         private readonly ILogger _logger;
 
         /// <summary>
+        /// 姣忎釜璁惧鐨勫紓姝ヤ簰鏂ラ攣瀛楀吀锛岀敤浜� Job 鎵ц涓庢秷鎭鐞嗕箣闂寸殑浜掓枼
+        /// </summary>
+        /// <remarks>
+        /// Key 涓鸿澶� IP 鍦板潃锛孷alue 涓鸿璁惧涓撳睘鐨� SemaphoreSlim(1,1)銆�
+        /// 纭繚鍚屼竴璁惧鐨� Job 杞鍜� TCP 娑堟伅澶勭悊涓嶄細鍚屾椂鎿嶄綔鐘舵�併��
+        /// </remarks>
+        private readonly ConcurrentDictionary<string, SemaphoreSlim> _robotLocks = new();
+
+        /// <summary>
         /// 鏋勯�犲嚱鏁�
         /// </summary>
         /// <param name="repository">浠撳偍鏈嶅姟瀹炰緥</param>
@@ -36,6 +47,20 @@
         }
 
         /// <summary>
+        /// 鑾峰彇鎴栧垱寤烘寚瀹氳澶囩殑寮傛浜掓枼閿�
+        /// </summary>
+        /// <remarks>
+        /// 浣跨敤 ConcurrentDictionary 纭繚姣忎釜璁惧 IP 瀵瑰簲鍞竴鐨� SemaphoreSlim(1,1)銆�
+        /// 璇ラ攣鐢ㄤ簬 Job 鎵ц涓� TCP 娑堟伅澶勭悊涔嬮棿鐨勪簰鏂ワ紝闃叉骞跺彂鎿嶄綔鍚屼竴璁惧鐘舵�併��
+        /// </remarks>
+        /// <param name="ipAddress">璁惧 IP 鍦板潃</param>
+        /// <returns>璇ヨ澶囩殑淇″彿閲忓疄渚�</returns>
+        public SemaphoreSlim GetOrCreateLock(string ipAddress)
+        {
+            return _robotLocks.GetOrAdd(ipAddress, _ => new SemaphoreSlim(1, 1));
+        }
+
+        /// <summary>
         /// 瀹夊叏鏇存柊 RobotSocketState锛岄槻姝㈠苟鍙戣鐩�
         /// </summary>
         /// <remarks>
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotSimpleCommandHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotSimpleCommandHandler.cs
index eb8c01e..4da6e19 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotSimpleCommandHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotSimpleCommandHandler.cs
@@ -1,8 +1,5 @@
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 using Serilog;
-using System.Net;
 using WIDESEAWCS_Common.TaskEnum;
-using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Tasks.Workflow.Abstractions;
 
@@ -108,8 +105,20 @@
                 case "homed":
                     state.Homed = "Homed";
 
-                    await _socketClientGateway.SendToClientAsync(state.IPAddress, "Homed");
-                    return true;
+                    if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                    {
+                        for (int i = 0; i < 5; i++)
+                        {
+                            QuartzLogHelper.LogDebug(_logger, $"鍙戦�佸洖闆跺畬鎴愭秷鎭紝IP: {state.IPAddress}锛屾鍦ㄩ噸璇�...", state.RobotCrane?.DeviceName ?? "Unknown");
+                            await _socketClientGateway.SendToClientAsync(state.IPAddress, "Homed");
+                        }
+                        return true;
+                    }
+                    else
+                    {
+                        QuartzLogHelper.LogError(_logger, $"鍙戦�佸洖闆跺畬鎴愭秷鎭け璐ワ紝IP: {state.IPAddress}", state.RobotCrane?.DeviceName ?? "Unknown");
+                        return false;
+                    }
 
                 // 鏈哄櫒浜烘鍦ㄨ繍琛�
                 case "running":
@@ -144,14 +153,42 @@
                 // 鏄惁鐢佃姱鍒颁綅
                 case "batteryarrived":
                     state.BatteryArrived = true;
-                    return true;
 
-                // 鏄惁鐢佃姱鍒颁綅
+                    if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                    {
+                        for (int i = 0; i < 5; i++)
+                        {
+                            QuartzLogHelper.LogDebug(_logger, $"鍙戦�佺數鑺埌浣嶆秷鎭紝IP: {state.IPAddress}锛屾鍦ㄩ噸璇�...", state.RobotCrane?.DeviceName ?? "Unknown");
+                            await _socketClientGateway.SendToClientAsync(state.IPAddress, "batteryarrived");
+                        }
+                        return true;
+                    }
+                    else
+                    {
+                        QuartzLogHelper.LogError(_logger, $"鍙戦�佺數鑺湭鍒颁綅娑堟伅澶辫触锛孖P: {state.IPAddress}", state.RobotCrane?.DeviceName ?? "Unknown");
+                        return false;
+                    }
+
+                // 鏄惁鐢佃姱娌″埌浣�
                 case "batteryarrivedno":
                     state.BatteryArrived = false;
 
-                    await _socketClientGateway.SendToClientAsync(state.IPAddress, "batteryarrivedno");
-                    return true;
+                    if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                    {
+                        for (int i = 0; i < 5; i++)
+                        {
+                            QuartzLogHelper.LogDebug(_logger, $"鍙戦�佺數鑺湭鍒颁綅娑堟伅锛孖P: {state.IPAddress}锛屾鍦ㄩ噸璇�...", state.RobotCrane?.DeviceName ?? "Unknown");
+                            await _socketClientGateway.SendToClientAsync(state.IPAddress, "batteryarrivedno");
+                        }
+
+                        return true;
+                    }
+                    else
+                    {
+                        QuartzLogHelper.LogError(_logger, $"鍙戦�佺數鑺湭鍒颁綅娑堟伅澶辫触锛孖P: {state.IPAddress}", state.RobotCrane?.DeviceName ?? "Unknown");
+                        return false;
+                    }
+
                 // ==================== 鎺ユ敹浠诲姟鍙嶉 ====================
 
                 // 鍙栬揣鎺ユ敹
@@ -160,8 +197,20 @@
                     if (!isResult)
                         return false;
 
-                    await _socketClientGateway.SendToClientAsync(state.IPAddress, "pickbatteryover");
-                    return true;
+                    if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                    {
+                        for (int i = 0; i < 5; i++)
+                        {
+                            QuartzLogHelper.LogDebug(_logger, $"鍙戦�佸彇璐ф帴鏀跺畬鎴愶紝IP: {state.IPAddress}锛屾鍦ㄩ噸璇�...", state.RobotCrane?.DeviceName ?? "Unknown");
+                            await _socketClientGateway.SendToClientAsync(state.IPAddress, "pickbatteryover");
+                        }
+                        return true;
+                    }
+                    else
+                    {
+                        QuartzLogHelper.LogError(_logger, $"鍙戦�佸彇璐у畬鎴愭秷鎭け璐ワ紝IP: {state.IPAddress}", state.RobotCrane?.DeviceName ?? "Unknown");
+                        return false;
+                    }
 
                 // 鏀捐揣鎺ユ敹
                 case "putbatteryover":
@@ -169,8 +218,20 @@
                     if (!isResult)
                         return false;
 
-                    await _socketClientGateway.SendToClientAsync(state.IPAddress, "putbatteryover");
-                    return true;
+                    if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                    {
+                        for (int i = 0; i < 5; i++)
+                        {
+                            QuartzLogHelper.LogDebug(_logger, $"鍙戦�佹斁璐ф帴鏀舵秷鎭紝IP: {state.IPAddress}锛屾鍦ㄩ噸璇�...", state.RobotCrane?.DeviceName ?? "Unknown");
+                            await _socketClientGateway.SendToClientAsync(state.IPAddress, "putbatteryover");
+                        }
+                        return true;
+                    }
+                    else
+                    {
+                        QuartzLogHelper.LogError(_logger, $"鍙戦�佹斁璐у畬鎴愭秷鎭け璐ワ紝IP: {state.IPAddress}", state.RobotCrane?.DeviceName ?? "Unknown");
+                        return false;
+                    }
 
                 // ==================== 鍏ㄩ儴瀹屾垚鍛戒护 ====================
 
@@ -194,15 +255,6 @@
                         // 鎹㈢洏浠诲姟锛氭牴鎹樁娈靛尯鍒嗗鐞�
                         if (robotTaskType == RobotTaskTypeEnum.ChangePallet)
                         {
-                            // 璋冪敤鎵归噺鎷嗙洏纭鎺ュ彛
-                            var sourcePallet = state.CurrentTask.RobotSourceAddressPalletCode;
-                            var confirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet, state.RobotCrane?.DeviceName);
-                            if (!confirmResult.IsSuccess && !confirmResult.Data.Status)
-                            {
-                                QuartzLogHelper.LogError(_logger, $"鎵归噺鎷嗙洏纭澶辫触: {confirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown");
-                                return false;
-                            }
-
                             if (state.ChangePalletPhase == 5)
                             {
                                 // FlowB 鏈�缁堥樁娈碉細鍋囩數鑺彇瀹岋紝婧愮┖鎵樼洏鍥炲簱 HCSC1
@@ -217,9 +269,6 @@
                                     return false;
                                 }
 
-                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-
                                 state.CurrentTask = null;
                                 state.CurrentTaskNum = null;
                                 state.RobotTaskTotalNum = 0;
@@ -228,7 +277,17 @@
                                 state.ChangePalletPhase = 0;
                                 state.CurrentBatchIndex = 1;
                                 state.IsInFakeBatteryMode = false;
-                                return true;
+
+                                if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                                {
+                                    await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                    QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                    return true;
+                                }
+                                else
+                                {
+                                    return false;
+                                }
                             }
                             else if (state.ChangePalletPhase != 0)
                             {
@@ -254,13 +313,19 @@
                             //    return false;
                             //}
 
-                            await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                            QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-
                             state.ChangePalletPhase = 0;
                             state.CurrentBatchIndex = 1;
                             state.IsInFakeBatteryMode = false;
-                            return true;
+                            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                            {
+                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
                         }
 
                         // 鎷嗙洏浠诲姟锛氱洿鎺ュ鐞嗗叆搴�
@@ -287,9 +352,16 @@
                                 return false;
                             }
 
-                            await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                            QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-                            return true;
+                            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                            {
+                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
                         }
                         return false;
                     }
@@ -313,6 +385,15 @@
                         // 鎹㈢洏浠诲姟锛氭牴鎹樁娈靛尯鍒嗗鐞�
                         if (robotTaskType == RobotTaskTypeEnum.ChangePallet)
                         {
+                            // 璋冪敤鎵归噺鎷嗙洏纭鎺ュ彛
+                            var sourcePallet = state.CurrentTask.RobotSourceAddressPalletCode;
+                            var splitConfirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet, state.RobotCrane?.DeviceName);
+                            if (!splitConfirmResult.IsSuccess && !splitConfirmResult.Data.Status)
+                            {
+                                QuartzLogHelper.LogError(_logger, $"鎵归噺鎷嗙洏纭澶辫触: {splitConfirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown");
+                                return false;
+                            }
+
                             // 璋冪敤鎵归噺缁勭洏纭鎺ュ彛
                             var targetPallet = state.CurrentTask.RobotTargetAddressPalletCode;
                             var confirmResult = _taskProcessor.PostGroupPalletConfirmAsync(targetPallet, state.RobotCrane?.DeviceName);
@@ -341,14 +422,20 @@
                                 state.RobotTaskTotalNum = 0;
                                 state.CellBarcode = new List<string>();
                                 state.CurrentBatchBarcodes = new List<string>();
-
-                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-
                                 state.ChangePalletPhase = 0;
                                 state.CurrentBatchIndex = 1;
                                 state.IsInFakeBatteryMode = false;
-                                return true;
+
+                                if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                                {
+                                    await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                    QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                    return true;
+                                }
+                                else
+                                {
+                                    return false;
+                                }
                             }
                             else if (state.ChangePalletPhase != 0)
                             {
@@ -379,14 +466,20 @@
                             state.RobotTaskTotalNum = 0;
                             state.CellBarcode = new List<string>();
                             state.CurrentBatchBarcodes = new List<string>();
-
-                            await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                            QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-
                             state.ChangePalletPhase = 0;
                             state.CurrentBatchIndex = 1;
                             state.IsInFakeBatteryMode = false;
-                            return true;
+
+                            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                            {
+                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
                         }
 
                         // 缁勭洏浠诲姟锛氱洿鎺ュ鐞嗗叆搴�
@@ -422,9 +515,16 @@
                             state.CellBarcode = new List<string>();  // 娓呯┖鏉$爜鍒楄〃
                             state.CurrentBatchBarcodes = new List<string>();  // 娓呯┖褰撳墠鎵规鏉$爜
 
-                            await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
-                            QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
-                            return true;
+                            if (_stateManager.TryUpdateStateSafely(state.IPAddress, state))
+                            {
+                                await _socketClientGateway.SendToClientAsync(state.IPAddress, $"Group,diskFinished");
+                                QuartzLogHelper.LogInfo(_logger, $"鍙戦�佹秷鎭細銆怗roup,diskFinished銆�", state.RobotCrane.DeviceName);
+                                return true;
+                            }
+                            else
+                            {
+                                return false;
+                            }
                         }
                         return false;
                     }
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
index 6d8f9a7..33bce5e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
@@ -1,3 +1,4 @@
+using Masuit.Tools;
 using Serilog;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core.Helper;
@@ -241,7 +242,6 @@
                     }
                     return;
                 }
-
             }
 
             // 闈炴崲鐩樹换鍔★細浣跨敤鍘熸湁鏍煎紡
@@ -337,7 +337,7 @@
                 string trayBarcode1 = RobotBarcodeGenerator.GenerateTrayBarcode("DB40.1020");
 
                 // 濡傛灉鏉$爜鐢熸垚鎴愬姛
-                if (!string.IsNullOrEmpty(trayBarcode1) && !string.IsNullOrEmpty(trayBarcode2))
+                if (!trayBarcode1.IsNullOrEmpty() && !trayBarcode2.IsNullOrEmpty())
                 {
                     //if (stateForUpdate.CellBarcode.Contains(trayBarcode1) || stateForUpdate.CellBarcode.Contains(trayBarcode2))
                     //{
@@ -357,21 +357,23 @@
 
                         QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫殑鐢佃姱鏉$爜鍞竴锛岀户缁墽琛岋紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
+                        // 璁板綍鏃ュ織锛氳鍙栨墭鐩樻潯鐮佹垚鍔�
+                        QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫數鑺潯鐮佹垚鍔�: 銆恵trayBarcode1}銆�-----銆恵trayBarcode2}銆戯紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+
                         // 灏嗘潯鐮佺疮绉埌 CellBarcode锛堝幓閲嶏級锛屽苟璁剧疆褰撳墠鎵规鏉$爜
-                        if (!stateForUpdate.CellBarcode.Contains(trayBarcode1))
+                        if (!stateForUpdate.CellBarcode.Contains(trayBarcode1) || !stateForUpdate.CellBarcode.Contains(trayBarcode2))
+                        {
+
                             stateForUpdate.CellBarcode.Add(trayBarcode1);
-                        if (!stateForUpdate.CellBarcode.Contains(trayBarcode2))
                             stateForUpdate.CellBarcode.Add(trayBarcode2);
 
-                        // 璁剧疆褰撳墠鎵规鏉$爜锛岀敤浜� WMS 鎻愪氦
-                        stateForUpdate.CurrentBatchBarcodes = new List<string>()
-                        {
-                            trayBarcode1, trayBarcode2
-                        };
+                            // 璁剧疆褰撳墠鎵规鏉$爜锛岀敤浜� WMS 鎻愪氦
+                            stateForUpdate.CurrentBatchBarcodes = new List<string>()
+                            {
+                                trayBarcode1, trayBarcode2
+                            };
+                        }
                     }
-
-                    // 璁板綍鏃ュ織锛氳鍙栨墭鐩樻潯鐮佹垚鍔�
-                    QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫數鑺潯鐮佹垚鍔�: 銆恵trayBarcode1}銆�-----銆恵trayBarcode2}銆戯紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
                     // 鍙戦�佸彇璐ф寚浠�
                     await _taskProcessor.SendSocketRobotPickAsync(task, stateForUpdate);
@@ -408,7 +410,7 @@
                     return;
                 }
 
-                QuartzLogHelper.LogDebug(_logger,$"HandlePutFinishedStateAsync锛氭崲鐩樹换鍔$洰鏍囨暟閲�: {targetNormalCount}锛屽綋鍓嶅凡瀹屾垚鏁伴噺: {currentCompletedCount}锛屾祦鍚�: {(isFlowA ? "A" : "B")}锛屼换鍔″彿: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+                QuartzLogHelper.LogDebug(_logger, $"HandlePutFinishedStateAsync锛氭崲鐩樹换鍔$洰鏍囨暟閲�: {targetNormalCount}锛屽綋鍓嶅凡瀹屾垚鏁伴噺: {currentCompletedCount}锛屾祦鍚�: {(isFlowA ? "A" : "B")}锛屼换鍔″彿: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
                 // 鍒濆鍖栨壒娆℃ā寮�
                 if (stateForUpdate.ChangePalletPhase == 0)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 4568c72..efaf9b7 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -81,7 +81,7 @@
         /// <summary>
         /// 鏃ュ織璁板綍鍣�
         /// </summary>
-        private readonly ILogger  _logger;
+        private readonly ILogger _logger;
 
         /// <summary>
         /// 鍫嗗灈鏈鸿澶囩紪鐮�
@@ -159,11 +159,8 @@
                     QuartzLogHelper.LogInfo(_logger, "Execute锛氳闃呬换鍔″畬鎴愪簨浠讹紝璁惧: {DeviceCode}", "璁㈤槄浠诲姟瀹屾垚浜嬩欢", _deviceCode, _deviceCode);
                 }
 
-                QuartzLogHelper.LogInfo(_logger, $"寮�濮嬫鏌ュ爢鍨涙満瀹屾垚鐘舵�侊紝銆恵_deviceCode}銆�", _deviceCode);
                 // ========== 妫�鏌ュ爢鍨涙満浠诲姟瀹屾垚鐘舵�� ==========
                 commonStackerCrane.CheckStackerCraneTaskCompleted();
-
-                QuartzLogHelper.LogInfo(_logger, $"妫�鏌ュ畬鎴愶紝姝e湪鐩戝惉鍫嗗灈鏈轰换鍔″畬鎴愶紝銆恵_deviceCode}銆�", _deviceCode);
 
                 // ========== 妫�鏌ユ槸鍚﹀彲浠ュ彂閫佹柊浠诲姟 ==========
                 //if (!commonStackerCrane.IsCanSendTask(commonStackerCrane.Communicator, commonStackerCrane.DeviceProDTOs, commonStackerCrane.DeviceProtocolDetailDTOs))
@@ -172,8 +169,6 @@
                     // 鍫嗗灈鏈轰笉鍙敤锛堝姝e湪鎵ц涓婁竴浠诲姟锛夛紝鐩存帴杩斿洖
                     return Task.CompletedTask;
                 }
-
-                QuartzLogHelper.LogInfo(_logger, $"鍫嗗灈鏈哄彲涓嬪彂浠诲姟锛屻�恵_deviceCode}銆�", _deviceCode);
 
                 // ========== 閫夋嫨浠诲姟 ==========
                 // 浠诲姟閫夋嫨涓嬫矇鍒颁笓鐢ㄩ�夋嫨鍣�
@@ -184,20 +179,14 @@
                     return Task.CompletedTask;
                 }
 
-                QuartzLogHelper.LogInfo(_logger, $"鑾峰彇鍒颁换鍔★紝寮�濮嬫瀯寤轰换鍔′笅鍙戝懡浠わ紝銆恵_deviceCode}銆�", _deviceCode);
-
                 // ========== 鏋勫缓鍛戒护 ==========
                 // 鍛戒护鏋勫缓涓嬫矇鍒颁笓鐢ㄦ瀯寤哄櫒
                 object? stackerCraneTaskCommand = _commandBuilder.ConvertToStackerCraneTaskCommand(task);
                 if (stackerCraneTaskCommand == null)
                 {
                     // 鍛戒护鏋勫缓澶辫触
-                    QuartzLogHelper.LogInfo(_logger, $"Execute锛氬懡浠ゆ瀯寤哄け璐ワ紝璁惧: {_deviceCode}锛屼换鍔″彿: {task.TaskNum}", _deviceCode);
                     return Task.CompletedTask;
                 }
-
-
-                QuartzLogHelper.LogInfo(_logger, $"鍛戒护鏋勫缓瀹屾垚锛屽紑濮嬩笅鍙戜换鍔★紝銆恵_deviceCode}銆�", _deviceCode);
 
                 // ========== 鍙戦�佸懡浠� ==========
                 bool sendFlag = SendStackerCraneCommand(commonStackerCrane, stackerCraneTaskCommand);
diff --git a/Code/WMS/WIDESEA_WMSClient/src/api/http.js b/Code/WMS/WIDESEA_WMSClient/src/api/http.js
index 0a82b23..0a26762 100644
--- a/Code/WMS/WIDESEA_WMSClient/src/api/http.js
+++ b/Code/WMS/WIDESEA_WMSClient/src/api/http.js
@@ -12,7 +12,7 @@
 let loadingInstance;
 let loadingStatus = false;
 if (process.env.NODE_ENV == 'development') {
-    axios.defaults.baseURL = window.webConfig.webApiBaseUrl;
+    axios.defaults.baseURL = window.webConfig.webApiProduction;
 }
 else if (process.env.NODE_ENV == 'debug') {
     axios.defaults.baseURL = window.webConfig.webApiBaseUrl;
diff --git a/Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js b/Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js
index 50c2798..ee9d66c 100644
--- a/Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js
+++ b/Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js
@@ -241,6 +241,11 @@
     name: 'outboundTimeConfig',
     component: () => import('@/views/system/outboundTimeConfig.vue')
   }
+  , {
+    path: '/palletOperation',
+    name: 'palletOperation',
+    component: () => import('@/views/taskinfo/palletOperation.vue')
+  }
 ]
 
 export default viewgird
diff --git a/Code/WMS/WIDESEA_WMSClient/src/views/taskinfo/palletOperation.vue b/Code/WMS/WIDESEA_WMSClient/src/views/taskinfo/palletOperation.vue
new file mode 100644
index 0000000..3c33ca3
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSClient/src/views/taskinfo/palletOperation.vue
@@ -0,0 +1,185 @@
+<template>
+  <div class="pallet-operation-page">
+    <el-card shadow="hover">
+      <template #header>
+        <span>缁勭洏/鎷嗙洏鎿嶄綔</span>
+      </template>
+
+      <el-form :model="formData" ref="formRef" label-width="100px" style="max-width: 600px">
+        <el-form-item label="鎿嶄綔绫诲瀷" prop="action" required>
+          <el-select v-model="formData.action" placeholder="璇烽�夋嫨鎿嶄綔绫诲瀷" @change="onActionChange">
+            <el-option label="缁勭洏" value="缁勭洏" />
+            <el-option label="鎷嗙洏" value="鎷嗙洏" />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="鎵樼洏鍙�" prop="palletCode" required>
+          <el-input v-model="formData.palletCode" placeholder="璇疯緭鍏ユ墭鐩樺彿" />
+        </el-form-item>
+
+        <el-form-item label="绾夸綋缂栧彿" prop="lineId" required>
+          <el-input v-model="formData.lineId" placeholder="璇疯緭鍏ョ嚎浣撶紪鍙�" />
+        </el-form-item>
+
+        <el-form-item label="鏈烘鎵嬪悕绉�" prop="robotName" required>
+          <el-input v-model="formData.robotName" placeholder="璇疯緭鍏ユ満姊版墜鍚嶇О" />
+        </el-form-item>
+
+        <el-form-item label="浠撳簱缂栧彿" prop="warehouseCode" required>
+          <el-input v-model="formData.warehouseCode" placeholder="璇疯緭鍏ヤ粨搴撶紪鍙�" />
+        </el-form-item>
+
+        <el-form-item label="浼樺厛绾�" prop="grade">
+          <el-input-number v-model="formData.grade" :min="1" :max="99" />
+        </el-form-item>
+      </el-form>
+    </el-card>
+
+    <!-- 鐢佃姱鍒楄〃锛堢粍鐩樻椂鏄剧ず锛� -->
+    <el-card v-if="formData.action === '缁勭洏'" shadow="hover" style="margin-top: 16px">
+      <template #header>
+        <div class="cell-header">
+          <span>鐢佃姱鍒楄〃</span>
+          <el-button type="primary" size="small" @click="addCellRow">娣诲姞琛�</el-button>
+        </div>
+      </template>
+
+      <el-table :data="formData.cells" border style="width: 100%" max-height="400">
+        <el-table-column label="搴忓彿" width="60" align="center">
+          <template v-slot="{ $index }">{{ $index + 1 }}</template>
+        </el-table-column>
+        <el-table-column label="鐢佃姱鐮�" min-width="200">
+          <template v-slot="{ row }">
+            <el-input v-model="row.sfcCode" size="small" placeholder="璇疯緭鍏ョ數鑺爜" />
+          </template>
+        </el-table-column>
+        <el-table-column label="閫氶亾鍙�" width="160">
+          <template v-slot="{ row }">
+            <el-input v-model="row.channel" size="small" placeholder="璇疯緭鍏ラ�氶亾鍙�" />
+          </template>
+        </el-table-column>
+        <el-table-column label="鎿嶄綔" width="80" align="center">
+          <template v-slot="{ $index }">
+            <el-button type="danger" size="small" link @click="removeCellRow($index)">鍒犻櫎</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-card>
+
+    <div style="margin-top: 16px; text-align: center">
+      <el-button type="primary" @click="submitForm" :loading="submitting">鎻愪氦</el-button>
+      <el-button @click="resetForm">閲嶇疆</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import { ref, reactive, getCurrentInstance } from "vue";
+
+export default {
+  name: "PalletOperation",
+  setup() {
+    const { proxy } = getCurrentInstance();
+    const formRef = ref(null);
+    const submitting = ref(false);
+
+    const defaultFormData = () => ({
+      action: "",
+      palletCode: "",
+      lineId: "",
+      robotName: "",
+      warehouseCode: "",
+      grade: 1,
+      cells: [],
+    });
+
+    const formData = reactive(defaultFormData());
+
+    /// 鎿嶄綔绫诲瀷鍙樻洿鏃讹紝缁勭洏鍒濆鍖栦竴鏉$┖琛岋紝鎷嗙洏娓呯┖鍒楄〃
+    const onActionChange = (val) => {
+      if (val === "缁勭洏") {
+        formData.cells = [{ sfcCode: "", channel: "" }];
+      } else {
+        formData.cells = [];
+      }
+    };
+
+    /// 娣诲姞鐢佃姱琛�
+    const addCellRow = () => {
+      formData.cells.push({ sfcCode: "", channel: "" });
+    };
+
+    /// 绉婚櫎鐢佃姱琛�
+    const removeCellRow = (index) => {
+      formData.cells.splice(index, 1);
+    };
+
+    /// 鎻愪氦琛ㄥ崟
+    const submitForm = () => {
+      if (!formData.action) return proxy.$message.error("璇烽�夋嫨鎿嶄綔绫诲瀷");
+      if (!formData.palletCode) return proxy.$message.error("璇疯緭鍏ユ墭鐩樺彿");
+      if (!formData.lineId) return proxy.$message.error("璇疯緭鍏ョ嚎浣撶紪鍙�");
+      if (!formData.robotName) return proxy.$message.error("璇疯緭鍏ユ満姊版墜鍚嶇О");
+      if (!formData.warehouseCode) return proxy.$message.error("璇疯緭鍏ヤ粨搴撶紪鍙�");
+
+      if (formData.action === "缁勭洏") {
+        if (formData.cells.length === 0) return proxy.$message.error("缁勭洏鏃惰嚦灏戦渶瑕佷竴涓數鑺�");
+        for (let i = 0; i < formData.cells.length; i++) {
+          if (!formData.cells[i].sfcCode) return proxy.$message.error(`绗�${i + 1}琛岀數鑺爜涓嶈兘涓虹┖`);
+          if (!formData.cells[i].channel) return proxy.$message.error(`绗�${i + 1}琛岄�氶亾鍙蜂笉鑳戒负绌篳);
+        }
+      }
+
+      const payload = {
+        action: formData.action,
+        palletCode: formData.palletCode,
+        lineId: formData.lineId,
+        robotName: formData.robotName,
+        warehouseCode: formData.warehouseCode,
+        grade: formData.grade,
+        cells: formData.action === "缁勭洏" ? formData.cells : null,
+      };
+
+      submitting.value = true;
+      proxy.http
+        .post("/api/Task/PalletOperation", payload, "鎻愪氦涓�...")
+        .then((res) => {
+          submitting.value = false;
+          if (!res.status) return proxy.$message.error(res.message);
+          proxy.$message.success(res.message || "鎿嶄綔鎴愬姛");
+        })
+        .catch(() => {
+          submitting.value = false;
+        });
+    };
+
+    /// 閲嶇疆琛ㄥ崟
+    const resetForm = () => {
+      Object.assign(formData, defaultFormData());
+    };
+
+    return {
+      formRef,
+      formData,
+      submitting,
+      onActionChange,
+      addCellRow,
+      removeCellRow,
+      submitForm,
+      resetForm,
+    };
+  },
+};
+</script>
+
+<style scoped>
+.pallet-operation-page {
+  padding: 20px;
+}
+
+.cell-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+</style>
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs
index 86728ff..8426635 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Middlewares/ApiLogMiddleware.cs
@@ -14,6 +14,18 @@
     public class ApiLogMiddleware
     {
         /// <summary>
+        /// 涓嶅啓鍏� Sys_Log 琛ㄧ殑鎺ュ彛璺緞锛堝彧鍐欐枃浠舵棩蹇楋級
+        /// </summary>
+        private static readonly string[] _apiLogSkipPaths =
+        {
+            "InOrOutCompleted",
+            "SendLocationStatus",
+            "RequestOutbound",
+            "GetPalletCodeCell",
+            "GetOutBoundTrayTask"
+        };
+
+        /// <summary>
         ///
         /// </summary>
         private readonly RequestDelegate _next;
@@ -21,6 +33,15 @@
         public ApiLogMiddleware(RequestDelegate next, ILogger<ApiLogMiddleware> logger)
         {
             _next = next;
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇褰撳墠璇锋眰璺緞鏄惁鍦ㄨ烦杩囨暟鎹簱鏃ュ織鍒楄〃涓�
+        /// </summary>
+        private static bool IsApiLogSkipPath(string? path)
+        {
+            if (string.IsNullOrEmpty(path)) return false;
+            return _apiLogSkipPaths.Any(skip => path.Contains(skip));
         }
 
         //todo
@@ -87,7 +108,8 @@
                     ms.Position = 0;
                     await ms.CopyToAsync(originalBody);
 
-                    if (!ignoreUrls.Any(x => context.Request.Path.Value?.Contains(x) ?? false))
+                    if (!ignoreUrls.Any(x => context.Request.Path.Value?.Contains(x) ?? false)
+                        && !IsApiLogSkipPath(context.Request.Path.Value))
                     {
                         Logger.Add(requestParam, responseParam);
                     }
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 2367be1..b5fe575 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -1,23 +1,14 @@
-using Mapster;
 using MapsterMapper;
 using Microsoft.Extensions.Configuration;
-using SqlSugar;
-using System.DirectoryServices.Protocols;
-using System.Text.Json;
-using WIDESEA_Common.Constants;
-using WIDESEA_Common.LocationEnum;
-using WIDESEA_Common.StockEnum;
-using WIDESEA_Common.TaskEnum;
-using WIDESEA_Common.WareHouseEnum;
+using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
+using SqlSugar;
+using WIDESEA_Common.Constants;
+using WIDESEA_Common.TaskEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Core;
-using WIDESEA_Core.Enums;
-using WIDESEA_Core.Helper;
-using WIDESEA_DTO.GradingMachine;
-using WIDESEA_DTO.MES;
 using WIDESEA_DTO.Task;
 using WIDESEA_IBasicService;
 using WIDESEA_IRecordService;
@@ -45,6 +36,7 @@
         private readonly IMesUploadHelper _mesUploadHelper;
         private readonly ISqlSugarClient _sqlSugarClient;
         private readonly IOptionsMonitor<OutboundTimeConfigOptions> _outboundTimeOptions;
+        private readonly ILogger<TaskService> _logger;
 
         public IRepository<Dt_Task> Repository => BaseDal;
 
@@ -74,7 +66,8 @@
             IMesLogService mesLogService,
             IMesUploadHelper mesUploadHelper,
             ISqlSugarClient sqlSugarClient,
-            IOptionsMonitor<OutboundTimeConfigOptions> outboundTimeOptions) : base(BaseDal)
+            IOptionsMonitor<OutboundTimeConfigOptions> outboundTimeOptions,
+            ILogger<TaskService> logger) : base(BaseDal)
         {
             _mapper = mapper;
             _stockInfoService = stockInfoService;
@@ -92,6 +85,7 @@
             _mesUploadHelper = mesUploadHelper;
             _sqlSugarClient = sqlSugarClient;
             _outboundTimeOptions = outboundTimeOptions;
+            _logger = logger;
         }
 
         /// <summary>
@@ -206,6 +200,5 @@
             // Remark 涓虹┖鏃讹紝鍥為��鍒板贩閬撻厤缃�
             return DetermineTargetAddress(roadway, addressMap);
         }
-
     }
 }
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
index b5dd9cb..d71074d 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_GradingMachine.cs
@@ -1,4 +1,7 @@
+using Serilog;
 using System.Text.Json;
+using System.Text.Encodings.Web;
+using System.Text.Unicode;
 using WIDESEA_Common.Constants;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
@@ -11,6 +14,13 @@
 {
     public partial class TaskService
     {
+        /// <summary>
+        /// JSON搴忓垪鍖栭�夐」锛堜腑鏂囦笉杞箟锛�
+        /// </summary>
+        private static readonly JsonSerializerOptions _jsonOptions = new()
+        {
+            Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
+        };
         #region 鍒嗗鏌滄帴鍙�
 
         /// <summary>
@@ -18,10 +28,14 @@
         /// </summary>
         public async Task<WebResponseContent> InOrOutCompletedAsync(GradingMachineInputDto input)
         {
+            var log = Log.ForContext("SourceContext", "鍒嗗鏌滃畬鎴愪俊鍙�");
+            log.Information("[InOrOutCompleted] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
             WebResponseContent content = new WebResponseContent();
             if (string.IsNullOrWhiteSpace(input.LocationCode))
             {
-                return content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+                var errResult = content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+                log.Warning("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                return errResult;
             }
 
             try
@@ -30,7 +44,11 @@
 
                 int locationStatus;
                 if (stockInfo == null)
-                    return content.Error("WMS鏈壘鍒板簱瀛樹俊鎭�");
+                {
+                    var errResult = content.Error("WMS鏈壘鍒板簱瀛樹俊鎭�");
+                    log.Warning("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                    return errResult;
+                }
                 locationStatus = MapLocationStatus(stockInfo.StockStatus);
 
                 int MapLocationStatus(int stockStatus) => stockStatus switch
@@ -47,11 +65,14 @@
                     IsNormalProcedure = 1,
                     LocationStatus = locationStatus
                 };
-                return content.OK(data: outPutDto);
+                var result = content.OK(data: outPutDto);
+                log.Information("[InOrOutCompleted] 鍝嶅簲: {Response}", JsonSerializer.Serialize(result, _jsonOptions));
+                return result;
             }
             catch (Exception ex)
             {
                 content.Error(ex.Message);
+                log.Error(ex, "[InOrOutCompleted] 寮傚父");
             }
 
             return content;
@@ -64,10 +85,14 @@
         /// <returns></returns>
         public async Task<WebResponseContent> SendLocationStatusAsync(GradingMachineInputDto input)
         {
+            var log = Log.ForContext("SourceContext", "鍒嗗鏌滅姸鎬佹洿鏂�");
+            log.Information("[SendLocationStatus] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
             WebResponseContent content = new WebResponseContent();
             if (string.IsNullOrWhiteSpace(input.LocationCode))
             {
-                return content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+                var errResult = content.Error($"璐т綅缂栧彿涓嶈兘涓虹┖");
+                log.Warning("[SendLocationStatus] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                return errResult;
             }
 
             try
@@ -86,10 +111,12 @@
                 {
                     content.Error("鏇存柊澶辫触");
                 }
+                log.Information("[SendLocationStatus] 鍝嶅簲: {Response}", JsonSerializer.Serialize(content, _jsonOptions));
             }
             catch (Exception ex)
             {
                 content.Error(ex.Message);
+                log.Error(ex, "[SendLocationStatus] 寮傚父");
             }
             return content;
         }
@@ -101,17 +128,23 @@
         /// <returns></returns>
         public async Task<WebResponseContent> RequestOutboundAsync(GradingMachineInputDto input)
         {
+            var log = Log.ForContext("SourceContext", "鍒嗗鏌滃嚭搴撹姹�");
+            log.Information("[RequestOutbound] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
             WebResponseContent content = new WebResponseContent();
             if (string.IsNullOrWhiteSpace(input.LocationCode) || string.IsNullOrWhiteSpace(input.PalletCode))
             {
-                return content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+                var errResult = content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+                log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                return errResult;
             }
             try
             {
                 var stock = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
                 if (stock == null)
                 {
-                    return content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+                    var errResult = content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+                    log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                    return errResult;
                 }
 
                 var taskList = new Dt_Task
@@ -139,17 +172,22 @@
                     var httpResponse = _httpClientHelper.Post<WebResponseContent>("http://localhost:9292/api/Task/ReceiveTask", JsonSerializer.Serialize(wmsTaskDtos)).Data;
                     if (result && httpResponse != null)
                     {
-                        return content.OK("鍑哄簱璇锋眰鎴愬姛");
+                        var okResult = content.OK("鍑哄簱璇锋眰鎴愬姛");
+                        log.Information("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(okResult, _jsonOptions));
+                        return okResult;
                     }
                     else
                     {
-                        return content.Error("鍑哄簱璇锋眰澶辫触");
+                        var errResult = content.Error("鍑哄簱璇锋眰澶辫触");
+                        log.Warning("[RequestOutbound] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                        return errResult;
                     }
                 });
             }
             catch (Exception ex)
             {
                 content.Error(ex.Message);
+                log.Error(ex, "[RequestOutbound] 寮傚父");
             }
             return content;
         }
@@ -161,17 +199,23 @@
         /// <returns></returns>
         public async Task<WebResponseContent> GetPalletCodeCellAsync(GradingMachineInputDto input)
         {
+            var log = Log.ForContext("SourceContext", "鍒嗗鏌滅數鑺煡璇�");
+            log.Information("[GetPalletCodeCell] 璇锋眰鍙傛暟: {Request}", JsonSerializer.Serialize(input, _jsonOptions));
             WebResponseContent content = new WebResponseContent();
             if (string.IsNullOrWhiteSpace(input.PalletCode) || string.IsNullOrWhiteSpace(input.LocationCode))
             {
-                return content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+                var errResult = content.Error($"鎵樼洏鍙锋垨鑰呰揣浣嶇紪鍙蜂笉鑳戒负绌�");
+                log.Warning("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                return errResult;
             }
             try
             {
                 var stockInfo = await _stockInfoService.GetStockInfoAsync(input.PalletCode, input.LocationCode);
                 if (stockInfo == null)
                 {
-                    return content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+                    var errResult = content.Error("鏈壘鍒板搴旂殑鎵樼洏");
+                    log.Warning("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(errResult, _jsonOptions));
+                    return errResult;
                 }
 
                 var outPutDtos = new
@@ -186,10 +230,13 @@
                         Channel = x.InboundOrderRowNo.ToString()
                     }).ToList()
                 };
-                return content.OK(data: outPutDtos);
+                var result = content.OK(data: outPutDtos);
+                log.Information("[GetPalletCodeCell] 鍝嶅簲: {Response}", JsonSerializer.Serialize(result, _jsonOptions));
+                return result;
             }
             catch (Exception ex)
             {
+                log.Error(ex, "[GetPalletCodeCell] 寮傚父");
                 return content.Error(ex.Message);
             }
         }
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
index b7d0898..0537ddf 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WIDESEA_TaskInfoService.csproj
@@ -15,4 +15,8 @@
     <ProjectReference Include="..\WIDESEA_ITaskInfoService\WIDESEA_ITaskInfoService.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <PackageReference Include="Serilog" Version="4.3.1" />
+  </ItemGroup>
+
 </Project>
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
index 43e60a1..d2e1d7a 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
@@ -10,6 +10,7 @@
 using Newtonsoft.Json.Converters;
 using Newtonsoft.Json.Serialization;
 using Serilog;
+using Serilog.Events;
 using Serilog.Formatting.Json;
 using System.Reflection;
 using System.Text;
@@ -20,6 +21,7 @@
 using WIDESEA_Core.Extensions;
 using WIDESEA_Core.Filter;
 using WIDESEA_Core.Helper;
+
 //using WIDESEA_Core.HostedService;
 using WIDESEA_Core.Middlewares;
 using WIDESEA_WMSServer.BackgroundServices;
@@ -56,6 +58,43 @@
             fileSizeLimitBytes: 10 * 1024 * 1024,
             shared: true
             )
+         // 鍒嗗鏌滄帴鍙g嫭绔嬫棩蹇楁枃浠�
+         .WriteTo.Logger(lc => lc
+            .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滃畬鎴愪俊鍙�")
+            .WriteTo.File(
+                "logs/鍒嗗鏌滃畬鎴愪俊鍙�-.log",
+                outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+                rollingInterval: RollingInterval.Day,
+                retainedFileCountLimit: 30,
+                fileSizeLimitBytes: 10 * 1024 * 1024,
+                shared: true))
+         .WriteTo.Logger(lc => lc
+            .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滅姸鎬佹洿鏂�")
+            .WriteTo.File(
+                "logs/鍒嗗鏌滅姸鎬佹洿鏂�-.log",
+                outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+                rollingInterval: RollingInterval.Day,
+                retainedFileCountLimit: 30,
+                fileSizeLimitBytes: 10 * 1024 * 1024,
+                shared: true))
+         .WriteTo.Logger(lc => lc
+            .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滃嚭搴撹姹�")
+            .WriteTo.File(
+                "logs/鍒嗗鏌滃嚭搴撹姹�-.log",
+                outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+                rollingInterval: RollingInterval.Day,
+                retainedFileCountLimit: 30,
+                fileSizeLimitBytes: 10 * 1024 * 1024,
+                shared: true))
+         .WriteTo.Logger(lc => lc
+            .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滅數鑺煡璇�")
+            .WriteTo.File(
+                "logs/鍒嗗鏌滅數鑺煡璇�-.log",
+                outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+                rollingInterval: RollingInterval.Day,
+                retainedFileCountLimit: 30,
+                fileSizeLimitBytes: 10 * 1024 * 1024,
+                shared: true))
          // 6. 鍙�夛細杈撳嚭鍒癝eq鏃ュ織鏈嶅姟鍣紙缁撴瀯鍖栨棩蹇楁湇鍔″櫒锛�
          // 闇�瑕佸畨瑁� Serilog.Sinks.Seq NuGet鍖咃紝骞剁‘淇漇eq鏈嶅姟鍦� http://localhost:5341 杩愯
          // 濡備笉闇�瑕丼eq鏃ュ織锛屾敞閲婃帀涓嬫柟浠g爜鍗冲彲
@@ -95,7 +134,6 @@
 builder.Services.AddSwaggerSetup();
 
 builder.Services.AddHttpContextSetup();
-
 
 builder.Services.AddMvc(options =>
 {
@@ -137,7 +175,6 @@
 builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
 
-
 var app = builder.Build();
 
 // 3. 閰嶇疆涓棿浠�
@@ -154,7 +191,6 @@
 app.UseApiLogMiddleware();
 // todo
 // app.UseRecordAccessLogsMiddle();
-
 
 DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
 defaultFilesOptions.DefaultFileNames.Clear();
@@ -182,4 +218,4 @@
 
 app.MapHub<WIDESEA_WMSServer.Hubs.StockHub>("/stockHub");
 
-app.Run();
+app.Run();
\ No newline at end of file

--
Gitblit v1.9.3