From 6fdcee2c8ac52649da57dbbaaa04823deb73ff98 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Mon, 5 Feb 2024 17:29:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?BookingOrderService=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=A5=E5=BF=97=EF=BC=9A=E8=AE=BE=E7=BD=AE=E8=B4=A7=E7=89=A9?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E3=80=81=E5=8F=96=E6=B6=88=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=B4=A7=E7=89=A9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/BookingOrderService.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 455ab67b..f7df8d77 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -9855,7 +9855,7 @@ namespace Myshipping.Application await _rep.AsUpdateable(order).IgnoreColumns().ExecuteCommandAsync(); // 记录日志 - await SaveLog(order, oldOrder, "即时刷新船期"); + await SaveLog(order, oldOrder, "手动刷新船期"); await SendBookingOrder(new long[] { Id }); if (!string.IsNullOrEmpty(order.VESSEL) && !string.IsNullOrEmpty(order.VOYNO)) @@ -9979,7 +9979,8 @@ namespace Myshipping.Application await _rep.UpdateAsync(x => x.Id == bookingId, x => new BookingOrder { BSSTATUSNAME = StatusName }); // 记录日志 - var newOrder = new BookingOrder() { BSSTATUSNAME = StatusName }; + var newOrder = order.Adapt(); + newOrder.BSSTATUSNAME = StatusName; await SaveLog(newOrder, order, "更新货物状态"); } } @@ -10485,6 +10486,8 @@ namespace Myshipping.Application { var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); + + var oldModel = model.Adapt(); model.BSSTATUSNAME = maxStatus.ShowName; //model.VERSION = IDGen.NextID().ToString().Replace("-", ""); @@ -10497,6 +10500,9 @@ namespace Myshipping.Application //it.VERSION }).ExecuteCommand(); + // 保存日志 + await SaveLog(model, oldModel, "设置货物状态"); + //推送东胜 if (isAutoSyncDS) await SendBookingOrder(new long[] { bookingId }); @@ -10577,6 +10583,8 @@ namespace Myshipping.Application var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); + var oldModel = model.Adapt(); + if (maxStatus != null) { model.BSSTATUSNAME = maxStatus.ShowName; @@ -10596,6 +10604,9 @@ namespace Myshipping.Application //it.VERSION }).ExecuteCommand(); + // 保存日志 + await SaveLog(model, oldModel, "取消设置货物状态"); + //推送东胜 if (isAutoSyncDS) //推送东胜 From e79fd6f21ef258ee8a54270d9ab325bc8b645ffb Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Tue, 6 Feb 2024 15:26:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BB=85=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E5=85=B6=E5=AE=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingValueAddedService.cs | 146 +++++++++--------- 1 file changed, 71 insertions(+), 75 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index ff26f0fa..b545223a 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -7,44 +7,29 @@ using Furion.FriendlyException; using Furion.JsonSerialization; using Furion.RemoteRequest.Extensions; using Mapster; -using MathNet.Numerics; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Rewrite; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; using Myshipping.Application.ConfigOption; using Myshipping.Application.Entity; using Myshipping.Application.Service.BookingOrder.Dto; using Myshipping.Core; using Myshipping.Core.Entity; using Myshipping.Core.Service; -using MySqlX.XDevAPI.Common; -using NPOI.SS.Formula.Functions; -using Org.BouncyCastle.Crypto; -using Org.BouncyCastle.Utilities; using SqlSugar; using StackExchange.Profiling.Internal; using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; -using System.Net.NetworkInformation; -using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; -using System.Threading; using System.Threading.Tasks; using System.Web; -using Ubiety.Dns.Core; using Yitter.IdGenerator; -using static Aliyun.OSS.Model.CreateSelectObjectMetaInputFormatModel; namespace Myshipping.Application { @@ -75,7 +60,7 @@ namespace Myshipping.Application const string CONST_MAPPING_BC_MODULE_ROUTE = "BC_DOWN_RT"; const string CONST_MAPPING_DRAFT_MODULE_ROUTE = "DRAFT_DOWN_RT"; const string CONST_MAPPING_MANIALLO_CHK_MODULE_ROUTE = "MANI_ALLOC_CHK_RT"; - + const string CONST_FORMAT_BC_URL = "{0}_bc_down_url"; const string CONST_FORMAT_DRAFT_URL = "{0}_draft_down_url"; const string CONST_FORMAT_MANIALLO_CHK_URL = "{0}_manialloc_chk_url"; @@ -87,7 +72,7 @@ namespace Myshipping.Application public BookingValueAddedService(ISysCacheService cache, ILogger logger, SqlSugarRepository bookingOrderRepository, - SqlSugarRepository djyWebsiteAccountConfigRepository, SqlSugarRepository sysUserRepository, + SqlSugarRepository djyWebsiteAccountConfigRepository, SqlSugarRepository sysUserRepository, SqlSugarRepository bookingLetteryardRepository, IBookingOrderService bookingOrderService , SqlSugarRepository taskBCInfoRepository, IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository statuslogRepository, SqlSugarRepository statuslogdetailRepository, @@ -124,7 +109,7 @@ namespace Myshipping.Application /// 订舱主键数组 /// 返回回执 [HttpPost("/BookingValueAdded/DownloadBookingConfirm")] - public async Task DownloadBookingConfirm([FromBody]long[] bookingIds) + public async Task DownloadBookingConfirm([FromBody] long[] bookingIds) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -152,7 +137,7 @@ namespace Myshipping.Application foreach (var bk in list) { - var sortNo = noList.FirstOrDefault(a=>a.id == bk.Id).no; + var sortNo = noList.FirstOrDefault(a => a.id == bk.Id).no; taskList.Add(Task.Run(() => InnerDownloadBookingConfirm(bk, batchNo, sortNo))); } @@ -186,9 +171,9 @@ namespace Myshipping.Application else { result.batchTotal = "- "; - } + } - if(fail > 0) + if (fail > 0) { result.batchTotal += "/" + fail.ToString(); } @@ -214,7 +199,7 @@ namespace Myshipping.Application /// 批次号 /// 请求顺序号 /// 返回回执 - private async Task InnerDownloadBookingConfirm(BookingOrder bookingOrder,string batchNo, int sortNo) + private async Task InnerDownloadBookingConfirm(BookingOrder bookingOrder, string batchNo, int sortNo) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -277,7 +262,7 @@ namespace Myshipping.Application string webKey = string.Format(CONST_FORMAT_WEB, bcOrDraftRouteCfg.MapCode); //获取个人对应的账户,这里GetAccountConfig逻辑优先取个人,个人没有配置取公司对应配置 - var userWebAccountConfig = GetAccountConfig(webKey, UserManager.UserId,UserManager.TENANT_ID).GetAwaiter() + var userWebAccountConfig = GetAccountConfig(webKey, UserManager.UserId, UserManager.TENANT_ID).GetAwaiter() .GetResult(); _logger.LogInformation("批次={no} 获取获取网站的账户完成,result={Num}", batchNo, JSON.Serialize(userWebAccountConfig)); @@ -305,8 +290,8 @@ namespace Myshipping.Application TimeSpan ts = eDate.Subtract(bDate); var timeDiff = ts.TotalMilliseconds; - _logger.LogInformation("批次={no} result={result} 请求BC远端下载结束 耗时:{timeDiff}ms. ", batchNo, - JSON.Serialize(rlt),timeDiff); + _logger.LogInformation("批次={no} result={result} 请求BC远端下载结束 耗时:{timeDiff}ms. ", batchNo, + JSON.Serialize(rlt), timeDiff); if (rlt.code == 200) { @@ -420,7 +405,7 @@ namespace Myshipping.Application /// 订舱主键数组 /// [HttpPost("/BookingValueAdded/DownloadDraft")] - public async Task DownloadDraft([FromBody]long[] bookingIds) + public async Task DownloadDraft([FromBody] long[] bookingIds) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); List> taskList = new List>(); @@ -447,7 +432,7 @@ namespace Myshipping.Application var noList = bookingIds.Select((a, idx) => new { no = idx + 1, id = a }).ToList(); foreach (var bk in list) { - var sortNo = noList.FirstOrDefault(a=>a.id == bk.Id).no; + var sortNo = noList.FirstOrDefault(a => a.id == bk.Id).no; taskList.Add(Task.Run(() => InnerDownloadDraft(bk, batchNo, sortNo))); } @@ -509,7 +494,7 @@ namespace Myshipping.Application /// 批次号 /// 请求顺序号 /// 返回回执 - private async Task InnerDownloadDraft(BookingOrder bookingOrder, string batchNo,int sortNo) + private async Task InnerDownloadDraft(BookingOrder bookingOrder, string batchNo, int sortNo) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -524,9 +509,9 @@ namespace Myshipping.Application 4、请求相应的链接。 5、返回成功写入附件。 */ - if(bookingOrder.CARRIERID.Equals("ESL", StringComparison.OrdinalIgnoreCase)) + if (bookingOrder.CARRIERID.Equals("ESL", StringComparison.OrdinalIgnoreCase)) { - if(string.IsNullOrWhiteSpace(bookingOrder.TMBLNO)) + if (string.IsNullOrWhiteSpace(bookingOrder.TMBLNO)) { if (!string.IsNullOrWhiteSpace(bookingOrder.CUSTNO)) { @@ -602,7 +587,7 @@ namespace Myshipping.Application string downloadFilePathRlt = string.Empty; string erroMsg = string.Empty; - if(bcOrDraftRouteCfg.MapCode.Trim().Equals("ESL", StringComparison.OrdinalIgnoreCase)) + if (bcOrDraftRouteCfg.MapCode.Trim().Equals("ESL", StringComparison.OrdinalIgnoreCase)) { ESLDraftRequestDto requestDto = new ESLDraftRequestDto { @@ -764,7 +749,8 @@ namespace Myshipping.Application { _logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info)); - var res = await url.OnClientCreating(client => { + var res = await url.OnClientCreating(client => + { // client 为 HttpClient 对象 client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 }).SetHttpMethod(HttpMethod.Post) @@ -816,7 +802,8 @@ namespace Myshipping.Application { _logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info)); - var res = await url.OnClientCreating(client => { + var res = await url.OnClientCreating(client => + { // client 为 HttpClient 对象 client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 }).SetHttpMethod(HttpMethod.Post) @@ -869,10 +856,11 @@ namespace Myshipping.Application { _logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info)); - var res = await url.OnClientCreating(client => { + var res = await url.OnClientCreating(client => + { // client 为 HttpClient 对象 - client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 - }).SetHttpMethod(HttpMethod.Post) + client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 + }).SetHttpMethod(HttpMethod.Post) .SetBody(JSON.Serialize(info), "application/json") .SetContentEncoding(Encoding.UTF8) .PostAsync(); @@ -918,7 +906,8 @@ namespace Myshipping.Application { _logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info)); - var res = await url.OnClientCreating(client => { + var res = await url.OnClientCreating(client => + { // client 为 HttpClient 对象 client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 }).SetHttpMethod(HttpMethod.Post) @@ -1146,7 +1135,7 @@ namespace Myshipping.Application if (rlt.status == 1) { - if(rlt.data == null || string.IsNullOrWhiteSpace(rlt.data.esl_no)) + if (rlt.data == null || string.IsNullOrWhiteSpace(rlt.data.esl_no)) { _logger.LogInformation("批次={no} 舱位分配查询失败,ESL号不存在", batchNo); @@ -1159,7 +1148,7 @@ namespace Myshipping.Application */ var bkInfo = _bookingOrderRepository.AsQueryable().First(a => a.Id == bookingOrder.Id); - if(bkInfo == null) + if (bkInfo == null) { _logger.LogInformation("批次={no} id={id} 订舱信息获取失败,无法更新", batchNo, bookingOrder.Id); @@ -1174,7 +1163,7 @@ namespace Myshipping.Application throw Oops.Oh($"主提单号已变更,无法更新"); }*/ - _logger.LogInformation("批次={no} 变更前记录 id={id} MBLNO={MBLNO} CUSTNO={CUSTNO} esl_no={eslno}", + _logger.LogInformation("批次={no} 变更前记录 id={id} MBLNO={MBLNO} CUSTNO={CUSTNO} esl_no={eslno}", batchNo, bookingOrder.Id, bkInfo.MBLNO, bkInfo.CUSTNO, rlt.data.esl_no); //bkInfo.CUSTNO = bkInfo.MBLNO; @@ -1383,7 +1372,8 @@ namespace Myshipping.Application { _logger.LogInformation("批次={no} 对应请求报文 request={res}", batchNo, JSON.Serialize(info)); - var res = await url.OnClientCreating(client => { + var res = await url.OnClientCreating(client => + { // client 为 HttpClient 对象 client.Timeout = TimeSpan.FromMinutes(15); // 设置超时时间 15分钟 }).SetHttpMethod(HttpMethod.Post) @@ -1419,7 +1409,7 @@ namespace Myshipping.Application /// 用户ID /// 租户ID /// 返回账户配置 - private async Task GetAccountConfig(string typeCode,long userId,long tendId) + private async Task GetAccountConfig(string typeCode, long userId, long tendId) { DjyWebsiteAccountConfig accountConfig = new DjyWebsiteAccountConfig(); accountConfig = await _djyWebsiteAccountConfigRepository.EntityContext.CopyNew().Queryable() @@ -1455,12 +1445,12 @@ namespace Myshipping.Application 2、解析识别结果,并返回BC的解析明细。 */ - if(bookingOrderId < 0) + if (bookingOrderId < 0) throw Oops.Oh($"订舱主键不能为空"); var bookingOrder = _bookingOrderRepository.AsQueryable().First(a => a.Id == bookingOrderId); - if(bookingOrder == null) + if (bookingOrder == null) throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); //获取解析BC文件链接 @@ -1501,11 +1491,11 @@ namespace Myshipping.Application { var currBC = bcParseRlt.data.BCList.FirstOrDefault(); - if(!string.IsNullOrWhiteSpace(currBC.Vessel) && Regex.IsMatch(currBC.Vessel, "\\(|(|\\)|)|\\n")) + if (!string.IsNullOrWhiteSpace(currBC.Vessel) && Regex.IsMatch(currBC.Vessel, "\\(|(|\\)|)|\\n")) { - if(Regex.IsMatch(currBC.Vessel, "\\(|(|\\)|)")) + if (Regex.IsMatch(currBC.Vessel, "\\(|(|\\)|)")) { - currBC.Vessel = Regex.Match(currBC.Vessel,"\\w+\\s?\\n?\\s?\\w+(?=\\()").Value; + currBC.Vessel = Regex.Match(currBC.Vessel, "\\w+\\s?\\n?\\s?\\w+(?=\\()").Value; } if (Regex.IsMatch(currBC.Vessel, "\\n")) @@ -1526,7 +1516,8 @@ namespace Myshipping.Application ETD = currBC.ETD }; - singleBCDto.BookingOrderBCDto = new BookingOrderBCDto { + singleBCDto.BookingOrderBCDto = new BookingOrderBCDto + { MBLNO = bookingOrder.MBLNO, CUSTNO = bookingOrder.CUSTNO, CLOSEDOCDATE = bookingOrder.CLOSEDOCDATE, @@ -1542,7 +1533,7 @@ namespace Myshipping.Application */ //读取文件配置 - var fileFullName = await FileAttachHelper.TempSaveWebFile(bookingOrder.Id.ToString(), file, batchNo); + var fileFullName = await FileAttachHelper.TempSaveWebFile(bookingOrder.Id.ToString(), file, batchNo); _logger.LogInformation("批次={no} 完成文件保存 filepath={path}", batchNo, fileFullName); @@ -1557,7 +1548,7 @@ namespace Myshipping.Application result.msg = $"解析BC失败,原因:{bcParseRlt.message}"; } } - catch(Exception ex) + catch (Exception ex) { _logger.LogInformation("批次={no} 解析BC异常,原因:{error} ", batchNo, ex.Message); @@ -1580,7 +1571,7 @@ namespace Myshipping.Application try { - var response = await requestUrl.SetContentType("multipart/form-data") + var response = await requestUrl.SetContentType("multipart/form-data") .SetBodyBytes((fileInfo.file.ToString(), fileInfo.fileBytes, HttpUtility.UrlEncode(fileInfo.fileName.ToString()))) .PostAsync(); @@ -1637,7 +1628,7 @@ namespace Myshipping.Application if (bookingOrder == null) throw Oops.Bah($"订舱信息获取失败,订舱信息不存在或已作废"); - var updateRlt = InnerBCUpdateBookingOrder(model, bookingOrder, batchNo,1).GetAwaiter().GetResult(); + var updateRlt = InnerBCUpdateBookingOrder(model, bookingOrder, batchNo, 1).GetAwaiter().GetResult(); if (!updateRlt.succ) throw Oops.Bah($"订舱信息更新失败,{updateRlt.msg}"); @@ -1671,7 +1662,7 @@ namespace Myshipping.Application var letterYardModel = _bookingLetteryardRepository.AsQueryable() .First(x => x.BookingId == model.BookingOrderId); - if(letterYardModel != null) + if (letterYardModel != null) letterYardDto.Id = letterYardModel.Id; } @@ -1696,7 +1687,7 @@ namespace Myshipping.Application //重新将暂存文件写入正式路径 //读取文件配置 - var bookFilePath = await FileAttachHelper.MoveFile(bookingOrder.Id.ToString(), model.FileTempPath,batchNo); + var bookFilePath = await FileAttachHelper.MoveFile(bookingOrder.Id.ToString(), model.FileTempPath, batchNo); //将BC引入的文件写入订舱的附件 await SaveEDIFile(bookingOrder.Id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, @@ -1729,7 +1720,7 @@ namespace Myshipping.Application /// 顺序号 /// 返回回执 private async Task InnerBCUpdateBookingOrder(SingleBCDto model, BookingOrder bookingOrder, - string batchNo,int sortNo) + string batchNo, int sortNo) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -1850,7 +1841,7 @@ namespace Myshipping.Application /// 批量BC更新列表 /// 返回回执 [HttpPost("/BookingValueAdded/BatchBCUpdate")] - public async Task BatchBCUpdate([FromBody]List batchBCList) + public async Task BatchBCUpdate([FromBody] List batchBCList) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); List> taskList = new List>(); @@ -1859,7 +1850,7 @@ namespace Myshipping.Application try { - var bcTaskList = batchBCList.Select(a=>a.bcPKId).Distinct().ToList(); + var bcTaskList = batchBCList.Select(a => a.bcPKId).Distinct().ToList(); var bkOrderList = batchBCList.Select(a => a.bkOrderId.Value).Distinct().ToList(); var bklist = _bookingOrderRepository.AsQueryable() @@ -1876,11 +1867,13 @@ namespace Myshipping.Application { var sortNo = noList.FirstOrDefault(a => a.id == bk.Id).no; - var currBC = batchBCList.Join(bclist, l => l.bcPKId, r => r.PK_ID, (l, r) => { + var currBC = batchBCList.Join(bclist, l => l.bcPKId, r => r.PK_ID, (l, r) => + { return r; }).FirstOrDefault(); - SingleBCDto singleBCDto = new SingleBCDto { + SingleBCDto singleBCDto = new SingleBCDto + { BLNo = currBC.MBL_NO, Vessel = currBC.VESSEL, Voyage = currBC.VOYNO, @@ -1889,7 +1882,7 @@ namespace Myshipping.Application VGMCutOffTime = currBC.VGM_CUTOFF_TIME, ClosingDate = currBC.CUT_SINGLE_TIME }; - taskList.Add(Task.Run(() => InnerBCUpdateBookingOrder(singleBCDto,bk, batchNo, sortNo))); + taskList.Add(Task.Run(() => InnerBCUpdateBookingOrder(singleBCDto, bk, batchNo, sortNo))); } Task.WaitAll(taskList.ToArray()); @@ -2063,20 +2056,22 @@ namespace Myshipping.Application try { - var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null,true) - .First(a=>a.Id == model.BookingId); + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); - if(bookingOrder == null) + if (bookingOrder == null) throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); - TrackingMessageInfo msgInfo = new TrackingMessageInfo { - Head = new TrackingMessageHeadInfo { + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { GID = IDGen.NextID().ToString(), MessageType = "PROJECT", ReceiverId = "ServiceProjectStatus", - ReceiverName= "服务项目和状态", + ReceiverName = "服务项目和状态", SenderId = "BookingOrder", SenderName = "海运订舱", RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), @@ -2097,7 +2092,7 @@ namespace Myshipping.Application OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, SourceType = TrackingSourceTypeEnum.MANUAL, - ProjectList = model.ProjectCodes.Select(a=> new TrackingMessageMainProjectInfo + ProjectList = model.ProjectCodes.Select(a => new TrackingMessageMainProjectInfo { ServiceProjectCode = a, }).ToList() @@ -2114,7 +2109,7 @@ namespace Myshipping.Application var timeDiff = ts.TotalMilliseconds; _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") - ,JSON.Serialize(rlt)); + , JSON.Serialize(rlt)); if (!rlt.succ) { @@ -2127,7 +2122,7 @@ namespace Myshipping.Application } } - catch(Exception ex) + catch (Exception ex) { result.succ = false; result.msg = $"服务项目保存失败,原因:{ex.Message}"; @@ -2439,7 +2434,8 @@ namespace Myshipping.Application DateTime bDate = DateTime.Now; - QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus { + QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus + { BookingId = model.BookingId, QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, TenantId = bookingOrder.TenantId.Value @@ -2451,9 +2447,9 @@ namespace Myshipping.Application TimeSpan ts = eDate.Subtract(bDate); var timeDiff = ts.TotalMilliseconds; - _logger.LogInformation("批次={no} id={id} 单票请求服务项目结果 耗时:{timeDiff}ms. ", batchNo, model.BookingId,timeDiff); + _logger.LogInformation("批次={no} id={id} 单票请求服务项目结果 耗时:{timeDiff}ms. ", batchNo, model.BookingId, timeDiff); } - catch(Exception ex) + catch (Exception ex) { result.succ = false; result.msg = $"获取服务项目列表失败,原因:{ex.Message}"; @@ -2537,9 +2533,9 @@ namespace Myshipping.Application try { - var rlt = await _bookingOrderService.SendBookingOrder(ids); + var rlt = await _bookingOrderService.SendBookingOrder(ids); - if(rlt != null) + if (rlt != null) { result.succ = true; result.msg = "同步完成"; @@ -2605,7 +2601,7 @@ namespace Myshipping.Application var curStr = reader.GetString(); Int32 curVal = 0; Int32.TryParse(curStr, out curVal); - return curVal; + return curVal; } else { From cb852bf3537a88007589f677be83a8464063f2af Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Tue, 6 Feb 2024 15:42:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E8=88=B1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9A=84=E6=97=A5=E5=BF=97=EF=BC=9A=E6=B4=BE?= =?UTF-8?q?=E8=BD=A6=E4=BB=BB=E5=8A=A1=E5=9B=9E=E5=86=99=E3=80=81=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=9B=B4=E6=96=B0=E8=88=B9=E6=9C=9F=E5=90=8E=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=9B=B4=E6=96=B0=E8=AE=A2=E8=88=B1=E3=80=81=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E8=BF=90=E8=B8=AA=E3=80=81=E6=89=A7=E8=A1=8C=E9=82=AE?= =?UTF-8?q?=E4=BB=B6Draft=E6=AF=94=E5=AF=B9=E3=80=81=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E9=82=AE=E4=BB=B6Draft=E6=AF=94=E5=AF=B9=EF=BC=88=E5=90=AB?= =?UTF-8?q?=E6=9C=89=E9=99=84=E4=BB=B6=EF=BC=89=E3=80=81=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AE=A2=E8=88=B1=E8=B4=A7=E7=89=A9=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 10 ++++-- .../BookingOrder/BookingValueAddedService.cs | 4 +-- .../BookingOrder/IBookingOrderService.cs | 13 +++---- .../BookingTruck/BookingTruckService.cs | 34 ++++++++++++------- .../BookingVesselInfoService.cs | 3 ++ .../Service/BookingYunZong/BookingYunZong.cs | 24 +++++++------ .../TaskManagePlat/TaskDraftCompareService.cs | 10 ++++++ 7 files changed, 65 insertions(+), 33 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index f7df8d77..526e4df1 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -10486,7 +10486,7 @@ namespace Myshipping.Application { var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); - + var oldModel = model.Adapt(); model.BSSTATUSNAME = maxStatus.ShowName; @@ -10622,8 +10622,9 @@ namespace Myshipping.Application /// /// /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// 调用方模块名 /// - public async Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false) + public async Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false, string fromFunc = null) { var bookingOrder = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); @@ -10650,6 +10651,8 @@ namespace Myshipping.Application var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); + var oldModel = model.Adapt(); + if (maxStatus != null) { model.BSSTATUSNAME = maxStatus.ShowName; @@ -10669,6 +10672,9 @@ namespace Myshipping.Application //it.VERSION }).ExecuteCommand(); + // 保存日志 + await SaveLog(model, oldModel, fromFunc); + //推送东胜 if (isAutoSyncDS) //推送东胜 diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index b545223a..43c4a571 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2304,7 +2304,7 @@ namespace Myshipping.Application result.succ = true; result.msg = "推送成功"; - await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true); + await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true, "手动设置订舱货物状态(启用)"); } } @@ -2398,7 +2398,7 @@ namespace Myshipping.Application result.succ = true; result.msg = "推送成功"; - await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true); + await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true, "手动设置订舱货物状态(取消)"); } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index f3e3c38f..bf64ce55 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -10,10 +10,10 @@ namespace Myshipping.Application { public interface IBookingOrderService { - + Task Delete(string Ids); - + Task Get(long Id); Task> GetLog(long Id); @@ -26,19 +26,19 @@ namespace Myshipping.Application Task AddFile(IFormFile file, [FromForm] BookingFileDto dto); Task> GetFile(long Id); - + Task> GetBookingStatusLog(long Id); - + /// /// 发送订舱、截单EDI /// /// 订舱、截单EDI请求 /// 返回回执 - Task SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model); + Task SendBookingOrClosingEDI(BookingOrClosingEDIOrderDto model); Task BachUpdate(BatchUpdate dto); @@ -106,8 +106,9 @@ namespace Myshipping.Application /// /// /// 是否默认同步东胜 true-自动同步 false-不自动同步 + /// 调用方模块名 /// - Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false); + Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false, string fromFunc = null); /// /// 检查是否VOLTA并返回初始数据 diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index 0e7cd3ac..1d2ab9e7 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -498,7 +498,7 @@ namespace Myshipping.Application model.YARDID = orderInfo.YARDID; model.YARD = orderInfo.YARD; - + model.InYardID = orderInfo.YARDID; model.InYard = orderInfo.YARD; model.MBLNo = orderInfo.MBLNO; @@ -509,7 +509,7 @@ namespace Myshipping.Application model.ClosingTime = orderInfo.CLOSINGDATE; - if(orderInfo.CLOSINGDATE.HasValue) + if (orderInfo.CLOSINGDATE.HasValue) { model.ReturnTime = orderInfo.CLOSINGDATE.Value; } @@ -641,7 +641,7 @@ namespace Myshipping.Application if (lastBookingTruckModel.KGS.HasValue) model.KGS = lastBookingTruckModel.KGS; - if(!string.IsNullOrWhiteSpace(lastBookingTruckModel.PayMethod)) + if (!string.IsNullOrWhiteSpace(lastBookingTruckModel.PayMethod)) model.PayMethod = lastBookingTruckModel.PayMethod; if (!string.IsNullOrWhiteSpace(lastBookingTruckModel.PayMethodName)) @@ -794,7 +794,7 @@ namespace Myshipping.Application string vesselVoyno = string.Empty; - if(!string.IsNullOrWhiteSpace(bookingOrder.VESSEL)) + if (!string.IsNullOrWhiteSpace(bookingOrder.VESSEL)) { vesselVoyno = bookingOrder.VESSEL; } @@ -835,7 +835,7 @@ namespace Myshipping.Application } }; - if(string.IsNullOrWhiteSpace(messageInfo.Main.TruckInfo.Vessel) + if (string.IsNullOrWhiteSpace(messageInfo.Main.TruckInfo.Vessel) && !string.IsNullOrWhiteSpace(bookingOrder.VESSEL)) { messageInfo.Main.TruckInfo.Vessel = bookingOrder.VESSEL; @@ -913,7 +913,7 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} id={id} 更新订舱的货物状态完成", batchNo, bookingOrder.Id); } - catch(Exception bkException) + catch (Exception bkException) { _logger.LogInformation("批次={no} id={id} 更新订舱的货物状态 YPC异常,原因:{erro}", batchNo, bookingOrder.Id, bkException.Message); } @@ -1020,7 +1020,7 @@ namespace Myshipping.Application /// 是否撤销后自动删除 true-删除 false-不删除 /// 返回回执 [HttpGet("/BookingTruck/Cancel")] - public async Task Cancel([FromQuery]long id, [FromQuery] bool isAfterDelete = false) + public async Task Cancel([FromQuery] long id, [FromQuery] bool isAfterDelete = false) { /* 撤销派车流程 @@ -1130,7 +1130,7 @@ namespace Myshipping.Application /// 批次号 /// 是否撤销后自动删除 true-删除 false-不删除 /// 返回回执 - private async Task InnerCancel(long id, string batchNo,bool isAfterDelete = false) + private async Task InnerCancel(long id, string batchNo, bool isAfterDelete = false) { /* 撤销派车流程 @@ -1222,7 +1222,7 @@ namespace Myshipping.Application { throw Oops.Oh($"请求撤销派车调度失败,原因={taskRlt.msg}", typeof(InvalidOperationException)); } - + //操作取消派车任务成功后,立即触发清空订舱的车队信息,并触发东胜同步删除 BookingTruckDto bookingTruckDto = model.Adapt(); @@ -1274,7 +1274,7 @@ namespace Myshipping.Application it.TaskNo }).ExecuteCommandAsync(); } - + result.succ = true; result.msg = "撤销成功"; } @@ -1854,7 +1854,7 @@ namespace Myshipping.Application } else if (operateType == OperateTypeEnum.Cancel) { - if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString() + if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString() && a.Status != BookingTruckStatus.SEND_DISPATCH.ToString())) { throw Oops.Oh($"派车状态只有已提交、已派车才能撤销派车", typeof(InvalidOperationException)); @@ -1941,7 +1941,9 @@ namespace Myshipping.Application if (bookingOrder != null) { - _logger.LogInformation("判断回写需要更新去掉订舱的车队 id={id} truckid={truckid} truck={truck}", + var oldOrder = bookingOrder.Adapt(); + + _logger.LogInformation("判断回写需要更新去掉订舱的车队 id={id} truckid={truckid} truck={truck}", bookingTruckInfo.BookingId.Value, bookingOrder.TRUCKERID, bookingOrder.TRUCKER); bookingOrder.TRUCKERID = null; @@ -1955,6 +1957,9 @@ namespace Myshipping.Application //it.VERSION }).ExecuteCommand(); + // 保存日志 + await _bookingOrderService.SaveLog(bookingOrder, oldOrder, "派车任务回写"); + var syncDongshengRlt = await _bookingOrderService.SendBookingOrder(new long[] { bookingTruckInfo.BookingId.Value }); _logger.LogInformation($"推送订舱同步东胜完毕,id={bookingTruckInfo.BookingId.Value} rlt={JSON.Serialize(syncDongshengRlt)}"); @@ -1976,6 +1981,8 @@ namespace Myshipping.Application { _logger.LogInformation("判断回写需要更新订舱的车队 id={id} truck={truck}", bookingTruckInfo.BookingId.Value, info.TruckName); + var oldOrder = bookingOrder.Adapt(); + bookingOrder.TRUCKERID = info.TruckCode; bookingOrder.TRUCKER = info.TruckName; //bookingOrder.VERSION = IDGen.NextID().ToString().Replace("-", ""); @@ -1987,6 +1994,9 @@ namespace Myshipping.Application //it.VERSION }).ExecuteCommand(); + // 保存日志 + await _bookingOrderService.SaveLog(bookingOrder, oldOrder, "派车任务回写"); + //这里直接调用订舱服务的功能,担心有异常所以这里单独做了异常捕获 try { diff --git a/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs b/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs index dee837ae..3b6c19bc 100644 --- a/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs +++ b/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs @@ -157,6 +157,8 @@ namespace Myshipping.Application _logger.LogInformation("手动更新船期:" + order.ToJsonString()); foreach (var it in order) { + var oldOrder = it.Adapt(); + bool flag = false; if (it.StartETA != dto.ETA) { @@ -209,6 +211,7 @@ namespace Myshipping.Application { issend = true; await _order.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync(); + await _bookingorderservice.SaveLog(it, oldOrder, "手动更新船期信息后批量更新订舱"); } } if (issend) diff --git a/Myshipping.Application/Service/BookingYunZong/BookingYunZong.cs b/Myshipping.Application/Service/BookingYunZong/BookingYunZong.cs index 4a4731d6..97c9c76a 100644 --- a/Myshipping.Application/Service/BookingYunZong/BookingYunZong.cs +++ b/Myshipping.Application/Service/BookingYunZong/BookingYunZong.cs @@ -16,6 +16,7 @@ using Furion.RemoteRequest.Extensions; using System.Net.Http; using Myshipping.Application.Service.BookingYunZong.Dto; using Myshipping.Core.Entity; +using Mapster; namespace Myshipping.Application { @@ -54,8 +55,9 @@ namespace Myshipping.Application [HttpPost("/BookingYunZong/RefreshYunZong")] public async Task RefreshYunZong(long[] Ids) { - var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id)&&x.IsDeleted==false&&x.ParentId==0&&x.IsBookingYZ!="0").ToListAsync(); - if (order==null|| order.Count==0) { + var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync(); + if (order == null || order.Count == 0) + { throw Oops.Bah("存在未订阅单据"); } @@ -70,7 +72,7 @@ namespace Myshipping.Application { throw Oops.Bah("未获取到相关SECRET,请联系管理员!"); } - + JArray jarrCZTemos = new JArray(); JArray jarrHLWTemos = new JArray(); JArray jarrYGTTemos = new JArray(); @@ -79,7 +81,7 @@ namespace Myshipping.Application if (!string.IsNullOrEmpty(item.YARDID) && !string.IsNullOrEmpty(item.MBLNO)) { - var YARDID= _cache.GetAllMappingYard().Result.Where(x => x.Module == "BillTrace" && x.Code == item.YARDID).Select(x => x.MapCode).FirstOrDefault(); + var YARDID = _cache.GetAllMappingYard().Result.Where(x => x.Module == "BillTrace" && x.Code == item.YARDID).Select(x => x.MapCode).FirstOrDefault(); JObject jobjczTemp = new JObject(); jobjczTemp.Add("web_code", new JValue(YARDID)); jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim())); @@ -163,7 +165,7 @@ namespace Myshipping.Application var mblno = item.GetValue("bno").ToString(); - var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno&&x.IsDeleted==false&&x.ParentId==0).Select(x => x.Id).FirstAsync(); + var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno && x.IsDeleted == false && x.ParentId == 0).Select(x => x.Id).FirstAsync(); var jarrInnerData = item.GetValue("data") as JArray; List yarddto = new List(); @@ -213,7 +215,7 @@ namespace Myshipping.Application BookingStatusLogDetail.OPTime = dt.TiXiangShiJian; await _statuslogdetail.InsertAsync(BookingStatusLogDetail); } - await _bookingorderservice.AutoYardData(bookingId); + await _bookingorderservice.AutoYardData(bookingId); } if (xl > 0 && fcnum > 0) { @@ -494,7 +496,7 @@ namespace Myshipping.Application bookingStatus.StaCate = "book_sta_cate_billtrace"; await _repBookingStatus.InsertAsync(bookingStatus); await _bookingorderservice.SetGoodsStatus("ZZFX", bookingOrder.Id); - + } } if (xl > 0 && wlnum > 0 && wlnum == xl) @@ -606,7 +608,7 @@ namespace Myshipping.Application foreach (var it in neworder) { - var _oldorder = it; + var _oldorder = it.Adapt(); if (it.ATD != SJLGShiJian) { it.ATD = SJLGShiJian; @@ -632,7 +634,7 @@ namespace Myshipping.Application foreach (var it in neworder) { - var _oldorder = it; + var _oldorder = it.Adapt(); if (it.StartETA != YJDGShiJian) { it.StartETA = YJDGShiJian; @@ -658,7 +660,7 @@ namespace Myshipping.Application foreach (var it in neworder) { - var _oldorder = it; + var _oldorder = it.Adapt(); if (it.StartATA != SJDGShiJian) { it.StartATA = SJDGShiJian; @@ -685,7 +687,7 @@ namespace Myshipping.Application foreach (var it in neworder) { - var _oldorder = it; + var _oldorder = it.Adapt(); if (it.YgtETD != YJLGShiJian) { it.YgtETD = YJLGShiJian; diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs index e0e6b051..6faeca1f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs @@ -229,6 +229,8 @@ namespace Myshipping.Application var entity = _bookingOrderRepository.AsQueryable().Filter(null, true) .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); + var oldEntity = entity.Adapt(); + entity.LstDraftCompareRlt = compareResult.extra2.Any(a => a.IsDiff) ? "DIFF" : "NO DIFF"; entity.LstDraftCompareDate = nowDate; @@ -239,6 +241,9 @@ namespace Myshipping.Application it.LstDraftCompareRlt }).ExecuteCommandAsync(); + // 保存日志 + await _bookingOrderService.SaveLog(entity, oldEntity, "执行邮件Draft比对"); + if (entity.LstDraftCompareRlt == "NO DIFF") { //推送状态 HDGSD-核对格式单 @@ -784,6 +789,8 @@ namespace Myshipping.Application var entity = _bookingOrderRepository.AsQueryable().Filter(null, true) .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); + var oldEntity = entity.Adapt(); + entity.LstDraftCompareRlt = compareResult.extra2.Any(a => a.IsDiff) ? "DIFF" : "NO DIFF"; entity.LstDraftCompareDate = nowDate; @@ -795,6 +802,9 @@ namespace Myshipping.Application }).ExecuteCommandAsync(); + // 添加日志 + await _bookingOrderService.SaveLog(entity, oldEntity, "执行邮件Draft比对(含有附件)"); + if (entity.LstDraftCompareRlt == "NO DIFF") { //推送状态 HDGSD-核对格式单