From 1f9a89458a66c12c1f7dfbceb2588ada8fbf16f4 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 13 十一月 2025 17:35:36 +0800
Subject: [PATCH] 新增移库页面与WebSocket支持,优化任务逻辑新增移库页面支持移库任务输入与提交。新增 WebSocket 支持(`websocket.js`、`WebSocketSetup.cs`),实现实时通信功能。 在任务状态枚举中新增 AGV 移库任务状`TaskStatusEnum.cs`)- 重构库存数据展示页面(`Home.vue`),新增数据总览与图表展示功能。 - 新增库存数据接口(`StockInfoService.cs`、`StockInfoController.cs`),支持库存统计与展示。 - 优化任务状态管理逻辑,支持 AGV 移库任务(`Dt_TaskService.cs`)。

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |  101 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 69 insertions(+), 32 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
index cd322d0..c125ee5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
@@ -964,6 +964,74 @@
     }
     #endregion 璇锋眰鍑哄簱锛堝疄鐩�&绌虹洏锛�
 
+    #region 璇锋眰绉诲簱浠诲姟
+    public async Task<WebResponseContent> RequestRelocationTaskAsync(string SourceAddress,string TargetAddress)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            var startLocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == SourceAddress);
+            var endLocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == TargetAddress);
+
+            if (!startLocation.IsNotEmptyOrNull() || !endLocation.IsNotEmptyOrNull())
+            {
+                return content.Error("搴撲綅淇℃伅涓嶅瓨鍦�");
+            }
+            if (endLocation.LocationStatus != (int)LocationEnum.Free)
+            {
+                return content.Error($"缁堢偣搴撲綅{endLocation.LocationCode}鏈浜庣┖闂茬姸鎬侊紝璇蜂汉宸ョ‘璁ゅ簱浣嶇姸鎬�");
+            }
+            if ((startLocation.AreaId == 1 || endLocation.AreaId == 1) && startLocation.AreaId != endLocation.AreaId)
+            {
+                return content.Error("绉诲簱璧风偣搴撲綅涓庣粓鐐瑰簱浣嶄笉鍦ㄥ悓涓�鍖哄煙");
+            }
+            if (startLocation.Floor != endLocation.Floor)
+            {
+                return content.Error("绉诲簱璧风偣搴撲綅涓庣粓鐐瑰簱浣嶄笉鍦ㄥ悓涓�妤煎眰");
+            }
+
+            var stock = await _stockInfoRepository.QueryFirstAsync(x => x.LocationCode == startLocation.LocationCode);
+            var taskNew = new Dt_Task
+            {
+                Grade = startLocation.Floor == "1F" ? 10 : 1,
+                Roadway = endLocation.RoadwayNo,
+                TargetAddress = endLocation.LocationCode,
+                Dispatchertime = DateTime.Now,
+                MaterialNo = "",
+                NextAddress = endLocation.LocationCode,
+                OrderNo = null,
+                PalletCode = stock == null ? "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000) : stock.PalletCode,
+                SourceAddress = startLocation.LocationCode,
+                CurrentAddress = startLocation.LocationCode,
+                TaskState = startLocation.AreaId == 1 ? (int)TaskRelocationStatusEnum.RelocationNew : (int)TaskRelocationStatusEnum.RelocationNewAGV,
+                TaskType = (int)TaskRelocationTypeEnum.Relocation,
+                TaskNum = BaseDal.GetTaskNo().Result,
+                CreateDate = DateTime.Now,
+                TaskId = 0,
+                AGVTaskNum = GenerateUniqueId(),
+                Floor = startLocation.Floor,
+            };
+
+
+            var result = AddTaskAsync(new List<Dt_Task>() { taskNew });
+            await _unitOfWorkManage.UseTranAsync(async () =>
+            {
+                await _locationStatusChangeRecordRepository.AddDataAsync(result.Item2);
+                await _locationRepository.UpdateDataAsync(result.Item1);
+                await BaseDal.AddDataAsync(taskNew);
+            });
+            await SendWCSTask(CreateListTaskDTO(taskNew));
+            return content.OK();
+        }
+        catch (Exception ex)
+        {
+            return content.Error(ex.Message);
+        }
+    }
+
+
+    #endregion
+
     #region 璇锋眰璺ㄦゼ灞�2浠诲姟
     /// <summary>
     /// 璇锋眰璺ㄦゼ灞�2浠诲姟
@@ -1258,7 +1326,7 @@
                             PalletCode = stock == null ? "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000) : stock.PalletCode,
                             SourceAddress = item.LocationCode,
                             CurrentAddress = item.LocationCode,
-                            TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
+                            TaskState = (int)TaskRelocationStatusEnum.RelocationNewAGV,
                             TaskType = (int)TaskRelocationTypeEnum.Relocation,
                             TaskNum = BaseDal.GetTaskNo().Result,
                             CreateDate = DateTime.Now,
@@ -1404,37 +1472,6 @@
         }
         return content;
     }
-    #endregion
-
-    #region 鑾峰彇浠诲姟鏁版嵁
-    public async Task<WebResponseContent> GetTaskData()
-    {
-        WebResponseContent content = new WebResponseContent();
-        try
-        {
-            var task = await BaseDal.QueryDataAsync(x => true);
-            var taskData = new List<TaskData>
-            {
-                new TaskData { Status = "宸插彇娑�", Count = task.Count+50 },
-                new TaskData { Status = "宸插畬鎴�", Count = 735 }
-            };
-
-            // 鏋勫缓绗﹀悎瑕佹眰鐨勬牸寮�
-            var result = taskData.Select(item => new
-            {
-                value = item.Count,
-                name = item.Status,
-                itemStyle = new { color = item.Status == "宸插彇娑�" ? "#FF0000" : "#00FF00" }
-            }).ToList();
-
-            return content.OK(data: result);
-        }
-        catch (Exception ex)
-        {
-            return content.Error(ex.Message);
-        }
-    }
-
     #endregion
 
     #endregion 澶栭儴鎺ュ彛鏂规硶

--
Gitblit v1.9.3