From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs |  140 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
new file mode 100644
index 0000000..1a085ab
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Outbound.cs
@@ -0,0 +1,140 @@
+using WIDESEA_Common.Constants;
+using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
+using WIDESEA_Common.WareHouseEnum;
+using WIDESEA_Core;
+using WIDESEA_DTO.Task;
+using WIDESEA_Model.Models;
+
+namespace WIDESEA_TaskInfoService
+{
+    public partial class TaskService
+    {
+        #region 鍑哄簱浠诲姟
+
+        /// <summary>
+        /// 鏍规嵁鎸囧畾鐨勪换鍔¤鎯呭紓姝ュ垱寤烘柊鐨勫嚭搴撲换鍔�
+        /// </summary>
+        public async Task<WebResponseContent> CreateTaskOutboundAsync(CreateTaskDto taskDto)
+        {
+            try
+            {
+                var stockResult = await _stockInfoService.GetStockInfoAsync(taskDto.WarehouseId);
+                if (stockResult == null || !stockResult.Any())
+                    return WebResponseContent.Instance.Error("鏈壘鍒板簱瀛樹俊鎭�");
+
+                var taskList = stockResult.Select(item => new Dt_Task
+                {
+                    WarehouseId = item.WarehouseId,
+                    PalletCode = item.PalletCode,
+                    PalletType = item.PalletType,
+                    SourceAddress = item.LocationCode,
+                    TargetAddress = taskDto.TargetAddress,
+                    Roadway = item.LocationDetails.RoadwayNo,
+                    TaskType = TaskTypeEnum.Outbound.GetHashCode(),
+                    TaskStatus = TaskStatusEnum.New.GetHashCode(),
+                    Grade = 1,
+                    TaskNum = 0,
+                    CurrentAddress = item.LocationCode,
+                    NextAddress = taskDto.TargetAddress,
+                    Creater = "system",
+                }).ToList();
+
+                var result = await BaseDal.AddDataAsync(taskList) > 0;
+                var wmstaskDto = result ? _mapper.Map<WMSTaskDTO>(taskList) : null;
+                return WebResponseContent.Instance.OK(result ? "浠诲姟鍒涘缓鎴愬姛" : "浠诲姟鍒涘缓澶辫触", wmstaskDto ?? new object());
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error($"浠诲姟鍒涘缓澶辫触: {ex.Message}");
+            }
+        }
+
+        /// <summary>
+        /// 鍑哄簱浠诲姟瀹屾垚 锛氫慨鏀瑰簱瀛橈紝淇敼璐т綅鐘舵�侊紝鍒犻櫎浠诲姟鏁版嵁锛屾坊鍔犲巻鍙蹭换鍔℃暟鎹�
+        /// </summary>
+        public async Task<WebResponseContent> OutboundFinishTaskAsync(CreateTaskDto taskDto)
+        {
+            try
+            {
+                var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
+                if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+
+                var location = await _locationInfoService.GetLocationInfo(task.Roadway, task.SourceAddress);
+                if (location == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑璐т綅");
+
+                var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode);
+                if (stockInfo == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴斿簱瀛樹俊鎭�");
+
+                // 鍒ゆ柇鏄笉鏄瀬鍗峰簱浠诲姟
+                if (taskDto.WarehouseId == (int)WarehouseEnum.FJ1 || taskDto.WarehouseId == (int)WarehouseEnum.ZJ1)
+                {
+                    OutTaskCompleteDto outTaskCompleteDto = new OutTaskCompleteDto()
+                    {
+                        TaskId = task.OrderNo ?? string.Empty,
+                        DevId = task.TargetAddress ?? string.Empty,
+                        ReqTime = DateTime.Now.ToString()
+                    };
+                    return await OutTaskComplete(outTaskCompleteDto);
+                }
+
+                WebResponseContent content = new WebResponseContent();
+                return await _unitOfWorkManage.BeginTranAsync(async () =>
+                {
+                    stockInfo.LocationId = 0;
+                    stockInfo.LocationCode = string.Empty;
+                    stockInfo.OutboundDate = DateTime.Now;
+
+                    location.LocationStatus = LocationStatusEnum.Free.GetHashCode();
+
+                    var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(location);
+                    var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo);
+                    if (!updateLocationResult || !updateStockResult)
+                        return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
+
+                    // 楂樻俯2鍙峰嚭搴撳埌CWSC1鏃讹紝鑷姩鍒涘缓鍏ュ簱浠诲姟鍒板父娓�1鍙峰贩閬�
+                    WMSTaskDTO? inboundTaskDto = null;
+                    if (task.TargetAddress == TaskAddressConstants.GW2_ADDRESS)
+                    {
+                        var inboundTask = new Dt_Task
+                        {
+                            TaskNum = await BaseDal.GetTaskNo(),
+                            PalletCode = task.PalletCode,
+                            PalletType = task.PalletType,
+                            Roadway = "CW1",
+                            TaskType = TaskInboundTypeEnum.Inbound.GetHashCode(),
+                            TaskStatus = TaskInStatusEnum.InNew.GetHashCode(),
+                            SourceAddress = task.TargetAddress,
+                            TargetAddress = task.TargetAddress,
+                            CurrentAddress = task.TargetAddress,
+                            NextAddress = task.TargetAddress,
+                            WarehouseId = (int)WarehouseEnum.CW1,
+                            Grade = 1,
+                            Creater = "system_auto"
+                        };
+                        await Repository.AddDataAsync(inboundTask);
+                        inboundTaskDto = _mapper.Map<WMSTaskDTO>(inboundTask);
+                    }
+
+                    var completeResult = await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
+                    if (!completeResult.Status)
+                        return completeResult;
+
+                    // 杩斿洖鍏ュ簱浠诲姟淇℃伅锛堝鏋滄湁锛�
+                    if (inboundTaskDto != null)
+                    {
+                        return content.OK("鍑哄簱瀹屾垚锛屽凡鍒涘缓鍏ュ簱浠诲姟", inboundTaskDto);
+                    }
+                    return content.OK("鍑哄簱瀹屾垚");
+                });
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error($"瀹屾垚浠诲姟澶辫触: {ex.Message}");
+            }
+        }
+
+        #endregion 鍑哄簱浠诲姟
+    }
+}

--
Gitblit v1.9.3