From 5683f6178291394d383215f746694258dff027e7 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 9 May 2024 10:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E7=94=A9=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E5=8A=A0=E8=BD=BD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskRollingNominationShowDto.cs | 5 ++ .../TaskManagePlat/Dtos/TaskManageMapper.cs | 1 + .../TaskManageRollingNominationService.cs | 3 +- .../TaskManageShareLinkService.cs | 83 ++++++++++++++++--- 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/Nomination/TaskRollingNominationShowDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/Nomination/TaskRollingNominationShowDto.cs index b9df6077..90c73437 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/Nomination/TaskRollingNominationShowDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/Nomination/TaskRollingNominationShowDto.cs @@ -221,6 +221,11 @@ namespace Myshipping.Application /// public string CtnNote { get; set; } + + /// + /// 箱号 + /// + public string EquipmentNumber { get; set; } } /// diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index 113e3947..c3388a4d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -941,6 +941,7 @@ namespace Myshipping.Application .Map(dest => dest.CtnCode, src => src.CTNCODE) .Map(dest => dest.CtnAll, src => src.CTNALL) .Map(dest => dest.CtnNum, src => src.CTNNUM) + .Map(dest => dest.EquipmentNumber, src => src.EQUIPMENT_NUMBER) .Map(dest => dest.PKId, src => src.PK_ID); config.ForType() diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs index 79bb1763..8fe48e41 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs @@ -326,7 +326,8 @@ namespace Myshipping.Application BatchId = preBillDispatch?.BATCH_ID, BookingId = preBillDetail.BOOKING_ID, GroupName = $"SHIPMENT_{idx + 1}", - CtnNote = ctnNote + CtnNote = ctnNote, + EquipmentNumber = preBillDetail.EQUIPMENT_NUMBER }; return preBillInfo; diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageShareLinkService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageShareLinkService.cs index acdc2943..229a7a34 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageShareLinkService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageShareLinkService.cs @@ -505,11 +505,7 @@ namespace Myshipping.Application.Service.TaskManagePlat }; var shipList = _taskRollingNominationShipInfoRepository.AsQueryable().Filter(null, true) - .Where(a => a.NOM_ID == rollModel.PK_ID && a.GROUP_INDX == 1 && a.IsDeleted == false).ToList(); - - if (shipList.Count == 0) - shipList = _taskRollingNominationShipInfoRepository.AsQueryable().Filter(null, true) - .Where(a => a.NOM_ID == rollModel.PK_ID && a.GROUP_INDX == 0 && a.IsDeleted == false).ToList(); + .Where(a => a.NOM_ID == rollModel.PK_ID && a.IsDeleted == false).ToList(); var fromEntity = shipList.Where(a => a.SHIP_TYPE.Equals("From", StringComparison.OrdinalIgnoreCase)).ToList(); @@ -517,28 +513,93 @@ namespace Myshipping.Application.Service.TaskManagePlat if (fromEntity.Count > 0) model.From = fromEntity.Select(p => p.Adapt()).ToList(); - var toEntity = shipList.Where(a => - a.SHIP_TYPE.Equals("To", StringComparison.OrdinalIgnoreCase)).ToList(); + var toEntity = shipList.Where(a => Regex.IsMatch(a.SHIP_TYPE, "To(\\s+[0-9]+)?" + , RegexOptions.IgnoreCase)).ToList(); if (toEntity.Count > 0) model.To = toEntity.Select(p => p.Adapt()).ToList(); + //这里为了前端原船和换船做了根据PORT对应 + var fromToList = model.From.GroupJoin(model.To, l => l.Port?.Trim(), r => r.Port?.Trim(), (l, r) => + { + TaskRollingNominationShipFromToDto dto = new TaskRollingNominationShipFromToDto(); + + dto.FromShip = l; + + var currArg = r.ToList(); + + if (currArg.Count > 0) + { + dto.ToShipList = currArg.Select((p, idx) => + { + if (Regex.IsMatch(p.ShipType, "[0-9]+")) + return new { SortNo = int.Parse(Regex.Match(p.ShipType, "[0-9]+").Value), Obj = p }; + + return new { SortNo = idx + 1, Obj = p }; + }).OrderBy(p => p.SortNo).Select(p => p.Obj).ToList(); + } + + return dto; + }).ToList(); + List> tuples = new List>(); model.LoadDetailList = list.Select(a => a.Detail.Adapt()).ToList(); + model.FromToList = new List(); + if (model.LoadDetailList.Count > 0) { model.TotalLoadCtnStat = string.Join(",", model.LoadDetailList.GroupBy(x => x.CtnAll) .Select(x => $"{x.Key}*{x.Sum(t => t.CtnNum)}").ToArray()); - var portList = model.LoadDetailList.Where(p => !string.IsNullOrWhiteSpace(p.PlaceOfReceipt)) - .Select(p => p.PlaceOfReceipt?.Trim()).Distinct().ToList(); + string rollRegex = "Roll\\s+to\\s+\\w+\\s+\\w{3,}\\/\\w+,\\s?if\\s+cannot\\s+catch\\s?,\\s+roll\\s+to\\s+\\w{3,}\\s+next\\s+sailing"; + + model.LoadDetailList.ForEach(p => + { + string vslCode = string.Empty; + string voyNo = string.Empty; + string strCode = string.Empty; + string strCode2 = string.Empty; + + if (Regex.IsMatch(p.Status, rollRegex,RegexOptions.IgnoreCase)) + { + string currS = Regex.Match(p.Status, "(?<=Roll\\sto\\s\\w+\\s)\\w{3,}\\/\\w+(?=,)").Value; + vslCode = Regex.Split(currS,"\\/")[0]?.Trim(); + voyNo = Regex.Split(currS, "\\/")[1]?.Trim(); + + strCode = Regex.Match(p.Status, "(?<=if\\scannot\\scatch\\s?,\\sroll\\sto\\s)\\w{3,}(?=\\s+next\\s+sailing)").Value?.Trim(); + } + + for (int i = 0; i < fromToList.Count; i++) + { + if (fromToList[i].FromShip.Port.Equals(p.PlaceOfReceipt, StringComparison.OrdinalIgnoreCase)) + { + var fromInfo = fromToList[i].FromShip.Adapt(); - model.From = model.From.Where(p => portList.Any(p2 => p2.Equals(p.Port?.Trim()))).ToList(); + List toShipList = new List(); - model.To = model.To.Where(p => portList.Any(p2 => p2.Equals(p.Port?.Trim()))).ToList(); + for (int j = 0; j < fromToList[i].ToShipList.Count; j++) + { + if (fromToList[i].ToShipList[j].VslCode.Equals(vslCode, StringComparison.OrdinalIgnoreCase)) + { + toShipList.Add(fromToList[i].ToShipList[j].Adapt()); + } + else if (fromToList[i].ToShipList[j].ShipString.Equals(strCode, StringComparison.OrdinalIgnoreCase)) + { + toShipList.Add(fromToList[i].ToShipList[j].Adapt()); + } + } + + model.FromToList.Add(new TaskRollingNominationShipFromToDto + { + FromShip = fromInfo, + ToShipList = toShipList + }); + } + } + }); } } catch (Exception ex)