From 62beb6391ff087fab92ad3352fe80783cc2c98ae Mon Sep 17 00:00:00 2001 From: cjy Date: Wed, 30 Oct 2024 14:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=A8=A1=E6=9D=BF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=91=BD=E5=90=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sys/Dtos/SysPrintTemplateListRes.cs | 6 +++- .../Sys/Dtos/SysPrintTemplateReq.cs | 6 +++- .../Sys/Dtos/SysPrintTemplateRes.cs | 6 +++- .../DS.WMS.PrintApi/Model/SysPrintTemplate.cs | 7 +++- .../Service/OpenPrintService.cs | 32 ++++++++++++++++++- 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateListRes.cs b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateListRes.cs index a65482d1..e89fec58 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateListRes.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateListRes.cs @@ -60,7 +60,11 @@ namespace DS.WMS.Core.Sys.Dtos /// [Description("是否可用")] public bool Disable { get; set; } - + /// + /// 命名规则 + /// + [Description("命名规则")] + public string NamingRule { get; set; } /// /// 备注 /// diff --git a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateReq.cs b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateReq.cs index 560f6bf4..d6d8c994 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateReq.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateReq.cs @@ -87,7 +87,11 @@ namespace DS.WMS.Core.Sys.Dtos /// [Description("是否可用")] public bool Disable { get; set; } - + /// + /// 命名规则 + /// + [Description("命名规则")] + public string NamingRule { get; set; } /// /// 备注 /// diff --git a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateRes.cs b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateRes.cs index 078153c7..23c08050 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateRes.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Dtos/SysPrintTemplateRes.cs @@ -87,7 +87,11 @@ namespace DS.WMS.Core.Sys.Dtos /// [Description("是否可用")] public bool Disable { get; set; } - + /// + /// 命名规则 + /// + [Description("命名规则")] + public string NamingRule { get; set; } /// /// 备注 /// diff --git a/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs b/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs index 5cb3e99b..64bb2986 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Model/SysPrintTemplate.cs @@ -79,7 +79,12 @@ namespace DS.WMS.PrintApi.Model /// [Description("是否可用")] public bool Disable { get; set; } - + /// + /// 命名规则 + /// + [Description("命名规则")] + [SugarColumn(IsNullable = true, ColumnDescription = "命名规则", Length = 200)] + public string NamingRule { get; set; } /// /// 备注 /// diff --git a/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs b/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs index 5c3e0480..5fd7edb0 100644 --- a/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs +++ b/ds-wms-service/DS.WMS.PrintApi/Service/OpenPrintService.cs @@ -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().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); }