新增下货纸

optimize
jianghaiqing 2 years ago
parent e5d2bf7b6f
commit 5ae1a75c9b

@ -94,7 +94,7 @@ namespace Myshipping.Application
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="model">提单纸登记请求参数</param>
/// <returns></returns>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> LaraPaperRegistPost(string taskPKId, LaraPaperRegistPostDto model);
/// <summary>
@ -105,11 +105,50 @@ namespace Myshipping.Application
IActionResult DownloadTaskAttach(string taskPKId);
///// <summary>
///// 正本附件批量打印
///// </summary>
///// <param name="PKIds">任务主键数组</param>
///// <returns>返回结果</returns>
//Task<TaskManageOrderResultDto> PrintBatch(string[] PKIds);
/// <summary>
/// 正本附件批量打印
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回文件流</returns>
Task<IActionResult> PrintBatch(string[] PKIds);
/// <summary>
/// 接收换船
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> AcceptChangeShip(string taskPKId);
/// <summary>
/// 取消换船
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> AcceptCancelChangeShip(string taskPKId);
/// <summary>
/// 转发电放邮件
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="toMail">指定邮件地址</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> SendTelexEmail(string taskPKId, string toMail);
/// <summary>
/// 发送下货纸
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="fileRole">文件功能 (9原始)</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> SendShippingOrder(string taskPKId, string fileRole = "9");
/// <summary>
/// 获取订舱详情
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
Task<TaskManageOrderResultDto> GetBookingOrderInfo(string taskPKId);
}
}

@ -1,4 +1,5 @@
using Furion.DependencyInjection;
using Furion;
using Furion.DependencyInjection;
using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.FriendlyException;
@ -18,8 +19,10 @@ using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common;
using Newtonsoft.Json.Linq;
using NPOI.HPSF;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Asn1.X500;
using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SqlSugar;
using StackExchange.Profiling.Internal;
using System;
@ -1539,6 +1542,7 @@ namespace Myshipping.Application
}
#endregion
#region 下载任务附件
/// <summary>
/// 下载任务附件
/// </summary>
@ -1564,6 +1568,224 @@ namespace Myshipping.Application
result = new FileStreamResult(new FileStream(fileInfo.FILE_PATH, FileMode.Open), "application/octet-stream") { FileDownloadName = fileInfo.FILE_NAME };
}
return result;
}
#endregion
#region 正本附件批量打印
/// <summary>
/// 正本附件批量打印
/// </summary>
/// <param name="PKIds">任务主键数组</param>
/// <returns>返回文件流</returns>
[HttpPost("/TaskManage/PrintBatch")]
public async Task<IActionResult> PrintBatch(string[] PKIds)
{
FileStreamResult result = null;
/*
1PDF
2
3http://开头的文档,需要使用下载文件,并变更为本地文件
4PDF
5
6
*/
try
{
var fileList = _taskBaseInfoRepository.EntityContext.Queryable<TaskBaseInfo>()
.InnerJoin<TaskFileInfo>((tsk, file) => tsk.PK_ID == file.TASK_PKID)
.Where((tsk, file) => PKIds.Contains(tsk.PK_ID) && file.FILE_TYPE.Equals(".pdf"))
.Select((tsk, file) => new { tsk = tsk, file = file }).ToList();
var calcList = fileList.GroupBy(t => t.tsk.PK_ID)
.Select(a =>
{
var currList = a.ToList();
return new
{
tsk = currList.FirstOrDefault().tsk,
clist = a.Select(x => x.file).ToList()
};
}).OrderByDescending(t => t.tsk.CreatedTime).ToList();
var pdfList = calcList.SelectMany(t => t.clist).Select((t, idx) => new
{
Idx = idx,
file = t
}).ToList();
if (pdfList.Count == 0)
throw Oops.Oh($"没有可以合并的PDF文件");
string filePath = string.Empty;
string tempFileName = IDGen.NextID().ToString();
var opt = App.GetOptions<TempFileOptions>().Path;
filePath = $"{Path.Combine(App.WebHostEnvironment.WebRootPath, opt)}\\TempPDFMerge\\";//服务器路径
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
filePath = filePath.Replace("\\", "/");
}
//预先创建目录
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
var mergePdfPath = Path.Combine(filePath, $"{tempFileName}.pdf");
/*
Document document = null;
PdfCopy copy = null;
pdfList.ForEach(t => {
if(t.Idx == 0)
{
if(t.file.FILE_PATH.IndexOf("http://") >=0)
{
//var dw = InnerRemoteDownFile(t.file.FILE_PATH).GetAwaiter().GetResult();
WebClient wc = new WebClient();
wc.DownloadFile(t.file.FILE_PATH, Path.Combine(filePath, $"{tempFileName}abc.pdf"));
//document = new Document(new PdfReader(dw).GetPageSize(1));
}
else
{
document = new Document(new PdfReader(t.file.FILE_PATH).GetPageSize(1));
}
copy = new PdfCopy(document, new FileStream(mergePdfPath, FileMode.Create));
}
else
{
PdfReader reader = null;
if (t.file.FILE_PATH.IndexOf("http://") >= 0)
{
var dw = InnerRemoteDownFile(t.file.FILE_PATH).GetAwaiter().GetResult();
reader = new PdfReader(dw);
}
else
{
reader = new PdfReader(t.file.FILE_PATH);
}
int n = reader.NumberOfPages;
for (int j = 1; j <= n; j++)
{
document.NewPage();
PdfImportedPage page = copy.GetImportedPage(reader, j);
copy.AddPage(page);
}
reader.Close();
}
});
document.Close();
*/
result = new FileStreamResult(new FileStream(mergePdfPath, FileMode.Open), "application/octet-stream") { FileDownloadName = $"{tempFileName}.pdf" };
}
catch (Exception ex)
{
throw Oops.Bah($"LARA提单纸登记异常,{0}", ex.Message);
}
return result;
}
#endregion
#region 下载文件
private async Task<Stream> InnerRemoteDownFile(string filePath)
{
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(filePath);
if (response.IsSuccessStatusCode)
{
System.Net.Http.HttpContent content = response.Content;
var contentStream = await content.ReadAsStreamAsync(); // get the actual content stream
return contentStream;
}
else
{
throw new FileNotFoundException($"{filePath} 文件下载失败");
}
}
}
#endregion
/// <summary>
/// 接收换船
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
public async Task<TaskManageOrderResultDto> AcceptChangeShip(string taskPKId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
return result;
}
/// <summary>
/// 取消换船
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
public async Task<TaskManageOrderResultDto> AcceptCancelChangeShip(string taskPKId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
return result;
}
/// <summary>
/// 转发电放邮件
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="toMail">指定邮件地址</param>
/// <returns>返回结果</returns>
public async Task<TaskManageOrderResultDto> SendTelexEmail(string taskPKId, string toMail)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
return result;
}
/// <summary>
/// 发送下货纸
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <param name="fileRole">文件功能 (9原始)</param>
/// <returns>返回结果</returns>
public async Task<TaskManageOrderResultDto> SendShippingOrder(string taskPKId, string fileRole = "9")
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
return result;
}
/// <summary>
/// 获取订舱详情
/// </summary>
/// <param name="taskPKId">任务主键</param>
/// <returns>返回结果</returns>
public async Task<TaskManageOrderResultDto> GetBookingOrderInfo(string taskPKId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
return result;
}
}

Loading…
Cancel
Save