|
|
|
@ -854,7 +854,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询船期数据EMC
|
|
|
|
|
/// 查询船期数据EMC(即将作废,用QueryShipInfo接口替代)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingCustomerOrder/QueryShipInfoEMC")]
|
|
|
|
@ -967,6 +967,144 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询船期数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingCustomerOrder/QueryShipInfo")]
|
|
|
|
|
public async Task<dynamic> QueryShipInfo(long custOrdId, string carr = "EMC")
|
|
|
|
|
{
|
|
|
|
|
var allSysConfig = await _cache.GetAllSysConfig();
|
|
|
|
|
var sCfgSpiderUrl = allSysConfig.FirstOrDefault(x => x.Code == "BookingPostApiServerAddr" && x.GroupCode == "DJY_CONST");
|
|
|
|
|
if (sCfgSpiderUrl == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("订舱API的爬虫URL地址未配置,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sCfgUserKey = allSysConfig.FirstOrDefault(x => x.Code == "BookingPostApiKey" && x.GroupCode == "DJY_CONST");
|
|
|
|
|
var sCfgUserSecret = allSysConfig.FirstOrDefault(x => x.Code == "BookingPostApiSecret" && x.GroupCode == "DJY_CONST");
|
|
|
|
|
if (sCfgUserKey == null || sCfgUserSecret == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("订舱API的KEY和密钥未配置,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region EMC
|
|
|
|
|
if (carr == "EMC")
|
|
|
|
|
{
|
|
|
|
|
var apiUrl = sCfgSpiderUrl.Value;
|
|
|
|
|
if (!apiUrl.EndsWith("/"))
|
|
|
|
|
{
|
|
|
|
|
apiUrl += "/";
|
|
|
|
|
}
|
|
|
|
|
apiUrl += "v1/emc/ship/query";
|
|
|
|
|
|
|
|
|
|
var custOrder = await _rep.AsQueryable().FirstAsync(x => x.Id == custOrdId);
|
|
|
|
|
var ctns = await _repCtn.AsQueryable().Where(x => x.BILLID == custOrdId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var mappingCtn = await _cache.GetAllMappingCtn();
|
|
|
|
|
var mappingPortLoad = await _cache.GetAllMappingPortLoad();
|
|
|
|
|
var mappingPort = await _cache.GetAllMappingPort();
|
|
|
|
|
|
|
|
|
|
//收货地
|
|
|
|
|
var mapPlaceReceipt = mappingPortLoad.FirstOrDefault(x => x.Module == "DjyCustBooking" && x.CarrierCode == "EMC" && x.Code == custOrder.PLACERECEIPTCODE);
|
|
|
|
|
if (mapPlaceReceipt == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到收货地映射信息:{custOrder.PLACERECEIPTCODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//起运港
|
|
|
|
|
var mapPortLoad = mappingPortLoad.FirstOrDefault(x => x.Module == "DjyCustBooking" && x.CarrierCode == "EMC" && x.Code == custOrder.PORTLOADCODE);
|
|
|
|
|
if (mapPortLoad == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到起运港映射信息:{custOrder.PORTLOADCODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//卸货港
|
|
|
|
|
var mapPort = mappingPort.FirstOrDefault(x => x.Module == "DjyCustBooking" && x.CarrierCode == "EMC" && x.Code == custOrder.PORTDISCHARGECODE);
|
|
|
|
|
if (mapPort == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到卸货港映射信息:{custOrder.PORTDISCHARGECODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//目的地
|
|
|
|
|
var mapDestination = mappingPort.FirstOrDefault(x => x.Module == "DjyCustBooking" && x.CarrierCode == "EMC" && x.Code == custOrder.DESTINATIONCODE);
|
|
|
|
|
if (mapDestination == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到目的地映射信息:{custOrder.DESTINATIONCODE}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//箱型转换
|
|
|
|
|
var disCtnCode = ctns.Select(x => x.CTNCODE).Distinct().ToList();
|
|
|
|
|
var mapCtnCode = new List<string>();
|
|
|
|
|
foreach (var ctnall in disCtnCode)
|
|
|
|
|
{
|
|
|
|
|
var mapCtn = mappingCtn.FirstOrDefault(x => x.Module == "DjyCustBooking" && x.CarrierCode == "EMC" && x.Code == ctnall);
|
|
|
|
|
if (mapCtn == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"未找到箱型映射信息:{ctnall}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapCtnCode.Add(mapCtn.MapName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var postModel = new
|
|
|
|
|
{
|
|
|
|
|
userKey = sCfgUserKey.Value,
|
|
|
|
|
userSecret = sCfgUserSecret.Value,
|
|
|
|
|
webAccount = custOrder.BookingAccount,
|
|
|
|
|
webPassword = custOrder.BookingPassword,
|
|
|
|
|
searchConditionDate = custOrder.ETD.Value.AddDays(-7).ToString("yyyy-MM-dd"),
|
|
|
|
|
originName = mapPlaceReceipt.MapName,
|
|
|
|
|
destinationName = mapDestination.MapName,
|
|
|
|
|
polPortName = mapPortLoad.MapName,
|
|
|
|
|
podPortName = mapPort.MapName,
|
|
|
|
|
serviceType = custOrder.ServiceType,
|
|
|
|
|
serviceMode = custOrder.ServiceMode,
|
|
|
|
|
bookingOffice = custOrder.BookingAddr,
|
|
|
|
|
isReefer = "N",
|
|
|
|
|
contractType = custOrder.ContractType,
|
|
|
|
|
contractNo = custOrder.CONTRACTNO,
|
|
|
|
|
containerTypeList = mapCtnCode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"发送查询API数据给爬虫({apiUrl}):{postModel.ToJsonString()}");
|
|
|
|
|
var rtnQuery = await apiUrl.SetBody(postModel)
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"爬虫返回:{rtnQuery}");
|
|
|
|
|
var jobjRtnQuery = JObject.Parse(rtnQuery);
|
|
|
|
|
if (jobjRtnQuery.GetIntValue("code") != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"查询船期数据出错:{jobjRtnQuery.GetStringValue("msg")}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var jarrVessel = jobjRtnQuery.GetJArrayValue("data");
|
|
|
|
|
return jarrVessel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region COSCO
|
|
|
|
|
//else if (carr == "COSCO")
|
|
|
|
|
//{
|
|
|
|
|
// var apiUrl = sCfgSpiderUrl.Value;
|
|
|
|
|
// if (!apiUrl.EndsWith("/"))
|
|
|
|
|
// {
|
|
|
|
|
// apiUrl += "/";
|
|
|
|
|
// }
|
|
|
|
|
// apiUrl += "v1/cosco/ship/schedule";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("不支持的船公司");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存船期数据EMC
|
|
|
|
|
/// </summary>
|
|
|
|
|