From 26bd7b11959f4223ae2dfd3e63582135487fbb34 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Fri, 12 Apr 2024 13:46:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=B2=E5=88=A0=E9=99=A4=E7=9A=84?= =?UTF-8?q?=E8=AE=A2=E8=88=B1=E6=8F=90=E7=A4=BA=E6=97=A0=E6=B3=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 73fd8830..0c5d644b 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1755,6 +1755,10 @@ namespace Myshipping.Application }; var mlist = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync(); + if (mlist.IsDeleted) + { + throw Oops.Bah("当前单据为【已删除】状态,无法修改"); + } if (!string.IsNullOrEmpty(reqId)) { From 00324ab33a650a5cf9d2ed3b4fc50da71d886422 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Fri, 12 Apr 2024 15:36:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=B7=E8=BF=90=E6=B8=AF=E4=B8=8E?= =?UTF-8?q?=E8=88=B9=E4=BB=A3=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Const/CommonConst.cs | 5 ++ .../Entity/CommonDB/RelaPortLoadForwarder.cs | 35 +++++++++ Myshipping.Core/Job/CacheCommonWorker.cs | 3 + Myshipping.Core/Myshipping.Core.xml | 77 ++++++++++++++++++- .../Service/Cache/ISysCacheService.cs | 12 +++ .../Service/Cache/SysCacheService.cs | 20 ++++- .../Service/CommonDB/CommonDBService.cs | 26 ++++++- .../Service/CommonDB/ICommonDBService.cs | 6 ++ 8 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 Myshipping.Core/Entity/CommonDB/RelaPortLoadForwarder.cs diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index 3aa0d089..124126a8 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -206,6 +206,11 @@ public class CommonConst /// 省份信息 /// public const string CACHE_KEY_COMMON_DB_PROVINCE = "CommonDbCodeProvince"; + + /// + /// 起运港与船代的关系 + /// + public const string CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER = "CommonDbRelaPortLoadForwarder"; #endregion public const string API_USER_HEADER_KEY = "USER_KEY"; diff --git a/Myshipping.Core/Entity/CommonDB/RelaPortLoadForwarder.cs b/Myshipping.Core/Entity/CommonDB/RelaPortLoadForwarder.cs new file mode 100644 index 00000000..02939270 --- /dev/null +++ b/Myshipping.Core/Entity/CommonDB/RelaPortLoadForwarder.cs @@ -0,0 +1,35 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Core.Entity +{ + [SugarTable("RelaPortLoadForwarder")] + [Description("起运港和船代的关系表")] + public class RelaPortLoadForwarder : CommonDbEntity + { + /// + /// 起运港代码 + /// + public string PortLoadCode { get; set; } + + /// + /// 船代代码 + /// + public string ForwarderCode { get; set; } + + /// + /// 模块(公用时为空字符串) + /// + public string Module { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + } +} diff --git a/Myshipping.Core/Job/CacheCommonWorker.cs b/Myshipping.Core/Job/CacheCommonWorker.cs index 2a12faa4..4be242b1 100644 --- a/Myshipping.Core/Job/CacheCommonWorker.cs +++ b/Myshipping.Core/Job/CacheCommonWorker.cs @@ -101,6 +101,9 @@ namespace Myshipping.Core.Job //航线与港口的的关系 await App.GetService().GetAllRelaPortCarrierLane(true); + //起运港与船代的的关系 + await App.GetService().GetAllRelaPortLoadForwarder(true); + //国家 await App.GetService().GetAllCountry(true); diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 820e1fbb..57f9f77e 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -782,6 +782,11 @@ 省份信息 + + + 起运港与船代的关系 + + 程序集 @@ -1727,6 +1732,26 @@ 备注 + + + 起运港代码 + + + + + 船代代码 + + + + + 模块(公用时为空字符串) + + + + + 备注 + + 自定义租户基类实体 @@ -2039,6 +2064,16 @@ 等级 + + + 客户端系统ID + + + + + 大简云GID + + 客户地址 @@ -2124,6 +2159,16 @@ 备注 + + + 客户端系统ID + + + + + 大简云GID + + 钉钉客服通知群配置 @@ -7327,6 +7372,12 @@ + + + 获取公共库 起运港与船代的关系表 + + + 获取公共库 国家 @@ -7549,6 +7600,12 @@ + + + 设置公共库 起运港与船代的关系表 + + + 设置公共库 国家 @@ -7873,7 +7930,13 @@ - 设置公共库 航线与港口的的关系表 + 获取公共库 航线与港口的的关系表 + + + + + + 获取公共库 起运港与船代的关系表 @@ -7991,6 +8054,12 @@ + + + 设置公共库 起运港与船代的关系表 + + + 设置公共库 国家 @@ -10153,6 +10222,12 @@ + + + 起运港与船代的关系 + + + 国家 diff --git a/Myshipping.Core/Service/Cache/ISysCacheService.cs b/Myshipping.Core/Service/Cache/ISysCacheService.cs index f9ad2c13..2cc6f8a5 100644 --- a/Myshipping.Core/Service/Cache/ISysCacheService.cs +++ b/Myshipping.Core/Service/Cache/ISysCacheService.cs @@ -109,6 +109,12 @@ public interface ISysCacheService /// Task> GetAllRelaPortCarrierLane(); + /// + /// 获取公共库 起运港与船代的关系表 + /// + /// + Task> GetAllRelaPortLoadForwarder(); + /// /// 获取公共库 国家 /// @@ -332,6 +338,12 @@ public interface ISysCacheService /// Task SetAllRelaPortCarrierLane(List list); + /// + /// 设置公共库 起运港与船代的关系表 + /// + /// + Task SetAllRelaPortLoadForwarder(List list); + /// /// 设置公共库 国家 /// diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs index eeb3e7ce..e6e70166 100644 --- a/Myshipping.Core/Service/Cache/SysCacheService.cs +++ b/Myshipping.Core/Service/Cache/SysCacheService.cs @@ -398,7 +398,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet } /// - /// 设置公共库 航线与港口的的关系表 + /// 获取公共库 航线与港口的的关系表 /// /// public Task> GetAllRelaPortCarrierLane() @@ -406,6 +406,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT); } + /// + /// 获取公共库 起运港与船代的关系表 + /// + /// + public Task> GetAllRelaPortLoadForwarder() + { + return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER); + } + /// /// 获取公共库 国家 /// @@ -580,6 +589,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT, list); } + /// + /// 设置公共库 起运港与船代的关系表 + /// + /// + public Task SetAllRelaPortLoadForwarder(List list) + { + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER, list); + } + /// /// 设置公共库 国家 /// diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index 10818afd..c0e89374 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -51,6 +51,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie private readonly SqlSugarRepository _mappingForwarder; private readonly SqlSugarRepository _codeCityRep; private readonly SqlSugarRepository _codeProvinceRep; + private readonly SqlSugarRepository _relaPortLoadForwarderRep; public CommonDBService(SqlSugarRepository codeCarrierRep, SqlSugarRepository codeVesselRep, SqlSugarRepository codeForwarderRep, @@ -80,7 +81,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie SqlSugarRepository codeCountryRep, SqlSugarRepository mappingForwarder, SqlSugarRepository codeCityRep, - SqlSugarRepository codeProvinceRep + SqlSugarRepository codeProvinceRep, + SqlSugarRepository relaPortLoadForwarderRep ) { _codeCarrierRep = codeCarrierRep; @@ -113,7 +115,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie _mappingForwarder = mappingForwarder; _codeCityRep = codeCityRep; _codeProvinceRep = codeProvinceRep; - + _relaPortLoadForwarderRep = relaPortLoadForwarderRep; } #endregion @@ -1918,6 +1920,26 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } + } + + [NonAction] + public async Task GetAllRelaPortLoadForwarder(bool flag = false) + { + if (flag) + { + if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_RELA_PORTLOAD_FORWARDER)) + { + var list = await _relaPortLoadForwarderRep.ToListAsync(); + await _sysCacheService.SetAllRelaPortLoadForwarder(list); + } + } + else + { + var list = await _relaPortLoadForwarderRep.ToListAsync(); + await _sysCacheService.SetAllRelaPortLoadForwarder(list); + } + + } /// diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index e9f3db31..ca8809ff 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -105,6 +105,12 @@ public interface ICommonDBService /// Task GetAllRelaPortCarrierLane(bool flag); + /// + /// 起运港与船代的关系 + /// + /// + Task GetAllRelaPortLoadForwarder(bool flag); + /// /// 国家 /// From 91753f9dd8d09a3f7295f196bd05ff418ba89b5c Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Fri, 12 Apr 2024 16:46:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8E=A7=E5=88=B6=E5=88=A0=E9=99=A4=E6=97=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=85=88=E8=AF=A2=E9=97=AE=E4=B8=9C=E8=83=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 117 ++++++++++-------- Myshipping.Core/Const/TenantParamCode.cs | 5 + Myshipping.Core/Myshipping.Core.xml | 5 + 3 files changed, 74 insertions(+), 53 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0c5d644b..d13a3cd8 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2291,6 +2291,9 @@ namespace Myshipping.Application // 要取消订阅运踪的列表 List waitUnsubscribeBilltrace = new(arr.Count()); + var tenantParamList = await _cache.GetAllTenantParam(); + var isAskDs = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == TenantParamCode.ASK_DS_BEFORE_DELETE_BOOKING_ORDER); + foreach (var ar in arr) { long Id = Convert.ToInt64(ar); @@ -2304,27 +2307,64 @@ namespace Myshipping.Application // 将待删除的订舱单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 + try { - Id = Id, - MBLNO = mblno - }); - bookingOrderDelete.Delete = deletelist; + await _cache.SetTimeoutAsync(deletingCacheKey, null, TimeSpan.FromMinutes(1)); + _logger.LogInformation("设置待删除的订舱单id到Cache中,key:" + deletingCacheKey); - var stn = await url.SetBody(bookingOrderDelete).PostAsStringAsync(); - var jobj = stn.ToJObject(); - _logger.LogInformation(mblno + "删除单据:" + jobj); - if (jobj.GetIntValue("Code") == 200) - { - JObject data = jobj.GetValue("Data") as JObject; - JArray NoDeleted = data.GetValue("NoDeleted") as JArray; var deleteTime = DateTime.Now; - if (NoDeleted == null || NoDeleted.Count() == 0) + if (isAskDs?.ItemCode == "YES") + { + BookingOrderDelete bookingOrderDelete = new BookingOrderDelete(); + List deletelist = new List + { + new BookingOrderDeleteDetail + { + Id = Id, + MBLNO = mblno + } + }; + bookingOrderDelete.Delete = deletelist; + + var stn = await url.SetBody(bookingOrderDelete).PostAsStringAsync(); + var jobj = stn.ToJObject(); + _logger.LogInformation(mblno + "删除单据:" + jobj); + if (jobj.GetIntValue("Code") == 200) + { + JObject data = jobj.GetValue("Data") as JObject; + JArray NoDeleted = data.GetValue("NoDeleted") as JArray; + if (NoDeleted == null || NoDeleted.Count() == 0 || (NoDeleted[0] is JObject re2 && re2.GetIntValue("Code") == 201)) + { + var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync(); + await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true }); + await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true }); + await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true, DeleteTime = deleteTime }); + await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true }); + _logger.LogInformation(mblno + "删除成功!"); + + // 取消订阅运踪 + waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); + + // 记录日志 + var newOrder = order.Adapt(); + newOrder.IsDeleted = true; + newOrder.DeleteTime = deleteTime; + await SaveLog(newOrder, order, "删除"); + } + else + { + var re = NoDeleted[0] as JObject; + string result = re.GetStringValue("Result"); + throw Oops.Bah(result); + } + } + else + { + throw Oops.Bah(mblno + "删除单据失败"); + } + } + else { var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync(); await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true }); @@ -2342,48 +2382,19 @@ namespace Myshipping.Application newOrder.DeleteTime = deleteTime; await SaveLog(newOrder, order, "删除"); } - else - { - var re = NoDeleted[0] as JObject; - if (re.GetIntValue("Code") == 201) - { - var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync(); - await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true }); - await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true }); - await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true, DeleteTime = deleteTime }); - await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id && x.IsDeleted == false, x => new BookingEDIExt { IsDeleted = true }); - _logger.LogInformation(mblno + "删除成功!"); - - // 取消订阅运踪 - waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); - - // 记录日志 - var newOrder = order.Adapt(); - newOrder.IsDeleted = true; - newOrder.DeleteTime = deleteTime; - await SaveLog(newOrder, order, "删除"); - } - else - { - await _cache.DelAsync(deletingCacheKey); - _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); - - string result = re.GetStringValue("Result"); - throw Oops.Bah(result); - } - - } } - else + catch (Exception) { await _cache.DelAsync(deletingCacheKey); _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); - throw Oops.Bah(mblno + "删除单据失败"); + throw; + } + finally + { + await _cache.DelAsync(deletingCacheKey); + _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); } - - await _cache.DelAsync(deletingCacheKey); - _logger.LogInformation("从Cache中移除待删除的订舱单id,key:" + deletingCacheKey); } // 取消订阅运踪 diff --git a/Myshipping.Core/Const/TenantParamCode.cs b/Myshipping.Core/Const/TenantParamCode.cs index a0549bca..ff8bb48b 100644 --- a/Myshipping.Core/Const/TenantParamCode.cs +++ b/Myshipping.Core/Const/TenantParamCode.cs @@ -24,5 +24,10 @@ /// 通过运踪更新船舶动态开关 /// public const string ENABLE_STATUS_TO_SAILING_DATE = "EnableStatusToSailingDate"; + + /// + /// 删除订舱前是否先询问东胜 + /// + public const string ASK_DS_BEFORE_DELETE_BOOKING_ORDER = "AskDsBeforeDeleteBookingOrder"; } } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 820e1fbb..89bc38d5 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -872,6 +872,11 @@ 通过运踪更新船舶动态开关 + + + 删除订舱前是否先询问东胜 + + 代码