diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedTraceFlowResultDto.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedTraceFlowResultDto.cs index fc2a179a..012f2799 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedTraceFlowResultDto.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedTraceFlowResultDto.cs @@ -81,6 +81,19 @@ namespace Myshipping.Application /// public string statusCnName { get; set; } + /// + /// 是否分段开始 + /// + public bool isSplitStart { get; set; } + /// + /// 是否分段结束 + /// + public bool isSplitEnd { get; set; } + + /// + /// 是否当前最新节点 + /// + public bool isCurrentStatus { get; set; } } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs index 70a516e1..92f89f00 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/QueryTraceAfterPortResultDto.cs @@ -401,5 +401,10 @@ namespace Myshipping.Application /// 状态代码中文名称 /// public string statusCnName { get; set; } + + /// + /// 是否当前最新节点 + /// + public bool isCurrentStatus { get; set; } } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs index c92378be..6a2a1be2 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedTraceProductService.cs @@ -18,6 +18,7 @@ using System.Linq; using System.Net.Http; using System.Reflection.Emit; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Yitter.IdGenerator; @@ -97,6 +98,7 @@ namespace Myshipping.Application string[] skipStatus = new string[] { "GIOI", "LOFV", "FVD", "FVA", "DFFV", "LOR", "DFR", "RA", "DIFR", "LOT", "DIFT", "ADI", "DIDI", "CGRL", "RFP","ETD","ETA", "LDI", "CDPOD", "BPOD" }; string[] transferStatus = new string[] { "AIP", "BIP", "ETDIP", "DIIP", "GOIP", "GIIP", "LIP", "EDIP", "DEIP", "EAIP" }; + if (queryRlt.code == 200) { var queryResult = queryRlt.data.FirstOrDefault(); @@ -107,6 +109,7 @@ namespace Myshipping.Application { //这里需要翻译一下箱型 var ctnCodeMappingList = _cache.GetAllMappingCtn().GetAwaiter().GetResult().ToList(); + var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList(); Dictionary referToCtnDict = new Dictionary(); @@ -116,11 +119,27 @@ namespace Myshipping.Application { result.resultData.containerInfoList.ForEach(s => { - var ctnMapping = ctnCodeMappingList.FirstOrDefault(t => t.MapCode.Equals(s.size)); + string ctnSize = s.size; + + if(!string.IsNullOrWhiteSpace(s.size)) + { + ctnSize = $"{Regex.Match(s.size, "[0-9]{2}")}{Regex.Match(s.size, "[a-zA-Z]{1,3}([0-9]{1})?")}"; + } + + var ctnCode = ctnCodeList.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t.EdiCode) && t.EdiCode.Equals(ctnSize)); - if(ctnMapping != null) + if (ctnCode != null) + { + s.sizeName = ctnCode.Name?.Trim(); + } + else { - s.sizeName = ctnMapping.MapName?.Trim(); + var ctnMapping = ctnCodeMappingList.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t.MapCode) && t.MapCode.Equals(ctnSize)); + + if (ctnMapping != null) + { + s.sizeName = ctnMapping.MapName?.Trim(); + } } if (s.containerStatusInfoList != null && s.containerStatusInfoList.Count > 0) @@ -157,8 +176,9 @@ namespace Myshipping.Application var ctnNo = referToCtnDict.OrderByDescending(a => a.Value).FirstOrDefault().Key; - var longContainerStatusList = result.resultData.containerInfoList.FirstOrDefault(a => a.containerNo.Equals(ctnNo, StringComparison.OrdinalIgnoreCase)) - .containerStatusInfoList; + var longContainerStatus = result.resultData.containerInfoList.FirstOrDefault(a => a.containerNo.Equals(ctnNo, StringComparison.OrdinalIgnoreCase)); + + var longContainerStatusList = longContainerStatus.containerStatusInfoList; var takeList = result.resultData.containerInfoList.SelectMany(p => p.containerStatusInfoList).GroupBy(a => a.statusCd).Select(a => @@ -221,10 +241,33 @@ namespace Myshipping.Application currStatus.statusCnName = kvp.Value.Item2; } + if(currStatus.statusCd.Equals("DPOL", StringComparison.OrdinalIgnoreCase)) + currStatus.isSplitStart = true; + + if (currStatus.statusCd.Equals("APOD", StringComparison.OrdinalIgnoreCase)) + currStatus.isSplitEnd = true; + + if (!string.IsNullOrWhiteSpace(longContainerStatus.currentNodeCd) && longContainerStatus.currentNodeCd.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase)) + { + currStatus.isCurrentStatus = true; + } + result.embedTraceFlowStatusList.Add(currStatus); } } } + + + result.resultData.containerInfoList.ForEach(b => + { + b.containerStatusInfoList.ForEach(c => { + if (!string.IsNullOrWhiteSpace(b.currentNodeCd) && b.currentNodeCd.Equals(c.statusCd, StringComparison.OrdinalIgnoreCase)) + { + c.isCurrentStatus = true; + } + }); + + }); } }