From 3f1ed69b76782153201e0b74a17b1ac4ed861842 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 16 Jan 2024 14:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BC=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enum/TaskFileCategoryEnum.cs | 12 ++++- .../Interface/ITaskManageBCService.cs | 3 +- .../Interface/ITaskManageService.cs | 3 +- .../TaskManagePlat/TaskManageBCService.cs | 16 ++++++- .../TaskManagePlat/TaskManageService.cs | 46 +++++++++++++++++-- 5 files changed, 70 insertions(+), 10 deletions(-) diff --git a/Myshipping.Application/Enum/TaskFileCategoryEnum.cs b/Myshipping.Application/Enum/TaskFileCategoryEnum.cs index 969900f2..65d285f3 100644 --- a/Myshipping.Application/Enum/TaskFileCategoryEnum.cs +++ b/Myshipping.Application/Enum/TaskFileCategoryEnum.cs @@ -16,6 +16,16 @@ namespace Myshipping.Application /// BC-Booking Confirmation /// [Description("Booking Confirmation")] - BC + BC, + /// + /// BC-Booking Confirmation通知 + /// + [Description("Booking Confirmation Notice")] + BC_NOTICE, + /// + /// 空 + /// + [Description("NONE")] + NONE, } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index 4ef4c40e..14c7ec51 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -36,8 +36,9 @@ namespace Myshipping.Application /// 任务ID下载附件 /// /// BC任务主键 + /// 附件分类代码 /// 返回数据流 - Task DownloadFile(string taskPKId); + Task DownloadFile(string taskPKId, string fileCategory = "BC"); /// /// 检索订舱信息 diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index ca55c400..18c47538 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -274,9 +274,10 @@ namespace Myshipping.Application /// 创建BC任务 /// /// 文件 + /// BC变更内容后文件 /// BC任务详情JSON /// 返回回执 - Task CreateBCTaskJob(IFormFile file, string jsonData); + Task CreateBCTaskJob(IFormFile file, IFormFile modifyFile, string jsonData); /// /// 获取任务列表 diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 937cc53c..07bcd81f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -335,9 +335,10 @@ namespace Myshipping.Application /// 任务ID下载附件 /// /// BC任务主键 + /// 附件分类代码 /// 返回数据流 [HttpGet("/TaskManageBC/DownloadFile")] - public async Task DownloadFile(string taskPKId) + public async Task DownloadFile([FromQuery] string taskPKId, [FromQuery] string fileCategory = "BC") { var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); if (bcTaskInfo == null) @@ -345,7 +346,18 @@ namespace Myshipping.Application throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); } - var fileInfo = await _taskFileRepository.AsQueryable().FirstAsync(u => u.TASK_PKID == taskPKId); + TaskFileCategoryEnum fileCategoryEnum = TaskFileCategoryEnum.NONE; + + System.Enum.TryParse(fileCategory, out fileCategoryEnum); + + if (fileCategoryEnum == TaskFileCategoryEnum.NONE) + { + throw Oops.Oh($"附件分类代码错误,请提供正确的分类代码"); + } + + string name = fileCategoryEnum.ToString(); + + var fileInfo = await _taskFileRepository.AsQueryable().FirstAsync(u => u.TASK_PKID == taskPKId && u.FILE_CATEGORY == name); if (fileInfo == null) { diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 492e6bcc..d796f1ca 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -222,9 +222,10 @@ namespace Myshipping.Application /// 任务详情 /// 批次号 /// 文件 + /// 变更文件内容后的文件 /// 返回回执 [SqlSugarUnitOfWork] - private async Task InitTaskJob(TaskManageOrderMessageInfo info,string batchNo, IFormFile file = null) + private async Task InitTaskJob(TaskManageOrderMessageInfo info,string batchNo, IFormFile file = null, IFormFile modifyFile = null) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -339,8 +340,13 @@ namespace Myshipping.Application { var bytes = file.ToByteArray(); + string attachFileType = string.Empty; + + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + attachFileType = "bcfiles"; + var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, file.FileName, - GetFileType(file.FileName), "bcfiles"); + GetFileType(file.FileName), attachFileType); if (!string.IsNullOrWhiteSpace(fileFullName)) { @@ -359,6 +365,35 @@ namespace Myshipping.Application } } + if (modifyFile != null) + { + var bytes = modifyFile.ToByteArray(); + + string attachFileType = string.Empty; + + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + attachFileType = "bcnoticefiles"; + + var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, modifyFile.FileName, + GetFileType(modifyFile.FileName), attachFileType); + + if (!string.IsNullOrWhiteSpace(fileFullName)) + { + if (info.Main.FileList == null) + { + info.Main.FileList = new List(); + } + + info.Main.FileList.Add(new TaskManageOrderFileInfo + { + PKId = IDGen.NextID().ToString(), + FileName = modifyFile.FileName, + FileType = Path.GetExtension(modifyFile.FileName).ToLower(), + FilePath = fileFullName + }); + } + } + #region 附件 //附件 if (info.Main.FileList != null && info.Main.FileList.Count > 0) @@ -4974,10 +5009,11 @@ namespace Myshipping.Application /// 创建BC任务 /// /// 文件 + /// BC变更内容后文件 /// BC任务详情JSON /// 返回回执 - [AllowAnonymous, HttpPost("/TaskManage/CreateBCTaskJob")] - public async Task CreateBCTaskJob(IFormFile file, [FromForm] string jsonData) + [AllowAnonymous, HttpPost("/TaskManage/CreateBCTaskJob"), ApiUser(ApiCode = "BCTaskManage")] + public async Task CreateBCTaskJob(IFormFile file, IFormFile modifyFile, [FromForm] string jsonData) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -4993,7 +5029,7 @@ namespace Myshipping.Application if(info == null) throw Oops.Bah("jsonData请求内容错误,无法反序列化报文"); - result = await InitTaskJob(info, batchNo, file); + result = await InitTaskJob(info, batchNo, file, modifyFile); } catch (Exception ex) {