| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// å个åºåºåæç»åºååé
|
| | | /// </summary> |
| | | /// <param name="outboundOrderDetail"></param> |
| | | /// <param name="stockSelectViews"></param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <returns></returns> |
| | | public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails) |
| | | { |
| | | if (!outboundOrderDetails.Any()) |
| | | { |
| | | throw new Exception($"æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | if (outboundOrderDetails.GroupBy(x => x.OrderId).Count() > 1) |
| | | { |
| | | throw new Exception($"请å¿åæ¶æä½å¤ä¸ªåæ®æç»"); |
| | | } |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, }).ToList(); |
| | | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | foreach (var item in groupDetails) |
| | | { |
| | | float originalNeedQuantity = item.OrderQuantity; |
| | | |
| | | float needQuantity = originalNeedQuantity; |
| | | |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, outboundOrder.WarehouseId); |
| | | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); |
| | | item.LockQuantity += needQuantity - residueQuantity; |
| | | outStocks.AddRange(autoAssignStocks); |
| | | float assignQuantity = needQuantity - residueQuantity; |
| | | //for (int i = 0; i < outboundOrderDetails.Count; i++) |
| | | //{ |
| | | // for (int j = 0; j < outStocks.Count; j++) |
| | | // { |
| | | // if(assignQuantity > 0) |
| | | // { |
| | | // if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= outStocks[j].) |
| | | // { |
| | | |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // if (assignQuantity > 0 && outboundOrderDetails[i].LockQuantity < outboundOrderDetails[i].OrderQuantity) |
| | | // { |
| | | // outStockLockInfos.AddRange(_outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetails[i], outStocks)); |
| | | // if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= assignQuantity) |
| | | // { |
| | | // outboundOrderDetails[i].LockQuantity += assignQuantity; |
| | | // break; |
| | | // } |
| | | // else |
| | | // { |
| | | // assignQuantity -= (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity); |
| | | // outboundOrderDetails[i].LockQuantity = outboundOrderDetails[i].OrderQuantity; |
| | | // } |
| | | // } |
| | | //} |
| | | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); |
| | | } |
| | | |
| | | |
| | | |
| | | return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éå®åºåï¼ç±äººå·¥æå®ï¼æå ä¸ç³»ç»åé
(å
å«é»è¾è¿ç®ï¼ä¸ä¿®æ¹æ°æ®åºæ°æ®) |
| | | /// </summary> |
| | | /// <param name="orderDetailId"></param> |