|
|
|
@ -2611,18 +2611,29 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 单票正本下载
|
|
|
|
|
/// <paramref name="downloadType">1=正本下载 2=副本下载</paramref>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("/BookingValueAdded/DownloadOriginal")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> DownloadOriginal(long id, bool? isCheck)
|
|
|
|
|
public async Task<TaskManageOrderResultDto> DownloadOriginal(long id, bool? isCheck, int downloadType = 1)
|
|
|
|
|
{
|
|
|
|
|
const string FileTypeCode = "zhengben";
|
|
|
|
|
const string FileTypeName = "正本";
|
|
|
|
|
string fileTypeCode = downloadType switch
|
|
|
|
|
{
|
|
|
|
|
1 => "zhengben",
|
|
|
|
|
2 => "fuben",
|
|
|
|
|
_ => throw new NotImplementedException()
|
|
|
|
|
};
|
|
|
|
|
string fileTypeName = downloadType switch
|
|
|
|
|
{
|
|
|
|
|
1 => "正本",
|
|
|
|
|
2 => "副本",
|
|
|
|
|
_ => throw new NotImplementedException()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
if (isCheck == true)
|
|
|
|
|
{
|
|
|
|
|
if (await _bookingFileRepository.IsExistsAsync(x => x.BookingId == id && x.TypeCode == FileTypeCode))
|
|
|
|
|
if (await _bookingFileRepository.IsExistsAsync(x => x.BookingId == id && x.TypeCode == fileTypeCode))
|
|
|
|
|
{
|
|
|
|
|
result.status = -1;
|
|
|
|
|
result.succ = false;
|
|
|
|
@ -2686,7 +2697,7 @@ namespace Myshipping.Application
|
|
|
|
|
carrierId = (carrierId ?? order.CARRIERID).ToUpper();
|
|
|
|
|
if (carrierId != "MSK")
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"船公司=[{order.CARRIER}]暂不支持正本下载");
|
|
|
|
|
throw Oops.Bah($"船公司=[{order.CARRIER}]暂不支持{fileTypeName}下载");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断签单方式是否符合条件
|
|
|
|
@ -2694,11 +2705,16 @@ namespace Myshipping.Application
|
|
|
|
|
issueType = issueType ?? order.ISSUETYPE;
|
|
|
|
|
if (!issueType.Equals("original", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("此单签单方式非[正本下载],无法下载正本");
|
|
|
|
|
throw Oops.Bah($"此单签单方式非[正本],无法下载");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 实时下载接口
|
|
|
|
|
url += "/documents_server/api/draft/v1/download_realtime";
|
|
|
|
|
url += downloadType switch
|
|
|
|
|
{
|
|
|
|
|
1 => "/documents_server/api/bill_lading/v1/download_realtime",
|
|
|
|
|
2 => "/documents_server/api/copy/v1/download_realtime",
|
|
|
|
|
_ => throw new NotImplementedException()
|
|
|
|
|
};
|
|
|
|
|
var body = new
|
|
|
|
|
{
|
|
|
|
|
web_code = carrierId,
|
|
|
|
@ -2712,7 +2728,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
{ "Token",token }, { "Content-Type", "application/json" }
|
|
|
|
|
};
|
|
|
|
|
_logger.LogInformation("请求正本下载接口开始,mblno={mblno}, url={url}, body={body}", order.MBLNO, url, body);
|
|
|
|
|
_logger.LogInformation("请求fileTypeName={fileTypeName}下载接口开始,mblno={mblno}, url={url}, body={body}", fileTypeName, order.MBLNO, url, body);
|
|
|
|
|
DateTime bDate = DateTime.Now;
|
|
|
|
|
var rtn = await url.OnClientCreating(client =>
|
|
|
|
|
{
|
|
|
|
@ -2723,12 +2739,12 @@ namespace Myshipping.Application
|
|
|
|
|
TimeSpan ts = eDate.Subtract(bDate);
|
|
|
|
|
var timeDiff = ts.TotalMilliseconds;
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("请求正本下载接口结束,mblno={mblno}, rtn={rtn}, 耗时:{timeDiff}ms", order.MBLNO, rtn, timeDiff);
|
|
|
|
|
_logger.LogInformation("请求fileTypeName={fileTypeName}下载接口结束,mblno={mblno}, rtn={rtn}, 耗时:{timeDiff}ms", fileTypeName, order.MBLNO, rtn, timeDiff);
|
|
|
|
|
|
|
|
|
|
var jsonRtn = JObject.Parse(rtn);
|
|
|
|
|
if (jsonRtn.GetIntValue("status") == 1)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("请求正本下载接口成功,转存本地,mblno={mblno}", order.MBLNO);
|
|
|
|
|
_logger.LogInformation("请求fileTypeName={fileTypeName}下载接口成功,转存本地,mblno={mblno}", fileTypeName, order.MBLNO);
|
|
|
|
|
|
|
|
|
|
var data = jsonRtn.GetJObjectValue("data");
|
|
|
|
|
|
|
|
|
@ -2740,7 +2756,15 @@ namespace Myshipping.Application
|
|
|
|
|
// 读取文件保存配置
|
|
|
|
|
var fileCfg = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
|
|
|
|
|
string relativePath = $"{fileCfg.relativePath}\\originalfiles\\{order.Id}";
|
|
|
|
|
// 实时下载接口
|
|
|
|
|
string floderName = downloadType switch
|
|
|
|
|
{
|
|
|
|
|
1 => "originalfiles",
|
|
|
|
|
2 => "copyfiles",
|
|
|
|
|
_ => throw new NotImplementedException()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string relativePath = $"{fileCfg.relativePath}\\{floderName}\\{order.Id}";
|
|
|
|
|
string relativeDic = $"{(!string.IsNullOrWhiteSpace(fileCfg.basePath) ? fileCfg.basePath : App.WebHostEnvironment.WebRootPath)}\\{relativePath}";
|
|
|
|
|
|
|
|
|
|
string fileSavePath = $"{relativeDic}\\{new System.IO.FileInfo(remoteFilePath).Name}";
|
|
|
|
@ -2781,15 +2805,15 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "正本下载成功";
|
|
|
|
|
result.msg = $"{fileTypeName}下载成功";
|
|
|
|
|
|
|
|
|
|
await _bookingFileRepository.DeleteAsync(x => x.TypeCode == FileTypeCode && x.BookingId == order.Id);
|
|
|
|
|
await SaveEDIFile(order.Id, bookFilePath, reallyFileName, FileTypeCode, FileTypeName);
|
|
|
|
|
await _bookingFileRepository.DeleteAsync(x => x.TypeCode == fileTypeCode && x.BookingId == order.Id);
|
|
|
|
|
await SaveEDIFile(order.Id, bookFilePath, reallyFileName, fileTypeCode, fileTypeName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var msg = jsonRtn.GetStringValue("message")?.Replace("爬虫", "");
|
|
|
|
|
_logger.LogInformation("请求正本下载接口失败,mblno={mblno}, 服务返回:{msg}", order.MBLNO, msg);
|
|
|
|
|
_logger.LogInformation("请求fileTypeName={fileTypeName}下载接口失败,mblno={mblno}, 服务返回:{msg}", fileTypeName, order.MBLNO, msg);
|
|
|
|
|
throw Oops.Bah(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2797,7 +2821,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.status = -2;
|
|
|
|
|
result.msg = $"正本下载失败,{ex.Message}";
|
|
|
|
|
result.msg = $"{fileTypeName}下载失败,{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|