From b72d5964a8031b5f0df3c04d3677d7b0cdb26ba3 Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@DESKTOP-5BIMHQ3> Date: 星期二, 12 三月 2024 11:47:41 +0800 Subject: [PATCH] 修改AGV转运完成功能 --- Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 188 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 168 insertions(+), 20 deletions(-) diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs index 4bb15cd..8c8c157 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs @@ -6,11 +6,13 @@ using Model.ModelDto.PdaDto; using SqlSugar; using WMS.BLL.LogServer; +using WMS.DAL; using WMS.Entity.BllAsnEntity; using WMS.Entity.BllCheckEntity; using WMS.Entity.BllSoEntity; using WMS.Entity.Context; using WMS.Entity.DataEntity; +using WMS.Entity.LogEntity; using WMS.Entity.SysEntity; using WMS.IBLL.IPdaServer; @@ -293,6 +295,17 @@ checkDetail.RealQty = qty; } checkDetail.CheckResult = 1; + var checkInfo = Db.Queryable<BllStockCheckLog>().First(m => + m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo); + checkInfo.RealQty = qty; + checkInfo.CheckResult = 1; + + checkInfo.CheckUserId = userId; + checkInfo.CheckDate = time; + + checkInfo.UpdateUser = userId; + checkInfo.UpdateTime = time; + Db.Updateable(checkInfo).ExecuteCommand(); Db.Updateable(checkDetail).ExecuteCommand(); Db.Updateable(list).ExecuteCommand(); } @@ -869,12 +882,36 @@ { throw new Exception("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�"); } + if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku)) + { + throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�"); + } try { + string EndLocat = string.Empty;//鐩爣浣嶇疆 + var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); if (stockDetail == null) { - throw new Exception("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); + 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); + } + else + { + EndLocat = ruku; + } + var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo); + if (stock == null) + { + throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!"); } if (string.IsNullOrEmpty(stockDetail.LocatNo)) { @@ -891,23 +928,50 @@ } //寮�鍚簨鍔� Db.BeginTran(); + + //娣诲姞鍑哄簱浠诲姟 + var taskNo = new Common().GetMaxNo("TK"); + var exTask = new LogTask + { + TaskNo = taskNo, + Sender = "WMS", + Receiver = "AGV", + IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛 + + StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆 + EndLocat = EndLocat,//鐩爣浣嶇疆 + PalletNo = palletNo,//鎵樼洏鐮� + IsSend = 1,//鏄惁鍙啀娆′笅鍙� + IsCancel = 1,//鏄惁鍙彇娑� + IsFinish = 1,//鏄惁鍙畬鎴� + Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟 + Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚 + OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗� + + CreateTime = DateTime.Now + }; + Db.Insertable(exTask).ExecuteCommand(); + //淇敼搴撳瓨鏄庣粏淇℃伅 - stockDetail.WareHouseNo = ""; - stockDetail.RoadwayNo = ""; - stockDetail.AreaNo = ""; - stockDetail.LocatNo = ""; - + stockDetail.Status = "4";//绉诲簱閿佸畾 + stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺 Db.Updateable(stockDetail).ExecuteCommand(); - //淇敼鍌ㄤ綅鍦板潃鐘舵�� - storageLocat.Status = "0";//绌哄偍浣� + //淇敼搴撳瓨淇℃伅 + stock.LockQty += (decimal)stockDetail.Qty; + Db.Updateable(stock).ExecuteCommand(); + //淇敼鍌ㄤ綅鍦板潃鐘舵�� + storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocat).ExecuteCommand(); + + //娣诲姞鎿嶄綔鏃ュ織璁板綍 + var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); + //鎻愪氦浜嬪姟 + Db.CommitTran(); #region 鍛煎彨灏忚溅浠g爜 #endregion - //鎻愪氦浜嬪姟 - Db.CommitTran(); } catch (Exception ex) { @@ -951,7 +1015,12 @@ var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); if (stockDetail == null) { - throw new Exception("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); + throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!"); + } + var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo); + if (stock == null) + { + throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!"); } if (string.IsNullOrEmpty(stockDetail.LocatNo)) { @@ -966,25 +1035,59 @@ { throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } + var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo); + if (storageArea == null) + { + throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!"); + } + string EndLocat = string.Empty;//鐩爣浣嶇疆 + EndLocat= GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo); //寮�鍚簨鍔� Db.BeginTran(); + + //娣诲姞鍑哄簱浠诲姟 + var taskNo = new Common().GetMaxNo("TK"); + var exTask = new LogTask + { + TaskNo = taskNo, + Sender = "WMS", + Receiver = "AGV", + IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛 + + StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆 + EndLocat = EndLocat,//鐩爣浣嶇疆 + PalletNo = palletNo,//鎵樼洏鐮� + IsSend = 1,//鏄惁鍙啀娆′笅鍙� + IsCancel = 1,//鏄惁鍙彇娑� + IsFinish = 1,//鏄惁鍙畬鎴� + Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟 + Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚 + OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗� + + CreateTime = DateTime.Now + }; + Db.Insertable(exTask).ExecuteCommand(); + //淇敼搴撳瓨鏄庣粏淇℃伅 - stockDetail.WareHouseNo = ""; - stockDetail.RoadwayNo = ""; - stockDetail.AreaNo = ""; - stockDetail.LocatNo = ""; - + stockDetail.Status = "4";//绉诲簱閿佸畾 + stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺 Db.Updateable(stockDetail).ExecuteCommand(); - //淇敼鍌ㄤ綅鍦板潃鐘舵�� - storageLocat.Status = "0";//绌哄偍浣� + //淇敼搴撳瓨淇℃伅 + stock.LockQty += (decimal)stockDetail.Qty; + Db.Updateable(stock).ExecuteCommand(); + //淇敼鍌ㄤ綅鍦板潃鐘舵�� + storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocat).ExecuteCommand(); + + //娣诲姞鎿嶄綔鏃ュ織璁板綍 + var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); + //鎻愪氦浜嬪姟 + Db.CommitTran(); #region 鍛煎彨灏忚溅浠g爜 #endregion - //鎻愪氦浜嬪姟 - Db.CommitTran(); } catch (Exception ex) { @@ -992,6 +1095,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) + { + 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) + .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 => new { m.Layer, m.Column, m.Row }).First(); + + if (locatInfo3 != null) + { + endLocat = locatInfo3.LocatNo; + } + } + return endLocat; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } #endregion } -- Gitblit v1.8.0