|
|
|
@ -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
|
|
|
|
|
}
|
|
|
|
|