修改MSK SPOT 订舱

master
jianghaiqing 5 months ago
parent f416d45556
commit 1d3dc78fb2

@ -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<BookingMSKSPOTAPIService> logger, ISysCacheService cache,
IDjyWebsiteAccountConfigService webAccountConfig, SqlSugarRepository<BookingDeliveryRecord> bookingDeliveryRecordRep,
ISysDataUserMenu sysDataUserMenuService,
@ -66,10 +65,10 @@ namespace Myshipping.Application.Service.BookingOrder
/// <param name="model">请求详情</param>
/// <returns>返回检索结果</returns>
[HttpPost("/BookingMSKSPOTAPI/SearchLocations")]
public async Task<List<MSKAPISPOTSearchLocationResultDataDto>> SearchLocations(QuerySPOTLocationsDto model)
public async Task<List<QueryLocationsResultDto>> SearchLocations(QuerySPOTLocationsDto model)
{
List<MSKAPISPOTSearchLocationResultDataDto> list = new List<MSKAPISPOTSearchLocationResultDataDto>();
List<QueryLocationsResultDto> list = new List<QueryLocationsResultDto>();
/*
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
/// <param name="model">请求船期详情</param>
/// <returns>返回船期结果</returns>
[HttpPost("/BookingMSKSPOTAPI/SearchShipSailingSchedule")]
public async Task<List<MSKAPISPOTScheduleRateResultShowDto>> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model)
public async Task<List<MSKAPISPOTScheduleRateResultShowDto>> SearchShipSailingSchedule(QueryMSKSPOTShipDateDto query)
{
List<MSKAPISPOTScheduleRateResultShowDto> list = new List<MSKAPISPOTScheduleRateResultShowDto>();
/*
MSKApiSailingSchedulePoint2Point
*/
try
{
var model = query.Adapt<QueryMSKSPOTScheduleDto>();
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<MSKSPOTBookingInitDto> 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
}

@ -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<QueryMSKSPOTShipDateDto, QueryMSKSPOTScheduleDto>()
.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);
}
}
}

@ -24,7 +24,7 @@ namespace Myshipping.Application
public List<MSKAPISPOTSearchLocationResultDataDto> data { get; set; }
}
public class MSKAPISPOTSearchLocationResultDataDto
public class MSKAPISPOTSearchLocationResultDataDto : QueryLocationsResultDto
{
/// <summary>
/// 港口 geo id

@ -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
/// <summary>
/// 箱量
/// </summary>
public int containerCount { get; set; }
public Nullable<int> containerCount { get; set; }
/// <summary>
/// 集装箱重量, 单位为吨
/// </summary>
public int containerWeight { get; set; }
public Nullable<int> containerWeight { get; set; }
}
}

@ -14,7 +14,7 @@ namespace Myshipping.Application
/// <summary>
/// 订舱方备案编号(马士基)
/// </summary>
public string bookedByMaerskPartyCode { get; set; }
public string bookedMaerskByPartyCode { get; set; }
/// <summary>
/// 订舱方备案全称(马士基)

