From 1d3dc78fb225c798b712d91dd1452ab52ae93dfe Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 2 Jul 2024 11:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20SPOT=20=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/BookingMSKSPOTAPIService.cs | 78 +++++++--- .../BookingOrder/Dto/MSKSPOT/MSKAPIMapper.cs | 27 ++++ .../MSKAPISPOTSearchLocationResultDto.cs | 2 +- .../MSKAPISPOTSearchScheduleRateDto.cs | 7 +- .../Dto/MSKSPOT/MSKSPOTBookingInitDto.cs | 2 +- ...eduleDto.cs => QueryMSKSPOTScheduleDto.cs} | 6 +- .../Dto/MSKSPOT/QueryMSKSPOTShipDateDto.cs | 136 ++++++++++++++++++ .../BookingOrder/IBookingMSKSPOTAPIService.cs | 4 +- .../Entity/DJY/DjyWebsiteAccountConfig.cs | 20 +++ Myshipping.Core/Myshipping.Core.xml | 20 +++ 10 files changed, 274 insertions(+), 28 deletions(-) create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPIMapper.cs rename Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/{QueryMSKSPOTShipSailingScheduleDto.cs => QueryMSKSPOTScheduleDto.cs} (94%) create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipDateDto.cs diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs index 8d571746..c8524999 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKSPOTAPIService.cs @@ -19,6 +19,8 @@ using System.Text.RegularExpressions; using Myshipping.Application.Helper; using Myshipping.Core.Const; using Yitter.IdGenerator; +using System.Diagnostics; +using Newtonsoft.Json; namespace Myshipping.Application.Service.BookingOrder { @@ -41,9 +43,6 @@ namespace Myshipping.Application.Service.BookingOrder const string CONST_MSK_SPOT_API_QUERY_SCHEDULE_RATE_URL = "MSKSPOTScheduleRate"; const string CONST_MSK_SPOT_API_LOCATION_URL = "MSKSPOTApilocation"; - //租户MSK SPOT的备案注册信息 - const string CONST_MSK_SPOT_COMPANY_INFO = "MSK_SPOT_API_COMPANY_INFO"; - public BookingMSKSPOTAPIService(ILogger logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, SqlSugarRepository bookingDeliveryRecordRep, ISysDataUserMenu sysDataUserMenuService, @@ -66,10 +65,10 @@ namespace Myshipping.Application.Service.BookingOrder /// 请求详情 /// 返回检索结果 [HttpPost("/BookingMSKSPOTAPI/SearchLocations")] - public async Task> SearchLocations(QuerySPOTLocationsDto model) + public async Task> SearchLocations(QuerySPOTLocationsDto model) { - List list = new List(); + List list = new List(); /* MSKApiCommodity @@ -142,7 +141,17 @@ namespace Myshipping.Application.Service.BookingOrder if (resultInfo != null && resultInfo.code == 200 && resultInfo.data != null && resultInfo.data.Count > 0) { - list = resultInfo.data; + list = resultInfo.data.Select(a => { + return new QueryLocationsResultDto { + carrierGeoID = a.geoId, + cityName = a.cityName, + countryCode = a.countryCode, + countryName = a.countryName, + locationName = a.locationName, + UNRegionName = a.regionName, + UNLocationCode = a.unLocCode, + }; + }).ToList(); } } catch (Exception ex) @@ -163,15 +172,14 @@ namespace Myshipping.Application.Service.BookingOrder /// 请求船期详情 /// 返回船期结果 [HttpPost("/BookingMSKSPOTAPI/SearchShipSailingSchedule")] - public async Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model) + public async Task> SearchShipSailingSchedule(QueryMSKSPOTShipDateDto query) { List list = new List(); - /* - MSKApiSailingSchedulePoint2Point - */ try { + var model = query.Adapt(); + if (string.IsNullOrWhiteSpace(model.originGeoId)) throw Oops.Oh($"起运地不能为空"); @@ -195,6 +203,17 @@ namespace Myshipping.Application.Service.BookingOrder if (string.IsNullOrWhiteSpace(model.containerType)) throw Oops.Oh($"箱型不能为空"); + if (!model.containerCount.HasValue || model.containerCount.Value <= 0) + throw Oops.Oh($"箱型不能为空"); + + if (!model.containerWeight.HasValue || model.containerWeight.Value <= 0) + throw Oops.Oh($"箱重不能为空"); + + if (model.containerWeight.HasValue) + { + model.containerWeight = model.containerWeight.Value / 1000; + } + string queryUrl = string.Empty; if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase)) @@ -265,7 +284,10 @@ namespace Myshipping.Application.Service.BookingOrder MSKAPISPOTSearchScheduleRateResultDto 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(); @@ -356,7 +378,7 @@ namespace Myshipping.Application.Service.BookingOrder //计算预计天数 if (showDto.ETD.HasValue && showDto.ETA.HasValue) { - TimeSpan ts = showDto.ETD.Value.Subtract(showDto.ETA.Value); + TimeSpan ts = showDto.ETA.Value.Subtract(showDto.ETD.Value); var timeDiff = ts.TotalHours; showDto.days = (int)Math.Ceiling(timeDiff / 24.0); @@ -448,7 +470,7 @@ namespace Myshipping.Application.Service.BookingOrder } catch (Exception ex) { - _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}"); + _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(query)} 原因:{ex.Message}"); throw Oops.Bah($"检索海运船期详情失败,{ex.Message}"); } @@ -1690,11 +1712,31 @@ namespace Myshipping.Application.Service.BookingOrder public async Task GetInitInfo() { - return null; - //var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_AMENDMENT_DEFAULT_PARAM, - // CONST_CANCELLATION_DEFAULT_PARAM, - // CONST_AMENDMENT_DING_DEFAULT_PARAM, - // CONST_CANCELLATION_DING_DEFAULT_PARAM }).GetAwaiter().GetResult(); + MSKSPOTBookingInitDto dto = null; + + var webAccountConfig = await _webAccountConfig.GetAccountConfigByTenantId("MSKSpotApi", 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 + { + bookedMaerskByPartyCode = webAccountConfig.RegistPartyCode, + bookedByCompanyName = webAccountConfig.RegistPartyName, + priceOwnerMaerskPartyCode = webAccountConfig.RegistPartyCode, + priceOwnerCompanyName = webAccountConfig.RegistPartyName, + bookedByPartyContactName = webAccountConfig.RegistContractName, + bookedByPartyContactEmail = webAccountConfig.RegistContractEmail, + }; + + return dto; } #endregion } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPIMapper.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPIMapper.cs new file mode 100644 index 00000000..46bcd58a --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPIMapper.cs @@ -0,0 +1,27 @@ +using Mapster; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class MSKAPIMapper : IRegister + { + public void Register(TypeAdapterConfig config) + { + config.ForType() + .Map(dest => dest.carrierId, src => src.carrierId) + .Map(dest => dest.originGeoId, src => src.carrierCollectionOriginGeoID) + .Map(dest => dest.destinationGeoId, src => src.carrierDeliveryDestinationGeoID) + .Map(dest => dest.brandScac, src => src.vesselOperatorCarrierCode) + .Map(dest => dest.containerType, src => src.ISOEquipmentCode) + .Map(dest => dest.containerCount, src => src.ISOEquipmentNum) + .Map(dest => dest.containerWeight, src => src.stuffingWeight) + .Map(dest => dest.departureDate, src => src.startDate) + .Map(dest => dest.originServiceMode, src => src.exportServiceMode) + .Map(dest => dest.destinationServiceMode, src => src.importServiceMode); + } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchLocationResultDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchLocationResultDto.cs index 8e31021d..4b7c37ac 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchLocationResultDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchLocationResultDto.cs @@ -24,7 +24,7 @@ namespace Myshipping.Application public List data { get; set; } } - public class MSKAPISPOTSearchLocationResultDataDto + public class MSKAPISPOTSearchLocationResultDataDto : QueryLocationsResultDto { /// /// 港口 geo id diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateDto.cs index c5498565..b8ba3780 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKAPISPOTSearchScheduleRateDto.cs @@ -1,4 +1,5 @@ -using System; +using Furion.RemoteRequest; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -89,11 +90,11 @@ namespace Myshipping.Application /// /// 箱量 /// - public int containerCount { get; set; } + public Nullable containerCount { get; set; } /// /// 集装箱重量, 单位为吨 /// - public int containerWeight { get; set; } + public Nullable containerWeight { get; set; } } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKSPOTBookingInitDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKSPOTBookingInitDto.cs index 48965737..e45d57ac 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKSPOTBookingInitDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/MSKSPOTBookingInitDto.cs @@ -14,7 +14,7 @@ namespace Myshipping.Application /// /// 订舱方备案编号(马士基) /// - public string bookedByMaerskPartyCode { get; set; } + public string bookedMaerskByPartyCode { get; set; } /// /// 订舱方备案全称(马士基) diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipSailingScheduleDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTScheduleDto.cs similarity index 94% rename from Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipSailingScheduleDto.cs rename to Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTScheduleDto.cs index 76950a47..eef6a8e3 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipSailingScheduleDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTScheduleDto.cs @@ -9,7 +9,7 @@ namespace Myshipping.Application /// /// /// - public class QueryMSKSPOTShipSailingScheduleDto + public class QueryMSKSPOTScheduleDto { /// /// 船公司代码 @@ -57,12 +57,12 @@ namespace Myshipping.Application public string containerType { get; set; } /// - /// 目的地城市名称 + /// 箱量 /// public Nullable containerCount { get; set; } /// - /// 目的都五字码 + /// 箱重 /// public Nullable containerWeight { get; set; } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipDateDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipDateDto.cs new file mode 100644 index 00000000..78b0fca8 --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKSPOT/QueryMSKSPOTShipDateDto.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class QueryMSKSPOTShipDateDto + { + /// + /// 船公司代码 + /// + public string carrierId { get; set; } + + /// + /// 起始地的GEO ID + /// + public string carrierCollectionOriginGeoID { get; set; } + + /// + /// 目的地的GEO ID + /// + public string carrierDeliveryDestinationGeoID { get; set; } + + /// + /// 起始地国家代码(英文) + /// + public string collectionOriginCountryCode { get; set; } + + /// + /// 起始地城市名 + /// + public string collectionOriginCityName { get; set; } + + /// + /// 起始地五字码 + /// + public string collectionOriginUNLocationCode { get; set; } + + /// + /// 起始地区代码 + /// + public string collectionOriginUNRegionCode { get; set; } + + /// + /// 目的地国家代码 二字码 + /// + public string deliveryDestinationCountryCode { get; set; } + + /// + /// 目的地城市名称 + /// + public string deliveryDestinationCityName { get; set; } + + /// + /// 目的都五字码 + /// + public string deliveryDestinationUNLocationCode { get; set; } + + /// + /// 目的地区代码 + /// + public string deliveryDestinationUNRegionCode { get; set; } + + /// + /// 承运人代码(MAEU, SEAU, SEJJ, MCPU, MAEI) + /// + public string vesselOperatorCarrierCode { get; set; } + + /// + /// 货物类型代码(DRY, REEFER) + /// + public string cargoType { get; set; } + + /// + /// 箱型代码 + /// + public string ISOEquipmentCode { get; set; } + + /// + /// 箱数量 + /// + public Nullable ISOEquipmentNum { get; set; } + + /// + /// 箱重量 + /// + public Nullable stuffingWeight { get; set; } + + /// + /// 重量单位(KGS, LBS) + /// + public string weightMeasurementUnit { get; set; } + + /// + /// 箱体积 + /// + public int stuffingVolume { get; set; } + + /// + /// 体积单位(MTQ, FTQ) + /// + public string volumeMeasurementUnit { get; set; } + + /// + /// 出口服务代码(CY, SD, CFS) + /// + public string exportServiceMode { get; set; } + + /// + /// 进口服务代码(CY, SD, CFS) + /// + public string importServiceMode { get; set; } + + /// + /// 开始时间 + /// + public string startDate { get; set; } + + /// + /// 开始时间类型(D, A) + /// + public string startDateType { get; set; } + + /// + /// 请求产品信息的时间段(P1W, P2W, P3W, P4W, P5W, P6W, P7W, P8W) + /// + public string dateRange { get; set; } + + /// + /// 船舶标志代号 + /// + public string vesselFlagCode { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs b/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs index a329e0be..5b58f8bd 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingMSKSPOTAPIService.cs @@ -18,7 +18,7 @@ namespace Myshipping.Application.Service.BookingOrder /// /// 请求详情 /// 返回检索结果 - Task> SearchLocations(QuerySPOTLocationsDto model); + Task> SearchLocations(QuerySPOTLocationsDto model); /// @@ -26,7 +26,7 @@ namespace Myshipping.Application.Service.BookingOrder /// /// 请求船期详情 /// 返回船期结果 - Task> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model); + Task> SearchShipSailingSchedule(QueryMSKSPOTShipDateDto query); /// /// 发送马士基订舱请求 diff --git a/Myshipping.Core/Entity/DJY/DjyWebsiteAccountConfig.cs b/Myshipping.Core/Entity/DJY/DjyWebsiteAccountConfig.cs index b6823233..f15a0514 100644 --- a/Myshipping.Core/Entity/DJY/DjyWebsiteAccountConfig.cs +++ b/Myshipping.Core/Entity/DJY/DjyWebsiteAccountConfig.cs @@ -32,5 +32,25 @@ namespace Myshipping.Core.Entity /// 是否为租户(公司)账号 /// public bool IsTenant { get; set; } + + /// + /// 备案代码 + /// + public string RegistPartyCode { get; set; } + + /// + /// 备案全称 + /// + public string RegistPartyName { get; set; } + + /// + /// 联系人 + /// + public string RegistContractName { get; set; } + + /// + /// 联系邮箱 + /// + public string RegistContractEmail { get; set; } } } \ No newline at end of file diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index bc6cba93..fa3a4aa9 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -2865,6 +2865,26 @@ 是否为租户(公司)账号 + + + 备案代码 + + + + + 备案全称 + + + + + 联系人 + + + + + 联系邮箱 + + 文档表