From aa75f3cbdcfce80d7ebd3c4f2bcfeea850949209 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 10 三月 2026 20:22:01 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs |  122 +++++++++++++++++++++++++++++++++-------
 1 files changed, 100 insertions(+), 22 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
index 1f2367c..a94fe87 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
@@ -15,24 +15,32 @@
 {
     public partial class TaskService
     {
+        #region 鍑箰澹换鍔″垱寤�
         /// <summary>
-        /// 鍒涘缓鍏ュ簱浠诲姟
+        /// 鍒涘缓鍑箰澹獳GV鍏ュ簱浠诲姟
         /// </summary>
         /// <param name="taskDTO"></param>
         /// <returns></returns>
         public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
                 int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
+                #region 鐐瑰埌鐐�
+                if (!string.IsNullOrEmpty(taskDTO.toLocationCode))
+                {
+                    var LocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐硅揣浣嶃�恵taskDTO.toLocationCode}銆�");
+                    if (LocationInfo.LocationStatus != LocationStatusEnum.Free.ObjToInt()) throw new Exception($"缁堢偣璐т綅銆恵taskDTO.toLocationCode}銆戣揣浣嶇姸鎬佷笉涓虹┖璐т綅");
+                }
+                #endregion
                 //鑾峰彇璐т綅淇℃伅
-                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.LocationType == containerType);
-                if (kLSLocationInfo == null) throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
-                Dt_Task dt_Task = new Dt_Task()
+                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
+                Dt_Task dt_Task = new()
                 {
                     TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     WMSTaskNum = taskDTO.taskCode,
-                    WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     Grade = taskDTO.taskPriority,
                     PalletCode = taskDTO.containerCode,
                     Roadway = kLSLocationInfo.RoadwayNo,
@@ -45,31 +53,53 @@
                     Creater = "WMS",
                 };
                 kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
-                Db.Ado.BeginTran();
-                BaseDal.AddData(dt_Task);
-                _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
+                try
+                {
+                    Db.Ado.BeginTran();
+                    BaseDal.AddData(dt_Task);
+                    _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
+                    Db.Ado.CommitTran();
+                }
+                catch (Exception ex)
+                {
+                    Db.Ado.RollbackTran();
+                    throw new Exception(ex.Message);
+                }
+
+                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>
+        /// 鍒涘缓鍑箰澹獳GV鍑哄簱浠诲姟
+        /// </summary>
+        /// <param name="taskDTO"></param>
+        /// <param name="taskType"></param>
+        /// <returns></returns>
         public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode);
-                if (kLSLocationInfo == null) throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
                 if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
-                Dt_Task dt_Task = new Dt_Task()
+                Dt_Task dt_Task = new()
                 {
                     TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     WMSTaskNum = taskDTO.taskCode,
-                    WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     Grade = taskDTO.taskPriority,
                     PalletCode = taskDTO.containerCode,
                     Roadway = kLSLocationInfo.RoadwayNo,
@@ -82,17 +112,65 @@
                     Creater = "WMS",
                 };
                 kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
-                Db.Ado.BeginTran();
-                BaseDal.AddData(dt_Task);
-                _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
-                Db.Ado.CommitTran();
+                try
+                {
+                    Db.Ado.BeginTran();
+                    BaseDal.AddData(dt_Task);
+                    _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
+                    Db.Ado.CommitTran();
+                }
+                catch (Exception ex)
+                {
+                    Db.Ado.RollbackTran();
+                    throw new Exception(ex.Message);
+                }
+                return content.OK(data: new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = "鎴愬姛锛�"
+                });
+            }
+            catch (Exception ex)
+            {
+                content.Data = new
+                {
+                    taskCode = taskDTO.taskCode,
+                    Message = $"澶辫触锛亄ex.Message}"
+                };
+                return content.Error(ex.Message);
+            }
+        }
+        #endregion
+
+        #region 5 璺ㄦゼ灞傝繍杈撲换鍔″垱寤�
+        public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType)
+        {
+            try
+            {
+
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)
             {
-                Db.Ado.RollbackTran();
                 throw new Exception(ex.Message);
             }
         }
+        #endregion
+
+
+        #region 6 瑁佸壀閫佽揣
+        public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
+        {
+            try
+            {
+
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+        }
+        #endregion
     }
 }

--
Gitblit v1.9.3