|
|
@ -157,9 +157,9 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
/// <param name="model">请求船期详情</param>
|
|
|
|
/// <param name="model">请求船期详情</param>
|
|
|
|
/// <returns>返回船期结果</returns>
|
|
|
|
/// <returns>返回船期结果</returns>
|
|
|
|
[HttpPost("/BookingMSKSPOTAPI/SearchShipSailingSchedule")]
|
|
|
|
[HttpPost("/BookingMSKSPOTAPI/SearchShipSailingSchedule")]
|
|
|
|
public async Task<List<MSKAPISPOTSearchScheduleRateResultDataDto>> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model)
|
|
|
|
public async Task<List<MSKAPISPOTScheduleRateResultShowDto>> SearchShipSailingSchedule(QueryMSKSPOTShipSailingScheduleDto model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<MSKAPISPOTSearchScheduleRateResultDataDto> list = new List<MSKAPISPOTSearchScheduleRateResultDataDto>();
|
|
|
|
List<MSKAPISPOTScheduleRateResultShowDto> list = new List<MSKAPISPOTScheduleRateResultShowDto>();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
MSKApiSailingSchedulePoint2Point
|
|
|
|
MSKApiSailingSchedulePoint2Point
|
|
|
@ -285,12 +285,158 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
if (resultInfo != null && resultInfo.code == 200
|
|
|
|
if (resultInfo != null && resultInfo.code == 200
|
|
|
|
&& resultInfo.data != null && resultInfo.data.Count > 0)
|
|
|
|
&& resultInfo.data != null && resultInfo.data.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
list = resultInfo.data;
|
|
|
|
foreach (var scheduleModel in resultInfo.data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CacheShipSailingSchedule(scheduleModel).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var scheduleModel in list)
|
|
|
|
list = resultInfo.data.Select(a =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await CacheShipSailingSchedule(scheduleModel);
|
|
|
|
MSKAPISPOTScheduleRateResultShowDto showDto = new MSKAPISPOTScheduleRateResultShowDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
priceID = a.priceID,
|
|
|
|
|
|
|
|
PId = a.PId,
|
|
|
|
|
|
|
|
MD5 = a.MD5,
|
|
|
|
|
|
|
|
totalAmount = a.totalAmount.HasValue ? (decimal)a.totalAmount.Value : 0,
|
|
|
|
|
|
|
|
TotalCurrency = a.totalCurrency,
|
|
|
|
|
|
|
|
orignCarrierCityGeoID = a.originGeoId,
|
|
|
|
|
|
|
|
orignUNLocationCode = a.originUnLocCode,
|
|
|
|
|
|
|
|
orignCityName = a.originCityName,
|
|
|
|
|
|
|
|
originRegionName = a.originRegionName,
|
|
|
|
|
|
|
|
originCountryName = a.originCountryName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deliveryCarrierCityGeoID = a.destinationGeoId,
|
|
|
|
|
|
|
|
deliveryUNLocationCode = a.destinationUnLocCode,
|
|
|
|
|
|
|
|
deliveryCityName = a.destinationCityName,
|
|
|
|
|
|
|
|
deliveryRegionName = a.destinationRegionName,
|
|
|
|
|
|
|
|
deliveryCountryName = a.destinationCountryName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vesselName = a.vesselName,
|
|
|
|
|
|
|
|
carrierDepartureVoyageNumber = a.voyageNumber,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Legs = new List<MSKAPISPOTScheduleRateResultShowLegsDto>()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ETD
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(a.departureDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DateTime currDate = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(a.departureDate, out currDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
showDto.ETD = currDate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,priceID={a.priceID} pid={a.PId} 预计离港日期departureDate={a.departureDate} 格式解析错误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ETA
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(a.arrivalDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DateTime currDate = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(a.arrivalDate, out currDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
showDto.ETA = currDate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,priceID={a.priceID} pid={a.PId} 预计到达日期 arrivalDate={a.arrivalDate} 格式解析错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算预计天数
|
|
|
|
|
|
|
|
if (showDto.ETD.HasValue && showDto.ETA.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TimeSpan ts = showDto.ETD.Value.Subtract(showDto.ETA.Value);
|
|
|
|
|
|
|
|
var timeDiff = ts.TotalHours;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showDto.days = (int)Math.Ceiling(timeDiff / 24.0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (a.isTransfer.Equals("true", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|
|
showDto.isTransfer = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Legs
|
|
|
|
|
|
|
|
if (a.scheduleDetails != null && a.scheduleDetails.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var legs = a.scheduleDetails.Select(b =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MSKAPISPOTScheduleRateResultShowLegsDto leg = new MSKAPISPOTScheduleRateResultShowLegsDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vesselName = b.transport.vessel.longName,
|
|
|
|
|
|
|
|
VoyageNo = b.transport.voyageNumber,
|
|
|
|
|
|
|
|
From = new MSKAPISPOTScheduleRateResultShowLegsLocationDto {
|
|
|
|
|
|
|
|
CityGeoId = b.fromLocation.cityGeoId,
|
|
|
|
|
|
|
|
CityName = b.fromLocation.cityName,
|
|
|
|
|
|
|
|
CountryCode = b.fromLocation.countryCode,
|
|
|
|
|
|
|
|
CountryName = b.fromLocation.countryName,
|
|
|
|
|
|
|
|
rkstCode = b.fromLocation.rkstCode,
|
|
|
|
|
|
|
|
SiteGeoId = b.fromLocation.siteGeoId,
|
|
|
|
|
|
|
|
LocationType = "From",
|
|
|
|
|
|
|
|
RegionName = b.fromLocation.regionName,
|
|
|
|
|
|
|
|
SiteName = b.fromLocation.siteName,
|
|
|
|
|
|
|
|
UnLocCode = b.fromLocation.unLocCode,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
To = new MSKAPISPOTScheduleRateResultShowLegsLocationDto {
|
|
|
|
|
|
|
|
CityGeoId = b.toLocation.cityGeoId,
|
|
|
|
|
|
|
|
CityName = b.toLocation.cityName,
|
|
|
|
|
|
|
|
CountryCode = b.toLocation.countryCode,
|
|
|
|
|
|
|
|
CountryName = b.toLocation.countryName,
|
|
|
|
|
|
|
|
rkstCode = b.toLocation.rkstCode,
|
|
|
|
|
|
|
|
SiteGeoId = b.toLocation.siteGeoId,
|
|
|
|
|
|
|
|
LocationType = "To",
|
|
|
|
|
|
|
|
RegionName = b.toLocation.regionName,
|
|
|
|
|
|
|
|
SiteName = b.toLocation.siteName,
|
|
|
|
|
|
|
|
UnLocCode = b.toLocation.unLocCode,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ETD
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(b.fromLocation.date))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DateTime currDate = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse($"{b.fromLocation.date} {b.fromLocation.time}", out currDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
leg.ETD = currDate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,航程明细 priceID={a.priceID} pid={a.PId} 预计离港日期fromLocation.date={b.fromLocation.date} {b.fromLocation.time} 格式解析错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ETA
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(b.toLocation.date))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DateTime currDate = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(a.arrivalDate, out currDate))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
leg.ETD = currDate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,航程明细 priceID={a.priceID} pid={a.PId} 预计到达日期 toLocation.date={b.toLocation.date} {b.toLocation.time} 格式解析错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return leg;
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
showDto.Legs = legs.OrderBy(t=>t.ETD).Select((t,idx)=> {
|
|
|
|
|
|
|
|
t.SortNo = idx + 1;
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return showDto;
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -315,7 +461,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
/// <param name="model">船期查询结果明细</param>
|
|
|
|
/// <param name="model">船期查询结果明细</param>
|
|
|
|
/// <param name="busiType">船期类型 MSKSPOT-马士基即期</param>
|
|
|
|
/// <param name="busiType">船期类型 MSKSPOT-马士基即期</param>
|
|
|
|
/// <returns>返回主键ID</returns>
|
|
|
|
/// <returns>返回主键ID</returns>
|
|
|
|
private async Task<long> CacheShipSailingSchedule(MSKAPISPOTSearchScheduleRateResultDataDto model,string busiType = "MSKSPOT")
|
|
|
|
private async Task CacheShipSailingSchedule(MSKAPISPOTSearchScheduleRateResultDataDto model,string busiType = "MSKSPOT")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
1、按照船期明细缓存,并把ID作为缓存的KEY
|
|
|
|
1、按照船期明细缓存,并把ID作为缓存的KEY
|
|
|
@ -344,8 +490,6 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _cache.SetTimeoutAsync(shareKey, Newtonsoft.Json.JsonConvert.SerializeObject(model), expireTimeSpan);
|
|
|
|
await _cache.SetTimeoutAsync(shareKey, Newtonsoft.Json.JsonConvert.SerializeObject(model), expireTimeSpan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return model.PId;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|