|
|
@ -452,20 +452,38 @@ namespace Myshipping.Application
|
|
|
|
4、请求相应的链接。
|
|
|
|
4、请求相应的链接。
|
|
|
|
5、返回成功写入附件。
|
|
|
|
5、返回成功写入附件。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if(string.IsNullOrWhiteSpace(bookingOrder.MBLNO))
|
|
|
|
if(bookingOrder.CARRIERID.Equals("ESL", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTNO))
|
|
|
|
if(string.IsNullOrWhiteSpace(bookingOrder.TMBLNO))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.bno = $"订 {bookingOrder.CUSTNO}";
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTNO))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.bno = $"订 {bookingOrder.CUSTNO}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (string.IsNullOrWhiteSpace(bookingOrder.MBLNO))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.bno = $"NO.{sortNo}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah($"EP号不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(bookingOrder.MBLNO))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.bno = $"NO.{sortNo}";
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTNO))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.bno = $"订 {bookingOrder.CUSTNO}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.bno = $"NO.{sortNo}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah($"主提单号不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah($"主提单号不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bcOrDraftRouteCfg = _cache.GetAllMappingCarrier().GetAwaiter().GetResult()
|
|
|
|
var bcOrDraftRouteCfg = _cache.GetAllMappingCarrier().GetAwaiter().GetResult()
|
|
|
|
.FirstOrDefault(t => t.Module.Equals(CONST_MAPPING_DRAFT_MODULE_ROUTE, StringComparison.OrdinalIgnoreCase)
|
|
|
|
.FirstOrDefault(t => t.Module.Equals(CONST_MAPPING_DRAFT_MODULE_ROUTE, StringComparison.OrdinalIgnoreCase)
|
|
|
@ -509,34 +527,80 @@ namespace Myshipping.Application
|
|
|
|
if (userWebAccountConfig == null)
|
|
|
|
if (userWebAccountConfig == null)
|
|
|
|
throw Oops.Oh($" 未配置个人或公司网站账户,网站{webKey}");
|
|
|
|
throw Oops.Oh($" 未配置个人或公司网站账户,网站{webKey}");
|
|
|
|
|
|
|
|
|
|
|
|
BCOrDraftRequestDto requestDto = new BCOrDraftRequestDto
|
|
|
|
string downloadFilePathRlt = string.Empty;
|
|
|
|
|
|
|
|
string erroMsg = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(bcOrDraftRouteCfg.MapCode.Trim().Equals("TSL", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
user_key = App.Configuration["BCOrDraftUserKey"],
|
|
|
|
ESLDraftRequestDto requestDto = new ESLDraftRequestDto
|
|
|
|
user_secret = App.Configuration["BCOrDraftUserSecret"],
|
|
|
|
{
|
|
|
|
web_user = userWebAccountConfig.Account?.Trim(),
|
|
|
|
u = userWebAccountConfig.Account?.Trim(),
|
|
|
|
web_psw = userWebAccountConfig.Password?.Trim(),
|
|
|
|
p = userWebAccountConfig.Password?.Trim(),
|
|
|
|
bno = bookingOrder.MBLNO,
|
|
|
|
ep_code = bookingOrder.TMBLNO?.Trim().ToUpper(),
|
|
|
|
is_parse = false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} json={json} 请求Draft远端下载开始", batchNo, JSON.Serialize(requestDto));
|
|
|
|
_logger.LogInformation("批次={no} json={json} 请求Draft远端下载开始", batchNo, JSON.Serialize(requestDto));
|
|
|
|
|
|
|
|
|
|
|
|
DateTime bDate = DateTime.Now;
|
|
|
|
DateTime bDate = DateTime.Now;
|
|
|
|
//开始请求BC
|
|
|
|
//开始请求BC
|
|
|
|
var rlt = await ExcuteDraftDownload(bcUrl, requestDto, batchNo);
|
|
|
|
var rlt = await ExcuteESLDraftDownload(bcUrl, requestDto, batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
DateTime eDate = DateTime.Now;
|
|
|
|
DateTime eDate = DateTime.Now;
|
|
|
|
TimeSpan ts = eDate.Subtract(bDate);
|
|
|
|
TimeSpan ts = eDate.Subtract(bDate);
|
|
|
|
var timeDiff = ts.TotalMilliseconds;
|
|
|
|
var timeDiff = ts.TotalMilliseconds;
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} result={result} 请求Draft远端下载结束 耗时:{timeDiff}ms. ", batchNo,
|
|
|
|
_logger.LogInformation("批次={no} result={result} 请求Draft远端下载结束 耗时:{timeDiff}ms. ", batchNo,
|
|
|
|
JSON.Serialize(rlt), timeDiff);
|
|
|
|
JSON.Serialize(rlt), timeDiff);
|
|
|
|
|
|
|
|
|
|
|
|
if (rlt.code == 200)
|
|
|
|
if (rlt.status == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
downloadFilePathRlt = rlt.data.api_path;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
erroMsg = rlt.message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BCOrDraftRequestDto requestDto = new BCOrDraftRequestDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
user_key = App.Configuration["BCOrDraftUserKey"],
|
|
|
|
|
|
|
|
user_secret = App.Configuration["BCOrDraftUserSecret"],
|
|
|
|
|
|
|
|
web_user = userWebAccountConfig.Account?.Trim(),
|
|
|
|
|
|
|
|
web_psw = userWebAccountConfig.Password?.Trim(),
|
|
|
|
|
|
|
|
bno = bookingOrder.MBLNO,
|
|
|
|
|
|
|
|
is_parse = false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} json={json} 请求Draft远端下载开始", batchNo, JSON.Serialize(requestDto));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime bDate = DateTime.Now;
|
|
|
|
|
|
|
|
//开始请求BC
|
|
|
|
|
|
|
|
var rlt = await ExcuteDraftDownload(bcUrl, requestDto, batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime eDate = DateTime.Now;
|
|
|
|
|
|
|
|
TimeSpan ts = eDate.Subtract(bDate);
|
|
|
|
|
|
|
|
var timeDiff = ts.TotalMilliseconds;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} result={result} 请求Draft远端下载结束 耗时:{timeDiff}ms. ", batchNo,
|
|
|
|
|
|
|
|
JSON.Serialize(rlt), timeDiff);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rlt.code == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
downloadFilePathRlt = rlt.data.FirstOrDefault().path;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
erroMsg = rlt.msg;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(downloadFilePathRlt))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation("批次={no} 下载文件成功,转存本地", batchNo);
|
|
|
|
_logger.LogInformation("批次={no} 下载文件成功,转存本地", batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
string currFilePath = rlt.data.FirstOrDefault().path;
|
|
|
|
string currFilePath = downloadFilePathRlt;
|
|
|
|
|
|
|
|
|
|
|
|
string fileTypeCode = "draft";
|
|
|
|
string fileTypeCode = "draft";
|
|
|
|
string fileTypeName = "Draft";
|
|
|
|
string fileTypeName = "Draft";
|
|
|
@ -594,7 +658,7 @@ namespace Myshipping.Application
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.succ = false;
|
|
|
|
result.succ = false;
|
|
|
|
result.msg = $"Draft下载失败,原因={rlt.msg}";
|
|
|
|
result.msg = $"Draft下载失败,原因={erroMsg}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
@ -705,6 +769,53 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ESL Draft请求远端下载
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// ESL Draft请求远端下载
|
|
|
|
|
|
|
|
/// 由于现有的ESL和TSL接口不一致,需要提供单独的POST方法
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="url">请求URL</param>
|
|
|
|
|
|
|
|
/// <param name="info">请求详情</param>
|
|
|
|
|
|
|
|
/// <param name="batchNo">批次号</param>
|
|
|
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
|
|
|
private async Task<ESLDraftAPIBaseResult> ExcuteESLDraftDownload(string url, ESLDraftRequestDto info, string batchNo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ESLDraftAPIBaseResult model = null;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、填充请求的类,并生成JSON报文
|
|
|
|
|
|
|
|
2、POST请求接口,并记录回执。
|
|
|
|
|
|
|
|
3、返回信息。
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var res = await url.SetHttpMethod(HttpMethod.Post)
|
|
|
|
|
|
|
|
.SetBody(JSON.Serialize(info), "application/json")
|
|
|
|
|
|
|
|
.SetContentEncoding(Encoding.UTF8)
|
|
|
|
|
|
|
|
.PostAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 对应请求报文完成 res={res}", batchNo, JSON.Serialize(res));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (res.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var userResult = await res.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model = JSON.Deserialize<ESLDraftAPIBaseResult>(userResult);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//写日志
|
|
|
|
|
|
|
|
if (ex is HttpRequestException)
|
|
|
|
|
|
|
|
throw Oops.Oh(10000002);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 到港时间更新
|
|
|
|
/// 到港时间更新
|
|
|
|