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/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index c861b2ac..71996df6 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);
}
diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs
index aa37b4a8..f1fa6295 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
{
@@ -36,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;
}
///
@@ -75,9 +83,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,10 +336,10 @@ 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);
+ var printFile = await _rep.AsQueryable().Filter(null, true).FirstAsync(u => u.Id == id);
if (printFile == null)
{
throw Oops.Bah(BookingErrorCode.BOOK115);
@@ -351,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;
}
///
@@ -388,7 +395,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.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;
}
}