optimize
wet 2 years ago
parent edfbce4e7b
commit 1086342c91

@ -21,6 +21,11 @@ namespace Myshipping.Application.Entity
/// 分类
/// </summary>
public string Type { get; set; }
/// <summary>
/// 模板id
/// </summary>
public string TemplateId { get; set; }
}
}

@ -9750,12 +9750,13 @@
<param name="Id">模板名称</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingTemplateService.ExportExcel(System.Int64,System.Int64)">
<member name="M:Myshipping.Application.BookingTemplateService.ExportExcel(System.Int64,System.Int64,System.Int64)">
<summary>
导出excel
</summary>
<param name="bookingId"></param>
<param name="excelTemplateId"></param>
<param name="printTemplateId"></param>
<returns></returns>
</member>
<member name="T:Myshipping.Application.BookingTemplateInput">

@ -22,6 +22,7 @@ using Furion;
using System;
using System.Web;
using System.Text;
using Myshipping.Application.ConfigOption;
namespace Myshipping.Application
{
@ -35,15 +36,17 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingOrder> _repOrder;
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
private readonly SqlSugarRepository<BookingExcelTemplateSub> _excelsubrep;
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
private readonly ILogger<BookingTemplate> _logger;
public BookingTemplateService(SqlSugarRepository<BookingTemplate> rep, SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<BookingExcelTemplateSub> excelsubrep, ILogger<BookingTemplate> logger)
public BookingTemplateService(SqlSugarRepository<BookingTemplate> rep, SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<BookingExcelTemplateSub> excelsubrep, SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, ILogger<BookingTemplate> logger)
{
_excelrep = excelrep;
_excelsubrep = excelsubrep;
_repOrder = repOrder;
_rep = rep;
_logger = logger;
_repPrintTemplate = repPrintTemplate;
}
/// <summary>
@ -249,18 +252,42 @@ namespace Myshipping.Application
/// </summary>
/// <param name="bookingId"></param>
/// <param name="excelTemplateId"></param>
/// <param name="printTemplateId"></param>
/// <returns></returns>
[HttpGet("/BookingTemplate/ExportExcel")]
public async Task<dynamic> ExportExcel([FromQuery] long bookingId, long excelTemplateId)
public async Task<dynamic> ExportExcel([FromQuery] long bookingId, long excelTemplateId,long printTemplateId)
{
if (bookingId == 0 || excelTemplateId == 0)
if (bookingId == 0 || excelTemplateId == 0|| printTemplateId==0)
{
throw Oops.Bah("请传入正确参数");
}
var excelwork = new HSSFWorkbook();
var sheet = excelwork.CreateSheet("订舱台账");
sheet.ForceFormulaRecalculation = true;
var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id== printTemplateId);
if (printTemplate == null)
{
throw Oops.Bah(BookingErrorCode.BOOK115);
}
var opt = App.GetOptions<PrintTemplateOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath);
_logger.LogInformation($"查找EXCEL模板文件{fileAbsPath}");
if (!File.Exists(fileAbsPath))
{
throw Oops.Bah(BookingErrorCode.BOOK115);
}
_logger.LogInformation($"准备调用EXCEL生成id{bookingId},文件:{printTemplate.FileName}");
var result = new FileStream(fileAbsPath, FileMode.Open) ;
var excelwork = new HSSFWorkbook(result);
var sheet = excelwork.GetSheetAt(0);
var order = await _repOrder.AsQueryable().Where(x => x.Id == bookingId).FirstAsync();
var entity = await _excelsubrep.AsQueryable().Where(x => x.Pid == excelTemplateId).OrderBy(x => x.Row).ToListAsync();
//单元格样式
@ -291,8 +318,8 @@ namespace Myshipping.Application
}
}
}
var opt = App.GetOptions<TempFileOptions>().Path;
var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions<TempFileOptions>().Path);//服务器路径
if (!Directory.Exists(fileFullPath))
{
Directory.CreateDirectory(fileFullPath);

@ -16981,9 +16981,14 @@
预抵日期
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfo.Wharf">
<member name="P:Myshipping.Application.Entity.DjyVesselInfo.Yard">
<summary>
默认码头
场站
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfo.YardCode">
<summary>
场站Code
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfo.ATD">
@ -17061,9 +17066,14 @@
预抵日期
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfoDto.Wharf">
<member name="P:Myshipping.Application.Entity.DjyVesselInfoDto.Yard">
<summary>
场站
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfoDto.YardCode">
<summary>
默认码头
场站Code
</summary>
</member>
<member name="P:Myshipping.Application.Entity.DjyVesselInfoDto.ATD">

Loading…
Cancel
Save