From d9fbbd25b001c4684a7b172431e9479f892b0a9f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 6 May 2024 16:11:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E5=9B=9E=E6=89=A7=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManageSISubmittedService.cs | 111 +++++++++++++++++- .../TaskManagePlat/TaskManageService.cs | 4 +- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs index 024f7114..78a0d4a6 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs @@ -8,6 +8,7 @@ using ICSharpCode.SharpZipLib.Zip; using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Myshipping.Application.ConfigOption; using Myshipping.Application.Entity; using Myshipping.Application.Entity.TaskManagePlat; using Myshipping.Application.Helper; @@ -18,6 +19,7 @@ using NPOI.OpenXmlFormats.Dml.Diagram; using RabbitMQ.Client; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; @@ -39,7 +41,9 @@ namespace Myshipping.Application private readonly SqlSugarRepository _bookingOrderRepository; private readonly SqlSugarRepository _bookingCtnRepository; private readonly SqlSugarRepository _businessCompareDiffRecordRepository; - + private readonly SqlSugarRepository _taskFileRepository; + private readonly SqlSugarRepository _bookingFileRepository; + private readonly ILogger _logger; private readonly IBookingValueAddedService _bookingValueAddedService; private readonly IDjyTenantParamService _djyTenantParamService; @@ -55,6 +59,8 @@ namespace Myshipping.Application SqlSugarRepository businessCompareDiffRecordRepository, SqlSugarRepository bookingCtnRepository, SqlSugarRepository taskSISubmittedCtnRepository, + SqlSugarRepository taskFileRepository, + SqlSugarRepository bookingFileRepository, IBookingValueAddedService bookingValueAddedService, IDjyTenantParamService djyTenantParamService, IBookingOrderService bookingOrderService) { @@ -68,6 +74,9 @@ namespace Myshipping.Application _bookingCtnRepository = bookingCtnRepository; _taskSISubmittedCtnRepository = taskSISubmittedCtnRepository; _bookingOrderService = bookingOrderService; + + _taskFileRepository = taskFileRepository; + _bookingFileRepository = bookingFileRepository; } #region 获取截单回执详情 @@ -496,6 +505,10 @@ namespace Myshipping.Application ctn.CreatedTime = DateTime.Now; ctn.CreatedUserId = UserManager.UserId; ctn.CreatedUserName = UserManager.Name; + ctn.KINDPKGS = x.KINDPKGS; + + if (string.IsNullOrWhiteSpace(x.KINDPKGS) && !string.IsNullOrWhiteSpace(siSubmitted.KINDPKGS)) + ctn.KINDPKGS = siSubmitted.KINDPKGS; if (x.WEIGHKGS.HasValue && x.KGS.HasValue) ctn.TAREWEIGHT = x.WEIGHKGS.Value - x.KGS.Value; @@ -521,6 +534,10 @@ namespace Myshipping.Application ctn.CreatedTime = DateTime.Now; ctn.CreatedUserId = UserManager.UserId; ctn.CreatedUserName = UserManager.Name; + ctn.KINDPKGS = x.KINDPKGS; + + if (string.IsNullOrWhiteSpace(x.KINDPKGS) && !string.IsNullOrWhiteSpace(siSubmitted.KINDPKGS)) + ctn.KINDPKGS = siSubmitted.KINDPKGS; if (x.WEIGHKGS.HasValue && x.KGS.HasValue) ctn.TAREWEIGHT = x.WEIGHKGS.Value - x.KGS.Value; @@ -546,6 +563,10 @@ namespace Myshipping.Application ctn.CreatedTime = DateTime.Now; ctn.CreatedUserId = UserManager.UserId; ctn.CreatedUserName = UserManager.Name; + ctn.KINDPKGS = x.KINDPKGS; + + if (string.IsNullOrWhiteSpace(x.KINDPKGS) && !string.IsNullOrWhiteSpace(siSubmitted.KINDPKGS)) + ctn.KINDPKGS = siSubmitted.KINDPKGS; if (x.WEIGHKGS.HasValue && x.KGS.HasValue) ctn.TAREWEIGHT = x.WEIGHKGS.Value - x.KGS.Value; @@ -572,6 +593,8 @@ namespace Myshipping.Application WEIGHKGS = x.WEIGHKGS, CBM = x.CBM, REMARK = "SI Add", + TAREWEIGHT = x.WEIGHKGS.HasValue && x.KGS.HasValue ? x.WEIGHKGS.Value - x.KGS.Value :0, + KINDPKGS = (string.IsNullOrWhiteSpace(x.KINDPKGS) && !string.IsNullOrWhiteSpace(siSubmitted.KINDPKGS))? siSubmitted.KINDPKGS: x.KINDPKGS, }); } @@ -583,6 +606,29 @@ namespace Myshipping.Application ctnList.ForEach(t => { if (t.REMARK.IndexOf("SI Add") < 0) ctnList.Remove(t); }); } + if(ctnList.Count > 0) + { + bkModel.ctnInputs = ctnList.Select(t => new BookingCtnDto + { + BILLID = t.BILLID, + CNTRNO = t.CNTRNO, + CTNALL = t.CTNALL, + CTNCODE = t.CTNCODE, + CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 0, + CBM = t.CBM.HasValue ? t.CBM.Value : 0, + KINDPKGS = t.KINDPKGS, + PKGS = t.PKGS.HasValue ? t.PKGS.Value : 0, + SEALNO = t.SEALNO, + KGS = t.KGS.HasValue ? t.KGS.Value : 0, + TAREWEIGHT = t.TAREWEIGHT.HasValue ? t.TAREWEIGHT.Value : 0, + WEIGHKGS = t.WEIGHKGS.HasValue ? t.WEIGHKGS.Value : 0, + WEIGHTYPE = t.WEIGHTYPE, + + Id = t.Id, + }).ToList(); + } + + //更新订舱数据 var bkRlt = await _bookingOrderService.Save(bkModel); @@ -669,6 +715,34 @@ namespace Myshipping.Application //处理附件 + var opt = App.GetOptions(); + var dirAbs = opt.basePath; + if (string.IsNullOrEmpty(dirAbs)) + { + dirAbs = App.WebHostEnvironment.WebRootPath; + } + + string batchNo = IDGen.NextID().ToString(); + + var fileList = _taskFileRepository.AsQueryable().Filter(null,true).Where(a => a.TASK_PKID == taskPkId && a.TenantId == taskBase.TenantId.Value).ToList(); + + fileList.ForEach(file => + { + if (file.FILE_CATEGORY == TaskFileCategoryEnum.SI_SUBMITTED.ToString()) + { + var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH); + + if (File.Exists(fileFullPath)) + { + //如果确认文件读取成功 + var bookFilePath = FileAttachHelper.MoveFile(bkRlt.Id.ToString(), fileFullPath, batchNo + , false, null, true).GetAwaiter().GetResult(); + + //将格式单附件写入订舱的附件 + SaveEDIFile(bkRlt.Id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBase.TenantId.Value).GetAwaiter(); + } + } + }); result.succ = true; result.msg = "处理成功"; @@ -751,6 +825,41 @@ namespace Myshipping.Application } #endregion + #region 异步写入附件表 + /// + /// 异步写入附件表 + /// + /// 订舱ID + /// 文件路径 + /// 文件名 + /// 租户ID + /// 附件类型代码 + /// 附件类型名称 + /// 附件模块代码 + /// + [NonAction] + private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId, + string fileTypeCode = "sifeed", string fileTypeName = "SI submitted", string moudle = "TaskSISubmitted") + { + /* + 直接将附件信息写入附件表 + */ + //EDI文件 + var bookFile = new BookingFile + { + Id = YitIdHelper.NextId(), + FileName = fileName, + FilePath = FilePath, + TypeCode = fileTypeCode, + TypeName = fileTypeName, + BookingId = boookId, + TenantId = tenantId, + Moudle = moudle + }; + + await _bookingFileRepository.InsertAsync(bookFile); + } + #endregion /// /// 获取SI反馈信息 diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 717a615a..3cb566a7 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -647,7 +647,7 @@ namespace Myshipping.Application { var ediCtnList = _cache.GetAllCodeCtn().GetAwaiter().GetResult(); - info.Main.SIFeedBack.ContaList.ForEach(async ctn => + info.Main.SIFeedBack.ContaList.ForEach(ctn => { var contaInfo = ctn.Adapt(); @@ -679,13 +679,11 @@ namespace Myshipping.Application }); } - /* var siService = _namedtaskSISubmittedServiceProvider .GetService(nameof(TaskManageSISubmittedService)); await siService.ProcessSISubmitted(taskSISubmitted.TASK_ID); - */ } #endregion