diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskCautionNoticeService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskCautionNoticeService.cs index ce0e6739..58cf8cd8 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskCautionNoticeService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskCautionNoticeService.cs @@ -21,6 +21,8 @@ using System.Net.Http; using Myshipping.Core.Helper; using NPOI.SS.Formula.Functions; using System.Reflection.Metadata; +using Furion; +using Myshipping.Application.Helper; namespace Myshipping.Application { @@ -135,19 +137,23 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(a.NOTIFY_EMAIL)) { //提取当前公共邮箱的配置 - DjyUserMailAccount publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" + DjyUserMailAccount publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == tenantId && x.ShowName == "PublicSend" && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); if (publicMailAccount == null) { //throw Oops.Oh($"提取公共邮箱配置失败,请在用户邮箱账号管理增加配置显示名为PublicSend或者配置个人邮箱"); + + _logger.LogInformation($"准备邮件通知通知给 uid={a.NOTIFY_USER_NAME} name={a.NOTIFY_USER_NAME},但是没有配置发送邮箱"); + + new EmailNoticeHelper().SendEmailNotice($"MBLNO={noticeInfo.MBL_NO} {cautionNoticeEnum.GetDescription()} 需要给推送邮件但是没有配公司邮箱", $"MBLNO={noticeInfo.MBL_NO} {cautionNoticeEnum.GetDescription()} 需要给推送邮件但是没有配公司邮箱", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList()); } EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { SendTo = a.NOTIFY_EMAIL, - Title = $"", - Body = $"", + Title = $"提单号:{noticeInfo.MBL_NO} {cautionNoticeEnum.GetDescription()}", + Body = $"提单号:{noticeInfo.MBL_NO} {cautionNoticeEnum.GetDescription()} {noticeInfo.NOTIFY_CONTENT}", Account = publicMailAccount.MailAccount?.Trim(), Password = publicMailAccount.Password?.Trim(), Server = publicMailAccount.SmtpServer?.Trim(), @@ -162,6 +168,9 @@ namespace Myshipping.Application var emailRlt = PushEmail(emailApiUserDefinedDto).GetAwaiter().GetResult(); _logger.LogInformation($"推送邮件完成,结果:{JSON.Serialize(emailRlt)}"); + + a.STATUS = emailRlt.succ ? "SUCC" : "FAILURE"; + a.STATUS_NAME = emailRlt.succ ? "成功" : "失败"; } } else if (a.NOTIFY_METHOD == CautionNoticeMethodEnum.DingDing.ToString()) @@ -172,13 +181,15 @@ namespace Myshipping.Application _logger.LogInformation($"钉钉通知完毕给 uid={a.NOTIFY_USER_NAME} name={a.NOTIFY_USER_NAME},内容:\r\n{noticeInfo.NOTIFY_CONTENT}"); + a.STATUS = "SUCC"; + a.STATUS_NAME = "成功"; } }); } } catch (Exception ex) { - + new EmailNoticeHelper().SendEmailNotice($"taskPKId={taskPKId} 有重要提醒任务发生异常", $"taskPKId={taskPKId} 有重要提醒任务发生异常 原因:{ex.Message}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList()); } return result;