diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index bb4c0b25..a683d4ab 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1684,6 +1684,12 @@ namespace Myshipping.Application throw Oops.Bah(BookingErrorCode.BOOK115); } + var order = await _rep.FirstOrDefaultAsync(x => x.Id == bookingId); + if (order == null) + { + throw Oops.Bah(BookingErrorCode.BOOK001); + } + var fileName = string.Empty; #region FastReport打印 @@ -1708,7 +1714,13 @@ namespace Myshipping.Application throw Oops.Bah("类型参数不正确"); } - fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));//名称 + var dicCate = (await _cache.GetAllDictData()).FirstOrDefault(x => x.Code == cateCode && x.TypeCode == "booking_template_category"); + if (dicCate == null) + { + throw Oops.Bah("分类代码参数不正确"); + } + + fileName = HttpUtility.UrlEncode($"{dicCate.Value}_{order.MBLNO}_{DateTime.Now.Ticks}{fileType}", Encoding.GetEncoding("UTF-8"));//名称 var opt = App.GetOptions().Path; var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径 if (!Directory.Exists(serverpath)) @@ -1735,7 +1747,6 @@ namespace Myshipping.Application var result = new FileStream(fileAbsPath, FileMode.Open); var excelwork = new HSSFWorkbook(result); var sheet = excelwork.GetSheetAt(0); - var order = await _rep.AsQueryable().Where(x => x.Id == bookingId).FirstAsync(); var entity = await _excelrep.AsQueryable().Where(x => x.PId == templateId).OrderBy(x => x.Row).ToListAsync(); //单元格样式 var cellStyle = NpoiExcelExportHelper._.CreateStyle(excelwork, HorizontalAlignment.Center, VerticalAlignment.Center, 10, true, 0);