From d50ced386ee8a541b1e41c97523a3723f12882a1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 18 Oct 2023 14:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=B4=A7=E7=BA=B8?= =?UTF-8?q?=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/Dtos/TaskMessageInfoDto.cs | 5 + .../ITaskShippingOrderCompareService.cs | 8 ++ .../TaskShippingOrderCompareService.cs | 97 +++++++++++++++++++ .../PublishProfiles/FolderProfile.pubxml.user | 2 +- 4 files changed, 111 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskMessageInfoDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskMessageInfoDto.cs index bae10621..5f721b27 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskMessageInfoDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskMessageInfoDto.cs @@ -30,6 +30,11 @@ namespace Myshipping.Application /// public string BusiPKId { get; set; } + /// + /// 比对ID + /// + public string TaskCompareId { get; set; } + /// /// 用户ID /// diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskShippingOrderCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskShippingOrderCompareService.cs index 0322deb9..2fa6fe4e 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskShippingOrderCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskShippingOrderCompareService.cs @@ -39,5 +39,13 @@ namespace Myshipping.Application /// 订舱主键 /// 返回回执 Task ExcuteAutoShippingOrderCompareAsync(string bookingId); + + + /// + /// 获取下货纸比对结果 + /// + /// 订舱主键 + /// 返回回执 + Task GetShippingOrderCompareResult(long bookingId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs index b9ee6e3c..9a851b62 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskShippingOrderCompareService.cs @@ -561,5 +561,102 @@ namespace Myshipping.Application return await InnerExcuteShippingOrderCompareAsync(bookingId, "AUTO"); } #endregion + + + /// + /// 获取下货纸比对结果 + /// + /// 订舱主键 + /// 返回回执 + [HttpGet("/TaskShippingOrderCompare/GetShippingOrderCompareResult")] + public async Task GetShippingOrderCompareResult(long bookingId) + { + string batchNo = IDGen.NextID().ToString(); + + TaskManageExcuteResultDto result = new TaskManageExcuteResultDto(); + + try + { + var model = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); + + DateTime nowDate = DateTime.Now; + + TaskMessageInfoDto msgModel = new TaskMessageInfoDto + { + Head = new TaskMessageHead + { + GID = batchNo, + MessageType = "DRAFT_COMPARE", + SenderId = App.Configuration["RulesEngineSender"], + SenderName = App.Configuration["RulesEngineSenderName"], + ReceiverId = "RulesEngine", + ReceiverName = "大简云规则引擎", + Version = "1.0", + RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"), + RequestAction = "Compare", + }, + Main = new TaskMessageMain + { + BusiPKId = bookingId.ToString(), + TaskCompareId = model.LstShipOrderCompareId, + } + }; + + _logger.LogInformation($"开始请求查询 msg={JSON.Serialize(msgModel)}"); + + result = await GetCompareResult(msgModel); + } + catch (Exception ex) + { + _logger.LogInformation("获取Draft比对结果异常,原因:{error}", ex.Message); + + throw Oops.Oh($"获取Draft比对结果异常,原因:{ex.Message}"); + } + + return result; + } + + #region 获取Draft比对结果 + /// + /// 获取Draft比对结果 + /// + /// 请求报文 + /// 返回回执 + [NonAction] + private async Task GetCompareResult(TaskMessageInfoDto info) + { + TaskManageExcuteResultDto model = null; + + var url = App.Configuration["GetShippingOrderCompareUrl"]; + + try + { + var res = await url.SetHttpMethod(HttpMethod.Post) + .SetBody(JSON.Serialize(info), "application/json") + .SetContentEncoding(Encoding.UTF8) + .PostAsync(); + + _logger.LogInformation("批次={no} 对应请求报文完成 res={res}", info.Head.GID, JSON.Serialize(res)); + + if (res.StatusCode == System.Net.HttpStatusCode.OK) + { + var userResult = await res.Content.ReadAsStringAsync(); + + _logger.LogInformation("对应请求报文 userResult={userResult}", userResult); + + model = JSON.Deserialize(userResult); + } + } + catch (Exception ex) + { + //写日志 + if (ex is HttpRequestException) + throw Oops.Oh(10000002); + } + + return model; + } + #endregion } } diff --git a/ServiceProjectSyncWin/Properties/PublishProfiles/FolderProfile.pubxml.user b/ServiceProjectSyncWin/Properties/PublishProfiles/FolderProfile.pubxml.user index 63994263..21897512 100644 --- a/ServiceProjectSyncWin/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/ServiceProjectSyncWin/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2023-09-04T09:20:02.6360803Z;True|2023-09-04T10:10:54.4958128+08:00; + True|2023-09-11T12:42:58.0481784Z;True|2023-09-11T20:42:47.7986046+08:00;True|2023-09-04T17:20:02.6360803+08:00;True|2023-09-04T10:10:54.4958128+08:00; \ No newline at end of file