diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index cbf1bd2a..67743df5 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1748,6 +1748,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打印 @@ -1772,7 +1778,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 = $"{dicCate.Value}_{order.MBLNO}_{DateTime.Now.Ticks}{fileType}";//名称 var opt = App.GetOptions().Path; var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径 if (!Directory.Exists(serverpath)) @@ -1799,7 +1811,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(); if (entity==null) { @@ -1813,7 +1824,7 @@ namespace Myshipping.Application if (entity.Where(x => x.Row == (_row + 1)).Count() > 0) { - ///创建行 + //创建行 var row = NpoiExcelExportHelper._.CreateRow(sheet, _row, 25); for (int _cellNum = 0; _cellNum < entity.Max(x => x.Column); _cellNum++) { @@ -1864,7 +1875,7 @@ namespace Myshipping.Application await _repUserConfig.UpdateAsync(usrCfg); } - return fileName; + return HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8")); } ///// @@ -1970,10 +1981,11 @@ namespace Myshipping.Application [HttpGet("/BookingOrder/PrintTemplateWithHistoryList")] public async Task PrintTemplateWithHistoryList(string cateCode, BookingPrintTemplateType printType) { + var typeCode = printType.ToString(); //当前公司所有已配置的模板 var allList = await _repPrintTemplate.AsQueryable() .Filter(null, true).InnerJoin((d, t) => d.Id == t.PrintTemplateId && t.SysUserId == UserManager.UserId) - .Where(d => d.TenantId == UserManager.TENANT_ID && d.CateCode.Contains(cateCode)) + .Where(d => d.TenantId == UserManager.TENANT_ID && d.CateCode.Contains(cateCode) && d.Type == typeCode) .Select(d => new { d.Id, @@ -2072,19 +2084,22 @@ namespace Myshipping.Application /// /// [HttpPost("/BookingSampleBill/Save")] - public async Task SampleBillSave(UpdateBookingSampleBillInput input) + public async Task SampleBillSave(UpdateBookingSampleBillInput input) { + BookingSampleBill entity = null; if (input.Id == 0) { - var entity = input.Adapt(); + entity = input.Adapt(); await _repSampleBill.InsertAsync(entity); } else { - var entity = _repSampleBill.FirstOrDefault(x => x.BookingId == input.Id); + entity = _repSampleBill.FirstOrDefault(x => x.BookingId == input.Id); entity = input.Adapt(entity); await _repSampleBill.UpdateAsync(entity); } + + return entity.Id; } ///