From e908538d433989f65f8537555acd924544e95482 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Thu, 24 Nov 2022 17:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Myshipping.Application.xml | 9 ++++++++- .../Service/BookingOrder/BookingOrderService.cs | 17 ++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index e6fa3930..21758494 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -4822,7 +4822,14 @@ 打印 订舱Id - 类型,1:pdf、2:xlsx + 打印类型代码,对应字典booking_template_type + + + + + 下载打印文件 + + 文件名 diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0892c817..ea01a004 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1211,25 +1211,20 @@ namespace Myshipping.Application /// 打印 /// /// 订舱Id - /// 类型,1:pdf、2:xlsx + /// 打印类型代码,对应字典booking_template_type /// [HttpGet("/BookingOrder/Print")] - public async Task Print(long bookingId, string type) + public async Task Print(long bookingId, string typeCode) { - var bs = await GetReportFile(bookingId, type); + var bs = await GetReportFile(bookingId, typeCode); var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));////名称 //var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName }; var opt = App.GetOptions().Path; var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径 - - if (bs != null) - { - using (System.IO.MemoryStream men = new MemoryStream(bs)) - { - System.Drawing.Bitmap bmp = System.Drawing.Bitmap.FromStream(men) as System.Drawing.Bitmap; - bmp.Save(serverpath); - } + if (!Directory.Exists(serverpath)) { + Directory.CreateDirectory(serverpath); } + await File.WriteAllBytesAsync(Path.Combine(serverpath, fileName),bs); return fileName; } ///