From 117691fb43f9f61c7b00665b7a035b29fb537c5c Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 15 May 2024 14:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=90=E8=B8=AA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=A2=9E=E5=8A=A0=E6=A8=AA=E5=90=91=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/QueryTraceAfterPortResultDto.cs | 5 + .../EmbedTraceProductService.cs | 99 +++++++++++++++++-- .../Interface/IEmbedTraceProductService.cs | 4 +- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs index 226bd251..2e7e818c 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs @@ -391,5 +391,10 @@ namespace Myshipping.Application /// 顺序号 /// public int sortNo { get; set; } + + /// + /// 状态代码中文名称 + /// + public string statusCnName { get; set; } } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs index f17ecde5..2f404668 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs @@ -5,6 +5,7 @@ using Furion.DynamicApiController; using Furion.FriendlyException; using Furion.JsonSerialization; using Furion.RemoteRequest.Extensions; +using Mapster; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -51,7 +52,7 @@ namespace Myshipping.Application /// 查询单票运踪流程详情 /// 返回回执 [AllowAnonymous, HttpPost("/EmbedTraceProduct/GetTraceFlowInfo"), ApiUser(ApiCode = "EmbedServiceTraceShow")] - public async Task GetTraceFlowInfo(EmbedQueryTraceFlowDto model) + public async Task GetTraceFlowInfo(EmbedQueryTraceFlowDto model) { /* 1、调取运踪接口。 embed_trace_flow_url @@ -59,7 +60,7 @@ namespace Myshipping.Application 3、返回结果 */ - QueryTraceAfterPortResultDataDto result = null; + EmbedTraceFlowResultDto result = null; string batchNo = IDGen.NextID().ToString(); @@ -89,27 +90,113 @@ namespace Myshipping.Application var statusDict = _cache.GetAllDictData().GetAwaiter().GetResult() .Where(t => t.TypeCode.Equals("after_port_trace_ctn_status", StringComparison.OrdinalIgnoreCase)).ToList(); - if(queryRlt.code == 200) + //按顺序取状态配置字典 + Dictionary> statusEnumDict = statusDict.Select(a => new { Key = a.Code, Val = new Tuple(a.Value, a.Sort), Sort = a.Sort }) + .OrderBy(a => a.Sort).ToDictionary(a => a.Key, b => b.Val); + + string[] skipStatus = new string[] { "GIOI", "LOFV", "FVD", "FVA", "DFFV" }; + + if (queryRlt.code == 200) { - result = queryRlt.data.FirstOrDefault(); + var queryResult = queryRlt.data.FirstOrDefault(); + + result = queryResult.Adapt(); if (result != null && result.resultData != null) { + Dictionary referToCtnDict = new Dictionary(); + if (result.resultData.containerInfoList != null && result.resultData.containerInfoList.Count > 0) { result.resultData.containerInfoList.ForEach(s => { if(s.containerStatusInfoList != null && s.containerStatusInfoList.Count > 0) { + referToCtnDict.Add(s.containerNo, s.containerStatusInfoList.Count); + s.containerStatusInfoList = s.containerStatusInfoList.Select((a, idx) => { a.sortNo = idx + 1; + + if (statusEnumDict.Any(p => p.Key.Equals(a.statusCd, StringComparison.OrdinalIgnoreCase))) + { + a.statusCnName = statusEnumDict[a.statusCd].Item1; + } + else + { + a.statusCnName = a.statusCd; + } + return a; }).ToList(); } }); } + + result.embedTraceFlowStatusList = new List(); + + var ctnNo = referToCtnDict.OrderByDescending(a => a.Value).FirstOrDefault().Key; + + var longContainerStatusList = result.resultData.containerInfoList.FirstOrDefault(a => a.containerNo.Equals(ctnNo, StringComparison.OrdinalIgnoreCase)) + .containerStatusInfoList; + + + var takeList = result.resultData.containerInfoList.SelectMany(p => p.containerStatusInfoList).GroupBy(a => a.statusCd).Select(a => + { + var currArg = a.ToList(); + + EmbedTraceFlowStatusInfo currStatus = new EmbedTraceFlowStatusInfo + { + voy = a.FirstOrDefault().voy, + statusDescription = a.FirstOrDefault().statusDescription, + statusTime = a.FirstOrDefault().statusTime, + vslName = a.FirstOrDefault().vslName, + statusCd = a.FirstOrDefault().statusCd, + statusPlace = a.FirstOrDefault().statusPlace, + statusTerminal = a.FirstOrDefault().statusTerminal, + statusCnName = a.FirstOrDefault().statusCnName, + sortNo = a.FirstOrDefault().sortNo, + }; + + if (!currArg.Any(a => !a.isEst.Equals("N", StringComparison.OrdinalIgnoreCase))) + { + currStatus.isComplete = true; + currStatus.hasStatusCtnNum = currArg.Count; + currStatus.noStatusCtnNum = 0; + } + else + { + currStatus.isComplete = true; + currStatus.hasStatusCtnNum = currArg.Count(a => a.isEst.Equals("N", StringComparison.OrdinalIgnoreCase)); + currStatus.noStatusCtnNum = currArg.Count(a => !a.isEst.Equals("N", StringComparison.OrdinalIgnoreCase)); + } + + currStatus.statusCtnStatic = $"{currStatus.hasStatusCtnNum}/{(currStatus.hasStatusCtnNum + currStatus.noStatusCtnNum)}"; + + return currStatus; + }).ToList(); + + foreach (KeyValuePair> kvp in statusEnumDict) + { + if(!skipStatus.Contains(kvp.Key)) + { + var currStatus = takeList.FirstOrDefault(p => p.statusCd.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase)); + + if(currStatus == null) + { + currStatus = new EmbedTraceFlowStatusInfo + { + statusCd = kvp.Key, + statusCnName = kvp.Value.Item1, + sortNo = kvp.Value.Item2, + statusCtnStatic = $"0/{referToCtnDict.Count}", + }; + } + + result.embedTraceFlowStatusList.Add(currStatus); + } + } } } @@ -124,7 +211,7 @@ namespace Myshipping.Application /// 查询单票运踪流程详情 /// 返回回执 [AllowAnonymous, HttpPost("/EmbedTraceProduct/GetTraceVerticalInfo"), ApiUser(ApiCode = "EmbedServiceTraceShow")] - public async Task GetTraceVerticalInfo(EmbedQueryTraceFlowDto model) + public async Task GetTraceVerticalInfo(EmbedQueryTraceFlowDto model) { /* 1、调取运踪接口。 embed_trace_flow_url @@ -132,7 +219,7 @@ namespace Myshipping.Application 3、返回结果 */ - QueryTraceAfterPortResultDataDto result = null; + EmbedTraceFlowResultDto result = null; return result; diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedTraceProductService.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedTraceProductService.cs index 0949e265..f6ce40ee 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedTraceProductService.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedTraceProductService.cs @@ -16,13 +16,13 @@ namespace Myshipping.Application /// /// 查询单票运踪流程详情 /// 返回回执 - Task GetTraceFlowInfo(EmbedQueryTraceFlowDto model); + Task GetTraceFlowInfo(EmbedQueryTraceFlowDto model); /// /// 获取单票运踪流程纵向详情 /// /// 查询单票运踪流程详情 /// 返回回执 - Task GetTraceVerticalInfo(EmbedQueryTraceFlowDto model); + Task GetTraceVerticalInfo(EmbedQueryTraceFlowDto model); } }