| | |
| | | { |
| | | decimal needQuantity = item.XqLen; |
| | | //è·åå¯ç¨åºå |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterialNo, item.Width, outBSTOrders.FirstOrDefault().WarehouseId); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterialNo, item.Width, outBSTOrders.FirstOrDefault().WarehouseId).Where(x=>!outStocks.Select(x=>x.PalletCode).Contains(x.PalletCode)).ToList(); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°å¯åé
åºå"); |
| | | continue; |
| | | } |
| | | //åé
å®é
åºå |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, needQuantity).OrderBy(x => x.StockLength - x.StockOutLength).ToList(); |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutOldStocks(stockInfos, needQuantity).ToList(); |
| | | //æ·»å åºååé
|
| | | outStocks.AddRange(autoAssignStocks); |
| | | //è·åææè¯¥ç©æåæ® |
| | |
| | | |
| | | decimal orderDetailNeedQuantity = details[i].XqLen - detailAssignQuantity; |
| | | |
| | | if (autoAssignStocks.Count==0) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | decimal useStockLength = autoAssignStocks[0].StockLength- autoAssignStocks[0].StockOutLength; |
| | | Dt_OutSGOrder? sGOrder = outBSTOrders.FirstOrDefault(x => x.Id == details[i].OutSGOrderId); |
| | | if (orderDetailNeedQuantity > useStockLength) |
| | | { |
| | | |
| | | //çæè¯¦æ
|
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(sGOrder, details[i], autoAssignStocks[0], useStockLength); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | details[i].AssignTotalUsage += useStockLength; |
| | | autoAssignStocks.Remove(autoAssignStocks[0]); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(sGOrder, details[i], autoAssignStocks[0], orderDetailNeedQuantity); |
| | | outStockLockInfos.Add(outStockLockInfo); |
| | | details[i].AssignTotalUsage = orderQuantity; |
| | | autoAssignStocks[0].StockOutLength-= orderDetailNeedQuantity; |
| | | autoAssignStocks[0].StockOutLength+= orderDetailNeedQuantity; |
| | | if (autoAssignStocks[0].StockOutLength== autoAssignStocks[0].StockLength) |
| | | { |
| | | autoAssignStocks.Remove(autoAssignStocks[0]); |
| | | } |
| | | assignStop =false; |
| | | } |
| | | } |