|
|
@ -24,6 +24,10 @@ using Org.BouncyCastle.Crypto;
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using static Aliyun.OSS.Model.InventoryConfigurationModel;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -173,11 +177,12 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
queryInfo.stuffingVolume = model.stuffingVolume;
|
|
|
|
queryInfo.stuffingVolume = model.stuffingVolume;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MSKAPISearchPoint2PointScheduleResultDto resultInfo = null;
|
|
|
|
MSKAPISearchPoint2PointScheduleResultDto resultInfo = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(queryInfo, Formatting.Indented, new JsonSerializerSettings
|
|
|
|
var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(queryInfo);
|
|
|
|
{
|
|
|
|
|
|
|
|
NullValueHandling = NullValueHandling.Ignore
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var rlt = await queryUrl.SetBody(jsonBody)
|
|
|
|
var rlt = await queryUrl.SetBody(jsonBody)
|
|
|
|
.PostAsStringAsync();
|
|
|
|
.PostAsStringAsync();
|
|
|
@ -203,80 +208,264 @@ 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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resultInfo.data.ForEach(a =>
|
|
|
|
resultInfo.data.ForEach(t =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
t.transportSchedules.ForEach(a =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currList = t.transportSchedules.Select(a =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
a.transportSchedules.ForEach(b =>
|
|
|
|
return GetShipScheduleShow(a);
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currList.Count > 0)
|
|
|
|
|
|
|
|
list.AddRange(currList);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah($"检索海运船期详情失败,{ex.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 组织返回船期数据
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 组织返回船期数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="model">查询的船期详情</param>
|
|
|
|
|
|
|
|
/// <returns>返回显示的船期数据</returns>
|
|
|
|
|
|
|
|
private SearchShipSailingScheduleResultDto GetShipScheduleShow(MSKAPISearchTransportSchedules model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto
|
|
|
|
|
|
|
|
|
|
|
|
SearchShipSailingScheduleResultDto showDto = new SearchShipSailingScheduleResultDto
|
|
|
|
{
|
|
|
|
{
|
|
|
|
carrierProductId = a.carrierProductId,
|
|
|
|
PId = model.PId,
|
|
|
|
carrierProductSequenceId = a.carrierProductSequenceId,
|
|
|
|
MD5 = model.MD5,
|
|
|
|
ETD = b.departureDateTime,
|
|
|
|
|
|
|
|
ATD = b.arrivalDateTime,
|
|
|
|
orignCarrierCityGeoID = model.originGeoId,
|
|
|
|
vesselOperatorCarrierCode = b.vesselOperatorCarrierCode
|
|
|
|
orignUNLocationCode = model.originUnLocCode,
|
|
|
|
|
|
|
|
orignCityName = model.originCityName,
|
|
|
|
|
|
|
|
originRegionName = model.originRegionName,
|
|
|
|
|
|
|
|
originCountryName = model.originCountryName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deliveryCarrierCityGeoID = model.destinationGeoId,
|
|
|
|
|
|
|
|
deliveryUNLocationCode = model.destinationUnLocCode,
|
|
|
|
|
|
|
|
deliveryCityName = model.destinationCityName,
|
|
|
|
|
|
|
|
deliveryRegionName = model.destinationRegionName,
|
|
|
|
|
|
|
|
deliveryCountryName = model.destinationCountryName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vesselName = model.firstDepartureVessel.vesselName,
|
|
|
|
|
|
|
|
carrierDepartureVoyageNumber = model.transportLegs.FirstOrDefault().transport.carrierDepartureVoyageNumber,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Legs = new List<MSKAPISPOTScheduleRateResultShowLegsDto>()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue)
|
|
|
|
//ETD
|
|
|
|
|
|
|
|
if (model.departureDateTime.HasValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value);
|
|
|
|
showDto.ETD = model.departureDateTime.Value;
|
|
|
|
var timeDiff = ts.TotalHours;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,预计离港日期查询为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info.days = (int)Math.Ceiling(timeDiff / 24.0);
|
|
|
|
//ETA
|
|
|
|
|
|
|
|
if (model.arrivalDateTime.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
showDto.ETA = model.arrivalDateTime.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"查询船期错误,预计到港日期查询为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (b.facilities != null)
|
|
|
|
//计算预计天数
|
|
|
|
|
|
|
|
if (showDto.ETD.HasValue && showDto.ETD.HasValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.orignCityName = b.facilities.collectionOrigin?.cityName;
|
|
|
|
TimeSpan ts = showDto.ETA.Value.Subtract(showDto.ETD.Value);
|
|
|
|
info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID;
|
|
|
|
var timeDiff = ts.TotalHours;
|
|
|
|
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;
|
|
|
|
showDto.days = (int)Math.Ceiling(timeDiff / 24.0);
|
|
|
|
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;
|
|
|
|
if (model.transportLegs.Count > 1)
|
|
|
|
info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode;
|
|
|
|
showDto.isTransfer = true;
|
|
|
|
info.vesselName = b.firstDepartureVessel?.vesselName;
|
|
|
|
|
|
|
|
|
|
|
|
//Legs
|
|
|
|
|
|
|
|
if (model.facilities != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
showDto.orignCountryCode = model.facilities.collectionOrigin.countryCode;
|
|
|
|
|
|
|
|
showDto.deliveryCountryCode = model.facilities.deliveryDestination.countryCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var legs = new List<MSKAPISPOTScheduleRateResultShowLegsDto>();
|
|
|
|
|
|
|
|
|
|
|
|
if (b.transportLegs != null && b.transportLegs.Count > 0)
|
|
|
|
for (int i = 0; i < model.transportLegs.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var firstTransportLegs = b.transportLegs.FirstOrDefault();
|
|
|
|
var b = model.transportLegs[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (firstTransportLegs.transport != null)
|
|
|
|
MSKAPISPOTScheduleRateResultShowLegsDto leg = new MSKAPISPOTScheduleRateResultShowLegsDto
|
|
|
|
{
|
|
|
|
{
|
|
|
|
info.transportMode = firstTransportLegs.transport.transportMode;
|
|
|
|
vesselName = b.transport.vessel.vesselName,
|
|
|
|
info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber;
|
|
|
|
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($"查询船期错误,预计到港日期查询为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info.transportLegs = b.transportLegs;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(info);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
else if(i == model.transportLegs.Count - 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
|
|
|
|
leg.To.CityGeoId = model.destinationGeoId;
|
|
|
|
|
|
|
|
leg.To.CountryName = model.destinationCountryName;
|
|
|
|
|
|
|
|
leg.To.RegionName = model.destinationRegionName;
|
|
|
|
|
|
|
|
leg.To.UnLocCode = model.destinationUnLocCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah($"检索海运船期详情失败,{ex.Message}");
|
|
|
|
legs.Add(leg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
|
|
showDto.Legs = legs.OrderBy(t => t.ETD).Select((t, idx) => {
|
|
|
|
|
|
|
|
t.SortNo = idx + 1;
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return showDto;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 缓存船期数据
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 缓存船期数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="model">船期查询结果明细</param>
|
|
|
|
|
|
|
|
/// <param name="busiType">船期类型 MSKSPOT-马士基即期</param>
|
|
|
|
|
|
|
|
/// <returns>返回主键ID</returns>
|
|
|
|
|
|
|
|
private async Task CacheShipSailingSchedule(MSKAPISearchTransportSchedules model, string busiType = "MSKCON")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、按照船期明细缓存,并把ID作为缓存的KEY
|
|
|
|
|
|
|
|
2、对数据进行JSON串行化的文本提取MD5
|
|
|
|
|
|
|
|
3、写入缓存,并返回ID
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
var newModel = model.Adapt<MSKAPISearchTransportSchedules>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MSKAPISearchPoint2PointScheduleResultDataDto GetCacheShipSailingSchedule(long pid, string busiType = "MSKCON")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_cache.Exists($"{pid}_{busiType}"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _cache.Get<MSKAPISearchPoint2PointScheduleResultDataDto>($"{pid}_{busiType}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 发送马士基订舱请求
|
|
|
|
#region 发送马士基订舱请求
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 发送马士基订舱请求
|
|
|
|
/// 发送马士基订舱请求
|
|
|
|