| | |
| | | //æ§è¡ååºæä½ |
| | | await ExecuteReturnOperations(orderNo, palletCode, stockInfo, task, statusAnalysis); |
| | | |
| | | await ReleaseAllLocksForReallocation(orderNo, palletCode, statusAnalysis); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | |
| | |
| | | PickQuantity = result.ActualPickedQty, |
| | | PickTime = DateTime.Now, |
| | | Operator = App.User.UserName, |
| | | OutStockLockId = result.FinalLockInfo.Id |
| | | OutStockLockId = result.FinalLockInfo.Id, |
| | | BarcodeUnit=result.FinalLockInfo.BarcodeUnit, |
| | | BarcodeQty=result.FinalLockInfo.BarcodeQty, |
| | | BatchNo= result.FinalLockInfo.BatchNo, |
| | | lineNo= result.FinalLockInfo.lineNo , |
| | | SupplyCode= result.FinalLockInfo.SupplyCode , |
| | | WarehouseCode = result.FinalLockInfo.WarehouseCode , |
| | | |
| | | |
| | | }; |
| | | |
| | | await Db.Insertable(pickingHistory).ExecuteCommandAsync(); |
| | |
| | | if (currentLockInfo.PickedQty < context.PickingRecord.PickQuantity) |
| | | return ValidationResult<bool>.Error($"éå®ä¿¡æ¯å·²æ£éæ°é({currentLockInfo.PickedQty})å°äºåæ¶æ°é({context.PickingRecord.PickQuantity})"); |
| | | |
| | | // éªè¯åºåæ°æ® |
| | | var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | .FirstAsync(x => x.Barcode == context.PickingRecord.Barcode && x.StockId == context.PickingRecord.StockId); |
| | | ////// éªè¯åºåæ°æ® |
| | | ////var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | //// .FirstAsync(x => x.Barcode == context.PickingRecord.Barcode && x.StockId == context.PickingRecord.StockId); |
| | | |
| | | if (currentStockDetail == null) |
| | | return ValidationResult<bool>.Error($"æªæ¾å°å¯¹åºçåºåæç»è®°å½"); |
| | | ////if (currentStockDetail == null) |
| | | //// return ValidationResult<bool>.Error($"æªæ¾å°å¯¹åºçåºåæç»è®°å½"); |
| | | |
| | | if (currentStockDetail.Status == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || |
| | | currentStockDetail.Status == StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | return ValidationResult<bool>.Error($"æ¡ç {context.PickingRecord.Barcode}å·²ç»ååºï¼æ æ³åæ¶åæ£"); |
| | | ////if (currentStockDetail.Status == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || |
| | | //// currentStockDetail.Status == StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | //// return ValidationResult<bool>.Error($"æ¡ç {context.PickingRecord.Barcode}å·²ç»ååºï¼æ æ³åæ¶åæ£"); |
| | | |
| | | // éªè¯ç¶ææµè½¬çåæ³æ§ |
| | | if (!await CanCancelPicking(currentLockInfo, currentStockDetail)) |
| | | if (!await CanCancelPicking(currentLockInfo, null)) |
| | | return ValidationResult<bool>.Error($"å½åç¶æä¸å
è®¸åæ¶åæ£"); |
| | | |
| | | return ValidationResult<bool>.Success(true); |
| | |
| | | if (lockInfo.Status != (int)OutLockStockStatusEnum.æ£é宿) |
| | | return false; |
| | | |
| | | // åºåç¶ææ£æ¥ |
| | | if (stockDetail.Status == StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | return false; |
| | | ////// åºåç¶ææ£æ¥ |
| | | ////if (stockDetail.Status == StockStatusEmun.åºåºå®æ.ObjToInt()) |
| | | //// return false; |
| | | |
| | | // å¦ææ¯æå
è®°å½ï¼è¿éè¦æ£æ¥ç¶éå®ä¿¡æ¯ç¶æ |
| | | if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue) |
| | |
| | | await UpdateStockInfoStatus(stockInfo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å®å
¨éæ¾éå®ï¼å
è®¸éæ°åé
åºå |
| | | /// </summary> |
| | | private async Task ReleaseAllLocksForReallocation(string orderNo, string palletCode, PalletStatusAnalysis analysis) |
| | | { |
| | | _logger.LogInformation($"å¼å§éæ¾éå®ä»¥ä¾¿éæ°åé
- 订å: {orderNo}, æç: {palletCode}"); |
| | | |
| | | // 1. å¤çæªåæ£çåºåºéå®è®°å½ - å®å
¨éæ¾ |
| | | if (analysis.HasRemainingLocks) |
| | | { |
| | | await ReleaseRemainingLocks(analysis.RemainingLocks); |
| | | } |
| | | |
| | | // 2. å¤çå·²ååºçéå®è®°å½ - å 餿æ è®°ä¸ºæ æ |
| | | await CleanupReturnedLocks(orderNo, palletCode); |
| | | |
| | | // 3. é置订åæç»çé宿°é |
| | | await ResetOrderDetailLockQuantities(analysis); |
| | | |
| | | _logger.LogInformation($"éå®éæ¾å®æ - 订å: {orderNo}, æç: {palletCode}"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éæ¾æªåæ£çéå®è®°å½ |
| | | /// </summary> |
| | | private async Task ReleaseRemainingLocks(List<Dt_OutStockLockInfo> remainingLocks) |
| | | { |
| | | var lockIds = remainingLocks.Select(x => x.Id).ToList(); |
| | | |
| | | // å°éå®è®°å½ç¶ææ¹ä¸º"已鿾"ï¼æè
ç´æ¥å é¤ |
| | | // æ è®°ä¸ºå·²éæ¾ |
| | | await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>() |
| | | .SetColumns(it => new Dt_OutStockLockInfo |
| | | { |
| | | Status = (int)OutLockStockStatusEnum.已鿾, // éè¦æ°å¢è¿ä¸ªç¶æ |
| | | // ReleaseTime = DateTime.Now, |
| | | Operator = App.User.UserName |
| | | }) |
| | | .Where(it => lockIds.Contains(it.Id)) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | // ç´æ¥å é¤ï¼æ´å½»åºï¼ |
| | | // await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>() |
| | | // .Where(it => lockIds.Contains(it.Id)) |
| | | // .ExecuteCommandAsync(); |
| | | |
| | | _logger.LogInformation($"éæ¾{remainingLocks.Count}æ¡æªåæ£éå®è®°å½"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¸
çå·²ååºçéå®è®°å½ |
| | | /// </summary> |
| | | private async Task CleanupReturnedLocks(string orderNo, string palletCode) |
| | | { |
| | | // æ¥æ¾ææç¶æä¸ºååºä¸çéå®è®°å½å¹¶éæ¾ |
| | | var returnedLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(it => it.OrderNo == orderNo && |
| | | it.PalletCode == palletCode && |
| | | it.Status == (int)OutLockStockStatusEnum.ååºä¸) |
| | | .ToListAsync(); |
| | | |
| | | if (returnedLocks.Any()) |
| | | { |
| | | var returnedLockIds = returnedLocks.Select(x => x.Id).ToList(); |
| | | |
| | | await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>() |
| | | .SetColumns(it => new Dt_OutStockLockInfo |
| | | { |
| | | Status = (int)OutLockStockStatusEnum.已鿾, |
| | | //ReleaseTime = DateTime.Now, |
| | | Operator = App.User.UserName |
| | | }) |
| | | .Where(it => returnedLockIds.Contains(it.Id)) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | _logger.LogInformation($"æ¸
ç{returnedLocks.Count}æ¡ååºä¸éå®è®°å½"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// é置订åæç»çé宿°é |
| | | /// </summary> |
| | | private async Task ResetOrderDetailLockQuantities(PalletStatusAnalysis analysis) |
| | | { |
| | | // æ¶éææåå½±åç订åæç»ID |
| | | var affectedOrderDetailIds = new HashSet<int>(); |
| | | |
| | | if (analysis.HasRemainingLocks) |
| | | { |
| | | foreach (var lockInfo in analysis.RemainingLocks) |
| | | { |
| | | affectedOrderDetailIds.Add(lockInfo.OrderDetailId); |
| | | } |
| | | } |
| | | |
| | | // éç½®è¿äºè®¢åæç»çé宿°é |
| | | foreach (var orderDetailId in affectedOrderDetailIds) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | | .SetColumns(it => new Dt_OutboundOrderDetail |
| | | { |
| | | LockQuantity = 0, // éç½®é宿°é |
| | | OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt() // éç½®ç¶æä¸ºæ°å»º |
| | | }) |
| | | .Where(it => it.Id == orderDetailId) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | | _logger.LogInformation($"éç½®{affectedOrderDetailIds.Count}个订åæç»çé宿°é"); |
| | | } |
| | | private async Task HandleRemainingLocksReturn(List<Dt_OutStockLockInfo> remainingLocks, int stockId) |
| | | { |
| | | var lockIds = remainingLocks.Select(x => x.Id).ToList(); |
| | |
| | | if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt()) |
| | | { |
| | | var allocate = _allocateService.Repository.QueryData(x => x.UpperOrderNo == outboundOrder.UpperOrderNo).First(); |
| | | var feedmodel = new AllocateDto |
| | | var allocatefeedmodel = new AllocateDto |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | |
| | | |
| | | |
| | | }).ToList(); |
| | | feedmodel.Details = groupedData; |
| | | allocatefeedmodel.Details = groupedData; |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(feedmodel); |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>() |
| | |
| | | FactoryArea = originalLock.FactoryArea, |
| | | lineNo = originalLock.lineNo, |
| | | WarehouseCode = originalLock.WarehouseCode, |
| | | BarcodeQty=originalLock.BarcodeQty, |
| | | BarcodeUnit=originalLock.BarcodeUnit, |
| | | |
| | | }; |
| | | |