From b58f631ab70e37037f013289b9d9c364bfdd484a Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Thu, 4 Jul 2024 17:59:30 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index f31a0ebd..c7416dda 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -12897,7 +12897,7 @@ namespace Myshipping.Application public async Task ReceiveBookingReject(ReceiveBookingRejectInputDto input) { // 客户订舱:运营端发送订舱数据给客户端 - if (App.Configuration["RunType"] == CommonConst.RUN_TYPE_DJY) + if (App.Configuration["RunType"] != CommonConst.RUN_TYPE_DJY) { return new ReceiveBcInfoResultDto(false, "非运营端,接收失败"); } From 856c4622f8fb694f56eb75c59cb4437f4ac4d1d8 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 4 Jul 2024 18:19:43 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20SPOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingMSKSPOTAPIService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index a655c3b5..cb61d6e3 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -623,7 +623,7 @@ namespace Myshipping.Application.Service.BookingOrder throw Oops.Oh("未配置发送订舱请求接口地址,请联系管理员"); var webAccountConfig = _webAccountConfig - .GetAccountConfig("MSKSpotApi", UserManager.UserId).GetAwaiter().GetResult(); + .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult(); if (webAccountConfig == null) throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi"); From 159cecb06cf9a127c2b1828ff3e663e4d3913914 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 4 Jul 2024 18:38:31 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20SPOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingMSKSPOTAPIService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index cb61d6e3..d2869dd8 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -118,7 +118,7 @@ namespace Myshipping.Application.Service.BookingOrder { userKey = App.Configuration["MSKAPIDjyUserKey"], userSecret = App.Configuration["MSKAPIDjyUserSecret"], - operatingEnvironment = "PRODUCTION",//App.Configuration["MSKAPIOPEnvironment"], + operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], spot_api_key = webAccountConfig.Account, brandScac = model.carrierCode, originPrefix = model.cityName @@ -244,7 +244,7 @@ namespace Myshipping.Application.Service.BookingOrder { userKey = App.Configuration["MSKAPIDjyUserKey"], userSecret = App.Configuration["MSKAPIDjyUserSecret"], - operatingEnvironment = "PRODUCTION",//App.Configuration["MSKAPIOPEnvironment"], + operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], spot_api_key = webAccountConfig.Account, originServiceMode = model.originServiceMode, destinationServiceMode = model.destinationServiceMode, @@ -1229,7 +1229,7 @@ namespace Myshipping.Application.Service.BookingOrder { userKey = App.Configuration["MSKAPIDjyUserKey"], userSecret = App.Configuration["MSKAPIDjyUserSecret"], - operatingEnvironment = "PRODUCTION",//App.Configuration["MSKAPIOPEnvironment"], + operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"], commodityName = model.commodityName, mskAppKey = webAccountConfig.Account }; From 60fab066b2f46851d94c04f982f0c2a50c5054be Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 4 Jul 2024 19:11:05 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20SPOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKSPOTAPIService.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index d2869dd8..c22e696c 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -726,7 +726,7 @@ namespace Myshipping.Application.Service.BookingOrder bookingDto.bookingBody.transport = new MSKAPIBookingTransport { carrierCode = model.carrierCode, - earliestDepartureDate = model.earliestDepartureDate.Value.ToString("yyyy-MM-ddTHH:mm:ss"), + //earliestDepartureDate = model.earliestDepartureDate.Value.ToString("yyyy-MM-ddTHH:mm:ss"), exportServiceMode = model.exportServiceMode, importServiceMode = model.importServiceMode, routeDetails = new MSKAPIBookingRouteDetails @@ -748,7 +748,22 @@ namespace Myshipping.Application.Service.BookingOrder } }; - for(int i=0;i< selectedShipSchedule.scheduleDetails.Count;i++) + //ETD + if (!string.IsNullOrWhiteSpace(selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.date)) + { + DateTime currDate = DateTime.MinValue; + + if (DateTime.TryParse($"{selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.date} {selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.time}", out currDate)) + { + bookingDto.bookingBody.transport.earliestDepartureDate = currDate.ToString("yyyy-MM-ddTHH:mm:ss"); + } + else + { + throw Oops.Bah($"查询船期错误,priceID={model.priceID} pid={model.PId} 预计离港日期departureDate={selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.date} {selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.time} 格式解析错误"); + } + } + + for (int i=0;i< selectedShipSchedule.scheduleDetails.Count;i++) { var detail = selectedShipSchedule.scheduleDetails[i]; @@ -768,7 +783,7 @@ namespace Myshipping.Application.Service.BookingOrder } } - //ETD + //ETA if (!string.IsNullOrWhiteSpace(detail.toLocation.date)) { DateTime currDate = DateTime.MinValue; From c2d52217196b8c6b2dc883eb1cdad153efa6f3e2 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 11:39:21 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=88=B9=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingCOSCOService.cs | 112 +++---- .../BookingOrder/BookingMSKAPIService.cs | 305 ++++++++++++++---- ...SKAPISearchPoint2PointScheduleResultDto.cs | 99 +++++- .../Dto/QueryShipSailingScheduleDto.cs | 20 ++ .../Dto/SearchShipSailingScheduleResultDto.cs | 111 ++----- Myshipping.Core/Myshipping.Core.xml | 20 ++ .../Dto/DjyWebsiteAccountConfigInput.cs | 22 +- 7 files changed, 486 insertions(+), 203 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingCOSCOService.cs b/Myshipping.Application/Service/BookingOrder/BookingCOSCOService.cs index d4b84f55..b53e2ea8 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingCOSCOService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingCOSCOService.cs @@ -148,62 +148,62 @@ namespace Myshipping.Application.Service.BookingOrder { resultInfo.data.ForEach(a => { - a.transportSchedules.ForEach(b => - { - SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto - { - carrierProductId = a.carrierProductId, - carrierProductSequenceId = a.carrierProductSequenceId, - ETD = b.departureDateTime, - ATD = b.arrivalDateTime, - vesselOperatorCarrierCode = b.vesselOperatorCarrierCode - }; - - if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue) - { - TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value); - var timeDiff = ts.TotalHours; - - info.days = (int)Math.Ceiling(timeDiff / 24.0); - } - - if (b.facilities != null) - { - info.orignCityName = b.facilities.collectionOrigin?.cityName; - info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID; - info.orignLocationName = b.facilities.collectionOrigin?.locationName; - info.orignCountryCode = b.facilities.collectionOrigin?.countryCode; - info.orignLocationType = b.facilities.collectionOrigin?.locationType; - info.orignUNLocationCode = b.facilities.collectionOrigin?.UNLocationCode; - info.orignUNRegionCode = b.facilities.collectionOrigin?.UNRegionCode; - - info.deliveryCityName = b.facilities.deliveryDestination?.cityName; - info.deliveryCarrierSiteGeoID = b.facilities.deliveryDestination?.carrierSiteGeoID; - info.deliveryLocationName = b.facilities.deliveryDestination?.locationName; - info.deliveryCountryCode = b.facilities.deliveryDestination?.countryCode; - info.deliveryLocationType = b.facilities.deliveryDestination?.locationType; - info.deliveryUNLocationCode = b.facilities.deliveryDestination?.UNLocationCode; - info.deliveryUNRegionCode = b.facilities.deliveryDestination?.UNRegionCode; - } - - info.vesselIMONumber = b.firstDepartureVessel?.vesselIMONumber; - info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode; - info.vesselName = b.firstDepartureVessel?.vesselName; - - if (b.transportLegs != null && b.transportLegs.Count > 0) - { - var firstTransportLegs = b.transportLegs.FirstOrDefault(); - - if (firstTransportLegs.transport != null) - { - info.transportMode = firstTransportLegs.transport.transportMode; - info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber; - } - - } - - list.Add(info); - }); + //a.transportSchedules.ForEach(b => + //{ + // SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto + // { + // carrierProductId = a.carrierProductId, + // carrierProductSequenceId = a.carrierProductSequenceId, + // ETD = b.departureDateTime, + // ATD = b.arrivalDateTime, + // vesselOperatorCarrierCode = b.vesselOperatorCarrierCode + // }; + + // if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue) + // { + // TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value); + // var timeDiff = ts.TotalHours; + + // info.days = (int)Math.Ceiling(timeDiff / 24.0); + // } + + // if (b.facilities != null) + // { + // info.orignCityName = b.facilities.collectionOrigin?.cityName; + // info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID; + // info.orignLocationName = b.facilities.collectionOrigin?.locationName; + // info.orignCountryCode = b.facilities.collectionOrigin?.countryCode; + // info.orignLocationType = b.facilities.collectionOrigin?.locationType; + // info.orignUNLocationCode = b.facilities.collectionOrigin?.UNLocationCode; + // info.orignUNRegionCode = b.facilities.collectionOrigin?.UNRegionCode; + + // info.deliveryCityName = b.facilities.deliveryDestination?.cityName; + // info.deliveryCarrierSiteGeoID = b.facilities.deliveryDestination?.carrierSiteGeoID; + // info.deliveryLocationName = b.facilities.deliveryDestination?.locationName; + // info.deliveryCountryCode = b.facilities.deliveryDestination?.countryCode; + // info.deliveryLocationType = b.facilities.deliveryDestination?.locationType; + // info.deliveryUNLocationCode = b.facilities.deliveryDestination?.UNLocationCode; + // info.deliveryUNRegionCode = b.facilities.deliveryDestination?.UNRegionCode; + // } + + // info.vesselIMONumber = b.firstDepartureVessel?.vesselIMONumber; + // info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode; + // info.vesselName = b.firstDepartureVessel?.vesselName; + + // if (b.transportLegs != null && b.transportLegs.Count > 0) + // { + // var firstTransportLegs = b.transportLegs.FirstOrDefault(); + + // if (firstTransportLegs.transport != null) + // { + // info.transportMode = firstTransportLegs.transport.transportMode; + // info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber; + // } + + // } + + // list.Add(info); + //}); }); } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index a157adff..3c8b7b0a 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -24,6 +24,10 @@ using Org.BouncyCastle.Crypto; using Yitter.IdGenerator; using MySqlX.XDevAPI.Common; using NPOI.OpenXmlFormats.Wordprocessing; +using Newtonsoft.Json; +using StackExchange.Profiling.Internal; +using SqlSugar; +using static Aliyun.OSS.Model.InventoryConfigurationModel; namespace Myshipping.Application.Service.BookingOrder { @@ -173,11 +177,12 @@ namespace Myshipping.Application.Service.BookingOrder queryInfo.stuffingVolume = model.stuffingVolume; } - MSKAPISearchPoint2PointScheduleResultDto resultInfo = null; - - var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(queryInfo); + var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(queryInfo, Formatting.Indented, new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }); var rlt = await queryUrl.SetBody(jsonBody) .PostAsStringAsync(); @@ -203,80 +208,264 @@ namespace Myshipping.Application.Service.BookingOrder if (resultInfo != null && resultInfo.code == 200 && resultInfo.data != null && resultInfo.data.Count > 0) { - resultInfo.data.ForEach(a => + resultInfo.data.ForEach(t => { - a.transportSchedules.ForEach(b => + t.transportSchedules.ForEach(a => { - SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto - { - carrierProductId = a.carrierProductId, - carrierProductSequenceId = a.carrierProductSequenceId, - ETD = b.departureDateTime, - ATD = b.arrivalDateTime, - vesselOperatorCarrierCode = b.vesselOperatorCarrierCode - }; + a.originGeoId = model.carrierCollectionOriginGeoID; + a.originUnLocCode = model.collectionOriginUNLocationCode; + a.originRegionName = model.collectionOriginUNRegionName; + a.originCityName = model.collectionOriginCityName; + a.originCountryName = model.collectionOriginCountryName; + + a.destinationGeoId = model.carrierDeliveryDestinationGeoID; + a.destinationUnLocCode = model.deliveryDestinationUNLocationCode; + a.destinationRegionName = model.deliveryDestinationUNRegionName; + a.destinationCityName = model.deliveryDestinationCityName; + a.destinationCountryName = model.deliveryDestinationCountryName; + + CacheShipSailingSchedule(a).GetAwaiter().GetResult(); + }); - if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue) - { - TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value); - var timeDiff = ts.TotalHours; + var currList = t.transportSchedules.Select(a => + { + return GetShipScheduleShow(a); + }).ToList(); - info.days = (int)Math.Ceiling(timeDiff / 24.0); - } + if (currList.Count > 0) + list.AddRange(currList); + }); + } + } + catch (Exception ex) + { + _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}"); - if (b.facilities != null) - { - info.orignCityName = b.facilities.collectionOrigin?.cityName; - info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID; - info.orignLocationName = b.facilities.collectionOrigin?.locationName; - info.orignCountryCode = b.facilities.collectionOrigin?.countryCode; - info.orignLocationType = b.facilities.collectionOrigin?.locationType; - info.orignUNLocationCode = b.facilities.collectionOrigin?.UNLocationCode; - info.orignUNRegionCode = b.facilities.collectionOrigin?.UNRegionCode; - - info.deliveryCityName = b.facilities.deliveryDestination?.cityName; - info.deliveryCarrierSiteGeoID = b.facilities.deliveryDestination?.carrierSiteGeoID; - info.deliveryLocationName = b.facilities.deliveryDestination?.locationName; - info.deliveryCountryCode = b.facilities.deliveryDestination?.countryCode; - info.deliveryLocationType = b.facilities.deliveryDestination?.locationType; - info.deliveryUNLocationCode = b.facilities.deliveryDestination?.UNLocationCode; - info.deliveryUNRegionCode = b.facilities.deliveryDestination?.UNRegionCode; - } + throw Oops.Bah($"检索海运船期详情失败,{ex.Message}"); + } - info.vesselIMONumber = b.firstDepartureVessel?.vesselIMONumber; - info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode; - info.vesselName = b.firstDepartureVessel?.vesselName; + return list; + } + #endregion - if (b.transportLegs != null && b.transportLegs.Count > 0) - { - var firstTransportLegs = b.transportLegs.FirstOrDefault(); + #region 组织返回船期数据 + /// + /// 组织返回船期数据 + /// + /// 查询的船期详情 + /// 返回显示的船期数据 + private SearchShipSailingScheduleResultDto GetShipScheduleShow(MSKAPISearchTransportSchedules model) + { - if (firstTransportLegs.transport != null) - { - info.transportMode = firstTransportLegs.transport.transportMode; - info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber; - } + SearchShipSailingScheduleResultDto showDto = new SearchShipSailingScheduleResultDto + { + PId = model.PId, + MD5 = model.MD5, - } + orignCarrierCityGeoID = model.originGeoId, + orignUNLocationCode = model.originUnLocCode, + orignCityName = model.originCityName, + originRegionName = model.originRegionName, + originCountryName = model.originCountryName, - info.transportLegs = b.transportLegs; + deliveryCarrierCityGeoID = model.destinationGeoId, + deliveryUNLocationCode = model.destinationUnLocCode, + deliveryCityName = model.destinationCityName, + deliveryRegionName = model.destinationRegionName, + deliveryCountryName = model.destinationCountryName, - list.Add(info); - }); - }); - } + vesselName = model.firstDepartureVessel.vesselName, + carrierDepartureVoyageNumber = model.transportLegs.FirstOrDefault().transport.carrierDepartureVoyageNumber, + + Legs = new List() + }; + + //ETD + if (model.departureDateTime.HasValue) + { + showDto.ETD = model.departureDateTime.Value; } - catch (Exception ex) + else { - _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}"); + throw Oops.Bah($"查询船期错误,预计离港日期查询为空"); + } - throw Oops.Bah($"检索海运船期详情失败,{ex.Message}"); + //ETA + if (model.arrivalDateTime.HasValue) + { + showDto.ETA = model.arrivalDateTime.Value; + } + else + { + throw Oops.Bah($"查询船期错误,预计到港日期查询为空"); } - return list; + //计算预计天数 + if (showDto.ETD.HasValue && showDto.ETD.HasValue) + { + TimeSpan ts = showDto.ETA.Value.Subtract(showDto.ETD.Value); + var timeDiff = ts.TotalHours; + + showDto.days = (int)Math.Ceiling(timeDiff / 24.0); + } + + if (model.transportLegs.Count > 1) + showDto.isTransfer = true; + + //Legs + if (model.facilities != null) + { + showDto.orignCountryCode = model.facilities.collectionOrigin.countryCode; + showDto.deliveryCountryCode = model.facilities.deliveryDestination.countryCode; + + var legs = new List(); + + for (int i = 0; i < model.transportLegs.Count; i++) + { + var b = model.transportLegs[i]; + + MSKAPISPOTScheduleRateResultShowLegsDto leg = new MSKAPISPOTScheduleRateResultShowLegsDto + { + vesselName = b.transport.vessel.vesselName, + VoyageNo = b.transport.carrierDepartureVoyageNumber, + From = new MSKAPISPOTScheduleRateResultShowLegsLocationDto + { + CityName = b.facilities.startLocation.cityName, + CountryCode = b.facilities.startLocation.countryCode, + SiteGeoId = b.facilities.startLocation.carrierSiteGeoID, + LocationType = "From", + }, + To = new MSKAPISPOTScheduleRateResultShowLegsLocationDto + { + CityName = b.facilities.endLocation.cityName, + CountryCode = b.facilities.endLocation.countryCode, + SiteGeoId = b.facilities.endLocation.carrierSiteGeoID, + LocationType = "To", + } + }; + + //ETD + if (b.departureDateTime.HasValue) + { + showDto.ETD = b.departureDateTime.Value; + } + else + { + throw Oops.Bah($"查询船期错误,预计离港日期查询为空"); + } + + //ETA + if (b.arrivalDateTime.HasValue) + { + showDto.ETA = b.arrivalDateTime.Value; + } + else + { + throw Oops.Bah($"查询船期错误,预计到港日期查询为空"); + } + + leg.SortNo = i + 1; + leg.From.SiteGeoId = b.facilities.startLocation.carrierSiteGeoID; + leg.From.CityName = b.facilities.startLocation.cityName; + leg.From.CountryCode = b.facilities.startLocation.countryCode; + leg.From.UnLocCode = b.facilities.startLocation.UNLocationCode; + + leg.To.SiteGeoId = b.facilities.endLocation.carrierSiteGeoID; + leg.To.CityName = b.facilities.endLocation.cityName; + leg.To.CountryCode = b.facilities.endLocation.countryCode; + leg.To.UnLocCode = b.facilities.endLocation.UNLocationCode; + + if (i == 0 && i == model.transportLegs.Count - 1) + { + leg.From.CityGeoId = model.originGeoId; + leg.From.CountryName = model.originCountryName; + leg.From.RegionName = model.originRegionName; + + leg.To.CityGeoId= model.destinationGeoId; + leg.To.CountryName = model.destinationCountryName; + leg.To.RegionName = model.destinationRegionName; + } + else + { + if(i == 0) + { + leg.From.CityGeoId = model.originGeoId; + leg.From.CountryName = model.originCountryName; + leg.From.RegionName = model.originRegionName; + leg.From.UnLocCode = model.originUnLocCode; + } + else if(i == model.transportLegs.Count - 1) + { + leg.To.CityGeoId = model.destinationGeoId; + leg.To.CountryName = model.destinationCountryName; + leg.To.RegionName = model.destinationRegionName; + leg.To.UnLocCode = model.destinationUnLocCode; + } + } + + legs.Add(leg); + } + + + showDto.Legs = legs.OrderBy(t => t.ETD).Select((t, idx) => { + t.SortNo = idx + 1; + return t; + }).ToList(); + } + + return showDto; + } + #endregion + + #region 缓存船期数据 + /// + /// 缓存船期数据 + /// + /// 船期查询结果明细 + /// 船期类型 MSKSPOT-马士基即期 + /// 返回主键ID + private async Task CacheShipSailingSchedule(MSKAPISearchTransportSchedules model, string busiType = "MSKCON") + { + /* + 1、按照船期明细缓存,并把ID作为缓存的KEY + 2、对数据进行JSON串行化的文本提取MD5 + 3、写入缓存,并返回ID + */ + var newModel = model.Adapt(); + + //newModel.priceID = null; + + var json = Newtonsoft.Json.JsonConvert.SerializeObject(newModel); + model.PId = YitIdHelper.NextId(); + + string md5 = json.ToMd5(); + + model.MD5 = md5; + + var shareKey = model.PId.ToString(); + + DateTime nowDate = DateTime.Now; + DateTime expireDateTime = DateTime.Now.AddHours(4); + + var expireTimeSpan = expireDateTime.Subtract(nowDate).Duration(); + + if (!_cache.Exists($"{shareKey}_{busiType}")) + { + await _cache.SetTimeoutAsync($"{shareKey}_{busiType}", Newtonsoft.Json.JsonConvert.SerializeObject(model), expireTimeSpan); + } } #endregion + private MSKAPISearchPoint2PointScheduleResultDataDto GetCacheShipSailingSchedule(long pid, string busiType = "MSKCON") + { + if (_cache.Exists($"{pid}_{busiType}")) + { + return _cache.Get($"{pid}_{busiType}"); + } + + return null; + } + #region 发送马士基订舱请求 /// /// 发送马士基订舱请求 diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs index 54009e9d..65062999 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKAPI/MSKAPISearchPoint2PointScheduleResultDto.cs @@ -58,6 +58,7 @@ namespace Myshipping.Application /// 产品从原产地到目的地的链接数 /// public List transportSchedules { get; set; } + } /// @@ -99,7 +100,103 @@ namespace Myshipping.Application /// 承运人代码(MAEU, SEAU, SEJJ, MCPU, MAEI) /// public string vesselOperatorCarrierCode { get; set; } -} + + //以下的字段是自己添加的不是船期返回的信息 + /// + /// 产品id + /// + public string carrierProductId { get; set; } + + /// + /// 产品序号 + /// + public string carrierProductSequenceId { get; set; } + + /// + /// 产品的生效日期,格式为YYYY-MM-DD + /// + public string productValidFromDate { get; set; } + + /// + /// 产品的截止日期,格式为YYYY-MM-DD + /// + public string productValidToDate { get; set; } + + /// + /// 产品从原产地到目的地的链接数 + /// + public string numberOfProductLinks { get; set; } + + /// + /// 船期MD5 + /// + public string MD5 { get; set; } + + /// + /// 主键ID + /// + public long PId { get; set; } + + /// + /// 起运地rkst代码 + /// + public string originRkstCode { get; set; } + + /// + /// 起运地geoID + /// + public string originGeoId { get; set; } + + /// + /// 起运地五子码 + /// + public string originUnLocCode { get; set; } + + /// + /// 起运地城市名 + /// + public string originCityName { get; set; } + + /// + /// 起运地区名 + /// + public string originRegionName { get; set; } + + /// + /// 起运地国家名 + /// + public string originCountryName { get; set; } + + /// + /// 目的地rkst代码 + /// + public string destinationRkstCode { get; set; } + + /// + /// 目的地geoID + /// + public string destinationGeoId { get; set; } + + /// + /// 目的地五子码 + /// + public string destinationUnLocCode { get; set; } + + /// + /// 目的地城市名 + /// + public string destinationCityName { get; set; } + + /// + /// 目的地区名 + /// + public string destinationRegionName { get; set; } + + /// + /// 目的地国家名 + /// + public string destinationCountryName { get; set; } + } /// /// 路线相关数据 diff --git a/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs index c5ad3cb9..33292a08 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/QueryShipSailingScheduleDto.cs @@ -36,6 +36,11 @@ namespace Myshipping.Application /// public string collectionOriginCityName { get; set; } + /// + /// 起始地国家名称(英文) + /// + public string collectionOriginCountryName { get; set; } + /// /// 起始地五字码 /// @@ -46,6 +51,11 @@ namespace Myshipping.Application /// public string collectionOriginUNRegionCode { get; set; } + /// + /// 起始地区名称 + /// + public string collectionOriginUNRegionName { get; set; } + /// /// 目的地国家代码 二字码 /// @@ -56,6 +66,11 @@ namespace Myshipping.Application /// public string deliveryDestinationCityName { get; set; } + /// + /// 目的地国家名称 二字码 + /// + public string deliveryDestinationCountryName { get; set; } + /// /// 目的都五字码 /// @@ -66,6 +81,11 @@ namespace Myshipping.Application /// public string deliveryDestinationUNRegionCode { get; set; } + /// + /// 目的地区名称 + /// + public string deliveryDestinationUNRegionName { get; set; } + /// /// 承运人代码(MAEU, SEAU, SEJJ, MCPU, MAEI) /// diff --git a/Myshipping.Application/Service/BookingOrder/Dto/SearchShipSailingScheduleResultDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/SearchShipSailingScheduleResultDto.cs index 2fbc4dfd..962ba46b 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/SearchShipSailingScheduleResultDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/SearchShipSailingScheduleResultDto.cs @@ -9,7 +9,7 @@ namespace Myshipping.Application /// /// 查询船期回执 /// - public class SearchShipSailingScheduleResultDto + public class SearchShipSailingScheduleResultDto : MSKAPISPOTScheduleRateResultShowDto { /// /// 产品id @@ -22,124 +22,63 @@ namespace Myshipping.Application public string carrierProductSequenceId { get; set; } /// - /// ETD + /// 起运地rkst代码 /// - public Nullable ETD { get; set; } + public string originRkstCode { get; set; } /// - /// ATD + /// 起运地geoID /// - public Nullable ATD { get; set; } + public string originGeoId { get; set; } /// - /// 城市名(始发地) + /// 起运地五子码 /// - public string orignCityName { get; set; } + public string originUnLocCode { get; set; } /// - /// 地点的GEO ID(始发地) + /// 起运地城市名 /// - public string orignCarrierSiteGeoID { get; set; } + public string originCityName { get; set; } /// - /// 地点的名称(始发地) + /// 起运地区名 /// - public string orignLocationName { get; set; } + public string originRegionName { get; set; } /// - /// 国家代码(始发地) + /// 起运地国家名 /// - public string orignCountryCode { get; set; } + public string originCountryName { get; set; } /// - /// 位置类型(始发地) + /// 目的地rkst代码 /// - public string orignLocationType { get; set; } + public string destinationRkstCode { get; set; } /// - /// 五字码(始发地) + /// 目的地geoID /// - public string orignUNLocationCode { get; set; } + public string destinationGeoId { get; set; } /// - /// 区代码(始发地) + /// 目的地五子码 /// - public string orignUNRegionCode { get; set; } + public string destinationUnLocCode { get; set; } /// - /// 城市名(目的地) + /// 目的地城市名 /// - public string deliveryCityName { get; set; } + public string destinationCityName { get; set; } /// - /// 地点的GEO ID(目的地) + /// 目的地区名 /// - public string deliveryCarrierSiteGeoID { get; set; } + public string destinationRegionName { get; set; } /// - /// 地点的名称(目的地) + /// 目的地国家名 /// - public string deliveryLocationName { get; set; } - - /// - /// 国家代码(目的地) - /// - public string deliveryCountryCode { 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 transportLegs { get; set; } + public string destinationCountryName { get; set; } } } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index aeeb19f5..494dd58f 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -14353,6 +14353,26 @@ 备注 + + + 备案代码 + + + + + 备案全称 + + + + + 联系人 + + + + + 联系邮箱 + + 网站账号维护新增输入参数 diff --git a/Myshipping.Core/Service/DjyWebsiteAccountConfig/Dto/DjyWebsiteAccountConfigInput.cs b/Myshipping.Core/Service/DjyWebsiteAccountConfig/Dto/DjyWebsiteAccountConfigInput.cs index c8b1f5dc..7fa0ee89 100644 --- a/Myshipping.Core/Service/DjyWebsiteAccountConfig/Dto/DjyWebsiteAccountConfigInput.cs +++ b/Myshipping.Core/Service/DjyWebsiteAccountConfig/Dto/DjyWebsiteAccountConfigInput.cs @@ -28,8 +28,26 @@ namespace Myshipping.Core.Service /// 备注 /// public virtual string Remark { get; set; } - - + + /// + /// 备案代码 + /// + public string RegistPartyCode { get; set; } + + /// + /// 备案全称 + /// + public string RegistPartyName { get; set; } + + /// + /// 联系人 + /// + public string RegistContractName { get; set; } + + /// + /// 联系邮箱 + /// + public string RegistContractEmail { get; set; } } /// From 884004e3468ec2200a460156cdc50ecc8057e760 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 11:52:47 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API=E8=AE=A2?= =?UTF-8?q?=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKAPIService.cs | 186 +++++++++++++++++- .../Service/BookingOrder/Dto/MSKBookingDto.cs | 20 ++ 2 files changed, 197 insertions(+), 9 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index 3c8b7b0a..a6b1a9f9 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -39,6 +39,8 @@ namespace Myshipping.Application.Service.BookingOrder { private readonly SqlSugarRepository _bookingDeliveryRecordRep; private readonly SqlSugarRepository _bookingDeliveryRecordCtnRep; + private readonly SqlSugarRepository _bookingDeliveryRecordShipScheduleRep; + private readonly ISysCacheService _cache; private readonly IDjyWebsiteAccountConfigService _webAccountConfig; private readonly ILogger _logger; @@ -52,7 +54,7 @@ namespace Myshipping.Application.Service.BookingOrder public BookingMSKAPIService(ILogger logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, SqlSugarRepository bookingDeliveryRecordRep, ISysDataUserMenu sysDataUserMenuService, - SqlSugarRepository bookingDeliveryRecordCtnRep) + SqlSugarRepository bookingDeliveryRecordCtnRep, SqlSugarRepository bookingDeliveryRecordShipScheduleRep) { _logger = logger; _cache = cache; @@ -60,6 +62,7 @@ namespace Myshipping.Application.Service.BookingOrder _bookingDeliveryRecordRep = bookingDeliveryRecordRep; _bookingDeliveryRecordCtnRep = bookingDeliveryRecordCtnRep; _sysDataUserMenuService = sysDataUserMenuService; + _bookingDeliveryRecordShipScheduleRep = bookingDeliveryRecordShipScheduleRep; } #region 检索海运船期详情 @@ -456,11 +459,11 @@ namespace Myshipping.Application.Service.BookingOrder } #endregion - private MSKAPISearchPoint2PointScheduleResultDataDto GetCacheShipSailingSchedule(long pid, string busiType = "MSKCON") + private MSKAPISearchTransportSchedules GetCacheShipSailingSchedule(long pid, string busiType = "MSKCON") { if (_cache.Exists($"{pid}_{busiType}")) { - return _cache.Get($"{pid}_{busiType}"); + return _cache.Get($"{pid}_{busiType}"); } return null; @@ -527,6 +530,37 @@ namespace Myshipping.Application.Service.BookingOrder //这里是校验必填项 ValidateMSKAPIData(model); + BookingDeliveryRecordShipSchedule shipScheduleRecord = null; + + MSKAPISearchTransportSchedules selectedShipSchedule = null; + + if (model.PId == 0) + throw Oops.Oh("船期信息不能为空,请重新检索船期"); + + if (model.PId > 0) + { + if (model.id.HasValue && model.id.Value > 0) + { + var recordId = model.id.Value; + + shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable() + .FirstAsync(a => a.RECORD_ID == recordId && a.SHIP_RATE_PID != null && + a.SHIP_RATE_PID.Value == model.PId && a.IsDeleted == false); + } + + if (shipScheduleRecord == null) + { + selectedShipSchedule = GetCacheShipSailingSchedule(model.PId); + } + else + { + selectedShipSchedule = JSON.Deserialize(shipScheduleRecord.SHIP_JSON); + } + + if (selectedShipSchedule == null) + throw Oops.Oh("船期数据校验失败,请重新查询船期信息"); + } + DateTime nowDate = DateTime.Now; var recordInfo = model.Adapt(); @@ -589,15 +623,13 @@ namespace Myshipping.Application.Service.BookingOrder { placeOfReceipt = new MSKAPIBookingRouteDetailsBase { - UNLocationCode = model.userPlaceOfReceiptUnLocCode - //: model.placeOfReceiptUnLocCode, - //cityName = model.placeOfReceiptCityName, + UNLocationCode = model.userPlaceOfReceiptUnLocCode, + maerskCityGeoId = selectedShipSchedule.originGeoId, }, placeOfDelivery = new MSKAPIBookingRouteDetailsBase { - UNLocationCode = model.userPlaceOfDeliveryUnLocCode - //: model.placeOfDeliveryUnLocCode, - //cityName = model.placeOfDeliveryCityName, + UNLocationCode = model.userPlaceOfDeliveryUnLocCode, + maerskCityGeoId = selectedShipSchedule.destinationGeoId, }, selectedRoute = new MSKAPIBookingRoute { @@ -634,6 +666,21 @@ namespace Myshipping.Application.Service.BookingOrder } }; + //ETD + //if (!string.IsNullOrWhiteSpace(selectedShipSchedule.facilities.) + //{ + // DateTime currDate = DateTime.MinValue; + + // if (DateTime.TryParse($"{selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.date} {selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.time}", out currDate)) + // { + // bookingDto.bookingBody.transport.earliestDepartureDate = currDate.ToString("yyyy-MM-ddTHH:mm:ss"); + // } + // else + // { + // throw Oops.Bah($"查询船期错误,priceID={model.priceID} pid={model.PId} 预计离港日期departureDate={selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.date} {selectedShipSchedule.scheduleDetails.FirstOrDefault().fromLocation.time} 格式解析错误"); + // } + //} + //if(!model.isSendNoSchedule) //{ // bookingDto.bookingBody.transport.routeDetails.selectedRoute.routeScheduleId = model.carrierProductId; @@ -1377,6 +1424,42 @@ namespace Myshipping.Application.Service.BookingOrder _logger.LogInformation($"获取请求马士基API订舱报文,JSON={JSON.Serialize(model)}"); + BookingDeliveryRecordShipSchedule shipScheduleRecord = null; + + MSKAPISearchTransportSchedules selectedShipSchedule = null; + + if (model.PId > 0) + { + if (model.id.HasValue && model.id.Value > 0) + { + var recordId = model.id.Value; + + shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable() + .FirstAsync(a => a.RECORD_ID == recordId && a.SHIP_RATE_PID != null && + a.SHIP_RATE_PID.Value == model.PId && a.IsDeleted == false); + } + + if (shipScheduleRecord == null) + { + selectedShipSchedule = GetCacheShipSailingSchedule(model.PId); + } + else + { + selectedShipSchedule = JSON.Deserialize(shipScheduleRecord.SHIP_JSON); + } + + if (selectedShipSchedule == null) + throw Oops.Oh("船期数据校验失败,请重新查询船期信息"); + + model.placeOfReceiptCountryName = selectedShipSchedule.originCountryName; + model.placeOfReceiptRegionName = selectedShipSchedule.originRegionName; + model.carrierCollectionOriginGeoID = selectedShipSchedule.originGeoId; + + model.placeOfDeliveryCountryName = selectedShipSchedule.destinationCountryName; + model.placeOfDeliveryRegionName = selectedShipSchedule.destinationRegionName; + model.carrierDeliveryDestinationGeoID = selectedShipSchedule.destinationGeoId; + } + if (model.ctns != null && model.ctns.Count > 0) { ctnStat = string.Join(",", model.ctns.GroupBy(a => a.ctnName) @@ -1407,6 +1490,8 @@ namespace Myshipping.Application.Service.BookingOrder entity.UpdatedUserId = UserManager.UserId; entity.UpdatedUserName = UserManager.Name; entity.CTN_STAT = ctnStat; + entity.BOOKING_CHANNEL_TYPE = "CON_API"; + entity.BOOKING_CHANNEL_TYPE_NAME = "合约API"; await _bookingDeliveryRecordRep.AsUpdateable(entity).IgnoreColumns(x => new { @@ -1498,6 +1583,27 @@ namespace Myshipping.Application.Service.BookingOrder } } + if (shipScheduleRecord == null) + { + if (model.PId > 0 && selectedShipSchedule != null) + { + shipScheduleRecord = new BookingDeliveryRecordShipSchedule + { + Id = YitIdHelper.NextId(), + RECORD_ID = model.id.Value, + SHIP_RATE_PID = selectedShipSchedule.PId, + SHIP_RATE_MD5 = selectedShipSchedule.MD5, + SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule), + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name + }; + + await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord); + } + } + return model.id.Value; } else @@ -1511,6 +1617,8 @@ namespace Myshipping.Application.Service.BookingOrder entity.STATUS = "TEMP"; entity.STATUS_NAME = "暂存"; entity.CTN_STAT = ctnStat; + entity.BOOKING_CHANNEL_TYPE = "CON_API"; + entity.BOOKING_CHANNEL_TYPE_NAME = "合约API"; await _bookingDeliveryRecordRep.InsertAsync(entity); @@ -1537,6 +1645,66 @@ namespace Myshipping.Application.Service.BookingOrder }); } + if (shipScheduleRecord == null) + { + if (model.PId > 0 && selectedShipSchedule != null) + { + shipScheduleRecord = new BookingDeliveryRecordShipSchedule + { + Id = YitIdHelper.NextId(), + RECORD_ID = entity.Id, + SHIP_RATE_PID = selectedShipSchedule.PId, + SHIP_RATE_MD5 = selectedShipSchedule.MD5, + SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule), + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name + }; + + await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord); + } + } + else + { + //只有船期发生变化时才重新写入新的船期记录 + if (model.PId != shipScheduleRecord.SHIP_RATE_PID.Value) + { + _logger.LogInformation($"MSK CON id={model.id} 换了船期 原记录:{selectedShipSchedule.PId} 新记录:{model.PId} 作废原船期,插入新船期"); + + shipScheduleRecord.IsDeleted = true; + shipScheduleRecord.UpdatedTime = nowDate; + shipScheduleRecord.UpdatedUserId = UserManager.UserId; + shipScheduleRecord.UpdatedUserName = UserManager.Name; + + await _bookingDeliveryRecordShipScheduleRep.AsUpdateable(shipScheduleRecord).UpdateColumns(x => new { + x.IsDeleted, + x.UpdatedUserId, + x.UpdatedUserName, + x.UpdatedTime + }).ExecuteCommandAsync(); + + shipScheduleRecord = new BookingDeliveryRecordShipSchedule + { + Id = YitIdHelper.NextId(), + RECORD_ID = model.id.Value, + SHIP_RATE_PID = selectedShipSchedule.PId, + SHIP_RATE_MD5 = selectedShipSchedule.MD5, + SHIP_JSON = Newtonsoft.Json.JsonConvert.SerializeObject(selectedShipSchedule), + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name + }; + + await _bookingDeliveryRecordShipScheduleRep.InsertAsync(shipScheduleRecord); + } + else + { + _logger.LogInformation($"MSK CON id={model.id} 船期没变化 model.PId={model.PId} shipScheduleRecord.SHIP_RATE_PID={shipScheduleRecord.SHIP_RATE_PID.Value}"); + } + } + return entity.Id; } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs index 25ccd7ec..73463198 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs @@ -27,6 +27,16 @@ namespace Myshipping.Application /// public long bookingId { get; set; } + /// + /// 主键ID + /// + public long PId { get; set; } + + /// + /// 船期MD5 + /// + public string MD5 { get; set; } + /// /// 合同唯一id /// @@ -360,6 +370,16 @@ namespace Myshipping.Application /// 箱型箱量列表 /// public List ctns { get; set; } + + /// + /// 收货地定位ID + /// + public string carrierCollectionOriginGeoID { get; set; } + + /// + /// 交货地定位ID + /// + public string carrierDeliveryDestinationGeoID { get; set; } } public class MSKBookingCtnInfo From d1a36940d423095691f96143a9c6bce7b5f20147 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 14:27:14 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKAPIService.cs | 133 ++++++++++++++++++ .../Service/BookingOrder/Dto/MSKBookingDto.cs | 5 + 2 files changed, 138 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index a6b1a9f9..2b37c6bb 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -686,6 +686,120 @@ namespace Myshipping.Application.Service.BookingOrder // bookingDto.bookingBody.transport.routeDetails.selectedRoute.routeScheduleId = model.carrierProductId; //} + for (int i = 0; i < selectedShipSchedule.transportLegs.Count; i++) + { + var detail = selectedShipSchedule.transportLegs[i]; + + var currDto = new MSKAPIBookingSchedules(); + + + //ETD + if (detail.departureDateTime.HasValue) + { + currDto.originDepartureDateTimeLocal = detail.departureDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss"); + } + else + { + throw Oops.Bah($"查询船期错误,pid={model.PId} 预计离港日期departureDate 格式解析错误"); + } + + //ETA + if (detail.arrivalDateTime.HasValue) + { + currDto.destinationArrivalDateTimeLocal = detail.arrivalDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss"); + } + else + { + throw Oops.Bah($"查询船期错误,pid={model.PId} 预计到港日期arrivalDateTime 格式解析错误"); + } + + currDto.transportMode = new MSKAPIBookingTransportMode + { + vessel = new MSKAPIBookingTransportModeVessel + { + name = detail.transport.vessel.vesselName, + maerskVesselCode = detail.transport.vessel.carrierVesselCode, + vesselIMONumber = detail.transport.vessel.vesselIMONumber + }, + exportVoyageNumber = detail.transport.carrierDepartureVoyageNumber, + }; + + currDto.serviceCode = detail.transport.carrierServiceCode; + currDto.transportModeCode = detail.transport.transportMode; + + //首个 + if (i == 0) + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.originGeoId, + }; + + if (i == selectedShipSchedule.transportLegs.Count - 1) + { + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.destinationGeoId, + }; + } + else + { + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.endLocation.carrierSiteGeoID, + }; + } + } + else if (i == selectedShipSchedule.transportLegs.Count - 1) + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.startLocation.carrierSiteGeoID, + }; + + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.destinationGeoId, + }; + } + else + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.startLocation.carrierSiteGeoID, + }; + + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.endLocation.carrierSiteGeoID, + }; + } + + bookingDto.bookingBody.transport.routeDetails.selectedRoute.bookingSchedules.Add(currDto); + } + + bookingDto.bookingBody.cargo = new MSKAPIBookingCargo { commodityCode = model.commodityCode, @@ -1392,6 +1506,25 @@ namespace Myshipping.Application.Service.BookingOrder }).ToList(); } + MSKAPISearchTransportSchedules selectedShipSchedule = null; + + if (model.PId > 0) + { + var shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable() + .FirstAsync(a => a.SHIP_RATE_PID != null && a.SHIP_RATE_PID.Value == model.PId); + + if (shipScheduleRecord != null) + { + selectedShipSchedule = JSON.Deserialize(shipScheduleRecord.SHIP_JSON); + + if (selectedShipSchedule != null) + { + model.selectedShipScheduleShow = GetShipScheduleShow(selectedShipSchedule); + } + + } + } + return model; } #endregion diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs index 73463198..2381f9c9 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs @@ -380,6 +380,11 @@ namespace Myshipping.Application /// 交货地定位ID /// public string carrierDeliveryDestinationGeoID { get; set; } + + /// + /// 选择的船期详情 + /// + public SearchShipSailingScheduleResultDto selectedShipScheduleShow { get; set; } } public class MSKBookingCtnInfo From 0fad1c56e829deaa5b287d57c52d3d2998ec5429 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 14:30:48 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=89=80=E6=9C=89=E8=BD=AC=E5=8F=91=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E8=B0=83=E5=8F=96=EF=BC=8C=E5=8E=BB=E6=8E=89=E6=8A=84=E9=80=81?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/RouteChangeAdvisoryService.cs | 2 +- .../Service/TaskManagePlat/TaskManageBCService.cs | 2 +- .../Service/TaskManagePlat/TaskManageCutDateChangeService.cs | 2 +- .../Service/TaskManagePlat/TaskManageDRAFTService.cs | 2 +- .../TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs | 2 +- .../TaskManagePlat/TaskManageRollingNominationService.cs | 2 +- .../Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs | 2 +- .../Service/TaskManagePlat/TaskTransPlanHasChangeService.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/RouteChangeAdvisoryService.cs b/Myshipping.Application/Service/TaskManagePlat/RouteChangeAdvisoryService.cs index 56b2289a..4d0b2884 100644 --- a/Myshipping.Application/Service/TaskManagePlat/RouteChangeAdvisoryService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/RouteChangeAdvisoryService.cs @@ -547,7 +547,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index fe996c9c..24203205 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -1908,7 +1908,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageCutDateChangeService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageCutDateChangeService.cs index 7a729dc2..3fefdbd1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageCutDateChangeService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageCutDateChangeService.cs @@ -634,7 +634,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs index 770f1418..3bccc7fa 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs @@ -368,7 +368,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs index 7b8ac5d5..c8260db8 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs @@ -560,7 +560,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs index 04b76b7f..8b81ec94 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs @@ -1668,7 +1668,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs index 67c0c531..34f2a98d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs @@ -403,7 +403,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskTransPlanHasChangeService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskTransPlanHasChangeService.cs index b310804d..df992dc4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskTransPlanHasChangeService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskTransPlanHasChangeService.cs @@ -661,7 +661,7 @@ namespace Myshipping.Application EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = toEmail, - CCTo = opEmail, + //CCTo = opEmail, Title = emailTitle, Body = emailHtml, Account = publicMailAccount.MailAccount?.Trim(), From 4d92c15a9c60be1a16e1c7e935dad6e1fbeff101 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 14:48:40 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKAPIService.cs | 38 +++++++++++++++++++ .../BookingOrder/IBookingMSKAPIService.cs | 7 ++++ 2 files changed, 45 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index 2b37c6bb..413fe8a5 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -2222,5 +2222,43 @@ namespace Myshipping.Application.Service.BookingOrder return "校验成功"; } #endregion + + #region 获取初始化页面默认值 + /// + /// 获取初始化页面默认值 + /// + /// 返回详情 + [HttpGet("/BookingMSKAPI/GetInitInfo")] + public async Task GetInitInfo() + { + MSKSPOTBookingInitDto dto = null; + + var webAccountConfig = await _webAccountConfig.GetAccountConfigByTenantId("MSKApi", UserManager.UserId, UserManager.TENANT_ID); + + if (webAccountConfig == null) + throw Oops.Oh("未配置公司账户维护-MSK即期,请联系管理员"); + + if (string.IsNullOrWhiteSpace(webAccountConfig.RegistPartyCode) + || string.IsNullOrWhiteSpace(webAccountConfig.RegistPartyName) || string.IsNullOrWhiteSpace(webAccountConfig.RegistContractName) + || string.IsNullOrWhiteSpace(webAccountConfig.RegistContractEmail)) + { + throw Oops.Oh("账户维护-MSK即期,未配置完整注册信息(备案代码、备案全称、联系人、邮箱必填),请联系管理员"); + } + + dto = new MSKSPOTBookingInitDto + { + bookedByMaerskPartyCode = webAccountConfig.RegistPartyCode, + bookedByCompanyName = webAccountConfig.RegistPartyName, + priceOwnerMaerskPartyCode = webAccountConfig.RegistPartyCode, + priceOwnerCompanyName = webAccountConfig.RegistPartyName, + bookedByCompanyContactName = webAccountConfig.RegistContractName, + bookedByCompanyContactEmail = webAccountConfig.RegistContractEmail, + priceOwnerContactName = webAccountConfig.RegistContractName, + priceOwnerContactEmail = webAccountConfig.RegistContractEmail, + }; + + return dto; + } + #endregion } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs index cd48acb6..ae755b99 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs @@ -102,5 +102,12 @@ namespace Myshipping.Application /// 操作类型 BC-同步BC状态 Cancellation-同步取消状态 /// 返回回执 Task SyncBCInfo(string mblno, long tenantId, string opTypeName = "BookingConfirmation"); + + /// + /// 获取初始化页面默认值 + /// + /// 返回详情 + + Task GetInitInfo(); } } From c759a142a8e8926d4c018baf69fb8730b05735bb Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 15:01:13 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API=20=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=8F=91=E9=80=81=E5=A2=9E=E5=8A=A0=201=E7=A7=92?= =?UTF-8?q?=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingMSKAPIService.cs | 3 +++ .../Service/BookingOrder/BookingMSKSPOTAPIService.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index 413fe8a5..aae6ea61 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -28,6 +28,7 @@ using Newtonsoft.Json; using StackExchange.Profiling.Internal; using SqlSugar; using static Aliyun.OSS.Model.InventoryConfigurationModel; +using System.Threading; namespace Myshipping.Application.Service.BookingOrder { @@ -1909,6 +1910,8 @@ namespace Myshipping.Application.Service.BookingOrder failNum++; } + + Thread.Sleep(1000); }); msgList.Add($"共计{totalNum} 条 成功{succNum}条 失败:{failNum}"); diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index c22e696c..36ee4b71 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -22,6 +22,7 @@ using Yitter.IdGenerator; using System.Diagnostics; using Newtonsoft.Json; using StackExchange.Profiling.Internal; +using System.Threading; namespace Myshipping.Application.Service.BookingOrder { @@ -1752,6 +1753,8 @@ namespace Myshipping.Application.Service.BookingOrder failNum++; } + + Thread.Sleep(1000); }); msgList.Add($"共计{totalNum} 条 成功{succNum}条 失败:{failNum}");