wet 2 years ago
commit acf3012238

@ -14711,7 +14711,7 @@
</summary>
<param name="taskPKId">任务主键</param>
<param name="model">提单纸登记请求参数</param>
<returns></returns>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.DownloadTaskAttach(System.String)">
<summary>
@ -14720,6 +14720,50 @@
<param name="taskPKId"></param>
<returns>返回文件流</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.PrintBatch(System.String[])">
<summary>
正本附件批量打印
</summary>
<param name="PKIds">任务主键数组</param>
<returns>返回文件流</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.AcceptChangeShip(System.String)">
<summary>
接收换船
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.AcceptCancelChangeShip(System.String)">
<summary>
取消换船
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.SendTelexEmail(System.String,System.String)">
<summary>
转发电放邮件
</summary>
<param name="taskPKId">任务主键</param>
<param name="toMail">指定邮件地址</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.SendShippingOrder(System.String,System.String)">
<summary>
发送下货纸
</summary>
<param name="taskPKId">任务主键</param>
<param name="fileRole">文件功能 (9原始)</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.ITaskManageService.GetBookingOrderInfo(System.String)">
<summary>
获取订舱详情
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
<member name="T:Myshipping.Application.TaskManageService">
<summary>
任务管理
@ -14853,5 +14897,49 @@
<param name="taskPKId"></param>
<returns>返回文件流</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.PrintBatch(System.String[])">
<summary>
正本附件批量打印
</summary>
<param name="PKIds">任务主键数组</param>
<returns>返回文件流</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.AcceptChangeShip(System.String)">
<summary>
接收换船
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.AcceptCancelChangeShip(System.String)">
<summary>
取消换船
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.SendTelexEmail(System.String,System.String)">
<summary>
转发电放邮件
</summary>
<param name="taskPKId">任务主键</param>
<param name="toMail">指定邮件地址</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.SendShippingOrder(System.String,System.String)">
<summary>
发送下货纸
</summary>
<param name="taskPKId">任务主键</param>
<param name="fileRole">文件功能 (9原始)</param>
<returns>返回结果</returns>
</member>
<member name="M:Myshipping.Application.TaskManageService.GetBookingOrderInfo(System.String)">
<summary>
获取订舱详情
</summary>
<param name="taskPKId">任务主键</param>
<returns>返回结果</returns>
</member>
</members>
</doc>

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

@ -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<SysUser> _repUser;
private readonly ILogger<BookingPrintTemplate> _logger;
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, SqlSugarRepository<BookingPrinttemplateRight> repRight, SqlSugarRepository<SysUser> repUser, SqlSugarRepository<BookingExcelTemplate> excelrep, ILogger<BookingPrintTemplate> logger)
private readonly IHttpContextAccessor _httpContextAccessor;
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep,
SqlSugarRepository<BookingPrinttemplateRight> repRight,
SqlSugarRepository<SysUser> repUser,
SqlSugarRepository<BookingExcelTemplate> excelrep,
ILogger<BookingPrintTemplate> logger,
IHttpContextAccessor httpContextAccessor)
{
_rep = rep;
_repRight = repRight;
_repUser = repUser;
_logger = logger;
_excelrep = excelrep;
_httpContextAccessor = httpContextAccessor;
}
/// <summary>
@ -75,9 +83,9 @@ namespace Myshipping.Application
[HttpGet("/BookingPrintTemplate/GetPrintTemplateList")]
public async Task<dynamic> 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
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/BookingPrintTemplate/download")]
[HttpGet("/BookingPrintTemplate/download"), AllowAnonymous]
public async Task<IActionResult> 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;
}
/// <summary>
@ -388,7 +395,7 @@ namespace Myshipping.Application
/// </summary>
/// <returns></returns>
[HttpGet("/BookingPrintTemplate/GetPrinttemplateRightList")]
public async Task<dynamic> GetPrinttemplateRightList(long userId,string cateCode,string type)
public async Task<dynamic> GetPrinttemplateRightList(long userId, string cateCode, string type)
{
var userlist = await _repUser.AsQueryable().Filter(null, true).ToListAsync();
var list = await _repRight.AsQueryable().InnerJoin<BookingPrintTemplate>((d, t) => d.PrintTemplateId == t.Id && t.TenantId == UserManager.TENANT_ID).

@ -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