|
|
@ -1666,9 +1666,10 @@ namespace Myshipping.Application
|
|
|
|
/// <param name="bookingId">订舱Id</param>
|
|
|
|
/// <param name="bookingId">订舱Id</param>
|
|
|
|
/// <param name="templateId">打印模板ID</param>
|
|
|
|
/// <param name="templateId">打印模板ID</param>
|
|
|
|
/// <param name="type">类型,1:pdf、2:xlsx、3:docx</param>
|
|
|
|
/// <param name="type">类型,1:pdf、2:xlsx、3:docx</param>
|
|
|
|
|
|
|
|
/// <param name="printType">打印类型,10:FastReport、20:Excel模板</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("/BookingOrder/PrintFastReport")]
|
|
|
|
[HttpGet("/BookingOrder/PrintFastReport")]
|
|
|
|
public async Task<string> PrintFastReport(long bookingId, long templateId, int type = 1)
|
|
|
|
public async Task<string> PrintFastReport(long bookingId, long templateId, int type = 1, BookingPrintTemplateType printType = BookingPrintTemplateType.FastReport)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == templateId);
|
|
|
|
var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == templateId);
|
|
|
|
if (printTemplate == null)
|
|
|
|
if (printTemplate == null)
|
|
|
@ -1676,38 +1677,46 @@ namespace Myshipping.Application
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK115);
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK115);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bs = await GenPrintFile(bookingId, printTemplate, type);
|
|
|
|
var fileName = string.Empty;
|
|
|
|
var fileType = "";
|
|
|
|
if (printType == BookingPrintTemplateType.FastReport)
|
|
|
|
if (type == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".pdf";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".xlsx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".docx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Bah("类型参数不正确");
|
|
|
|
var bs = await GenPrintFile(bookingId, printTemplate, type);
|
|
|
|
}
|
|
|
|
var fileType = "";
|
|
|
|
|
|
|
|
if (type == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".pdf";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".xlsx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".docx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("类型参数不正确");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));//名称
|
|
|
|
fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));//名称
|
|
|
|
var opt = App.GetOptions<TempFileOptions>().Path;
|
|
|
|
var opt = App.GetOptions<TempFileOptions>().Path;
|
|
|
|
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
|
|
|
|
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
|
|
|
|
if (!Directory.Exists(serverpath))
|
|
|
|
if (!Directory.Exists(serverpath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Directory.CreateDirectory(serverpath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fullPath = Path.Combine(serverpath, fileName);
|
|
|
|
|
|
|
|
await File.WriteAllBytesAsync(fullPath, bs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (printType == BookingPrintTemplateType.ExcelTemplate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(serverpath);
|
|
|
|
//todo:excel模板打印功能
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fullPath = Path.Combine(serverpath, fileName);
|
|
|
|
|
|
|
|
await File.WriteAllBytesAsync(fullPath, bs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//记录打印次数和时间,用于前端动态展示常用的打印类型
|
|
|
|
//记录打印次数和时间,用于前端动态展示常用的打印类型
|
|
|
|
var printRecentListKey = $"{PrintRecentListTypeKey}_{printTemplate.CateCode}_{BookingPrintTemplateType.FastReport}";
|
|
|
|
var printRecentListKey = $"{PrintRecentListTypeKey}_{printTemplate.CateCode}_{printType}";
|
|
|
|
var usrCfg = _repUserConfig.AsQueryable().First(x => x.CreatedUserId == UserManager.UserId && x.Type == printRecentListKey);
|
|
|
|
var usrCfg = _repUserConfig.AsQueryable().First(x => x.CreatedUserId == UserManager.UserId && x.Type == printRecentListKey);
|
|
|
|
if (usrCfg == null)
|
|
|
|
if (usrCfg == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1724,7 +1733,6 @@ namespace Myshipping.Application
|
|
|
|
await _repUserConfig.UpdateAsync(usrCfg);
|
|
|
|
await _repUserConfig.UpdateAsync(usrCfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fileName;
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|