|
|
@ -2359,7 +2359,7 @@ namespace Myshipping.Application
|
|
|
|
catch { }
|
|
|
|
catch { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await SendLetterYard(input.BookingId);
|
|
|
|
//await SendLetterYard(input.BookingId);
|
|
|
|
return rtnId;
|
|
|
|
return rtnId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2624,135 +2624,6 @@ namespace Myshipping.Application
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
await SendBookingOrder(new long[] { bookingId });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取放舱pdf(准备作废,后期使用打印相关接口)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
|
|
|
/// <param name="type">类型,1:pdf、2:xlsx、3:docx</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/BookingOrder/LetterYardPdf")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> LetterYardPdf(long bookingId, int type = 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId);
|
|
|
|
|
|
|
|
if (letterYard == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("放舱信息未找到,请先保存数据");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileType = "";
|
|
|
|
|
|
|
|
if (type == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".pdf";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".xlsx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type == 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fileType = ".docx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("类型参数不正确");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bs = await GetReportFile(bookingId, "fangcang", type);
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
|
|
|
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取放舱excel(准备作废,后期使用打印相关接口)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/BookingOrder/LetterYardXlsx")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> LetterYardXlsx(long bookingId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var letterYard = await _repLetterYard.FirstOrDefaultAsync(x => x.BookingId == bookingId);
|
|
|
|
|
|
|
|
if (letterYard == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("放舱信息未找到,请先保存数据");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var bs = await GetReportFile(bookingId, "fangcang", 2);
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.xlsx", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
|
|
|
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 生成报表文件(准备作废)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
|
|
|
/// <param name="type">类型,1:pdf、2:xlsx、3:docx</param>
|
|
|
|
|
|
|
|
/// <param name="typeCode">报表类型代码,例如fangcang、samplebill等</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
|
|
|
private async Task<byte[]> GetReportFile(long bookingId, string typeCode, int type = 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//打印报表服务地址
|
|
|
|
|
|
|
|
var reportUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "url_report_generate").Value;
|
|
|
|
|
|
|
|
if (!reportUrl.EndsWith("/"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
reportUrl += "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//订舱数据
|
|
|
|
|
|
|
|
var order = _rep.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK001);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"查找模板:bookingId-{bookingId} TenantId-{order.TenantId}");
|
|
|
|
|
|
|
|
var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.TenantId == order.TenantId && x.TypeCode == typeCode);
|
|
|
|
|
|
|
|
if (printTemplate == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK115);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<PrintTemplateOptions>();
|
|
|
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath);
|
|
|
|
|
|
|
|
_logger.LogInformation($"查找模板文件:{fileAbsPath}");
|
|
|
|
|
|
|
|
if (!File.Exists(fileAbsPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK115);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"准备调用报表生成:id:{bookingId},文件:{printTemplate.FileName}");
|
|
|
|
|
|
|
|
var genUrl = $"{reportUrl}Report/BookingReport?bookingId={bookingId}&type={type}";
|
|
|
|
|
|
|
|
var rtn = await genUrl
|
|
|
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
|
|
|
.SetBodyBytes(("file", File.ReadAllBytes(fileAbsPath), HttpUtility.UrlEncode(printTemplate.FileName, Encoding.GetEncoding("UTF-8"))))
|
|
|
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
|
|
|
var jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用报表生成返回:{rtn}");
|
|
|
|
|
|
|
|
if (jobjRtn.GetBooleanValue("Success"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//调用读取文件
|
|
|
|
|
|
|
|
var fn = jobjRtn.GetStringValue("Data");
|
|
|
|
|
|
|
|
_logger.LogInformation($"准备调用读取报表文件:id:{bookingId},文件名:{fn}");
|
|
|
|
|
|
|
|
var readFileUrl = $"{reportUrl}Report/GetFile?fileName={fn}";
|
|
|
|
|
|
|
|
var bs = await readFileUrl.GetAsByteArrayAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"调用读取报表文件返回:{bs.Length}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return bs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah($"生成报表文件失败:{jobjRtn.GetStringValue("Message")}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 生成打印报表文件
|
|
|
|
/// 生成打印报表文件
|
|
|
@ -3483,25 +3354,6 @@ namespace Myshipping.Application
|
|
|
|
return entity.Id;
|
|
|
|
return entity.Id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取样单pdf(准备作废,后期使用打印相关api)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bookingId"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/BookingOrder/SampleBillPdf")]
|
|
|
|
|
|
|
|
public async Task<IActionResult> SampleBillPdf(long bookingId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var samp = await _repSampleBill.FirstOrDefaultAsync(x => x.BookingId == bookingId);
|
|
|
|
|
|
|
|
if (samp == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah("请先保存提单确认数据后再继续");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bs = await GetReportFile(bookingId, "tidanqueren");
|
|
|
|
|
|
|
|
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.xlsx", Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
|
|
|
var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 小票链接
|
|
|
|
#region 小票链接
|
|
|
|