diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 984859a1..2f3e3d94 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1436,6 +1436,12 @@ namespace Myshipping.Application long Id = Convert.ToInt64(ar); var mblno = order.Where(x => x.Id == Id).Select(x => x.MBLNO).FirstOrDefault(); + + // 将待删除的订舱单id存放到Cache中。目的:使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑,来决定是否推送(如果是正在处理删除逻辑的数据,则不推送) + string deletingCacheKey = $"DeletingBookingOrderId_{ar}"; + await _cache.SetTimeoutAsync(deletingCacheKey, null, TimeSpan.FromMinutes(1)); + _logger.LogInformation("设置待删除的订舱单id到Cache中,key:" + deletingCacheKey); + BookingOrderDelete bookingOrderDelete = new BookingOrderDelete(); List deletelist = new List(); deletelist.Add(new BookingOrderDeleteDetail @@ -1477,6 +1483,9 @@ namespace Myshipping.Application } else { + await _cache.DelAsync(deletingCacheKey); + _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); + string result = re.GetStringValue("Result"); throw Oops.Bah(result); } @@ -1485,9 +1494,14 @@ namespace Myshipping.Application } else { - + await _cache.DelAsync(deletingCacheKey); + _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); + throw Oops.Bah(mblno + "删除单据失败"); } + + await _cache.DelAsync(deletingCacheKey); + _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); } #region 消息队列推送删除信息 //var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault(); @@ -8503,6 +8517,11 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 { continue; } + //2023-9-26,添加校验:推送前通过Cache判断一下待推送的数据是否正在走删除逻辑 + if (await _cache.ExistsAsync($"DeletingBookingOrderId_{item.Id}")) + { + continue; + } var dto = item.Adapt();