diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 7942b4b3..db7418b2 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -255,28 +255,7 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) { - _logger.LogInformation("提单号:" + input.MBLNO + " 调用运踪接口"); - var key = _webconfig.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl"); - - var url = _cache.GetAllDictData().Result; - - BillTraceDto billdto = new BillTraceDto(); - List billTraceList = new List(); - billTraceList.Add(new BillTraceList - { - MBLNO = input.MBLNO, - YARD = input.YARD, - YardCode = input.YARDID, - CARRIER = null, - CARRIERID = null, - isBook = false - }); - billdto.Children = billTraceList; - billdto.Key = key.Account; - billdto.PWD = key.Password; - var json = billdto.ToJsonString(); - var html = await url.FirstOrDefault(x=>x.TypeCode== "url_set"&&x.Code== "seae_billtraceurl").Value.SetHttpMethod(HttpMethod.Post).SetQueries(new { msg = json }).SetRetryPolicy(3, 5000).SendAsAsync(); - _logger.LogInformation("提单号:" + input.MBLNO + " 调用运踪接口返回" + html.ToJsonString()); + await SendTrace(input.YARDID, input.YARD, input.MBLNO); } } @@ -380,29 +359,9 @@ namespace Myshipping.Application }); if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO") { - if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO)) { - _logger.LogInformation("提单号:" + input.MBLNO + " 调用运踪接口"); - var key = _webconfig.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl"); - var url = _cache.GetAllDictData().Result; - BillTraceDto billdto = new BillTraceDto(); - List billTraceList = new List(); - billTraceList.Add(new BillTraceList - { - MBLNO = input.MBLNO, - YARD = input.YARD, - YardCode = input.YARDID, - CARRIER = null, - CARRIERID = null, - isBook = false - }); - billdto.Children = billTraceList; - billdto.Key = key.Account; - billdto.PWD = key.Password; - var json = billdto.ToJsonString(); - var html = await url.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "seae_billtraceurl").Value.SetHttpMethod(HttpMethod.Post).SetQueries(new { msg = json }).SetRetryPolicy(3, 5000).SendAsAsync(); - _logger.LogInformation("提单号:" + input.MBLNO + " 调用运踪接口返回" + html.ToJsonString()); + await SendTrace(input.YARDID, input.YARD, input.MBLNO); } } } @@ -550,5 +509,31 @@ namespace Myshipping.Application var list = await _bookingfile.FirstOrDefaultAsync(u => u.BookingId == Id); return list; } + + + + public async Task SendTrace(string YARDID, string YARD, string MBLNO) + { + _logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口"); + var key = _webconfig.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl"); + var url = _cache.GetAllDictData().Result; + BillTraceDto billdto = new BillTraceDto(); + List billTraceList = new List(); + billTraceList.Add(new BillTraceList + { + MBLNO = MBLNO, + YARD = YARD, + YardCode = YARDID, + CARRIER = null, + CARRIERID = null, + isBook = false + }); + billdto.Children = billTraceList; + billdto.Key = key.Account; + billdto.PWD = key.Password; + var json = billdto.ToJsonString(); + var html = await url.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "seae_billtraceurl").Value.SetHttpMethod(HttpMethod.Post).SetQueries(new { msg = json }).SetRetryPolicy(3, 5000).SendAsAsync(); + _logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口返回" + html.ToJsonString()); + } } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index c0a760a7..a157007b 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -26,5 +26,7 @@ namespace Myshipping.Application Task AddFile(IFormFile file, [FromForm] BookingFileDto dto); Task GetFile(long Id); + + Task SendTrace(string YARDID, string YARD, string MBLNO); } } \ No newline at end of file diff --git a/Myshipping.Core/Service/Dict/ISysDictDataService.cs b/Myshipping.Core/Service/Dict/ISysDictDataService.cs index 58bbc676..0802fecb 100644 --- a/Myshipping.Core/Service/Dict/ISysDictDataService.cs +++ b/Myshipping.Core/Service/Dict/ISysDictDataService.cs @@ -17,4 +17,6 @@ public interface ISysDictDataService Task QueryDictDataPageList([FromQuery] DictDataInput input); Task UpdateDictData(UpdateDictDataInput input); Task> GetDictDataByCode(string code); + + Task CacheData(); } diff --git a/Myshipping.Core/Service/Dict/SysDictDataService.cs b/Myshipping.Core/Service/Dict/SysDictDataService.cs index bba48bb5..f6832527 100644 --- a/Myshipping.Core/Service/Dict/SysDictDataService.cs +++ b/Myshipping.Core/Service/Dict/SysDictDataService.cs @@ -79,19 +79,7 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT await _sysDictDataRep.InsertAsync(dictData); - ////设置缓存 - await _cache.DelAsync(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA); - var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto - { - Id = d.Id, - TypeName = t.Name, - TypeCode = t.Code, - Value = d.Value, - Code = d.Code, - Sort = d.Sort, - Remark = d.Remark - }).ToListAsync(); - await _cache.SetAllDictData(list); + await CacheData(); } @@ -110,19 +98,7 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT await _sysDictDataRep.DeleteAsync(dictData); - ////设置缓存 - await _cache.DelAsync(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA); - var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto - { - Id = d.Id, - TypeName = t.Name, - TypeCode = t.Code, - Value = d.Value, - Code = d.Code, - Sort = d.Sort, - Remark = d.Remark - }).ToListAsync(); - await _cache.SetAllDictData(list); + await CacheData(); } /// @@ -144,19 +120,7 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT await _sysDictDataRep.AsUpdateable(dictData).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); - ////设置缓存 - await _cache.DelAsync(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA); - var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto - { - Id = d.Id, - TypeName = t.Name, - TypeCode = t.Code, - Value = d.Value, - Code = d.Code, - Sort = d.Sort, - Remark = d.Remark - }).ToListAsync(); - await _cache.SetAllDictData(list); + await CacheData(); } /// @@ -185,19 +149,7 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT throw Oops.Oh(ErrorCode.D3005); dictData.Status = input.Status; - ////设置缓存 - await _cache.DelAsync(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA); - var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto - { - Id = d.Id, - TypeName = t.Name, - TypeCode = t.Code, - Value = d.Value, - Code = d.Code, - Sort = d.Sort, - Remark = d.Remark - }).ToListAsync(); - await _cache.SetAllDictData(list); + await CacheData(); } /// @@ -226,8 +178,29 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT { await _sysDictDataRep.DeleteAsync(u => u.TypeId == dictTypeId); - ////设置缓存 - await _cache.DelAsync(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA); + await CacheData(); + } + + /// + /// 根据字典Code返回字典值列表 + /// + /// + /// + [NonAction] + public async Task> GetDictDataByCode(string code) + { + var payment = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Code == code).Select().ToListAsync(); + return payment; + } + + /// + /// 缓存数据 + /// + /// + /// + [NonAction] + public async Task CacheData() + { var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto { Id = d.Id, @@ -242,15 +215,4 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT } - /// - /// 根据字典Code返回字典值列表 - /// - /// - /// - [NonAction] - public async Task> GetDictDataByCode(string code) - { - var payment = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Where((d, t) => t.Code == code).Select().ToListAsync(); - return payment; - } } diff --git a/Myshipping.Web.Core/Startup.cs b/Myshipping.Web.Core/Startup.cs index d94c9728..834dd673 100644 --- a/Myshipping.Web.Core/Startup.cs +++ b/Myshipping.Web.Core/Startup.cs @@ -113,6 +113,9 @@ public class Startup : AppStartup //缓存EDI数据 App.GetService().CacheData(); + + //缓存字典数据 + App.GetService().CacheData(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env)