From a9513fe0529abf7d63a955b83a4e784ce531be4b Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期三, 10 九月 2025 08:58:25 +0800
Subject: [PATCH] PDA AGV转运功能增加货架库到平库转运

---
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs |   51 +++++++++++++++++++++++++++++++++++----------------
 1 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 89f6e78..581136c 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -691,9 +691,9 @@
             {
                 throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
             }
-            if (models.WareHouseNo != "W04")
+            if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
             {
-                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴鎴栬揣鏋跺簱鍐�,璇锋鏌�!");
             }
             return models.LocatNo;
         }
@@ -721,7 +721,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (models.WareHouseNo != "W04")
+                if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -731,8 +731,14 @@
                     throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
 
-                
-                storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+                if (models.WareHouseNo == "W02")
+                {
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04" && (w.AreaNo == "B01" || w.AreaNo == "B02")).OrderBy(o => o.AreaNo).ToListAsync();
+                }
+                else
+                {
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+                }
                 
             }
             return storageArea;
@@ -829,7 +835,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (stockDetail.WareHouseNo != "W04")
+                if (stockDetail.WareHouseNo != "W04" && stockDetail.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -1001,9 +1007,13 @@
                 }
                 //鏍规嵁鐩爣鍖哄煙鑾峰彇鐩爣鍌ㄤ綅鍦板潃
                 EndLocat = await GetLocat(areaNo);
+                if (string.IsNullOrEmpty(EndLocat))
+                {
+                    throw Oops.Bah("鑾峰彇鐩爣鍌ㄤ綅澶辫触!");
+                }
                 
                 //璧峰鍌ㄤ綅淇℃伅
-                var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+                var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == locatNo);
                 if (storageLocat == null)
                 {
                     throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
@@ -1026,10 +1036,10 @@
                     Receiver = "WCS",
                     IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
 
-                    StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+                    StartLocat = storageLocat.LocatNo,//璧峰浣嶇疆
                     EndLocat = EndLocat,//鐩爣浣嶇疆
                     PalletNo = palletNo,//鎵樼洏鐮�
-                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", stockDetail.LocatNo, EndLocat),
+                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", storageLocat.LocatNo, EndLocat),
                     IsSend = 1,//鏄惁鍙啀娆′笅鍙�
                     IsCancel = 1,//鏄惁鍙彇娑�
                     IsFinish = 1,//鏄惁鍙畬鎴�
@@ -1046,11 +1056,11 @@
                 await Db.Updateable(storageLocat).ExecuteCommandAsync();
 
                 //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
-                if (storageLocatEnd != null)
-                {
-                    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
-                    await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
-                }
+                //if (storageLocatEnd != null)
+                //{
+                //    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                //    await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+                //}
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV绌烘墭杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
 
@@ -1265,9 +1275,18 @@
             string endLocat = string.Empty;//鐩爣鍌ㄤ綅
             //褰撳墠鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
             var storageLocatList = await Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W04" && w.AreaNo == areaNo).ToListAsync();
-           
-            var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+
+            var locatInfo2 = new SysStorageLocat();
+            if (areaNo == "B10")
+            {
+                locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0")
                            .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+            }
+            else
+            {
+                locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+                               .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+            }            
 
             if (locatInfo2 != null)
             {

--
Gitblit v1.8.0