From ef9cf134141a73b5ce3da8e1cc947adaa5a254de Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Wed, 11 Jan 2023 09:07:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=94=BE=E5=BC=80AllowAnonymous=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=89=8D=E7=AB=AF=E4=BF=9D=E5=AD=98=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B9=B1=E7=A0=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingPrintTemplateService.cs | 11 ++++++----- Myshipping.Core/Myshipping.Core.xml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs index aa37b4a8..a81e7ba6 100644 --- a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs +++ b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using Myshipping.Application.Service.BookingPrintTemplate.Dto; using Myshipping.Core.Entity; using Myshipping.Application.Service.BookingTemplate.Dto; +using Microsoft.AspNetCore.Authorization; namespace Myshipping.Application { @@ -75,9 +76,9 @@ namespace Myshipping.Application [HttpGet("/BookingPrintTemplate/GetPrintTemplateList")] public async Task GetPrintTemplateList(string KeyWord) { - return await _rep.AsQueryable().Where(x => x.TenantId == UserManager.TENANT_ID).WhereIF(!string.IsNullOrWhiteSpace(KeyWord), x => x.FileName.StartsWith(KeyWord)) - .ToListAsync(); - + return await _rep.AsQueryable().Where(x => x.TenantId == UserManager.TENANT_ID).WhereIF(!string.IsNullOrWhiteSpace(KeyWord), x => x.FileName.StartsWith(KeyWord)) + .ToListAsync(); + } @@ -328,7 +329,7 @@ namespace Myshipping.Application /// /// /// - [HttpGet("/BookingPrintTemplate/download")] + [HttpGet("/BookingPrintTemplate/download"), AllowAnonymous] public async Task Download(long id) { var printFile = await _rep.FirstOrDefaultAsync(u => u.Id == id); @@ -388,7 +389,7 @@ namespace Myshipping.Application /// /// [HttpGet("/BookingPrintTemplate/GetPrinttemplateRightList")] - public async Task GetPrinttemplateRightList(long userId,string cateCode,string type) + public async Task GetPrinttemplateRightList(long userId, string cateCode, string type) { var userlist = await _repUser.AsQueryable().Filter(null, true).ToListAsync(); var list = await _repRight.AsQueryable().InnerJoin((d, t) => d.PrintTemplateId == t.Id && t.TenantId == UserManager.TENANT_ID). diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 2af87591..52457906 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -5445,7 +5445,7 @@ 创建第几行(从0开始) 行高 - + 创建行内指定的单元格 From 5ae1a75c9b581607525ec63204b392044f3e22d1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 11 Jan 2023 09:19:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8B=E8=B4=A7?= =?UTF-8?q?=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/ITaskManageService.cs | 53 ++++- .../TaskManagePlat/TaskManageService.cs | 224 +++++++++++++++++- 2 files changed, 269 insertions(+), 8 deletions(-) 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; } } From a1f84c3eadb3ad10db215822a8f4c9968d52d974 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Wed, 11 Jan 2023 09:22:36 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingPrintTemplate/BookingPrintTemplateService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs index a81e7ba6..fa80629c 100644 --- a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs +++ b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs @@ -332,7 +332,7 @@ namespace Myshipping.Application [HttpGet("/BookingPrintTemplate/download"), AllowAnonymous] public async Task Download(long id) { - var printFile = await _rep.FirstOrDefaultAsync(u => u.Id == id); + var printFile = await _rep.AsQueryable().Filter(null, true).FirstAsync(u => u.Id == id); if (printFile == null) { throw Oops.Bah(BookingErrorCode.BOOK115); From 90bce86274f1f72b3065804a0faae4309c053ab5 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Wed, 11 Jan 2023 09:35:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6=E5=90=8D=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Myshipping.Application.xml | 90 ++++++++++++++++++- .../BookingPrintTemplateService.cs | 14 ++- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 53e04f0c..8c44bcc5 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -14711,7 +14711,7 @@ 任务主键 提单纸登记请求参数 - + 返回结果 @@ -14720,6 +14720,50 @@ 返回文件流 + + + 正本附件批量打印 + + 任务主键数组 + 返回文件流 + + + + 接收换船 + + 任务主键 + 返回结果 + + + + 取消换船 + + 任务主键 + 返回结果 + + + + 转发电放邮件 + + 任务主键 + 指定邮件地址 + 返回结果 + + + + 发送下货纸 + + 任务主键 + 文件功能 (9原始) + 返回结果 + + + + 获取订舱详情 + + 任务主键 + 返回结果 + 任务管理 @@ -14853,5 +14897,49 @@ 返回文件流 + + + 正本附件批量打印 + + 任务主键数组 + 返回文件流 + + + + 接收换船 + + 任务主键 + 返回结果 + + + + 取消换船 + + 任务主键 + 返回结果 + + + + 转发电放邮件 + + 任务主键 + 指定邮件地址 + 返回结果 + + + + 发送下货纸 + + 任务主键 + 文件功能 (9原始) + 返回结果 + + + + 获取订舱详情 + + 任务主键 + 返回结果 + diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs index fa80629c..f1fa6295 100644 --- a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs +++ b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs @@ -37,14 +37,21 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repUser; private readonly ILogger _logger; private readonly SqlSugarRepository _excelrep; - - public BookingPrintTemplateService(SqlSugarRepository rep, SqlSugarRepository repRight, SqlSugarRepository repUser, SqlSugarRepository excelrep, ILogger logger) + private readonly IHttpContextAccessor _httpContextAccessor; + + public BookingPrintTemplateService(SqlSugarRepository rep, + SqlSugarRepository repRight, + SqlSugarRepository repUser, + SqlSugarRepository excelrep, + ILogger logger, + IHttpContextAccessor httpContextAccessor) { _rep = rep; _repRight = repRight; _repUser = repUser; _logger = logger; _excelrep = excelrep; + _httpContextAccessor = httpContextAccessor; } /// @@ -352,8 +359,7 @@ namespace Myshipping.Application throw Oops.Bah(BookingErrorCode.BOOK115); } - var fileName = HttpUtility.UrlEncode(printFile.FileName, Encoding.GetEncoding("UTF-8")); - var result = new FileStreamResult(new FileStream(fileFullPath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName }; + var result = new FileStreamResult(new FileStream(fileFullPath, FileMode.Open), "application/octet-stream") { FileDownloadName = printFile.FileName }; return result; } /// From 83bf6d43acc4488711268ab7adaef64a62a207f2 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Wed, 11 Jan 2023 09:47:49 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=94=BE=E8=88=B1=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E8=88=B9=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 4d8975f9..b4de3130 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1296,7 +1296,7 @@ namespace Myshipping.Application //vgm链接 allowCarrier = _cache.GetAllDictData().Result.Where(x => x.TypeCode == "vgm_carrier_list").Select(x => x.Code).ToList(); - if (!allowCarrier.Contains(order.CARRIERID)) + if (allowCarrier.Contains(order.CARRIERID)) { await VgmLink(input.BookingId); }