| | |
| | | } |
| | | try |
| | | { |
| | | string EndLocat = string.Empty;//目标位置 |
| | | string EndLocat = string.Empty;//目标位置 |
| | | |
| | | 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); |
| | |
| | | { |
| | | throw new Exception("所选区域信息不存在,请检查!"); |
| | | } |
| | | 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); |
| | | } |
| | | else |
| | | { |
| | | EndLocat = ruku; |
| | | } |
| | | |
| | | var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); |
| | | if (stockDetail == null) |
| | | { |
| | | throw new Exception("托盘上物料库存明细信息不存在,请检查!"); |
| | | } |
| | | var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo); |
| | | if (stock == null) |
| | |
| | | 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(); |
| | | |
| | | //添加操作日志记录 |
| | |
| | | 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); |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | |
| | |
| | | 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(); |
| | | |
| | | //添加操作日志记录 |
| | |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | 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 |
| | | |
| | | } |