打印模板支持命名规则

dev
cjy 4 weeks ago
parent 4d690f6eb0
commit 62beb6391f

@ -60,7 +60,11 @@ namespace DS.WMS.Core.Sys.Dtos
/// </summary>
[Description("是否可用")]
public bool Disable { get; set; }
/// <summary>
/// 命名规则
/// </summary>
[Description("命名规则")]
public string NamingRule { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -87,7 +87,11 @@ namespace DS.WMS.Core.Sys.Dtos
/// </summary>
[Description("是否可用")]
public bool Disable { get; set; }
/// <summary>
/// 命名规则
/// </summary>
[Description("命名规则")]
public string NamingRule { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -87,7 +87,11 @@ namespace DS.WMS.Core.Sys.Dtos
/// </summary>
[Description("是否可用")]
public bool Disable { get; set; }
/// <summary>
/// 命名规则
/// </summary>
[Description("命名规则")]
public string NamingRule { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -79,7 +79,12 @@ namespace DS.WMS.PrintApi.Model
/// </summary>
[Description("是否可用")]
public bool Disable { get; set; }
/// <summary>
/// 命名规则
/// </summary>
[Description("命名规则")]
[SugarColumn(IsNullable = true, ColumnDescription = "命名规则", Length = 200)]
public string NamingRule { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Data;
using System.Dynamic;
using FastReport.Cloud.OAuth;
namespace DS.WMS.PrintApi.Service
{
@ -387,10 +388,33 @@ namespace DS.WMS.PrintApi.Service
var basePath = String.Empty;
var savePath = "wwwroot/PrintTempFile";
var fileName = DateTime.Now.Ticks + "-" + NumUtil.GetRandomString(3);
var fileName =string.Empty;
if (!string.IsNullOrEmpty(template.NamingRule))
{
fileName = template.NamingRule;
var id = sugarParams.Where(x=>x.ParameterName.ToLower()=="@id").FirstOrDefault().Value;
if (id != null) {
var info = tenantDb.Queryable<dynamic>().AS("op_sea_export").Where("id=@id", new { id = id }).First();
if (fileName.Contains("[委托编号]"))
{
fileName = fileName.Replace("[委托编号]", info.MBLNO);
}
if (fileName.Contains("[提单号]"))
{
fileName = fileName.Replace("[提单号]", info.CustomerNo);
}
}
}
if (string.IsNullOrEmpty(fileName))
fileName = DateTime.Now.Ticks + "-" + NumUtil.GetRandomString(3);
//var fileName = DateTime.Now.Ticks + "-" + NumUtil.GetRandomString(3);
var printFileName = $"{fileName}.frx";
var printFile = Path.Combine(savePath, printFileName);
if (File.Exists(printFile))
File.Delete(printFile);
//写入CRX文件
using (FileStream fs = new FileStream(printFile, FileMode.Create))
@ -450,6 +474,8 @@ namespace DS.WMS.PrintApi.Service
{
printName = $"{fileName}.pdf";
saveFile = Path.Combine(savePath, printName);
if (File.Exists(saveFile))
File.Delete(saveFile);
PDFExport pdfExport = new PDFExport();
pdfExport.Export(report, saveFile);
@ -472,6 +498,8 @@ namespace DS.WMS.PrintApi.Service
{
printName = $"{fileName}.xlsx";
saveFile = Path.Combine(savePath, printName);
if (File.Exists(saveFile))
File.Delete(saveFile);
Excel2007Export excelExport = new Excel2007Export();
excelExport.Export(report, saveFile);
}
@ -479,6 +507,8 @@ namespace DS.WMS.PrintApi.Service
{
printName = $"{fileName}.doc";
saveFile = Path.Combine(savePath, printName);
if (File.Exists(saveFile))
File.Delete(saveFile);
Word2007Export wordExport = new Word2007Export();
wordExport.Export(report, saveFile);
}

Loading…
Cancel
Save