|
|
|
@ -52,7 +52,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingLogDetail> _bookinglogdetail;
|
|
|
|
|
private readonly SqlSugarRepository<BookingRemark> _bookingremark;
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingfile;
|
|
|
|
|
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _webconfig;
|
|
|
|
|
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _repWebAcc;
|
|
|
|
|
private readonly SqlSugarRepository<SysDictData> _dicdata;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrint;
|
|
|
|
|
private readonly ILogger<BookingOrderService> _logger;
|
|
|
|
@ -63,6 +63,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingLetteryard> _repLetterYard;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _repUser;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderUrl> _repOrderUrl;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderContact> _repOrderContact;
|
|
|
|
|
|
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
|
|
|
|
|
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
|
|
|
|
@ -70,7 +71,7 @@ namespace Myshipping.Application
|
|
|
|
|
SqlSugarRepository<SysDictData> dicdata, SqlSugarRepository<BookingStatusLog> statuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail,
|
|
|
|
|
ILogger<BookingOrderService> logger, ISysCacheService cache,
|
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
|
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl)
|
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
@ -80,7 +81,7 @@ namespace Myshipping.Application
|
|
|
|
|
this._bookinglogdetail = bookinglogdetail;
|
|
|
|
|
this._bookingremark = bookingremark;
|
|
|
|
|
this._bookingfile = bookingfile;
|
|
|
|
|
this._webconfig = webconfig;
|
|
|
|
|
this._repWebAcc = webconfig;
|
|
|
|
|
this._repPrint = repPrint;
|
|
|
|
|
this._dicdata = dicdata;
|
|
|
|
|
this._cache = cache;
|
|
|
|
@ -90,6 +91,7 @@ namespace Myshipping.Application
|
|
|
|
|
this._repLetterYard = repLetterYard;
|
|
|
|
|
this._repUser = repUser;
|
|
|
|
|
this._repOrderUrl = repOrderUrl;
|
|
|
|
|
this._repOrderContact = repOrderContact;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 主表和箱信息
|
|
|
|
@ -399,11 +401,11 @@ namespace Myshipping.Application
|
|
|
|
|
[HttpGet("/BookingOrder/get")]
|
|
|
|
|
public async Task<BookingOrderOutput> Get(long Id)
|
|
|
|
|
{
|
|
|
|
|
BookingOrderOutput list = new BookingOrderOutput();
|
|
|
|
|
BookingOrderOutput ordOut = new BookingOrderOutput();
|
|
|
|
|
var main = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
|
|
|
|
|
if (main != null)
|
|
|
|
|
{
|
|
|
|
|
list = main.Adapt<BookingOrderOutput>();
|
|
|
|
|
ordOut = main.Adapt<BookingOrderOutput>();
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
|
|
|
|
|
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
|
|
|
|
|
foreach (var item in ctninput)
|
|
|
|
@ -411,9 +413,20 @@ namespace Myshipping.Application
|
|
|
|
|
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
|
|
|
|
|
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
|
|
|
|
|
}
|
|
|
|
|
list.ctnInputs = ctninput;
|
|
|
|
|
ordOut.ctnInputs = ctninput;
|
|
|
|
|
|
|
|
|
|
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
|
|
|
|
|
if (ordUrl != null)
|
|
|
|
|
{
|
|
|
|
|
ordOut.Link = new BookingOrderUrlOutput()
|
|
|
|
|
{
|
|
|
|
|
LinkUrlTxxp = ordUrl.UrlTxxp,
|
|
|
|
|
LinkUrlVgm = ordUrl.UrlVgm,
|
|
|
|
|
LinkUrlVmgSi = ordUrl.UrlVgmSi,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
return ordOut;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -562,7 +575,7 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task SendTrace(string BusinessId, string YARDID, string YARD, string MBLNO)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("提单号:" + MBLNO + " 调用运踪接口");
|
|
|
|
|
var key = _webconfig.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl");
|
|
|
|
|
var key = _repWebAcc.FirstOrDefault(x => x.TenantId == Convert.ToInt64(UserManager.TENANT_ID) && x.TypeCode == "seae_billtraceurl");
|
|
|
|
|
var url = _cache.GetAllDictData().Result;
|
|
|
|
|
BillTraceDto billdto = new BillTraceDto();
|
|
|
|
|
List<BillTraceList> billTraceList = new List<BillTraceList>();
|
|
|
|
@ -849,7 +862,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//亿通账号
|
|
|
|
|
var ytAcc = _webconfig.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb");
|
|
|
|
|
var ytAcc = _repWebAcc.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.TypeCode == "YitongWeb");
|
|
|
|
|
if (ytAcc == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK119);
|
|
|
|
@ -939,7 +952,155 @@ namespace Myshipping.Application
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region VGM及VMG链接
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取VGM、VGM&SI链接
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/vgmlink")]
|
|
|
|
|
public async Task<string[]> VgmLink(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (order == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK001);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == bookingId);
|
|
|
|
|
if (ordUrl == null)
|
|
|
|
|
{
|
|
|
|
|
ordUrl = new BookingOrderUrl();
|
|
|
|
|
ordUrl.BookingId = bookingId;
|
|
|
|
|
await _repOrderUrl.InsertAsync(ordUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(ordUrl.UrlVgm))
|
|
|
|
|
{
|
|
|
|
|
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验船公司
|
|
|
|
|
if (string.IsNullOrEmpty(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK118);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断船公司是否支持
|
|
|
|
|
var allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList();
|
|
|
|
|
if (!allowCarrier.Contains(order.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK117);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//船公司网站账号
|
|
|
|
|
var carrWebAccMap = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "carrier_web_account_mapping" && x.Code == order.CARRIERID);
|
|
|
|
|
var webacc = _repWebAcc.FirstOrDefault(x => x.TypeCode == carrWebAccMap.Value && x.CreatedUserId == UserManager.UserId);
|
|
|
|
|
if (webacc == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK125);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//场站转换
|
|
|
|
|
var yardset = _cache.GetAllMappingYard().Result.FirstOrDefault(y => y.Code == order.YARDID && y.Module == "BookingVgm");
|
|
|
|
|
if (yardset == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK120, order.YARDID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.BILLID == bookingId).ToListAsync();
|
|
|
|
|
//校验箱子数据录入
|
|
|
|
|
if (ctns.Where(c => string.IsNullOrEmpty(c.CTNALL) || !c.CTNNUM.HasValue).Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK121);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//箱型映射
|
|
|
|
|
var ctnMapping = await _cache.GetAllMappingCtn();
|
|
|
|
|
ctnMapping = ctnMapping.Where(x => x.Module == "BookingVgm").ToList();
|
|
|
|
|
if (ctnMapping.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK122);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var expCode = ctns.Select(x => x.CTNCODE).Distinct().Except(ctnMapping.Select(y => y.Code)).ToList();
|
|
|
|
|
if (expCode.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK123, string.Join(',', expCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var user = await _repUser.FirstOrDefaultAsync(x => x.Id == UserManager.UserId);
|
|
|
|
|
|
|
|
|
|
//调用小票服务
|
|
|
|
|
var dicUrlTxxp = _cache.GetAllDictData().Result.First(x => x.TypeCode == "url_set" && x.Code == "vgm_link_service");
|
|
|
|
|
var postObj = new
|
|
|
|
|
{
|
|
|
|
|
SystemCode = "djy_hechuan",
|
|
|
|
|
billOrderId = order.Id.ToString(),
|
|
|
|
|
sendOrderCode = order.MBLNO,
|
|
|
|
|
customerName = $"{UserManager.TENANT_NAME}+{UserManager.Name}", //公司名称+用户姓名
|
|
|
|
|
customerId = order.CUSTOMERID.ToString(),
|
|
|
|
|
agentName = string.IsNullOrEmpty(order.FORWARDER) ? UserManager.TENANT_NAME : order.FORWARDER,
|
|
|
|
|
carrierCode = order.CARRIERID,
|
|
|
|
|
userName = webacc.Account,
|
|
|
|
|
userPassword = webacc.Password,
|
|
|
|
|
depotCode = yardset.MapCode,
|
|
|
|
|
depotName = order.YARD,
|
|
|
|
|
linkName = UserManager.Name,
|
|
|
|
|
linkMobile = user.Tel,
|
|
|
|
|
linkEmail = user.Email,
|
|
|
|
|
userId = UserManager.DjyUserId,
|
|
|
|
|
returnUrl = "",
|
|
|
|
|
shipName = order.VESSEL,
|
|
|
|
|
voyNo = order.VOYNO,
|
|
|
|
|
etdstr = order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
potrSend = order.PORTLOAD,
|
|
|
|
|
potrGoal = order.PORTDISCHARGE,
|
|
|
|
|
boxinfoStr = order.CNTRTOTAL,
|
|
|
|
|
vgmEndTimeStr = order.CLOSEVGMDATE.HasValue ? order.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd") : string.Empty,
|
|
|
|
|
returnOkUrl = "",
|
|
|
|
|
SiReturnUrl = "",
|
|
|
|
|
DataInfoJson = new
|
|
|
|
|
{
|
|
|
|
|
order.SHIPPER,
|
|
|
|
|
order.CONSIGNEE,
|
|
|
|
|
order.NOTIFYPARTY,
|
|
|
|
|
order.MARKS,
|
|
|
|
|
order.DESCRIPTION,
|
|
|
|
|
order.BLFRT,
|
|
|
|
|
order.SERVICE,
|
|
|
|
|
order.ISSUETYPE,
|
|
|
|
|
order.TRANSPORT,
|
|
|
|
|
order.TRANSPORTID,
|
|
|
|
|
order.DESTINATION,
|
|
|
|
|
order.DESTINATIONID,
|
|
|
|
|
order.KINDPKGS,
|
|
|
|
|
order.THIRDPAYADDR,
|
|
|
|
|
order.PORTLOAD,
|
|
|
|
|
order.PORTLOADID,
|
|
|
|
|
order.PORTDISCHARGE,
|
|
|
|
|
order.PORTDISCHARGEID
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string strPostObj = postObj.ToJsonString();
|
|
|
|
|
_logger.LogInformation($"调用VGM链接接口传递数据:{strPostObj}");
|
|
|
|
|
var strResp = await dicUrlTxxp.Value.SetBody(postObj).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation($"调用VGM链接接口返回:{strResp}");
|
|
|
|
|
|
|
|
|
|
var jobjResp = JObject.Parse(strResp);
|
|
|
|
|
int respCode = jobjResp.GetIntValue("code");
|
|
|
|
|
if (respCode != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(BookingErrorCode.BOOK126, jobjResp.GetStringValue("message"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存url
|
|
|
|
|
var memoData = jobjResp.GetJObjectValue("memoData");
|
|
|
|
|
ordUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
|
|
|
|
|
ordUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
|
|
|
|
|
await _repOrderUrl.UpdateAsync(ordUrl);
|
|
|
|
|
return new string[] { ordUrl.UrlVgm, ordUrl.UrlVgmSi };
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 订舱、截单EDI
|
|
|
|
|