|
|
|
@ -85,6 +85,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<SysTenant> _repTenant;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
|
|
|
|
|
private readonly SqlSugarRepository<BookingEDIExt> _bookingEDIExt;
|
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
|
|
|
|
|
|
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
|
|
|
|
|
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
|
|
|
|
@ -96,7 +97,8 @@ namespace Myshipping.Application
|
|
|
|
|
ILogger<BookingOrderService> logger, ISysCacheService cache,
|
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
|
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact, SqlSugarRepository<BookingSampleBill> repSampleBill,
|
|
|
|
|
SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt)
|
|
|
|
|
SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt,
|
|
|
|
|
IHttpContextAccessor httpContextAccessor)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
@ -122,6 +124,7 @@ namespace Myshipping.Application
|
|
|
|
|
this._repTenant = repTenant;
|
|
|
|
|
this._repBookingStatus = repBookingStatus;
|
|
|
|
|
this._bookingEDIExt = bookingEDIExt;
|
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 主表和箱信息
|
|
|
|
@ -1180,6 +1183,8 @@ namespace Myshipping.Application
|
|
|
|
|
reportUrl += "/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reportUrl = "http://127.0.0.1:8101/"; //test
|
|
|
|
|
|
|
|
|
|
//订舱数据
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (order == null)
|
|
|
|
@ -1233,6 +1238,7 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Bah($"生成报表文件失败:{jobjRtn.GetStringValue("Message")}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 打印
|
|
|
|
@ -1270,6 +1276,50 @@ namespace Myshipping.Application
|
|
|
|
|
var result = new FileStreamResult(new FileStream(Path.Combine(fileFullPath, fileName), FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打印(可浏览器预览)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId">订舱Id</param>
|
|
|
|
|
/// <param name="typeCode">打印类型代码,对应字典booking_template_type</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/PrintWithView")]
|
|
|
|
|
public async Task<string> PrintWithView(long bookingId, string typeCode)
|
|
|
|
|
{
|
|
|
|
|
var bs = await GetReportFile(bookingId, typeCode);
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));//名称
|
|
|
|
|
var opt = App.GetOptions<TempFileOptions>().Path;
|
|
|
|
|
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
|
|
|
|
|
if (!Directory.Exists(serverpath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(serverpath);
|
|
|
|
|
}
|
|
|
|
|
var fullPath = Path.Combine(serverpath, fileName);
|
|
|
|
|
await File.WriteAllBytesAsync(fullPath, bs);
|
|
|
|
|
var vid = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
await _cache.SetTimeoutAsync(vid, fullPath, TimeSpan.FromSeconds(300));
|
|
|
|
|
return vid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下载打印文件(PDF直接预览)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="vid">查看ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/ViewPrintPdf/{vid}"), AllowAnonymous]
|
|
|
|
|
public void ViewPrintPdf(string vid)
|
|
|
|
|
{
|
|
|
|
|
if (_cache.Exists(vid))
|
|
|
|
|
{
|
|
|
|
|
var fileFullName = _cache.Get(vid);
|
|
|
|
|
var readMem = new ReadOnlyMemory<byte>(File.ReadAllBytes(fileFullName));
|
|
|
|
|
_httpContextAccessor.HttpContext.Response.BodyWriter.WriteAsync(readMem);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("下载链接失效,请重新打印");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下货纸
|
|
|
|
|