From a3236b51b5691b8c47f4ebaf1d885314a4bab3bd Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期二, 13 八月 2024 11:17:18 +0800 Subject: [PATCH] 拼箱功能开发 --- Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 145 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 118 insertions(+), 27 deletions(-) diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs index f2b8b13..7c9a782 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs @@ -5,6 +5,7 @@ using Model.ModelDto.BllCheckDto; using Model.ModelDto.PdaDto; using SqlSugar; +using Utility; using WMS.BLL.LogServer; using WMS.DAL; using WMS.Entity.BllAsnEntity; @@ -177,15 +178,15 @@ { if (string.IsNullOrWhiteSpace(crNo)) { - throw new Exception("鐩樼偣鍗曟嵁涓嶈兘涓虹┖"); + throw Oops.Bah("鐩樼偣鍗曟嵁涓嶈兘涓虹┖"); } if (string.IsNullOrWhiteSpace(crDetail)) { - throw new Exception("鐗╂枡鎵规涓嶈兘涓虹┖"); + throw Oops.Bah("鐗╂枡鎵规涓嶈兘涓虹┖"); } if (string.IsNullOrWhiteSpace(palletNo)) { - throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�"); + throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�"); } //绠辩爜涓虹┖ 鏄暣鎵樿鐩樼偣鐨勯兘姝e父 var detail = crDetail.Split("-"); @@ -196,7 +197,16 @@ m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo); if (checkDetail == null) { - throw new Exception("鏈煡璇㈠埌鏈洏鐐圭殑鐩樼偣鏄庣粏淇℃伅"); + throw Oops.Bah("鏈煡璇㈠埌鏈洏鐐圭殑鐩樼偣鏄庣粏淇℃伅"); + } + var modSku = Db.Queryable<SysMaterials>().Where(s => s.SkuNo == sku).First(); + if (modSku.IsPasteCode == "1" && isContinue == "1") + { + throw Oops.Bah("璐存爣鐗╂枡涓嶅厑璁告暟閲忕洏鐐�"); + } + else if (modSku.IsPasteCode == "0" && isContinue == "0") + { + throw Oops.Bah("涓嶈创鏍囩墿鏂欒浣跨敤鏁伴噺鐩樼偣"); } //鐩樼偣璁板綍 var checkLog = Db.Queryable<BllStockCheckLog>().Where(m => @@ -216,7 +226,7 @@ if (checkLog.Count() == 0 && isContinue == "0") { - throw new Exception("鏈煡璇㈠埌鏈洏鐐圭殑绠辨敮淇℃伅"); + throw Oops.Bah("鏈煡璇㈠埌鏈洏鐐圭殑绠辨敮淇℃伅"); } var list = checkLog.ToList(); @@ -232,7 +242,7 @@ l.CheckDate = time; l.CheckUserId = userId; - num += int.Parse(l.Qty.ToString()); + num += Convert.ToInt32(l.Qty); } if (checkDetail.RealQty == null) @@ -262,7 +272,7 @@ if (checkLog.Count() == 0 && isContinue == "0") { - throw new Exception("鏈煡璇㈠埌绠辨敮淇℃伅"); + throw Oops.Bah("鏈煡璇㈠埌绠辨敮淇℃伅"); } // @@ -270,7 +280,7 @@ { if (qty == null || qty <= 0) { - throw new Exception("鏁伴噺鐩樼偣鏃躲�佺洏浜忔暟閲忎笉鑳戒负绌轰笖闇�澶т簬0"); + throw Oops.Bah("鏁伴噺鐩樼偣鏃躲�佺洏浜忔暟閲忎笉鑳戒负绌轰笖闇�澶т簬0"); } } @@ -283,7 +293,7 @@ l.CheckResult = 1; l.CheckDate = time; l.CheckUserId = userId; - num -= int.Parse(l.RealQty.ToString()); + num -= Convert.ToInt32(l.RealQty); } if (checkDetail.RealQty == null) { @@ -316,12 +326,12 @@ { if (string.IsNullOrWhiteSpace(boxNo) || string.IsNullOrWhiteSpace(boxNo3)) { - throw new Exception("鐩樼泩鏃剁鐮佷笌鏀爜涓嶈兘涓虹┖"); + throw Oops.Bah("鐩樼泩鏃剁鐮佷笌鏀爜涓嶈兘涓虹┖"); } } if (qty == null || qty <= 0) { - throw new Exception("鐩樼泩鏃舵暟閲忎笉鑳戒负绌轰笖闇�澶т簬0"); + throw Oops.Bah("鐩樼泩鏃舵暟閲忎笉鑳戒负绌轰笖闇�澶т簬0"); } if (isContinue == "0") { @@ -331,7 +341,7 @@ .Count(m => m.IsDel == "0" && m.BoxNo == boxNo && m.BoxNo3 == boxNo3); if (count > 0 || count2 > 0) { - throw new Exception("褰撳墠搴撳瓨涓凡瀛樺湪璇ョ鏀俊鎭�"); + throw Oops.Bah("褰撳墠搴撳瓨涓凡瀛樺湪璇ョ鏀俊鎭�"); } } BllStockCheckLog crLog = new BllStockCheckLog(); @@ -395,7 +405,7 @@ else { Db.RollbackTran(); - throw new Exception("鐩樼偣缁撴灉涓嶇锛岃鏍稿疄锛�"); + throw Oops.Bah("鐩樼偣缁撴灉涓嶇锛岃鏍稿疄锛�"); } var checkLogNum = Db.Queryable<BllStockCheckLog>().Where(m => m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo); if (checkLogNum.Count(m => m.CheckResult == null) == 0) @@ -776,7 +786,7 @@ var storageArea = new List<SysStorageArea>(); if (string.IsNullOrEmpty(palletNo)) { - storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o=>o.AreaNo).ToList(); + storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); } else { @@ -798,7 +808,7 @@ { throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } - + if (storageLocat.AreaNo.Contains("B0")) { storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B0") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); @@ -807,7 +817,7 @@ { storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B1") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); } - } + } return storageArea; } catch (Exception ex) @@ -893,7 +903,7 @@ if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku)) { throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�"); - } + } try { string EndLocat = string.Empty;//鐩爣浣嶇疆 @@ -902,7 +912,7 @@ if (log != null) { throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!"); - } + } var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); if (stockDetail == null) { @@ -915,7 +925,7 @@ { throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!"); } - EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo); + EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo, palletNo); } else { @@ -950,7 +960,7 @@ throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } } - + //寮�鍚簨鍔� Db.BeginTran(); @@ -995,7 +1005,7 @@ { storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocatEnd).ExecuteCommand(); - } + } //娣诲姞鎿嶄綔鏃ュ織璁板綍 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); //鎻愪氦浜嬪姟 @@ -1018,7 +1028,7 @@ /// <param name="palletNo"></param> /// <param name="areaNo"></param> /// <param name="userId"></param> - public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId) + public void AgvTransport2(string soNo, string palletNo, string areaNo, int userId) { if (string.IsNullOrEmpty(soNo)) { @@ -1054,7 +1064,7 @@ string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')"; stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList(); } - if (stockDetailList.Count<=0) + if (stockDetailList.Count <= 0) { throw new Exception("鎵樼洏鏄庣粏涓嶅瓨鍦�,璇锋鏌�!"); } @@ -1067,7 +1077,7 @@ foreach (var item in stockDetailList) { //浠诲姟淇℃伅 - var logInfo = log.First(w =>w.PalletNo == item.PalletNo); + var logInfo = log.First(w => w.PalletNo == item.PalletNo); if (logInfo != null) { throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}宸叉湁灏忚溅绛夊緟鎵ц鎴栨鍦ㄦ墽琛岀殑浠诲姟!"); @@ -1177,7 +1187,7 @@ /// <param name="skuNo"></param> /// <param name="lotNo"></param> /// <returns></returns> - private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo,string hasLocatNoList="") + private string GetLocat(string areaNo, string skuNo, string lotNo, string palletNo, string hasLocatNoList = "") { try { @@ -1186,7 +1196,7 @@ 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(); + .OrderByDescending(o => o.LocatNo).Select(s => s.LocatNo).Distinct().ToList(); foreach (var item in locatList) { var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First(); @@ -1201,7 +1211,7 @@ if (string.IsNullOrEmpty(endLocat)) { var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0" && !hasLocatNoList.Contains(w.LocatNo)) - .OrderByDescending(m => m.Layer).OrderByDescending(m=>m.Column).OrderByDescending(m=> m.Row).First(); + .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First(); if (locatInfo3 != null) { @@ -1217,5 +1227,86 @@ } #endregion + #region 闆剁瑙g粦 + public void LingxingUnbind(string palletNo,string boxNo, int userId) + { + try + { + if (string.IsNullOrEmpty(palletNo)) + { + throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�"); + } + if (string.IsNullOrEmpty(boxNo)) + { + throw new Exception("绠辩爜涓嶈兘涓虹┖"); + } + //寮�鍚簨鍔� + Db.BeginTran(); + var comTime = DateTime.Now; + + //鎵樼洏搴撳瓨鏄庣粏淇℃伅 + var detail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); + if (detail == null) + { + throw new Exception("璇ユ墭鐩樺簱瀛樻槑缁嗕俊鎭笉瀛樺湪"); + } + //搴撳瓨绠辨敮鏄庣粏淇℃伅 + var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.StockDetailId == detail.Id && w.BoxNo == boxNo).ToList(); + if (boxList.Count <= 0) + { + throw new Exception("璇ョ鐮佸簱瀛樼鏀俊鎭笉瀛樺湪"); + } + decimal boxQty = 0;//绠卞唴鏁伴噺 + foreach (var item in boxList) + { + boxQty += item.Qty; + + item.StockDetailId = 0;//娓呯┖鎵樼洏澶栭敭 + } + //鏇存柊搴撳瓨绠辨敮鏄庣粏琛� + Db.Updateable(boxList).ExecuteCommand(); + + detail.Qty -= boxQty;//鎵樼洏搴撳瓨鏁伴噺 + detail.BitPalletMark = "1";//闆舵墭鏍囪 + //鏇存柊鎵樼洏搴撳瓨琛� + Db.Updateable(detail).ExecuteCommand(); + + //娣诲姞鎵樼洏瑙g粦缁戝畾璁板綍 + var unBind = new BllPalletUnbind() + { + UpbindPalletNo = palletNo, + BindPalletNo = "", + LotNo = detail.LotNo, + LotText = detail.LotText, + SupplierLot = detail.SupplierLot, + SkuNo = detail.SkuNo, + SkuName = detail.SkuName, + Standard = detail.Standard, + Qty = boxQty, + PalletNo2 = detail.PalletNo2, + PalletNo3 = detail.PalletNo3, + BoxNo = boxNo, + InspectNo = "", + InspectStatus = detail.InspectStatus, + + IsDel = "0", + CreateTime = comTime, + CreateUser = userId + }; + Db.Insertable(unBind).ExecuteCommand(); + + //娣诲姞鎿嶄綔鏃ュ織 + new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"闆剁瑙g粦锛氬師鎵樼洏鐮侊細{palletNo}涓婄殑绠辩爜{boxNo}瑙g粦", userId); + //鎻愪氦浜嬪姟 + Db.CommitTran(); + } + catch (Exception e) + { + //鍥炴粴浜嬪姟 + Db.RollbackTran(); + throw new Exception(e.Message); + } + } + #endregion } } -- Gitblit v1.8.0