diff --git a/Myshipping.Application/Helper/PrintHelper.cs b/Myshipping.Application/Helper/PrintHelper.cs index 02976b39..d7b23427 100644 --- a/Myshipping.Application/Helper/PrintHelper.cs +++ b/Myshipping.Application/Helper/PrintHelper.cs @@ -28,7 +28,17 @@ namespace Myshipping.Application { public static class PrintHelper { - public static async Task GeneratePrintFile(string BusiJson,string reportUrl, PrintFileTypeEnum printFileType, + /// + /// 生成打印文件 + /// + /// 业务详情JSON + /// 请求生成URL + /// 数据源Key + /// 文档类型 + /// 文档模板 + /// 返回文件二进制 + public static async Task GeneratePrintFile(string busiJson,string reportUrl, string dataSourceKey, + PrintFileTypeEnum printFileType, BookingPrintTemplate printTemplate) { var logger = Log.CreateLogger(nameof(PrintHelper)); @@ -77,10 +87,11 @@ namespace Myshipping.Application file.Close(); NameValueCollection par = new NameValueCollection(); - par.Add("printType", ((int)printFileType).ToString()); - par.Add("dataJson", BusiJson); + par.Add("printType", printFileType.ToString().ToLower()); + par.Add($"dataJson{dataSourceKey}", busiJson); - var rtn = TransmitFile(reportUrl, par, new { + var genUrl = $"{reportUrl}Report/PrintReport"; + var rtn = TransmitFile(genUrl, par, new { file = "file", fileName = printTemplate.FileName, fileBytes = heByte diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index d7e2f14d..503a380e 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -56,6 +56,7 @@ namespace Myshipping.Application private readonly ITaskManageExternalService _taskManageExternalService; const string PRINT_LIST_TYPE_KEY = "booking_truck_print_list"; + const string PRINT_DATASOURCE_KEY = "booking_order"; public BookingTruckService(ISysCacheService cache, ILogger logger, SqlSugarRepository bookingTruckRepository, @@ -176,6 +177,8 @@ namespace Myshipping.Application it.TruckName, it.TruckCode, it.Status, + it.TruckFlowNo, + it.TaskNo }).ExecuteCommandAsync(); await _bookingTruckContaRepository.DeleteAsync(x => x.TruckId == model.Id); @@ -186,15 +189,6 @@ namespace Myshipping.Application { ctn.TruckId = entity.Id; - //await _bookingTruckContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new - //{ - // it.TenantId, - // it.CreatedTime, - // it.CreatedUserId, - // it.CreatedUserName, - // it.IsDeleted, - //}).ExecuteCommandAsync(); - await _bookingTruckContaRepository.InsertAsync(ctn); }); } @@ -1493,8 +1487,6 @@ namespace Myshipping.Application reportUrl += "/"; } - var genUrl = $"{reportUrl}PrintReport"; - var truckOrder = _bookingTruckRepository.AsQueryable().First(a => a.Id == bookingTruckId); if (truckOrder == null) @@ -1507,7 +1499,8 @@ namespace Myshipping.Application if (truckCtnList.Count > 0) model.ContaList = truckCtnList.Adapt>(); - return await PrintHelper.GeneratePrintFile(JSON.Serialize(model), genUrl, printFileType, printTemplate); + return await PrintHelper.GeneratePrintFile(JSON.Serialize(model), reportUrl, PRINT_DATASOURCE_KEY, + printFileType, printTemplate); } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageTruckService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageTruckService.cs index c2a8336b..879b60ce 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageTruckService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageTruckService.cs @@ -40,7 +40,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _bookingExcelTemplateRepository; const string PRINT_LIST_TYPE_KEY = "booking_truck_print_list"; - + const string PRINT_DATASOURCE_KEY = "booking_order"; public TaskManageTruckService(SqlSugarRepository taskTruckRepository, SqlSugarRepository taskTruckContaRepository, SqlSugarRepository taskBaseRepository, @@ -633,7 +633,8 @@ namespace Myshipping.Application if (truckCtnList.Count > 0) model.ContaList = truckCtnList.Adapt>(); - return await PrintHelper.GeneratePrintFile(JSON.Serialize(model), genUrl, printFileType, printTemplate); + return await PrintHelper.GeneratePrintFile(JSON.Serialize(model), genUrl, PRINT_DATASOURCE_KEY, + printFileType, printTemplate); } ///