| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Enums; |
| | |
| | | residueQuantity = needQuantity; |
| | | return outStocks; |
| | | } |
| | | //PP大å·åºåºï¼æ°ï¼ |
| | | public List<Dt_StockInfo> GetOutboundPPStocks(List<Dt_StockInfo> stockInfos, string materielCode, float needQuantity, out float residueQuantity,string targetAddressCode = "") |
| | | { |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | stockInfos = stockInfos.OrderBy(x => |
| | | x.WarehouseId == WarehouseEnum.HA581.ObjToInt()? 0 : |
| | | x.WarehouseId == WarehouseEnum.HA58.ObjToInt()? 1 : |
| | | 2 |
| | | ).ToList(); |
| | | |
| | | public List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, int warehoseId) |
| | | // è®¡ç®æ»å¯ç¨åºåï¼ä»
ç»è®¡æå®ç©æç¼ç ï¼ |
| | | float stockTotalQuantity = stockInfos |
| | | .Select(x => x.Details |
| | | .Where(d => d.MaterielCode == materielCode) |
| | | .Sum(v => v.StockQuantity - v.OutboundQuantity) |
| | | ).Sum(x => x); |
| | | |
| | | if (stockTotalQuantity >= needQuantity)//åºåå¤ |
| | | { |
| | | int index = 0; |
| | | while (needQuantity > 0 && index < stockInfos.Count) |
| | | { |
| | | Dt_StockInfo stockInfo = stockInfos[index]; |
| | | decimal useableStockQuantity = stockInfo.Details |
| | | .Where(x => x.MaterielCode == materielCode) |
| | | .Sum(x => (decimal)x.StockQuantity - (decimal)x.OutboundQuantity); |
| | | |
| | | if (useableStockQuantity < (decimal)needQuantity && useableStockQuantity > 0) |
| | | { |
| | | // å¯ç¨éä¸è¶³ï¼å
¨é¨åºåº |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | if (x.MaterielCode == materielCode) |
| | | x.OutboundQuantity = x.StockQuantity; |
| | | }); |
| | | needQuantity = (float)((decimal)needQuantity - useableStockQuantity); |
| | | } |
| | | else if (useableStockQuantity > 0) |
| | | { |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode) |
| | | { |
| | | decimal currentStock = (decimal)x.StockQuantity; |
| | | decimal currentOutbound = (decimal)x.OutboundQuantity; |
| | | decimal currentNeed = (decimal)needQuantity; |
| | | decimal available = currentStock - currentOutbound; |
| | | |
| | | if (available >= currentNeed) |
| | | { |
| | | x.OutboundQuantity = (float)(currentOutbound + currentNeed); |
| | | needQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | needQuantity = (float)(currentNeed - available); |
| | | x.OutboundQuantity = x.StockQuantity; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | // ä»
å°æå®é
åºåºçåºåå å
¥ç»æé |
| | | if (useableStockQuantity > 0) |
| | | { |
| | | stockInfo.Remark = targetAddressCode; |
| | | outStocks.Add(stockInfo); |
| | | } |
| | | |
| | | index++; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("åºåä¸è¶³"); |
| | | } |
| | | residueQuantity = needQuantity; |
| | | return outStocks; |
| | | } |
| | | |
| | | public List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, int warehoseId) |
| | | { |
| | | if ((materielCode.Equals("405000585")|| materielCode.Equals("405000831") || materielCode.Equals("405005565") || materielCode.Equals("405405097") || materielCode.Equals("405005461")) && warehoseId == 5) |
| | | { |
| | |
| | | |
| | | return BaseDal.GetStockInfos(materielCode, batchNo, locationCodes); |
| | | } |
| | | //PP大å·åºåº(æ°) |
| | | public List<Dt_StockInfo> GetUseablePPStocks(string materielCode, string batchNo, int warehoseId) |
| | | { |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutPPLocationCodes(warehoseId); |
| | | |
| | | return BaseDal.GetStockInfos(materielCode, batchNo, locationCodes); |
| | | } |
| | | |
| | | public List<Dt_StockInfo> GetUseableStocks(string materielCode, string batchNo, string palletcode, int warehoseId) |
| | | { |