From 8f7e6826d51a25c7b368c210dbb321d423d24a85 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期一, 10 十一月 2025 17:24:12 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs |   78 ++++++++++++++++++++++++++-------------
 1 files changed, 52 insertions(+), 26 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 3346e80..93056e6 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"
@@ -490,6 +490,12 @@
         WebResponseContent content = new WebResponseContent();
         try
         {
+            var task = BaseDal.QueryFirst(x => x.PalletCode == taskDto.PalletCode);
+            if (task != null)
+            {
+                return content.Error("璇ユ墭鐩樺凡缁忓瓨鍦ㄤ换鍔★紝璇峰嬁閲嶅涓嬪彂");
+            }
+
             var boxingInfo = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == taskDto.PalletCode && x.StockStatus == (int)StockStateEmun.缁勭洏鏆傚瓨);
 
             if (boxingInfo == null)
@@ -983,7 +989,7 @@
         }
         if (!LocationIsOutBound(StartAddress))
         {
-            throw new Exception($"璧风偣搴撲綅{StartAddress.LocationCode}鍑哄簱璺緞琚崰鐢紝璇蜂汉宸ョ‘璁ゅ啀涓嬪彂浠诲姟");
+            throw new Exception($"璧风偣搴撲綅{StartAddress.LocationCode}鍑哄簱璺緞琚崰鐢紝璇风◢鍚庨噸璇�");
         }
         DtLocationInfo location = null;
         if (taskDto.AreaId != 0)
@@ -1255,6 +1261,10 @@
                 //todo鏌ヨ鍐呬晶搴撳瓨淇℃伅
                 var stock = await _stockInfoRepository.QueryFirstAsync(x => x.LocationCode == locationLateral.LocationCode);
 
+                if (stock == null)
+                {
+                    return content.Error($"鏈壘鍒版祬浣峽locationLateral.LocationCode}搴撳瓨淇℃伅");
+                }
                 Dt_Task taskNew = new Dt_Task
                 {
                     Grade = 1,
@@ -1277,7 +1287,6 @@
                 var taskDTO = CreateListTaskDTO(taskNew);
 
                 var isResult = await AddTaskAsync(taskNew, locationLateral, TargetAddress);
-                //UpdateLocationStatus(TargetAddress, LocationEnum.Lock);
                 UpdateLocationStatus(TargetAddress, LocationEnum.Lock, taskNew.TaskNum.Value, (int)StatusChangeTypeEnum.AutomaticRelocation);
                 if (!isResult)
                 {
@@ -1350,28 +1359,43 @@
                         return content.Error("璧风偣鏈畾涔夋垨缁堢偣鍖哄煙鏈壘鍒扮┖闂插簱浣�");
                     }
                     //todo鏌ヨ绉诲簱搴撳瓨淇℃伅
-
-                    Dt_Task taskNew = new Dt_Task
+                    var stock = _stockInfoRepository.QueryFirst(x => x.LocationCode == item.LocationCode);
+                    if (stock == null)
                     {
-                        Grade = item.Column,
-                        Roadway = "AGV",
-                        TargetAddress = Targetlocation.LocationCode,
-                        Dispatchertime = DateTime.Now,
-                        MaterialNo = "",
-                        NextAddress = Targetlocation.LocationCode,
-                        OrderNo = null,
-                        PalletCode = _random.Next(0, 10000).ToString(),
-                        SourceAddress = item.LocationCode,
-                        CurrentAddress = item.LocationCode,
-                        TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
-                        TaskType = (int)TaskRelocationTypeEnum.Relocation,
-                        TaskNum = BaseDal.GetTaskNo().Result,
-                        CreateDate = DateTime.Now,
-                        TaskId = 0,
-                        AGVTaskNum = GenerateUniqueId(),
-                        Floor = item.Floor,
-                        Remark = item.AreaId.ToString(),
-                    };
+                        return content.Error($"鏈壘鍒版祬浣峽item.LocationCode}搴撳瓨淇℃伅");
+                    }
+                    var Relocationtask = BaseDal.QueryFirst(x => x.PalletCode == stock.PalletCode && x.TaskType == (int)TaskRelocationTypeEnum.Relocation);
+                    Dt_Task taskNew = new Dt_Task();
+                    if (Relocationtask != null)
+                    {
+                        taskDTO.Add(CreateTaskDTO(Relocationtask));
+                        //return content.OK(data:taskDTO);
+                        continue;
+                    }
+                    else
+                    {
+                        taskNew = new Dt_Task
+                        {
+                            Grade = item.Column,
+                            Roadway = "AGV",
+                            TargetAddress = Targetlocation.LocationCode,
+                            Dispatchertime = DateTime.Now,
+                            MaterialNo = "",
+                            NextAddress = Targetlocation.LocationCode,
+                            OrderNo = null,
+                            PalletCode = stock.PalletCode,
+                            SourceAddress = item.LocationCode,
+                            CurrentAddress = item.LocationCode,
+                            TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
+                            TaskType = (int)TaskRelocationTypeEnum.Relocation,
+                            TaskNum = BaseDal.GetTaskNo().Result,
+                            CreateDate = DateTime.Now,
+                            TaskId = 0,
+                            AGVTaskNum = GenerateUniqueId(),
+                            Floor = item.Floor,
+                            Remark = item.AreaId.ToString(),
+                        };
+                    }
                     taskDTO.Add(CreateTaskDTO(taskNew));
 
                     var isResult = await AddTaskAsync(taskNew, item, Targetlocation);
@@ -2079,6 +2103,7 @@
             TaskState = task.TaskState,
             Id = 0,
             TaskType = task.TaskType,
+            Floor =task.Floor,
             AGVTaskNum = task.AGVTaskNum,
         } };
     }
@@ -2097,7 +2122,8 @@
             Id = 0,
             TaskType = task.TaskType,
             AGVTaskNum = task.AGVTaskNum,
-            Remark= task.Remark
+            Remark = task.Remark,
+            Floor = task.Floor,
         };
     }
 
@@ -2281,7 +2307,7 @@
                 TaskNum = task.TaskNum.Value,
                 LocationId = StartAddress.Id,
                 LocationCode = StartAddress.LocationCode,
-                ChangeType = (int)StatusChangeTypeEnum.AutomaticInbound,
+                ChangeType = (int)StatusChangeTypeEnum.AutomaticRelocation,
             },
             new LocationChangeRecordDto()
             {
@@ -2290,7 +2316,7 @@
                 TaskNum = task.TaskNum.Value,
                 LocationId = EndAddress.Id,
                 LocationCode = EndAddress.LocationCode,
-                ChangeType = (int)StatusChangeTypeEnum.AutomaticInbound,
+                ChangeType = (int)StatusChangeTypeEnum.AutomaticRelocation,
             },
         };
 

--
Gitblit v1.9.3