|
|
@ -129,6 +129,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
const string CONST_TSL_EDI_URL = "tsl_edi_declare_url";
|
|
|
|
const string CONST_TSL_EDI_URL = "tsl_edi_declare_url";
|
|
|
|
const string CONST_TSL_TYPE_CODE = "TslWeb";
|
|
|
|
const string CONST_TSL_TYPE_CODE = "TslWeb";
|
|
|
|
|
|
|
|
const string CONST_ONE_SOFILE_CATE_CODE = "one_so_file_template";
|
|
|
|
|
|
|
|
const string PRINT_DATASOURCE_KEY = "booking_order";
|
|
|
|
|
|
|
|
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
|
|
|
|
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
|
|
|
|
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
|
|
|
@ -6250,11 +6252,80 @@ namespace Myshipping.Application
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 打印船公司ONE的订舱附件(生成后自动写入订舱附件)
|
|
|
|
/// 打印船公司ONE的订舱附件(生成后自动写入订舱附件)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="bookingId">订舱ID</param>
|
|
|
|
/// <param name="model">订舱详情</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task PrintCarrierOneSOFileAsync(long bookingId)
|
|
|
|
private async Task PrintCarrierOneSOFileAsync(BookingOrder model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、提取默认的ONE订舱附件打印模板。
|
|
|
|
|
|
|
|
2、生成打印文件。
|
|
|
|
|
|
|
|
3、将文件写入订舱附件。
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var printTemplate = await _repPrintTemplate.AsQueryable()
|
|
|
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
|
|
|
.InnerJoin<BookingPrinttemplateRight>((d, t) => d.Id == t.PrintTemplateId
|
|
|
|
|
|
|
|
&& t.SysUserId == UserManager.UserId)
|
|
|
|
|
|
|
|
.Where(d => d.TenantId == UserManager.TENANT_ID
|
|
|
|
|
|
|
|
&& d.CateCode.Equals(CONST_ONE_SOFILE_CATE_CODE)
|
|
|
|
|
|
|
|
&& d.Type == BookingPrintTemplateType.FastReport.ToString())
|
|
|
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//取到打印模板文件
|
|
|
|
|
|
|
|
if(printTemplate == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件 batchNo={batchno} 获取模板文件失败", batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("获取模板文件失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件 batchNo={batchno} 获取模板文件成功", batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//打印报表服务地址
|
|
|
|
|
|
|
|
var reportUrl = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" &&
|
|
|
|
|
|
|
|
x.Code == "url_report_generate").Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(reportUrl))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件 batchNo={batchno} 获取打印报表服务地址失败", batchNo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("获取打印报表服务地址失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!reportUrl.EndsWith("/"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
reportUrl += "/";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//调取生成打印二进制流
|
|
|
|
|
|
|
|
var bs = await PrintHelper.GeneratePrintFile(JSON.Serialize(model), reportUrl,
|
|
|
|
|
|
|
|
PRINT_DATASOURCE_KEY, PrintFileTypeEnum.PDF, printTemplate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存文件
|
|
|
|
|
|
|
|
var bookFilePath = await FileAttachHelper.SaveFile(model.Id.ToString(), bs, batchNo, "",
|
|
|
|
|
|
|
|
PrintFileTypeEnum.PDF, "sofile", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件 批次={no} id={id} 完成文件保存 {filepath}", batchNo
|
|
|
|
|
|
|
|
, model.Id, bookFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//写入订舱随附单据
|
|
|
|
|
|
|
|
string fileTypeCode = "sofile";
|
|
|
|
|
|
|
|
string fileTypeName = "订舱附件";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将BC引入的文件写入订舱的附件
|
|
|
|
|
|
|
|
await SaveEDIFile(model.Id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name,
|
|
|
|
|
|
|
|
fileTypeCode, fileTypeName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件 批次={no} id={id} 完成写入附件表 {filepath}", batchNo
|
|
|
|
|
|
|
|
, model.Id, bookFilePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation("打印船公司ONE的订舱附件失败 batchNo={batchno} 原因={reason}", batchNo,ex.GetMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|