@ -9,7 +9,7 @@ namespace Myshipping.Application
/// <summary>
///
/// </summary>
public class QueryMSKSPOTShipSailingScheduleDto
public class QueryMSKSPOTScheduleDto
{
/// <summary>
/// 船公司代码
@ -57,12 +57,12 @@ namespace Myshipping.Application
public string containerType { get; set; }
/// <summary>
/// 目的地城市名称
/// 箱量
/// </summary>
public Nullable<int> containerCount { get; set; }
/// <summary>
/// 目的都五字码
/// 箱重
/// </summary>
public Nullable<int> containerWeight { get; set; }

@ -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
{
/// <summary>
/// 船公司代码
/// </summary>
public string carrierId { get; set; }
/// <summary>
/// 起始地的GEO ID
/// </summary>
public string carrierCollectionOriginGeoID { get; set; }
/// <summary>
/// 目的地的GEO ID
/// </summary>
public string carrierDeliveryDestinationGeoID { get; set; }
/// <summary>
/// 起始地国家代码(英文)
/// </summary>
public string collectionOriginCountryCode { get; set; }
/// <summary>
/// 起始地城市名
/// </summary>
public string collectionOriginCityName { get; set; }
/// <summary>
/// 起始地五字码
/// </summary>
public string collectionOriginUNLocationCode { get; set; }
/// <summary>
/// 起始地区代码
/// </summary>
public string collectionOriginUNRegionCode { get; set; }
/// <summary>
/// 目的地国家代码 二字码
/// </summary>
public string deliveryDestinationCountryCode { get; set; }
/// <summary>
/// 目的地城市名称
/// </summary>
public string deliveryDestinationCityName { get; set; }
/// <summary>
/// 目的都五字码
/// </summary>
public string deliveryDestinationUNLocationCode { get; set; }
/// <summary>
/// 目的地区代码
/// </summary>
public string deliveryDestinationUNRegionCode { get; set; }
/// <summary>
/// 承运人代码MAEU, SEAU, SEJJ, MCPU, MAEI
/// </summary>
public string vesselOperatorCarrierCode { get; set; }
/// <summary>
/// 货物类型代码DRY, REEFER
/// </summary>
public string cargoType { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string ISOEquipmentCode { get; set; }
/// <summary>
/// 箱数量
/// </summary>
public Nullable<int> ISOEquipmentNum { get; set; }
/// <summary>
/// 箱重量
/// </summary>
public Nullable<int> stuffingWeight { get; set; }
/// <summary>
/// 重量单位KGS, LBS
/// </summary>
public string weightMeasurementUnit { get; set; }
/// <summary>
/// 箱体积
/// </summary>
public int stuffingVolume { get; set; }
/// <summary>
/// 体积单位MTQ, FTQ
/// </summary>
public string volumeMeasurementUnit { get; set; }
/// <summary>
/// 出口服务代码CY, SD, CFS
/// </summary>
public string exportServiceMode { get; set; }
/// <summary>
/// 进口服务代码CY, SD, CFS
/// </summary>
public string importServiceMode { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string startDate { get; set; }
/// <summary>
/// 开始时间类型D, A
/// </summary>
public string startDateType { get; set; }
/// <summary>
/// 请求产品信息的时间段P1W, P2W, P3W, P4W, P5W, P6W, P7W, P8W
/// </summary>
public string dateRange { get; set; }
/// <summary>
/// 船舶标志代号
/// </summary>
public string vesselFlagCode { get; set; }
}
}

@ -18,7 +18,7 @@ namespace Myshipping.Application.Service.BookingOrder
/// </summary>
/// <param name="model">请求详情</param>
/// <returns>返回检索结果</returns>
Task<List<MSKAPISPOTSearchLocationResultDataDto>> SearchLocations(QuerySPOTLocationsDto model);
Task<List<QueryLocationsResultDto>> SearchLocations(QuerySPOTLocationsDto model);
/// <summary>
@ -26,7 +26,7 @@ namespace Myshipping.Application.Service.BookingOrder
/// </summary>
/// <param name="model">请求船期详情</param>
/// <returns>返回船期结果</returns>
Task<List<MSKAPISPOTScheduleRateResultShowDto>> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model);
Task<List<MSKAPISPOTScheduleRateResultShowDto>> SearchShipSailingSchedule(QueryMSKSPOTShipDateDto query);
/// <summary>
/// 发送马士基订舱请求

@ -32,5 +32,25 @@ namespace Myshipping.Core.Entity
/// 是否为租户(公司)账号
/// </summary>
public bool IsTenant { get; set; }
/// <summary>
/// 备案代码
/// </summary>
public string RegistPartyCode { get; set; }
/// <summary>
/// 备案全称
/// </summary>
public string RegistPartyName { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string RegistContractName { get; set; }
/// <summary>
/// 联系邮箱
/// </summary>
public string RegistContractEmail { get; set; }
}
}

@ -2865,6 +2865,26 @@
是否为租户(公司)账号
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyWebsiteAccountConfig.RegistPartyCode">
<summary>
备案代码
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyWebsiteAccountConfig.RegistPartyName">
<summary>
备案全称
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyWebsiteAccountConfig.RegistContractName">
<summary>
联系人
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyWebsiteAccountConfig.RegistContractEmail">
<summary>
联系邮箱
</summary>
</member>
<member name="T:Myshipping.Core.Entity.Documentation">
<summary>
文档表

Loading…
Cancel
Save