From e5642daf4b6820d0706967e486b16e8d33a46d6d Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期四, 26 十二月 2024 14:37:52 +0800
Subject: [PATCH] 1

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index af55b8a..85c1e58 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -865,7 +865,15 @@
         {
             Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call");
 
-            DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == station.productLine);
+            var stockInfo = _stockInfoRepository.Db.Queryable<DtStockInfo>()
+                    .Includes(x => x.LocationInfo) // 棰勫姞杞絃ocationInfo
+                    .Includes(x => x.StockInfoDetails) // 棰勫姞杞絊tockInfoDetails
+                    .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true) // 杩囨护鏉′欢
+                    .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock) // 杩囨护鏉′欢
+                    .OrderBy(x => x.OutboundTime) // 鎺掑簭
+                    .First(); // 鑾峰彇绗竴涓厓绱�
+
+            //DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == station.productLine);
             if (stockInfo == null) throw new Exception("搴撳唴鏃犳弧瓒虫潯浠剁殑搴撳瓨鍙嚭搴�");
 
             DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode);
@@ -875,7 +883,7 @@
             // 鍒涘缓鏂颁换鍔″疄渚�
             var task = new Dt_Task
             {
-                CurrentAddress = locationInfo.RoadwayNo,
+                CurrentAddress = stockInfo.LocationCode,
                 Grade = 1,
                 Roadway = locationInfo.RoadwayNo,
                 TargetAddress = json.Position,
@@ -893,6 +901,9 @@
 
             WMSTaskDTO taskDTO = CreateTaskDTO(task);
 
+            BaseDal.AddData(task);
+            stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
+            _locationRepository.UpdateData(stockInfo.LocationInfo);
 
             return content.OK(data: taskDTO);
         }
@@ -916,7 +927,7 @@
 
             if (emergencyTask == null) throw new Exception("鐏鍙傛暟涓虹┖");
 
-            DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.Row == emergencyTask.row && x.Column == emergencyTask.column && x.Layer == emergencyTask.layer && x.RoadwayNo == emergencyTask.Roadway);
+            DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.Row == emergencyTask.row && x.Column == emergencyTask.column && x.Layer == emergencyTask.layer && x.AreaId == emergencyTask.zone);
             if (locationInfo == null)
             {
                 throw new Exception("鏈煡搴撲綅");

--
Gitblit v1.9.3