diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs
index cc4b104a..bca74f42 100644
--- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs
@@ -94,7 +94,7 @@ namespace Myshipping.Application
///
/// 任务主键
/// 提单纸登记请求参数
- ///
+ /// 返回结果
Task LaraPaperRegistPost(string taskPKId, LaraPaperRegistPostDto model);
///
@@ -105,11 +105,50 @@ namespace Myshipping.Application
IActionResult DownloadTaskAttach(string taskPKId);
- /////
- ///// 正本附件批量打印
- /////
- ///// 任务主键数组
- ///// 返回结果
- //Task PrintBatch(string[] PKIds);
+ ///
+ /// 正本附件批量打印
+ ///
+ /// 任务主键数组
+ /// 返回文件流
+ Task PrintBatch(string[] PKIds);
+
+ ///
+ /// 接收换船
+ ///
+ /// 任务主键
+ /// 返回结果
+ Task AcceptChangeShip(string taskPKId);
+
+ ///
+ /// 取消换船
+ ///
+ /// 任务主键
+ /// 返回结果
+ Task AcceptCancelChangeShip(string taskPKId);
+
+ ///
+ /// 转发电放邮件
+ ///
+ /// 任务主键
+ /// 指定邮件地址
+ /// 返回结果
+ Task SendTelexEmail(string taskPKId, string toMail);
+
+ ///
+ /// 发送下货纸
+ ///
+ /// 任务主键
+ /// 文件功能 (9原始)
+ /// 返回结果
+ Task SendShippingOrder(string taskPKId, string fileRole = "9");
+
+ ///
+ /// 获取订舱详情
+ ///
+ /// 任务主键
+ /// 返回结果
+ Task GetBookingOrderInfo(string taskPKId);
+
+
}
}
diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
index 9f8cf32e..ee8368e1 100644
--- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
@@ -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 下载任务附件
///
/// 下载任务附件
///
@@ -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 正本附件批量打印
+ ///
+ /// 正本附件批量打印
+ ///
+ /// 任务主键数组
+ /// 返回文件流
+ [HttpPost("/TaskManage/PrintBatch")]
+ public async Task PrintBatch(string[] PKIds)
+ {
+ FileStreamResult result = null;
+ /*
+ 1、通过任务主键获取所有的文件列表。只合并PDF文件,其他的文件不处理。
+ 2、创建临时文件存放目录。
+ 3、如果是http://开头的文档,需要使用下载文件,并变更为本地文件
+ 4、PDF合成所有文件。
+ 5、写入下载记录表。
+ 6、返回文件流。
+ */
+
+ try
+ {
+ var fileList = _taskBaseInfoRepository.EntityContext.Queryable()
+ .InnerJoin((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().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 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
+
+
+ ///
+ /// 接收换船
+ ///
+ /// 任务主键
+ /// 返回结果
+ public async Task AcceptChangeShip(string taskPKId)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ return result;
+ }
+
+ ///
+ /// 取消换船
+ ///
+ /// 任务主键
+ /// 返回结果
+ public async Task AcceptCancelChangeShip(string taskPKId)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ return result;
+ }
+
+ ///
+ /// 转发电放邮件
+ ///
+ /// 任务主键
+ /// 指定邮件地址
+ /// 返回结果
+ public async Task SendTelexEmail(string taskPKId, string toMail)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ return result;
+ }
+
+ ///
+ /// 发送下货纸
+ ///
+ /// 任务主键
+ /// 文件功能 (9原始)
+ /// 返回结果
+ public async Task SendShippingOrder(string taskPKId, string fileRole = "9")
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ return result;
+ }
+
+ ///
+ /// 获取订舱详情
+ ///
+ /// 任务主键
+ /// 返回结果
+ public async Task GetBookingOrderInfo(string taskPKId)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
return result;
}
}