| | |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(warehouse.WarehouseId); |
| | | return BaseDal.GetProStocks(mesRworkOutboundOrder, locationCodes); |
| | | } |
| | | //æ¥æ¾å¯ç¨æ¥åºåºå |
| | | public List<Dt_ProStockInfo> GetUseableStocks(int warehoseId, Dt_ErpProScrapSheetDetail erpProScrapSheetDetail) |
| | | { |
| | | List<string> locationCodes = _basicRepository.LocationInfoRepository.GetCanOutLocationCodes(warehoseId); |
| | | return BaseDal.GetProStocks(erpProScrapSheetDetail, locationCodes); |
| | | } |
| | | /// <summary> |
| | | /// è·ååºåºåºå |
| | | /// </summary> |
| | |
| | | return assignOutStocks; |
| | | } |
| | | /// <summary> |
| | | /// è·åæ¥åºåºå |
| | | /// </summary> |
| | | public List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_ErpProScrapSheetDetail outOrderDetail, float needQuantity, out float residueQuantity) |
| | | { |
| | | List<Dt_ProStockInfo> assignOutStocks = new List<Dt_ProStockInfo>(); |
| | | float stockTotalQuantity = stockInfos.Select(x => x.proStockInfoDetails.Sum(v => v.StockPcsQty - v.OutboundQuantity)).Sum(x => x); |
| | | //stockInfos = stockInfos.OrderBy(x => x.Id).ToList(); |
| | | if (stockTotalQuantity >= needQuantity)//åºåå¤ |
| | | { |
| | | int index = 0; |
| | | while (needQuantity > 0) |
| | | { |
| | | Dt_ProStockInfo stockInfo = stockInfos[index]; |
| | | float useableStockQuantity = stockInfo.proStockInfoDetails |
| | | .Where(x => |
| | | x.ProductCode == outOrderDetail.ScrapProCode |
| | | && x.ProductVersion==outOrderDetail.ScrapProVersion |
| | | && x.LotNumber == outOrderDetail.ScrapProLotNo) |
| | | .Sum(x => x.StockPcsQty - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity && useableStockQuantity > 0) |
| | | { |
| | | stockInfo.proStockInfoDetails.Where(x => |
| | | x.ProductCode == outOrderDetail.ScrapProCode |
| | | && x.ProductVersion == outOrderDetail.ScrapProVersion |
| | | && x.LotNumber == outOrderDetail.ScrapProLotNo).ToList().ForEach(x => x.OutboundQuantity = x.StockPcsQty); |
| | | needQuantity -= useableStockQuantity; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.proStockInfoDetails.ForEach(x => |
| | | { |
| | | //满足æ¡ä»¶è¿è¡åé
|
| | | if ((x.StockPcsQty > x.OutboundQuantity) |
| | | && x.ProductCode == outOrderDetail.ScrapProCode |
| | | && x.ProductVersion == outOrderDetail.ScrapProVersion |
| | | && x.LotNumber == outOrderDetail.ScrapProLotNo) |
| | | { |
| | | if (x.StockPcsQty - x.OutboundQuantity >= needQuantity) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | needQuantity = 0; |
| | | x.OutDetailId = outOrderDetail.Id; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockPcsQty - x.OutboundQuantity); |
| | | x.OutboundQuantity = x.StockPcsQty; |
| | | x.OutDetailId = outOrderDetail.Id; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | assignOutStocks.Add(stockInfo); |
| | | index++; |
| | | } |
| | | } |
| | | residueQuantity = needQuantity; |
| | | return assignOutStocks; |
| | | } |
| | | /// <summary> |
| | | /// è·åMESæåºåºå |
| | | /// </summary> |
| | | public List<Dt_ProStockInfo> GetOutboundStocks(List<Dt_ProStockInfo> stockInfos, Dt_MesRworkOutboundOrder mesRworkOutboundOrder, float needQuantity, out float residueQuantity) |