jianghaiqing 5 months ago
commit 289f00c9f4

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

@ -10440,7 +10440,7 @@ namespace Myshipping.Application
}
//提箱返场
var statusloglist = _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && (x.Status == "提箱" || x.Status == "返场") && x.IsDeleted == false).ToList();
var statusloglist = _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).ToList();
var statuslogId = statusloglist.Select(x => x.Id).ToList();
//运踪状态详情
var statuslogdetaillist = _statuslogdetail.AsQueryable().Where(x => statuslogId.Contains(x.PId)).ToList();

@ -2300,7 +2300,8 @@ namespace Myshipping.Application
Code = t.Code,
Value = t.Value
}).ToListAsync();
bool flag = false;
var sendDsList = new List<long>();
foreach (var item in all)
{
// 当BusinessId不为空时将BusinessId的值转为订舱主键否则仍然使用BookingId作为订舱记录主键
@ -2377,7 +2378,7 @@ namespace Myshipping.Application
if (item.Status == "提箱" || item.Status == "返场")
{
flag = true;
sendDsList.Add(item.BookingId);
}
#endregion
@ -2409,7 +2410,7 @@ namespace Myshipping.Application
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("BG", item.BookingId);
flag = true;
sendDsList.Add(item.BookingId);
}
}
if (item.Status == "装载")
@ -2424,7 +2425,7 @@ namespace Myshipping.Application
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("ZZFX", item.BookingId);
flag = true;
sendDsList.Add(item.BookingId);
}
}
if (item.Status == "码放")
@ -2439,7 +2440,7 @@ namespace Myshipping.Application
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("MTFX", item.BookingId);
flag = true;
sendDsList.Add(item.BookingId);
}
}
if (item.Status == "装船")
@ -2510,7 +2511,7 @@ namespace Myshipping.Application
bookingStatus.StaCate = "book_sta_cate_billtrace";
await _repBookingStatus.InsertAsync(bookingStatus);
await _bookingorderservice.SetGoodsStatus("YRG", item.BookingId);
flag = true;
sendDsList.Add(item.BookingId);
}
@ -2547,7 +2548,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
@ -2591,7 +2592,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
}
@ -2611,7 +2612,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
}
@ -2631,7 +2632,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
}
@ -2651,7 +2652,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
@ -2688,7 +2689,7 @@ namespace Myshipping.Application
x.UpdatedUserId,
x.UpdatedUserName
}).ExecuteCommandAsync();
flag = true;
sendDsList.Add(item.BookingId);
await _bookingorderservice.SaveLog(newOrder, oldOrder, "运踪更新船期");
}
@ -2715,9 +2716,9 @@ namespace Myshipping.Application
}
if (flag)
if (sendDsList.Count > 0)
{
await _bookingorderservice.SendBookingOrder(new long[] { all[0].BookingId });
await _bookingorderservice.SendBookingOrder(sendDsList.ToArray());
}

Loading…
Cancel
Save