From 2a59bf6eaed221b221271d60772da4b04451849f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 9 Oct 2023 11:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=BC=E5=BC=8F=E5=8D=95?= =?UTF-8?q?=E6=AF=94=E5=AF=B9=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?API=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/TaskDraftCompareService.cs | 26 +++++++------- .../ServiceWorkFlowManageService.cs | 35 +++---------------- 2 files changed, 17 insertions(+), 44 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs index 5a763c3f..5bb02dfb 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs @@ -72,7 +72,7 @@ namespace Myshipping.Application /// 请求文件 /// 邮件Draft比对请求报文 /// 返回回执 - [AllowAnonymous,HttpPost("/TaskDraftCompare/ExcuteEmailDraftCompare")] + [AllowAnonymous,HttpPost("/TaskDraftCompare/ExcuteEmailDraftCompare"), ApiUser(ApiCode = "ExcuteEmailDraftCompare")] public async Task ExcuteEmailDraftCompareAsync(IFormFile file, [FromForm] string jsonData) { string batchNo = IDGen.NextID().ToString(); @@ -161,7 +161,7 @@ namespace Myshipping.Application } var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) - .First(a => a.MBLNO.Equals(billNo) && !a.IsDeleted && a.TenantId == long.Parse(model.Main.TenantId)); + .First(a => a.MBLNO.Equals(billNo) && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); if (bookingOrder == null) { @@ -194,12 +194,12 @@ namespace Myshipping.Application var userInfo = _sysUserRepository.AsQueryable().First(a => a.Id == bookingOrder.CreatedUserId); mainInfo.BusiPKId = bookingOrder.Id.ToString(); - mainInfo.UserId = bookingOrder.CreatedUserId.ToString(); - mainInfo.UserName = bookingOrder.CreatedUserName; - mainInfo.UserEmail = userInfo?.Email; + mainInfo.UserId = UserManager.UserId.ToString(); + mainInfo.UserName = UserManager.Name; + mainInfo.UserEmail = UserManager.Email; var contaList = _bookingOrderContaRepository.AsQueryable().Filter(null,true) - .Where(x => x.BILLID == bookingOrder.Id && !x.IsDeleted && x.TenantId == long.Parse(model.Main.TenantId)).ToList(); + .Where(x => x.BILLID == bookingOrder.Id && !x.IsDeleted && x.TenantId == UserManager.TENANT_ID).ToList(); _logger.LogInformation("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count); @@ -227,7 +227,7 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 对应请求报文完成 msg={msg}", batchNo, JSON.Serialize(msgModel)); var entity = _bookingOrderRepository.AsQueryable().Filter(null, true) - .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == long.Parse(model.Main.TenantId)); + .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); entity.LstDraftCompareRlt = compareResult.extra2.Any(a => a.IsDiff) ? "DIFF" : "NO DIFF"; entity.LstDraftCompareDate = nowDate; @@ -598,7 +598,7 @@ namespace Myshipping.Application /// 请求附件文件 /// 邮件Draft比对请求报文 /// 返回回执 - [AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailAttachedSheetDraftCompare")] + [AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailAttachedSheetDraftCompare"), ApiUser(ApiCode = "ExcuteEmailDraftCompare")] public async Task ExcuteEmailAttachedSheetDraftCompareAsync(IFormFile file, IFormFile fileAttach, string jsonData) { string batchNo = IDGen.NextID().ToString(); @@ -748,12 +748,12 @@ namespace Myshipping.Application var userInfo = _sysUserRepository.AsQueryable().First(a => a.Id == bookingOrder.CreatedUserId); mainInfo.BusiPKId = bookingOrder.Id.ToString(); - mainInfo.UserId = bookingOrder.CreatedUserId.ToString(); - mainInfo.UserName = bookingOrder.CreatedUserName; - mainInfo.UserEmail = userInfo?.Email; + mainInfo.UserId = UserManager.UserId.ToString(); + mainInfo.UserName = UserManager.Name; + mainInfo.UserEmail = UserManager.Email; var contaList = _bookingOrderContaRepository.AsQueryable().Filter(null, true) - .Where(x => x.BILLID == bookingOrder.Id && !x.IsDeleted && x.TenantId == long.Parse(model.Main.TenantId)) + .Where(x => x.BILLID == bookingOrder.Id && !x.IsDeleted && x.TenantId == UserManager.TENANT_ID) .ToList(); _logger.LogInformation("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count); @@ -782,7 +782,7 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 对应请求报文完成 msg={msg}", batchNo, JSON.Serialize(msgModel)); var entity = _bookingOrderRepository.AsQueryable().Filter(null, true) - .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == long.Parse(model.Main.TenantId)); + .First(a => a.Id == bookingOrder.Id && !a.IsDeleted && a.TenantId == UserManager.TENANT_ID); entity.LstDraftCompareRlt = compareResult.extra2.Any(a => a.IsDiff) ? "DIFF" : "NO DIFF"; entity.LstDraftCompareDate = nowDate; diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index c5be6701..8d5cd091 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -2224,20 +2224,6 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); - string operUserId = bookingOrder.CreatedUserId.ToString(); - string operUserName = bookingOrder.CreatedUserName; - - //这里因为没有登录所以导致异常,因为当前接口是不验证登录的所以这里加了异常捕获,异常后登录人从订舱上制单人取。 - try - { - operUserId = UserManager.UserId.ToString(); - operUserName = UserManager.Name; - } - catch (Exception ex) - { - _logger.LogInformation("批次={no} 这里因为是非登录请求接口所以自动捕获异常", batchNo); - } - TrackingMessageInfo msgInfo = new TrackingMessageInfo { Head = new TrackingMessageHeadInfo @@ -2263,8 +2249,8 @@ namespace Myshipping.Application OperTenantId = bookingOrder.TenantId.Value, OperTenantName = bookingOrder.TenantName, OpertType = TrackingOperTypeEnum.MANUAL, - OperUserId = operUserId, - OperUserName = operUserName, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, SourceType = model.SourceType, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo { @@ -2332,19 +2318,6 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); - string operUserId = bookingOrder.CreatedUserId.ToString(); - string operUserName = bookingOrder.CreatedUserName; - - try - { - operUserId = UserManager.UserId.ToString(); - operUserName = UserManager.Name; - } - catch (Exception ex) - { - _logger.LogInformation("批次={no} 这里因为是非登录请求接口所以自动捕获异常", batchNo); - } - TrackingMessageInfo msgInfo = new TrackingMessageInfo { Head = new TrackingMessageHeadInfo @@ -2370,8 +2343,8 @@ namespace Myshipping.Application OperTenantId = bookingOrder.TenantId.Value, OperTenantName = bookingOrder.TenantName, OpertType = TrackingOperTypeEnum.MANUAL, - OperUserId = operUserId, - OperUserName = operUserName, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, SourceType = model.SourceType, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo {