diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index b88de866..d71f5239 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -157,9 +157,9 @@ namespace Myshipping.Application.Service.BookingOrder /// 请求船期详情 /// 返回船期结果 [HttpPost("/BookingMSKSPOTAPI/SearchShipSailingSchedule")] - public async Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model) + public async Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model) { - List list = new List(); + List list = new List(); /* MSKApiSailingSchedulePoint2Point @@ -285,12 +285,158 @@ namespace Myshipping.Application.Service.BookingOrder if (resultInfo != null && resultInfo.code == 200 && resultInfo.data != null && resultInfo.data.Count > 0) { - list = resultInfo.data; - - foreach (var scheduleModel in list) + foreach (var scheduleModel in resultInfo.data) { - await CacheShipSailingSchedule(scheduleModel); + CacheShipSailingSchedule(scheduleModel).GetAwaiter().GetResult(); } + + list = resultInfo.data.Select(a => + { + MSKAPISPOTScheduleRateResultShowDto showDto = new MSKAPISPOTScheduleRateResultShowDto + { + priceID = a.priceID, + PId = a.PId, + MD5 = a.MD5, + totalAmount = a.totalAmount.HasValue ? (decimal)a.totalAmount.Value : 0, + TotalCurrency = a.totalCurrency, + orignCarrierCityGeoID = a.originGeoId, + orignUNLocationCode = a.originUnLocCode, + orignCityName = a.originCityName, + originRegionName = a.originRegionName, + originCountryName = a.originCountryName, + + deliveryCarrierCityGeoID = a.destinationGeoId, + deliveryUNLocationCode = a.destinationUnLocCode, + deliveryCityName = a.destinationCityName, + deliveryRegionName = a.destinationRegionName, + deliveryCountryName = a.destinationCountryName, + + vesselName = a.vesselName, + carrierDepartureVoyageNumber = a.voyageNumber, + + Legs = new List() + }; + + //ETD + if (!string.IsNullOrWhiteSpace(a.departureDate)) + { + DateTime currDate = DateTime.MinValue; + + if (DateTime.TryParse(a.departureDate, out currDate)) + { + showDto.ETD = currDate; + } + else + { + throw Oops.Bah($"查询船期错误,priceID={a.priceID} pid={a.PId} 预计离港日期departureDate={a.departureDate} 格式解析错误"); + } + } + + //ETA + if (!string.IsNullOrWhiteSpace(a.arrivalDate)) + { + DateTime currDate = DateTime.MinValue; + + if (DateTime.TryParse(a.arrivalDate, out currDate)) + { + showDto.ETA = currDate; + } + else + { + throw Oops.Bah($"查询船期错误,priceID={a.priceID} pid={a.PId} 预计到达日期 arrivalDate={a.arrivalDate} 格式解析错误"); + } + } + + //计算预计天数 + if (showDto.ETD.HasValue && showDto.ETA.HasValue) + { + TimeSpan ts = showDto.ETD.Value.Subtract(showDto.ETA.Value); + var timeDiff = ts.TotalHours; + + showDto.days = (int)Math.Ceiling(timeDiff / 24.0); + } + + if (a.isTransfer.Equals("true", StringComparison.OrdinalIgnoreCase)) + showDto.isTransfer = true; + + //Legs + if (a.scheduleDetails != null && a.scheduleDetails.Count > 0) + { + var legs = a.scheduleDetails.Select(b => + { + MSKAPISPOTScheduleRateResultShowLegsDto leg = new MSKAPISPOTScheduleRateResultShowLegsDto + { + vesselName = b.transport.vessel.longName, + VoyageNo = b.transport.voyageNumber, + From = new MSKAPISPOTScheduleRateResultShowLegsLocationDto { + CityGeoId = b.fromLocation.cityGeoId, + CityName = b.fromLocation.cityName, + CountryCode = b.fromLocation.countryCode, + CountryName = b.fromLocation.countryName, + rkstCode = b.fromLocation.rkstCode, + SiteGeoId = b.fromLocation.siteGeoId, + LocationType = "From", + RegionName = b.fromLocation.regionName, + SiteName = b.fromLocation.siteName, + UnLocCode = b.fromLocation.unLocCode, + }, + To = new MSKAPISPOTScheduleRateResultShowLegsLocationDto { + CityGeoId = b.toLocation.cityGeoId, + CityName = b.toLocation.cityName, + CountryCode = b.toLocation.countryCode, + CountryName = b.toLocation.countryName, + rkstCode = b.toLocation.rkstCode, + SiteGeoId = b.toLocation.siteGeoId, + LocationType = "To", + RegionName = b.toLocation.regionName, + SiteName = b.toLocation.siteName, + UnLocCode = b.toLocation.unLocCode, + } + }; + + //ETD + if (!string.IsNullOrWhiteSpace(b.fromLocation.date)) + { + DateTime currDate = DateTime.MinValue; + + if (DateTime.TryParse($"{b.fromLocation.date} {b.fromLocation.time}", out currDate)) + { + leg.ETD = currDate; + } + else + { + throw Oops.Bah($"查询船期错误,航程明细 priceID={a.priceID} pid={a.PId} 预计离港日期fromLocation.date={b.fromLocation.date} {b.fromLocation.time} 格式解析错误"); + } + } + + //ETA + if (!string.IsNullOrWhiteSpace(b.toLocation.date)) + { + DateTime currDate = DateTime.MinValue; + + if (DateTime.TryParse(a.arrivalDate, out currDate)) + { + leg.ETD = currDate; + } + else + { + throw Oops.Bah($"查询船期错误,航程明细 priceID={a.priceID} pid={a.PId} 预计到达日期 toLocation.date={b.toLocation.date} {b.toLocation.time} 格式解析错误"); + } + } + + return leg; + }).ToList(); + showDto.Legs = legs.OrderBy(t=>t.ETD).Select((t,idx)=> { + t.SortNo = idx + 1; + return t; + }).ToList(); + } + + return showDto; + }).ToList(); + + + } else { @@ -315,7 +461,7 @@ namespace Myshipping.Application.Service.BookingOrder /// 船期查询结果明细 /// 船期类型 MSKSPOT-马士基即期 /// 返回主键ID - private async Task CacheShipSailingSchedule(MSKAPISPOTSearchScheduleRateResultDataDto model,string busiType = "MSKSPOT") + private async Task CacheShipSailingSchedule(MSKAPISPOTSearchScheduleRateResultDataDto model,string busiType = "MSKSPOT") { /* 1、按照船期明细缓存,并把ID作为缓存的KEY @@ -344,8 +490,6 @@ namespace Myshipping.Application.Service.BookingOrder { await _cache.SetTimeoutAsync(shareKey, Newtonsoft.Json.JsonConvert.SerializeObject(model), expireTimeSpan); } - - return model.PId; } #endregion diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateResultDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateResultDto.cs index 9b65691b..696f9674 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateResultDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateResultDto.cs @@ -40,6 +40,282 @@ namespace Myshipping.Application public long PId { get; set; } } + public class MSKAPISPOTScheduleRateResultShowDto + { + /// + /// 主键ID + /// + public long PId { get; set; } + + /// + /// 船期MD5 + /// + public string MD5 { get; set; } + + /// + /// 价格id, 可进一步通过API进行其他操作 + /// + public string priceID { get; set; } + + /// + /// 币别 + /// + public string TotalCurrency { get; set; } + + /// + /// 金额 + /// + public decimal totalAmount { get; set; } + + /// + /// 是否中转 + /// + public bool isTransfer { get; set; } + + /// + /// ETD + /// + public Nullable ETD { get; set; } + + /// + /// ETA + /// + public Nullable ETA { get; set; } + + /// + /// 城市名(始发地) + /// + public string orignCityName { get; set; } + + /// + /// 地点的GEO ID(始发地) + /// + public string orignCarrierSiteGeoID { get; set; } + + /// + /// 地点的CITY GEO ID(始发地) + /// + public string orignCarrierCityGeoID { get; set; } + + /// + /// 地点的名称(始发地) + /// + public string orignLocationName { get; set; } + + /// + /// 省 + /// + public string originRegionName { get; set; } + + /// + /// 国家代码(始发地) + /// + public string orignCountryCode { get; set; } + + /// + ///国家名称(始发地) + /// + public string originCountryName { get; set; } + + /// + /// 位置类型(始发地) + /// + public string orignLocationType { get; set; } + + /// + /// 五字码(始发地) + /// + public string orignUNLocationCode { get; set; } + + /// + /// 区代码(始发地) + /// + public string orignUNRegionCode { get; set; } + + /// + /// 城市名(目的地) + /// + public string deliveryCityName { get; set; } + + /// + /// 地点的GEO ID(目的地) + /// + public string deliveryCarrierSiteGeoID { get; set; } + + /// + /// 地点的CITY GEO ID(目的地) + /// + public string deliveryCarrierCityGeoID { get; set; } + + /// + /// 地点的名称(目的地) + /// + public string deliveryLocationName { get; set; } + + /// + /// 省 + /// + public string deliveryRegionName { get; set; } + + /// + /// 国家代码(目的地) + /// + public string deliveryCountryCode { get; set; } + + /// + /// 国家名称(目的地) + /// + public string deliveryCountryName { get; set; } + + /// + /// 位置类型(目的地) + /// + public string deliveryLocationType { get; set; } + + /// + /// 五字码(目的地) + /// + public string deliveryUNLocationCode { get; set; } + + /// + /// 区代码(目的地) + /// + public string deliveryUNRegionCode { get; set; } + + + /// + /// IMO + /// + public string vesselIMONumber { get; set; } + + /// + /// 航次号 + /// + public string carrierVesselCode { get; set; } + + /// + /// 运输方式 + /// + public string transportMode { get; set; } + + /// + /// 船名 + /// + public string vesselName { get; set; } + + /// + /// 航次代码 + /// + public string carrierDepartureVoyageNumber { get; set; } + + /// + /// 承运人代码(MAEU, SEAU, SEJJ, MCPU, MAEI) + /// + public string vesselOperatorCarrierCode { get; set; } + + /// + /// 行程天数 + /// + public int days { get; set; } + + /// + /// 航程明细 + /// + public List Legs { get; set; } + } + + public class MSKAPISPOTScheduleRateResultShowLegsDto + { + /// + /// 排序值 + /// + public int SortNo { get; set; } + + /// + /// 船名 + /// + public string vesselName { get; set; } + + /// + /// 航次 + /// + public string VoyageNo { get; set; } + + /// + /// ETD + /// + public Nullable ETD { get; set; } + + /// + /// ATD + /// + public Nullable ETA { get; set; } + + /// + /// 起始地 + /// + public MSKAPISPOTScheduleRateResultShowLegsLocationDto From { get; set; } + + /// + /// 目的地 + /// + public MSKAPISPOTScheduleRateResultShowLegsLocationDto To { get; set; } + + } + + public class MSKAPISPOTScheduleRateResultShowLegsLocationDto + { + /// + /// 定位类型 From-起始地 To-目的地 + /// + public string LocationType { get; set; } + /// + /// 码头定位ID + /// + public string SiteGeoId { get; set; } + + /// + /// 城市定位ID + /// + public string CityGeoId { get; set; } + + /// + /// + /// + public string rkstCode { get; set; } + + /// + /// 城市定位ID + /// + public string UnLocCode { get; set; } + + /// + /// 码头全称 + /// + public string SiteName { get; set; } + + /// + /// 城市名 + /// + public string CityName { get; set; } + + /// + /// 省 + /// + public string RegionName { get; set; } + + /// + /// 特别行政区或国家代码 + /// + public string CountryCode { get; set; } + + /// + /// 特别行政区或国家名称 + /// + public string CountryName { get; set; } + } + + /// /// 马士基即期船期查询结果 /// @@ -146,7 +422,7 @@ namespace Myshipping.Application public string voyageNumber { get; set; } /// - /// 航次 + /// 海运费 /// public Nullable oceanFreight { get; set; } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs index 1c00f7f1..208dab2a 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs @@ -26,7 +26,7 @@ namespace Myshipping.Application.Service.BookingOrder /// /// 请求船期详情 /// 返回船期结果 - Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model); + Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model); /// /// 发送马士基订舱请求 diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 7b3130b0..c95b40e3 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -3784,7 +3784,7 @@ namespace Myshipping.Application cautionNoticeTaskWholeShipDto.VoynoNewVal = bcTargetDto.VoyNo; cautionNoticeTaskWholeShipDto.IsVesselChange = true; - //isNeedWholeShip = true; + isNeedWholeShip = true; } else { @@ -3860,26 +3860,6 @@ namespace Myshipping.Application _logger.LogInformation($"触发整船提醒完成,结果={JSON.Serialize(wholeShipRlt)}"); } - else - { - if (cautionNoticeTaskWholeShipDto.IsVesselChange) - { - if (bookingSlotAllocList.Count > 0) - { - bookingSlotAllocList.ForEach(async ca => - { - var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false - && x.TenantId == UserManager.TENANT_ID); - - CreateTask(CautionNoticeTaskEnum.ChangeVesselVoyno, bcSrcDto, userList, bookingInfo, slotInfo, srcVesselVoyno, targetVesselVoyno, $"提单号:{bcSrcDto.MBLNo} \r\n船名航次变更了 \r\n原:{srcVesselVoyno} \r\n新:{targetVesselVoyno}", true); - }); - } - else if (slotInfo != null) - { - CreateTask(CautionNoticeTaskEnum.ChangeVesselVoyno, bcSrcDto, userList, null, slotInfo, srcVesselVoyno, targetVesselVoyno, $"提单号:{bcSrcDto.MBLNo} \r\n船名航次变更了 \r\n原:{srcVesselVoyno} \r\n新:{targetVesselVoyno}", true); - } - } - } } }