|
|
@ -59,6 +59,8 @@ using System.Text.RegularExpressions;
|
|
|
|
using MathNet.Numerics.Distributions;
|
|
|
|
using MathNet.Numerics.Distributions;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Myshipping.Application.EDI.ESL;
|
|
|
|
using Myshipping.Application.EDI.ESL;
|
|
|
|
|
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -93,6 +95,7 @@ namespace Myshipping.Application
|
|
|
|
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
|
|
|
|
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
|
|
|
|
private readonly SqlSugarRepository<BookingEDIExt> _bookingEDIExt;
|
|
|
|
private readonly SqlSugarRepository<BookingEDIExt> _bookingEDIExt;
|
|
|
|
private readonly SqlSugarRepository<DjyUserConfig> _repUserConfig;
|
|
|
|
private readonly SqlSugarRepository<DjyUserConfig> _repUserConfig;
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
|
|
|
|
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
|
|
|
|
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
|
|
|
|
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
|
|
|
@ -105,7 +108,8 @@ namespace Myshipping.Application
|
|
|
|
ILogger<BookingOrderService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right,
|
|
|
|
ILogger<BookingOrderService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right,
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact, SqlSugarRepository<BookingSampleBill> repSampleBill,
|
|
|
|
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact, SqlSugarRepository<BookingSampleBill> repSampleBill,
|
|
|
|
SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt,
|
|
|
|
SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<DjyUserMailAccount> repUserMail,
|
|
|
|
|
|
|
|
SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt,
|
|
|
|
IHttpContextAccessor httpContextAccessor)
|
|
|
|
IHttpContextAccessor httpContextAccessor)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this._logger = logger;
|
|
|
|
this._logger = logger;
|
|
|
@ -133,6 +137,7 @@ namespace Myshipping.Application
|
|
|
|
this._repBookingStatus = repBookingStatus;
|
|
|
|
this._repBookingStatus = repBookingStatus;
|
|
|
|
this._bookingEDIExt = bookingEDIExt;
|
|
|
|
this._bookingEDIExt = bookingEDIExt;
|
|
|
|
this._repUserConfig = repUserConfig;
|
|
|
|
this._repUserConfig = repUserConfig;
|
|
|
|
|
|
|
|
this._excelrep = excelrep;
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1712,7 +1717,55 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (printType == BookingPrintTemplateType.ExcelTemplate)
|
|
|
|
else if (printType == BookingPrintTemplateType.ExcelTemplate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//todo:excel模板打印功能
|
|
|
|
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生成:id:{bookingId},文件:{printTemplate.FileName}");
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
for (int _row = 0; _row < entity.Max(x => x.Row); _row++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (entity.Where(x => x.Row == _row + 1 && x.Column == _cellNum + 1).Count() > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var name = entity.Where(x => x.Row == _row + 1 && x.Column == _cellNum + 1).Select(x => x.Field).FirstOrDefault();
|
|
|
|
|
|
|
|
var _name = descriptor.Name.ToLower();
|
|
|
|
|
|
|
|
if (name == _name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var value = descriptor.GetValue(order).ToString();
|
|
|
|
|
|
|
|
var cell = NpoiExcelExportHelper._.CreateCells(row, cellStyle, _cellNum + 1, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions<TempFileOptions>().Path);//服务器路径
|
|
|
|
|
|
|
|
if (!Directory.Exists(fileFullPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Directory.CreateDirectory(fileFullPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fileName = string.Format("订舱{0}.xls", DateTime.Now.Ticks);
|
|
|
|
|
|
|
|
_logger.LogInformation("导出excel:" + Path.Combine(fileFullPath, fileName));
|
|
|
|
|
|
|
|
var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
|
|
|
|
|
|
|
excelwork.Write(filestream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//记录打印次数和时间,用于前端动态展示常用的打印类型
|
|
|
|
//记录打印次数和时间,用于前端动态展示常用的打印类型
|
|
|
|