From da1fc2bf0f7855e7e6af6956dd5cda8f8974e656 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Tue, 26 Sep 2023 11:32:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8SendBookingOrder()=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E8=AE=A2=E8=88=B1=E5=8D=95=E6=95=B0=E6=8D=AE=E5=89=8D?= =?UTF-8?q?=E9=80=9A=E8=BF=87Cache=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E8=B5=B0=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=9D=A5=E5=86=B3=E5=AE=9A=E6=98=AF=E5=90=A6=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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();