| | |
| | | |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"ç©æ[{item.MaterielCode}]æ¹æ¬¡[{item.BatchNo}]æªæ¾å°å¯åé
åºå"); |
| | | throw new Exception($"ç©æ[{item.MaterielCode}]æ¹æ¬¡[{item.BatchNo}]ä¾åºå[{item.SupplyCode}]æªæ¾å°å¯åé
åºå"); |
| | | } |
| | | |
| | | // åé
åºåï¼æå
è¿å
åºï¼ |
| | |
| | | private bool CanReassignOrder(Dt_OutboundOrder outboundOrder) |
| | | { |
| | | // å
è®¸éæ°åé
çç¶æ |
| | | var allowedStatus = new[] {OutOrderStatusEnum.æªå¼å§, OutOrderStatusEnum.åºåºä¸,OutOrderStatusEnum.é¨å宿}; |
| | | var allowedStatus = new[] { OutOrderStatusEnum.æªå¼å§, OutOrderStatusEnum.åºåºä¸, OutOrderStatusEnum.é¨å宿 }; |
| | | |
| | | return allowedStatus.Contains((OutOrderStatusEnum)outboundOrder.OrderStatus); |
| | | } |
| | |
| | | |
| | | // æ´æ°æç»çå·²åé
æ°é |
| | | detail.AllocatedQuantity += assignQuantity; |
| | | detail.LockQuantity = detail.AllocatedQuantity; |
| | | remainingAllocate -= assignQuantity; |
| | | allocatedQuantity += assignQuantity; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) |
| | | AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) |
| | | public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | // éªè¯ç¨æ·éæ© |
| | | (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews); |
| | |
| | | decimal totalAssignedFromUserSelection = 0; |
| | | |
| | | // æå
è¿å
åºæåºç¨æ·éæ©çåºå |
| | | var userSelectedStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes( |
| | | stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | var userSelectedStocks = _stockService.StockInfoService.GetStockInfosByPalletCodes(stockSelectViews.Select(x => x.PalletCode).ToList()); |
| | | |
| | | var sortedUserSelectedStocks = userSelectedStocks |
| | | .OrderBy(x => x.CreateDate) |
| | | .ToList(); |
| | | var sortedUserSelectedStocks = userSelectedStocks.OrderBy(x => x.CreateDate).ToList(); |
| | | |
| | | // åé
ç¨æ·éæ©çåºå |
| | | foreach (var stock in sortedUserSelectedStocks) |
| | |
| | | outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode); |
| | | |
| | | // ç¡®å®åé
æ°éï¼åç¨æ·éæ©æ°éãå¯ç¨æ°éåå©ä½éæ±çæå°å¼ |
| | | var assignQuantity = Math.Min( |
| | | Math.Min(userSelection.UseableQuantity, availableQuantity), |
| | | remainingNeedQuantity); |
| | | var assignQuantity = Math.Min(Math.Min(userSelection.UseableQuantity, availableQuantity),remainingNeedQuantity); |
| | | |
| | | if (assignQuantity <= 0) continue; |
| | | |
| | |
| | | } |
| | | |
| | | // å¦æç¨æ·éæ©çåºåä¸å¤ï¼èªå¨åé
å©ä½é¨å |
| | | decimal autoAssignedQuantity = 0; |
| | | |
| | | if (remainingNeedQuantity > 0) |
| | | { |
| | | List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks( |
| | | outboundOrderDetail.MaterielCode, outboundOrderDetail.BatchNo, ""); |
| | | //// å¯éï¼è¿éå¯ä»¥æ ¹æ®ä¸å¡éæ±å³å®æ¯å¦å
许èªå¨åé
|
| | | //// å¦æè¦æ±ä¸¥æ ¼æç¨æ·éæ©åºåºï¼å¯ä»¥æåºå¼å¸¸ |
| | | //// throw new Exception($"ç¨æ·éæ©çåºåæ°éä¸è¶³ï¼è¿é{remainingNeedQuantity}ï¼è¯·éæ°éæ©"); |
| | | |
| | | // æé¤ç¨æ·å·²éæ©çæç |
| | | autoStocks = autoStocks |
| | | .Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)) |
| | | .ToList(); |
| | | //// 妿éè¦èªå¨åé
ï¼è®°å½æ¥å¿ |
| | | //_logger.LogInformation($"ç¨æ·éæ©çåºåæ°éä¸è¶³ï¼è¿é{remainingNeedQuantity}ï¼ç³»ç»å°èªå¨åé
"); |
| | | |
| | | var (autoAssignStocks, stockAllocations) = _stockService.StockInfoService.GetOutboundStocks( |
| | | autoStocks, outboundOrderDetail.MaterielCode, remainingNeedQuantity, out decimal residueQuantity); |
| | | //List<Dt_StockInfo> autoStocks = _stockService.StockInfoService.GetUseableStocks( |
| | | // outboundOrderDetail.MaterielCode, |
| | | // outboundOrderDetail.BatchNo, |
| | | // ""); |
| | | |
| | | // æ£æ¥èªå¨åé
ç»æ |
| | | autoAssignedQuantity = remainingNeedQuantity - residueQuantity; |
| | | if (autoAssignedQuantity <= 0 && remainingNeedQuantity > 0) |
| | | { |
| | | // é¨ååé
æ¯å¯ä»¥æ¥åçï¼è®°å½è¦åä½ä¸æ¥é |
| | | _logger.LogWarning($"èªå¨åé
失败ï¼å©ä½éæ±{remainingNeedQuantity}æ æ³æ»¡è¶³"); |
| | | } |
| | | else if (autoAssignedQuantity > 0) |
| | | { |
| | | outStocks.AddRange(autoAssignStocks); |
| | | //// æé¤ç¨æ·å·²éæ©ä¸å·²åé
çæç |
| | | //var assignedPalletCodes = outStocks.Select(x => x.PalletCode).ToList(); |
| | | //autoStocks = autoStocks |
| | | // .Where(x => !assignedPalletCodes.Contains(x.PalletCode)) |
| | | // .ToList(); |
| | | |
| | | // 为èªå¨åé
çåºåå建éå®è®°å½ |
| | | var autoLockInfos = CreateLockInfosForAutoAssign(outboundOrder, outboundOrderDetail, autoAssignStocks, stockAllocations); |
| | | outStockLockInfos.AddRange(autoLockInfos); |
| | | } |
| | | //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}æ æ³æ»¡è¶³"); |
| | | //} |
| | | } |
| | | |
| | | // æ´æ°é宿°é |
| | | outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection + autoAssignedQuantity; |
| | | outboundOrderDetail.LockQuantity += totalAssignedFromUserSelection + totalAssignedFromUserSelection; |
| | | |
| | | // æ´æ°ç¶æ |
| | | UpdateOrderDetailStatus(outboundOrderDetail, remainingNeedQuantity - autoAssignedQuantity); |
| | | UpdateOrderDetailStatus(outboundOrderDetail, remainingNeedQuantity); |
| | | |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()); |
| | | |
| | |
| | | decimal remainingAssign = assignQuantity; |
| | | |
| | | // æå
è¿å
åºåé
åºåæç» |
| | | var sortedDetails = stock.Details |
| | | var query = stock.Details.AsQueryable() |
| | | .Where(d => d.MaterielCode == detail.MaterielCode && |
| | | d.BatchNo == detail.BatchNo && |
| | | (d.StockQuantity - d.OutboundQuantity) > 0) |
| | | .OrderBy(d => d.CreateDate) |
| | | .ToList(); |
| | | (d.StockQuantity - d.OutboundQuantity) > 0); |
| | | // .OrderBy(d => d.CreateDate); |
| | | |
| | | if (!string.IsNullOrEmpty(detail.BatchNo)) |
| | | { |
| | | query = query.Where(x => x.BatchNo == detail.BatchNo); |
| | | } |
| | | // 妿åºåºåæä¾åºåè¦æ±ï¼æä¾åºåè¿æ»¤ |
| | | if (!string.IsNullOrEmpty(detail.SupplyCode)) |
| | | { |
| | | query = query.Where(d => d.SupplyCode == detail.SupplyCode); |
| | | } |
| | | var sortedDetails= query.ToList().OrderBy(d => d.CreateDate); |
| | | |
| | | |
| | | foreach (var stockDetail in sortedDetails) |
| | | { |