From c71c0e3e641f54f8c1deec44bb570b4f1b2ee07e Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 10 四月 2026 14:44:29 +0800
Subject: [PATCH] 添加海康任务对货位的判断

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs |  411 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 306 insertions(+), 105 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 6b91064..043ff1b 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"
@@ -10,6 +10,11 @@
 using WIDESEAWCS_Common.LocationEnum;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_DTO;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_QuartzJob;
+using System.Reflection.Metadata;
 
 namespace WIDESEAWCS_TaskInfoService
 {
@@ -23,21 +28,30 @@
         /// <returns></returns>
         public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
+            Dt_KLSLocationInfo? kLSLocationInfo = null;
             try
             {
-                int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
+                int containerType = taskDTO.containerCode.Contains("LLM") ? (int)LocationTypeEnum.LargePallet : (int)LocationTypeEnum.SmallPallet;
+                #region 鐐瑰埌鐐�
+                if (!string.IsNullOrEmpty(taskDTO.toLocationCode))
+                {
+                    kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐硅揣浣嶃�恵taskDTO.toLocationCode}銆�");
+                    if (kLSLocationInfo.LocationStatus != (int)LocationStatusEnum.Free) 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()
+                else
+                    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,
-                    TaskState = TaskStatusEnum.New.ObjToInt(),
+                    TaskState = (int)TaskStatusEnum.New,
                     TaskType = taskType,
                     SourceAddress = taskDTO.fromLocationCode,
                     CurrentAddress = taskDTO.fromLocationCode,
@@ -45,17 +59,40 @@
                     TargetAddress = kLSLocationInfo.LocationCode,
                     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();
+                kLSLocationInfo.LocationStatus = (int)LocationStatusEnum.InLock;
+                #region 涓嬪彂鍑箰澹换鍔�
+                content = SendKLSTask(dt_Task);
+                if (!content.Status) throw new Exception(content.Message);
+                dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+                dt_Task.Dispatchertime = DateTime.Now;
+                #endregion
+                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>
@@ -66,20 +103,21 @@
         /// <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}銆戯紒");
-                if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
-                Dt_Task dt_Task = new Dt_Task()
+                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+                if (kLSLocationInfo.LocationStatus != (int)LocationStatusEnum.InStock) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+                if (kLSLocationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵kLSLocationInfo.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+                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,
-                    TaskState = TaskStatusEnum.New.ObjToInt(),
+                    TaskState = (int)TaskStatusEnum.New,
                     TaskType = taskType,
                     SourceAddress = taskDTO.fromLocationCode,
                     CurrentAddress = taskDTO.fromLocationCode,
@@ -87,108 +125,271 @@
                     TargetAddress = taskDTO.toLocationCode,
                     Creater = "WMS",
                 };
-                kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
-                Db.Ado.BeginTran();
+                kLSLocationInfo.LocationStatus = (int)LocationStatusEnum.OutLock;
+                #region 涓嬪彂鍑箰澹换鍔�
+                content = SendKLSTask(dt_Task);
+                if (!content.Status) throw new Exception(content.Message);
+                dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+                dt_Task.Dispatchertime = DateTime.Now;
+                #endregion
+                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 涓嬪彂鍑箰澹换鍔�
+        public WebResponseContent SendKLSTask(Dt_Task task)
+        {
+            WebResponseContent content = new WebResponseContent();
+            GALAXISTaskInfo gALAXISTaskInfo = new();
+            GALAXISReturn agvContent = new();
+            try
+            {
+                gALAXISTaskInfo.groupId = DateTime.Now.ToString("yyMMddHHmmss") + task.TaskNum;
+                gALAXISTaskInfo.msgTime = DateTime.Now.ToString();
+                GALAXISTask gALAXISTask = new GALAXISTask()
+                {
+                    taskId = task.WMSTaskNum,
+                    taskType = task.TaskType == (int)TaskTypeEnum.MLInbound ? 0 : 1,
+                    barCode = task.PalletCode,
+                    endNode = task.TargetAddress,
+                    startNode = task.SourceAddress,
+                    priorityCode = task.Grade
+                };
+                gALAXISTaskInfo.tasks.Add(gALAXISTask);
+                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GALAXISTaskInfo)) ?? throw new Exception("鏈壘鍒板嚡涔愬+AGV浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
+                string response = HttpHelper.Post(apiInfo.ApiAddress, gALAXISTaskInfo.Serialize());
+                agvContent = response.DeserializeObject<GALAXISReturn>();
+                content.OK(data: agvContent);
+                if (agvContent.success)
+                {
+                    if (agvContent.data.returnStatus != 0) throw new Exception(agvContent.data.returnInfo);
+                }
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            finally
+            {
+                _trackloginfoService.AddTrackLog(gALAXISTaskInfo, content, "涓嬪彂鍑箰澹獳GV浠诲姟", "", agvContent.data.returnInfo);
+            }
+            return content;
+        }
+        #endregion
+
+        #region 5 璺ㄦゼ灞傝繍杈撲换鍔″垱寤� 锛堥兘鏄偣鍒扮偣锛�
+        public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                Dt_StationManger? stationInfo = null;
+                Dt_Task dt_Task = null;
+                //鍏ュ簱 鍒颁竴妤间笁涓珯鍙扮殑浣嶇疆
+                if (taskType == (int)TaskTypeEnum.Q3RK)//6-1妤�
+                {
+                    var  ionInfo = _stationMangerService.Repository.QueryFirst(x => x.StationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐圭珯鍙般�恵taskDTO.toLocationCode}銆戯紒");
+                    var StationInfo = _stationInfo.Repository.QueryFirst(x => x.StationCode == taskDTO.fromLocationCode ) ?? throw new Exception($"鏈壘鍒皗taskDTO.fromLocationCode}璧风偣璐т綅");
+                    if (StationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵StationInfo.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+                    if (StationInfo.StationStatus != (int)LocationStatusEnum.InStock) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶇姸鎬佷笉鍙互鍑哄簱");
+                    if (StationInfo.FloorNumber != "FF") throw new Exception($"銆恵taskDTO.fromLocationCode}銆戠殑妤煎眰鍜屼换鍔$被鍨嬫ゼ灞備笉鍖归厤");
+                   
+                    dt_Task = new Dt_Task()
+                    {
+                        TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                        WMSTaskNum = taskDTO.taskCode,
+                        Grade = taskDTO.taskPriority,
+                        PalletCode = taskDTO.containerCode,
+                        Roadway = "1",
+                        TaskState = (int)TaskStatusEnum.New,
+                        TaskType = taskType,
+                        SourceAddress = taskDTO.fromLocationCode,
+                        CurrentAddress = taskDTO.fromLocationCode,
+                        NextAddress = taskDTO.toLocationCode,
+                        TargetAddress = taskDTO.toLocationCode,
+                        Creater = "WMS",
+                    };
+                }
+                //鍑哄簱
+                if (taskType == (int)TaskTypeEnum.Q3CK)//1-6妤�
+                {
+                    var StationInfo = _stationInfo.Repository.QueryFirst(x => x.StationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈獅taskDTO.toLocationCode}缁堢偣璐т綅");
+                    if (StationInfo.StationStatus != (int)LocationStatusEnum.Free) throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝綋鍓嶇姸鎬佷笉鍙互鏀捐揣");
+                    if (StationInfo.FloorNumber != "FF") throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戠殑妤煎眰涓庝换鍔$被鍨嬫ゼ灞備笉鍖归厤");
+
+                    var ionInfo = _stationMangerService.Repository.QueryFirst(x => x.StationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐圭珯鍙般�恵taskDTO.fromLocationCode}銆戯紒");
+                    if (ionInfo.Remark != taskDTO.containerCode) throw new Exception($"璧风偣绔欏彴銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵ionInfo.Remark}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+                    
+                    dt_Task = new Dt_Task()
+                    {
+                        TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                        WMSTaskNum = taskDTO.taskCode,
+                        //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                        Grade = taskDTO.taskPriority,
+                        PalletCode = taskDTO.containerCode,
+                        Roadway = "1",
+                        TaskState = (int)TaskStatusEnum.New,
+                        TaskType = taskType,
+                        SourceAddress = taskDTO.fromLocationCode,
+                        CurrentAddress = taskDTO.fromLocationCode,
+                        NextAddress = taskDTO.toLocationCode,
+                        TargetAddress = taskDTO.toLocationCode,
+                        Creater = "WMS",
+                    };
+                }
+                try
+                {
+                    Db.Ado.BeginTran();
+                    BaseDal.AddData(dt_Task);
+                    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.Error(ex.Message);
+            }
+            return content;
+        }
+        #endregion
+
+
+        #region 6 瑁佸壀閫佽揣
+        public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
+        {
+            WebResponseContent content = new WebResponseContent();
+            Dt_StationInfo? stationInfo = null;
+            try
+            {
+                #region 鏄惁闇�瑕佸垽鏂钩搴撳簱浣嶇姸鎬�
+                if (taskType == (int)TaskTypeEnum.CK3F|| taskType == (int)TaskTypeEnum.F03)
+                {
+                    stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+                    if (stationInfo.StationName != LocationStatusEnum.Free.ToString()) throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝簱浣嶇姸鎬佷笉鍙叆搴擄紒");
+                }
+                else if (taskType == (int)TaskTypeEnum.RK3F || taskType == (int)TaskTypeEnum.F04)
+                {
+                    stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+                    if (stationInfo.StationName != LocationStatusEnum.InStock.ToString()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+                    if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵stationInfo.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+                }
+                else if(taskType==(int)TaskTypeEnum.F02)
+                {
+                    stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+                    if (stationInfo.StationName != LocationStatusEnum.Free.ToString()) throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝簱浣嶇姸鎬佷笉鍙叆搴擄紒");
+                    stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+                    if (stationInfo.StationName != LocationStatusEnum.InStock.ToString()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+                    if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵stationInfo.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+                }
+                #endregion
+
+                Dt_Task dt_Task = new Dt_Task()
+                {
+                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    WMSTaskNum = taskDTO.taskCode,
+                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    Grade = taskDTO.taskPriority,
+                    PalletCode = taskDTO.containerCode,
+                    Roadway = "",
+                    TaskState = (int)TaskStatusEnum.New,
+                    TaskType = taskType,
+                    SourceAddress = taskDTO.fromLocationCode,
+                    CurrentAddress = taskDTO.fromLocationCode,
+                    NextAddress = taskDTO.toLocationCode,
+                    TargetAddress = taskDTO.toLocationCode,
+                    Creater = "WMS",
+                };
+                content = SendHIKROBOTTask(dt_Task);
+                if (!content.Status) throw new Exception(content.Message);
+                dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+                dt_Task.Dispatchertime = DateTime.Now;
                 BaseDal.AddData(dt_Task);
-                _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)
             {
-                Db.Ado.RollbackTran();
-                throw new Exception(ex.Message);
+                content.Error(ex.Message);
             }
+            return content;
         }
         #endregion
 
-        #region RGV浠诲姟鍒涘缓
-        /// <summary>
-        /// 鍒涘缓鍥涘悜杞﹀叆搴撲换鍔�
-        /// </summary>
-        /// <param name="taskDTO"></param>
-        /// <param name="taskType"></param>
-        /// <returns></returns>
-        public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
+
+        #region 5绌鸿溅杞繍
+        public WebResponseContent HKF01Transport(TaskDTO taskDTO, int taskType)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                Db.Ado.BeginTran();
+                var stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+                if (stationInfo.StationStatus != (int)LocationStatusEnum.InStock) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鏄湁璐э紒");
+                if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"褰撳墠搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵stationInfo.PalletCode}銆戜笌浠诲姟鐨勬枡绠卞彿銆恵taskDTO.containerCode}銆戜笉鍖归厤");
 
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
+
+                var stationInfo2 = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+                if (stationInfo2.StationStatus != (int)LocationStatusEnum.Free) throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鏄┖闂诧紒");
+
+                var dt_Task = new Dt_Task()
+                {
+                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    WMSTaskNum = taskDTO.taskCode,
+                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    Grade = taskDTO.taskPriority,
+                    PalletCode = taskDTO.containerCode,
+                    Roadway = "1",
+                    TaskState = (int)TaskStatusEnum.New,
+                    TaskType = taskType,
+                    SourceAddress = taskDTO.fromLocationCode,
+                    CurrentAddress = taskDTO.fromLocationCode,
+                    NextAddress = taskDTO.toLocationCode,
+                    TargetAddress = taskDTO.toLocationCode,
+                    Creater = "WMS",
+                };
+                content = SendHIKROBOTTask(dt_Task);
+                if (!content.Status) throw new Exception(content.Message);
+                dt_Task.Dispatchertime = DateTime.Now;
+                BaseDal.AddData(dt_Task);
             }
             catch (Exception ex)
             {
-                Db.Ado.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
-            }
-        }
-        /// <summary>
-        /// 鍒涘缓鍥涘悜杞﹀嚭搴撲换鍔�
-        /// </summary>
-        /// <param name="taskDTO"></param>
-        /// <param name="taskType"></param>
-        /// <returns></returns>
-        public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
-        {
-            try
-            {
-                Db.Ado.BeginTran();
 
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
+                content.Error(ex.Message);
             }
-            catch (Exception ex)
-            {
-                Db.Ado.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
-            }
-        }
-        #endregion
-
-        #region 娴峰悍AGV浠诲姟鍒涘缓
-        /// <summary>
-        /// 鍒涘缓娴峰悍AGV鍏ュ簱浠诲姟
-        /// </summary>
-        /// <param name="taskDTO"></param>
-        /// <param name="taskType"></param>
-        /// <returns></returns>
-        public WebResponseContent CreateHKNewInTask(TaskDTO taskDTO, int taskType)
-        {
-            try
-            {
-                Db.Ado.BeginTran();
-
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
-            }
-            catch (Exception ex)
-            {
-                Db.Ado.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
-            }
-        }
-        /// <summary>
-        /// 鍒涘缓娴峰悍AGV鍑哄簱浠诲姟
-        /// </summary>
-        /// <param name="taskDTO"></param>
-        /// <param name="taskType"></param>
-        /// <returns></returns>
-        public WebResponseContent CreateHKNewOutTask(TaskDTO taskDTO, int taskType)
-        {
-            try
-            {
-                Db.Ado.BeginTran();
-
-                Db.Ado.CommitTran();
-                return WebResponseContent.Instance.OK();
-            }
-            catch (Exception ex)
-            {
-                Db.Ado.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
-            }
+            return content;
         }
         #endregion
     }

--
Gitblit v1.9.3