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/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs |   69 ++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 21 deletions(-)

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

--
Gitblit v1.9.3