| | |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | //if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | //{ |
| | | // throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | //} |
| | | |
| | | if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.Outbound.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | { |
| | | throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | throw new Exception("æéåºåºåæç»åå¨å·²å®æç¶æï¼æ æ³éæ°åé
"); |
| | | } |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutboundOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | |
| | | CleanupPreviousInvalidLocks(outboundOrderDetails); |
| | | |
| | | (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetails); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | |
| | | } |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | /// <summary> |
| | | /// æ¸
çä¹åçæ æéå®è®°å½ |
| | | /// </summary> |
| | | private void CleanupPreviousInvalidLocks(List<Dt_OutboundOrderDetail> orderDetails) |
| | | { |
| | | var orderIds = orderDetails.Select(x => x.OrderId).Distinct().ToList(); |
| | | var orderNos = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => orderIds.Contains(x.Id)) |
| | | .Select(x => x.OrderNo) |
| | | .ToList(); |
| | | |
| | | // æ¸
çç¶æä¸º"已鿾"æ"ååºä¸"çæ§éå®è®°å½ |
| | | foreach (var orderNo in orderNos) |
| | | { |
| | | _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>() |
| | | .SetColumns(x => new Dt_OutStockLockInfo |
| | | { |
| | | Status = (int)OutLockStockStatusEnum.已鿾 |
| | | }) |
| | | .Where(x => x.OrderNo == orderNo && |
| | | (x.Status == (int)OutLockStockStatusEnum.ååºä¸ || |
| | | x.Status == (int)OutLockStockStatusEnum.已鿾)) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡åæ°æ®æ´æ°å°æ°æ®åº |
| | |
| | | /// <summary> |
| | | /// åæ¹åé
åºå |
| | | /// </summary> |
| | | public async Task<WebResponseContent> BatchAllocateStock(string orderNo, int orderDetailId, decimal batchQuantity, string outStation) |
| | | public async Task<WebResponseContent> GenerateOutboundBatchTasksAsync(int orderDetailId, decimal batchQuantity, string outStation) |
| | | { |
| | | try |
| | | { |
| | |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = await BatchAllocateStockDataHandle(orderNo, orderDetailId, batchQuantity, outStation); |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = await BatchAllocateStockDataHandle(orderDetailId, batchQuantity, outStation); |
| | | |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _logger.LogError($"åæ¹åé
åºå失败 - OrderNo: {orderNo}, OrderDetailId: {orderDetailId}, Quantity: {batchQuantity}, Error: {ex.Message}"); |
| | | _logger.LogError($"åæ¹åé
åºå失败 - OrderDetailId: {orderDetailId}, Quantity: {batchQuantity}, Error: {ex.Message}"); |
| | | return WebResponseContent.Instance.Error($"åæ¹åé
失败ï¼{ex.Message}"); |
| | | } |
| | | } |
| | |
| | | /// åæ¹åé
åºåæ°æ®å¤ç |
| | | /// </summary> |
| | | public async Task<(List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?)> |
| | | BatchAllocateStockDataHandle(string orderNo, int orderDetailId, decimal batchQuantity, string outStation) |
| | | BatchAllocateStockDataHandle( int orderDetailId, decimal batchQuantity, string outStation) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | var outboundOrder = await _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().FirstAsync(x => x.Id == outboundOrderDetail.OrderId); |
| | | if(outboundOrder == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åºåºåä¿¡æ¯"); |
| | | } |
| | | // éªè¯è®¢åæç»ç¶æ |
| | | if (outboundOrderDetail.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && |
| | | if (outboundOrderDetail.OrderDetailStatus > OrderDetailStatusEnum.Outbound.ObjToInt() && |
| | | outboundOrderDetail.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) |
| | | { |
| | | throw new Exception("æéåºåºåæç»åå¨åºåºä¸æå·²å®æ"); |
| | | } |
| | | |
| | | |
| | | // éªè¯åé
æ°é |
| | | decimal allocatedQty = outboundOrderDetail.AllocatedQuantity; |
| | | decimal overOutQty = outboundOrderDetail.OverOutQuantity; |
| | |
| | | if (allocateResult.Item1 != null && allocateResult.Item1.Count > 0) |
| | | { |
| | | // åå»ºåæ¹è®°å½ |
| | | await CreateBatchRecord(orderNo, orderDetailId, batchQuantity, batchNo); |
| | | |
| | | Dt_OutboundOrder outboundOrder = await _outboundOrderService.Repository.QueryFirstAsync(x => x.Id == outboundOrderDetail.OrderId); |
| | | await CreateBatchRecord(outboundOrder.OrderNo, orderDetailId, batchQuantity, batchNo); |
| | | |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OutOrderTypeEnum.Issue => TaskTypeEnum.Outbound, |