|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|