From 964db60bb3d2e9a0a695b71554a98765e900732a Mon Sep 17 00:00:00 2001 From: yuyou_x <2336760928@qq.com> Date: 星期六, 16 三月 2024 10:58:34 +0800 Subject: [PATCH] Merge branch 'yyk' --- Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 104 insertions(+), 14 deletions(-) diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs index 958d468..7b98079 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs @@ -885,22 +885,33 @@ if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku)) { throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�"); - } - string EndLocat = string.Empty;//鐩爣浣嶇疆 - if (!string.IsNullOrEmpty(areaNo)) - { - EndLocat = areaNo; - } - else - { - EndLocat = ruku; - } + } try { + string EndLocat = string.Empty;//鐩爣浣嶇疆 + + var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1")); + if (log != null) + { + throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!"); + } var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); if (stockDetail == null) { throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!"); + } + if (!string.IsNullOrEmpty(areaNo)) + { + var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo); + if (storageArea == null) + { + throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!"); + } + EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo); + } + else + { + EndLocat = ruku; } var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo); if (stock == null) @@ -915,11 +926,23 @@ { throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!"); } + //璧峰鍌ㄤ綅淇℃伅 var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo); if (storageLocat == null) { throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } + //鐩爣鍌ㄤ綅淇℃伅 + var storageLocatEnd = new SysStorageLocat(); + if (!string.IsNullOrEmpty(areaNo)) + { + storageLocatEnd = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0"); + if (storageLocatEnd == null) + { + throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); + } + } + //寮�鍚簨鍔� Db.BeginTran(); @@ -954,10 +977,16 @@ stock.LockQty += (decimal)stockDetail.Qty; Db.Updateable(stock).ExecuteCommand(); - //淇敼鍌ㄤ綅鍦板潃鐘舵�� - storageLocat.Status = "3";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 + //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵�� + storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocat).ExecuteCommand(); + //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵�� + if (storageLocatEnd != null) + { + storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 + Db.Updateable(storageLocatEnd).ExecuteCommand(); + } //娣诲姞鎿嶄綔鏃ュ織璁板綍 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); //鎻愪氦浜嬪姟 @@ -996,6 +1025,12 @@ } try { + var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1")); + if (log != null) + { + throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!"); + } + var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo); if (notice == null) { @@ -1035,7 +1070,13 @@ throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!"); } string EndLocat = string.Empty;//鐩爣浣嶇疆 - EndLocat= Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.AreaNo==storageArea.AreaNo && w.Status=="0" &&w.Flag=="0").Select(s=>s.LocatNo).First(); + EndLocat= GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo); + //鐩爣鍌ㄤ綅淇℃伅 + var storageLocatEnd = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0"); + if (storageLocatEnd == null) + { + throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); + } //寮�鍚簨鍔� Db.BeginTran(); @@ -1071,8 +1112,12 @@ Db.Updateable(stock).ExecuteCommand(); //淇敼鍌ㄤ綅鍦板潃鐘舵�� - storageLocat.Status = "3";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 + storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocat).ExecuteCommand(); + + //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵�� + storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 + Db.Updateable(storageLocatEnd).ExecuteCommand(); //娣诲姞鎿嶄綔鏃ュ織璁板綍 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); @@ -1089,6 +1134,51 @@ throw new Exception(ex.Message); } } + /// <summary> + /// 鏍规嵁鍖哄煙鍒嗛厤鍌ㄤ綅 + /// </summary> + /// <param name="areaNo"></param> + /// <param name="skuNo"></param> + /// <param name="lotNo"></param> + /// <returns></returns> + private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo) + { + try + { + string endLocat = string.Empty;//鐩爣鍌ㄤ綅 + //褰撶劧鍖哄煙鎵�鏈夊偍浣嶄俊鎭� + var storageLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToList(); + //鍚屽尯鍩熷悓鎵规鐗╂枡鐨勫偍浣嶄俊鎭� + List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo) + .OrderByDescending(o=>o.LocatNo).Select(s=>s.LocatNo).Distinct().ToList(); + foreach (var item in locatList) + { + var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First(); + + var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.LocatNo != locatInfo.LocatNo && w.Row == locatInfo.Row) + .OrderByDescending(o => o.Column).First(); + if (locatInfo2 != null) + { + endLocat = locatInfo2.LocatNo; + } + } + if (string.IsNullOrEmpty(endLocat)) + { + var locatInfo3 = 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 (locatInfo3 != null) + { + endLocat = locatInfo3.LocatNo; + } + } + return endLocat; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } #endregion } -- Gitblit v1.8.0