From a1795465c5b51eb53d83d9a874c7923c9f5bfa85 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 10 三月 2026 16:05:06 +0800
Subject: [PATCH] 优化WMS任务下发接口

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs |   49 +++++++++++++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
index 055df4a..911a361 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
@@ -10,6 +10,10 @@
 using WIDESEAWCS_DTO.WMS;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_Core.Helper;
+using HslCommunication.Core.IMessage;
+using WIDESEAWCS_DTO.RGV.FOURBOT;
+using Newtonsoft.Json;
+using System.Reflection.Metadata;
 
 namespace WIDESEAWCS_TaskInfoService
 {
@@ -24,19 +28,14 @@
         /// <returns></returns>
         public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                //List<Dt_RGVLocationInfo>? rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt());
-                //if (rGVLocationInfos.Count < 1) throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
-                //var rGVLocationInfo = rGVLocationInfos.OrderBy(x => x.Depth).First();
-                //var rGVLocationInfo = _rGVLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
                 Dt_StationManger stationManger = _stationMangerService.GetInStationInfo(taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐逛綅缃�恵taskDTO.fromLocationCode}銆戠珯鍙颁俊鎭紒");
-                //if (stationManger.IsOccupied == 1) throw new Exception($"璧风偣浣嶇疆銆恵taskDTO.fromLocationCode}銆戠珯鍙拌鍗犵敤锛岃閲婃斁锛�");
                 Dt_Task dt_Task = new()
                 {
                     TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     WMSTaskNum = taskDTO.taskCode,
-                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     Grade = taskDTO.taskPriority,
                     PalletCode = taskDTO.containerCode,
                     Roadway = taskDTO.toAreaCode,
@@ -44,22 +43,25 @@
                     TaskType = taskType,
                     SourceAddress = taskDTO.fromLocationCode,
                     CurrentAddress = taskDTO.fromLocationCode,
-                    NextAddress = stationManger.RGVStationCode,//鎵惧叆搴撶珯鍙板搴旂殑澶栧舰妫�娴嬬紪鍙�
+                    NextAddress = stationManger.RGVStationCode,
                     TargetAddress = "",
-                    //Remark = taskDTO.toAreaCode,
                     Creater = "WMS",
                 };
-                //rGVLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
-                //Db.Ado.BeginTran();
                 BaseDal.AddData(dt_Task);
-                //_rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
-                //Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
+                return content.OK(data: new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = "鎴愬姛锛�"
+                });
             }
             catch (Exception ex)
             {
-                //Db.Ado.RollbackTran();
-                throw new Exception(ex.Message);
+                content.Data = new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = $"澶辫触锛亄ex.Message}"
+                };
+                return content.Error(ex.Message);
             }
         }
         /// <summary>
@@ -70,17 +72,15 @@
         /// <returns></returns>
         public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                //Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode);
-                //if (dt_Task != null) throw new Exception($"鎵樼洏鍙枫�恵taskDTO.containerCode}銆戝凡瀛樺湪浠诲姟");
                 Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
                 if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
                 Dt_Task dt_Task = new()
                 {
                     TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     WMSTaskNum = taskDTO.taskCode,
-                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     Grade = taskDTO.taskPriority,
                     PalletCode = taskDTO.containerCode,
                     Roadway = rGVLocationInfo.RoadwayNo,
@@ -105,11 +105,20 @@
                     Db.Ado.RollbackTran();
                     throw new Exception(ex.Message);
                 }
-                return WebResponseContent.Instance.OK();
+                return content.OK(data: new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = "鎴愬姛锛�"
+                });
             }
             catch (Exception ex)
             {
-                throw new Exception(ex.Message);
+                content.Data = new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = $"澶辫触锛亄ex.Message}"
+                };
+                return content.Error(ex.Message);
             }
         }
         #endregion

--
Gitblit v1.9.3