| | |
| | | |
| | | // æç©æåæ¹æ¬¡åç»å¤ç |
| | | var groupDetails = outboundOrderDetails |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode }) |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode,x.WarehouseCode }) |
| | | .Select(x => new |
| | | { |
| | | MaterielCode = x.Key.MaterielCode, |
| | | BatchNo = x.Key.BatchNo, |
| | | SupplyCode = x.Key.SupplyCode, |
| | | Details = x.ToList(), |
| | | WarehouseCode=x.Key.WarehouseCode, |
| | | TotalNeedQuantity = CalculateReassignNeedQuantity(x.ToList()) |
| | | }) |
| | | .Where(x => x.TotalNeedQuantity > 0) |
| | |
| | | foreach (var item in groupDetails) |
| | | { |
| | | var needQuantity = item.TotalNeedQuantity; |
| | | |
| | | |
| | | // è·åå¯ç¨åºåï¼æå
è¿å
åºæåºï¼ |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode, outboundOrder.FactoryArea); |
| | | |
| | | if (!stockInfos.Any()) |
| | | { |
| | |
| | | |
| | | // æç©æåæ¹æ¬¡åç»å¤çï¼è¿éåªæä¸ä¸ªæç»ï¼ |
| | | var groupDetails = new List<Dt_OutboundOrderDetail> { orderDetail } |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode }) |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode ,x.WarehouseCode}) |
| | | .Select(x => new |
| | | { |
| | | MaterielCode = x.Key.MaterielCode, |
| | | BatchNo = x.Key.BatchNo, |
| | | SupplyCode = x.Key.SupplyCode, |
| | | WarehouseCode=x.Key.WarehouseCode, |
| | | Details = x.ToList(), |
| | | TotalNeedQuantity = batchQuantity // 使ç¨åæ¹æ°é |
| | | }) |
| | |
| | | var needQuantity = item.TotalNeedQuantity; |
| | | |
| | | // è·åå¯ç¨åºåï¼æå
è¿å
åºæåºï¼ |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode,outboundOrder.FactoryArea); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"ç©æ[{item.MaterielCode}]æ¹æ¬¡[{item.BatchNo}]æªæ¾å°å¯åé
åºå"); |
| | |
| | | |
| | | if (remainingNeedQuantity > 0) |
| | | { |
| | | //// å¯éï¼è¿éå¯ä»¥æ ¹æ®ä¸å¡éæ±å³å®æ¯å¦å
许èªå¨åé
|
| | | //// å¦æè¦æ±ä¸¥æ ¼æç¨æ·éæ©åºåºï¼å¯ä»¥æåºå¼å¸¸ |
| | | //// throw new Exception($"ç¨æ·éæ©çåºåæ°éä¸è¶³ï¼è¿é{remainingNeedQuantity}ï¼è¯·éæ°éæ©"); |
| | | |
| | | //// 妿éè¦èªå¨åé
ï¼è®°å½æ¥å¿ |
| | | //_logger.LogInformation($"ç¨æ·éæ©çåºåæ°éä¸è¶³ï¼è¿é{remainingNeedQuantity}ï¼ç³»ç»å°èªå¨åé
"); |
| | | |
| | | //List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks( |
| | | // outboundOrderDetail.MaterielCode, |
| | | // outboundOrderDetail.BatchNo, |
| | | // ""); |
| | | |
| | | //// æé¤ç¨æ·å·²éæ©ä¸å·²åé
çæç |
| | | //var assignedPalletCodes = outStocks.Select(x => x.PalletCode).ToList(); |
| | | //autoStocks = autoStocks |
| | | // .Where(x => !assignedPalletCodes.Contains(x.PalletCode)) |
| | | // .ToList(); |
| | | |
| | | //var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks( |
| | | // autoStocks, |
| | | // outboundOrderDetail.MaterielCode, |
| | | // remainingNeedQuantity, |
| | | // out decimal residueQuantity); |
| | | |
| | | //if (autoAssignStocks != null && autoAssignStocks.Any()) |
| | | //{ |
| | | // outStocks.AddRange(autoAssignStocks); |
| | | |
| | | // // 为èªå¨åé
çåºåå建éå®è®°å½ |
| | | // var autoLockInfos = CreateLockInfosForAutoAssign(outboundOrder, outboundOrderDetail, autoAssignStocks, stockAllocations); |
| | | // outStockLockInfos.AddRange(autoLockInfos); |
| | | |
| | | // // æ´æ°å·²åé
æ°é |
| | | // decimal autoAssignedQuantity = remainingNeedQuantity - residueQuantity; |
| | | // totalAssignedFromUserSelection += autoAssignedQuantity; |
| | | // remainingNeedQuantity = residueQuantity; // æ´æ°å©ä½éæ± |
| | | //} |
| | | //else if (remainingNeedQuantity > 0) |
| | | //{ |
| | | // _logger.LogWarning($"èªå¨åé
失败ï¼å©ä½éæ±{remainingNeedQuantity}æ æ³æ»¡è¶³"); |
| | | //} |
| | | |
| | | } |
| | | |
| | | // æ´æ°é宿°é |
| | |
| | | .Where(d => d.MaterielCode == detail.MaterielCode && |
| | | (d.StockQuantity - d.OutboundQuantity) > 0 && |
| | | d.Barcode == barcode); // åªåé
æå®æ¡ç |
| | | |
| | | query = query.Where(x => x.WarehouseCode == detail.WarehouseCode); |
| | | |
| | | if (!string.IsNullOrEmpty(detail.BatchNo)) |
| | | { |