diff --git a/src/WMS.Web.Domain/Services/Public/SendMessageService.cs b/src/WMS.Web.Domain/Services/Public/SendMessageService.cs
index e0eb25b5..2cc706ff 100644
--- a/src/WMS.Web.Domain/Services/Public/SendMessageService.cs
+++ b/src/WMS.Web.Domain/Services/Public/SendMessageService.cs
@@ -27,7 +27,7 @@ namespace WMS.Web.Domain.Services
///
/// 阿里云短息服务
///
- public class SendMessageService: ISendMessageService
+ public class SendMessageService : ISendMessageService
{
private readonly ILogger _logger;
private readonly IClientProfile profile;
@@ -41,7 +41,7 @@ namespace WMS.Web.Domain.Services
private readonly IErpService _erpService;
public SendMessageService(ILogger logger,
- IOptions emailOptions,
+ IOptions emailOptions,
IOptions smsOptions,
IInStockRepositories inStockRepositories,
IErpService erpService,
@@ -75,7 +75,7 @@ namespace WMS.Web.Domain.Services
request.SignName = _smsOptions.SignName; // 短信签名
//request.SignName = "深圳市元创时代"; // 短信签名
request.TemplateCode = _smsOptions.TemplateCode; // 短信模板编号
- request.TemplateParam = "{\"material\":\"" + content+"\"}"; // 模板参数,根据实际情况填写
+ request.TemplateParam = "{\"material\":\"" + content + "\"}"; // 模板参数,根据实际情况填写
try
{
@@ -87,13 +87,13 @@ namespace WMS.Web.Domain.Services
_logger.LogInformation($"短信发送消息:成功->短信签名:{_smsOptions.SignName}->手机号码:" + phoneNumbers + " 内容:" + content);
return Result.ReSuccess();
}
- else
+ else
{
_logger.LogInformation($"短信发送消息:失败->原因:{response.Message}->短信签名:{_smsOptions.SignName}->手机号码:" + phoneNumbers + " 内容:" + content);
- return Result.ReFailure(response.Code,6000);
+ return Result.ReFailure(response.Code, 6000);
}
-
+
}
catch (ServerException e)
{
@@ -105,7 +105,7 @@ namespace WMS.Web.Domain.Services
_logger.LogInformation($"短信发送消息:Client失败:{e.ErrorMessage}->手机号码:" + phoneNumbers + " 内容:" + content);
return Result.ReFailure(e.ErrorMessage, 6000);
}
-
+
}
///
@@ -114,7 +114,7 @@ namespace WMS.Web.Domain.Services
///
///
///
- public async Task SendEmail(List toMailList,string textBody,string coustomerName)
+ public async Task SendEmail(List toMailList, string textBody, string coustomerName)
{
// 创建 MimeMessage 实例
MimeMessage message = new MimeMessage();
@@ -123,7 +123,7 @@ namespace WMS.Web.Domain.Services
//message.To.Add(new MailboxAddress("Recipient Name", "244188119@qq.com")); // 设置收件人姓名和邮箱地址
message.To.AddRange(toMailList);
//message.Subject = _emailOptions.SendTitle+$"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"; // 设置邮件主题
- message.Subject =$"【元创时代】-产品入库通知{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"; // 设置邮件主题
+ message.Subject = $"【元创时代】-产品入库通知{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"; // 设置邮件主题
// 创建邮件正文
BodyBuilder bodyBuilder = new BodyBuilder();
@@ -141,13 +141,13 @@ namespace WMS.Web.Domain.Services
await client.SendAsync(message); // 发送邮件
await client.DisconnectAsync(true); // 断开连接
}
- _logger.LogInformation("邮箱发送消息:成功->收件方:"+JsonConvert.SerializeObject(toMailList)+" 内容:"+textBody);
+ _logger.LogInformation("邮箱发送消息:成功->收件方:" + JsonConvert.SerializeObject(toMailList) + " 内容:" + textBody);
return Result.ReSuccess();
}
catch (Exception ex)
{
_logger.LogInformation("邮箱发送消息:失败->收件方:" + JsonConvert.SerializeObject(toMailList) + " 内容:" + textBody);
- return Result.ReFailure("邮箱发送失败:"+ex.Message,50006);
+ return Result.ReFailure("邮箱发送失败:" + ex.Message, 50006);
}
}
@@ -155,7 +155,7 @@ namespace WMS.Web.Domain.Services
/// 获取数据
///
///
- public async Task>> GetSendContent()
+ public async Task>> GetSendContent()
{
//1.获取物料集合和组织集合和供应商的集合
var materials = new List();
@@ -164,29 +164,29 @@ namespace WMS.Web.Domain.Services
materials = materials_result.Data.ToList();
//客户
- var customerList= await _subscribeNotificationRepositories.GetList();
+ var customerList = await _subscribeNotificationRepositories.GetList();
//要处理发送的明细
- var notSendDetails=await _inStockTaskRepositories.GetNotSendErpDetails();
+ var notSendDetails = await _inStockTaskRepositories.GetNotSendErpDetails();
var sendDataList = new List();
- if (customerList != null && customerList.Count != 0)
+ if (customerList != null && customerList.Count != 0)
{
- if (notSendDetails != null && notSendDetails.Count != 0)
+ if (notSendDetails != null && notSendDetails.Count != 0)
{
- var taskIds= notSendDetails.GroupBy(x => x.Fid).Select(x => x.Key).ToList();
+ var taskIds = notSendDetails.GroupBy(x => x.Fid).Select(x => x.Key).ToList();
- var instockTotalDetails= await _inStockRepositories.GetInStockTotalDetails(taskIds);
+ var instockTotalDetails = await _inStockRepositories.GetInStockTotalDetails(taskIds);
foreach (var item in customerList)
- {
- var current_notSendDetails= notSendDetails.Where(x => x.CustomerCode == item.CustomerNumber).ToList();
- if (current_notSendDetails != null && current_notSendDetails.Count != 0)
+ {
+ var current_notSendDetails = notSendDetails.Where(x => x.CustomerCode == item.CustomerNumber).ToList();
+ if (current_notSendDetails != null && current_notSendDetails.Count != 0)
{
var data = new SendDataDto();
data.CustomerCode = item.CustomerNumber;
data.CustomerName = item.CustomerName;
data.PhoneNumbers = string.Join(",", item.Telephones);
- data.Emails= string.Join(",", item.Emails);
+ data.Emails = string.Join(",", item.Emails);
foreach (var ema in item.Emails)
{
data.EmailList.Add(new MailboxAddress("Recipient Name", ema));
@@ -199,7 +199,7 @@ namespace WMS.Web.Domain.Services
det.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, current_det.MaterialNumber);
det.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, current_det.MaterialNumber);
det.MaterialNumber = current_det.MaterialNumber;
- det.Qty=instockTotalDetails.Where(x => x.TaskId == current_det.Fid && x.MaterialNumber == current_det.MaterialNumber).Sum(x => x.Qty);
+ det.Qty = instockTotalDetails.Where(x => x.TaskId == current_det.Fid && x.MaterialNumber == current_det.MaterialNumber).Sum(x => x.Qty);
if (det.Qty > 0)
data.Details.Add(det);
}
@@ -219,7 +219,7 @@ namespace WMS.Web.Domain.Services
/// 执行
///
///
- public async Task Execute()
+ public async Task Execute()
{
try
{
@@ -232,7 +232,7 @@ namespace WMS.Web.Domain.Services
if (sendContentList != null && sendContentList.Count != 0)
{
-
+
foreach (var item in sendContentList)
{
@@ -242,7 +242,7 @@ namespace WMS.Web.Domain.Services
{
update_taskDetailsIds.Add(det.TaskDetailId);
if (i == item.Details.Count)
- content = det.Specifications + " X 数量" +Convert.ToInt32(det.Qty);
+ content = det.Specifications + " X 数量" + Convert.ToInt32(det.Qty);
else
content = det.Specifications + " X 数量" + Convert.ToInt32(det.Qty) + ",";
i = i + 1;
@@ -251,12 +251,12 @@ namespace WMS.Web.Domain.Services
//邮箱
await this.SendEmail(item.EmailList, content, item.CustomerName);
//短信
- var sms_result= this.SendSms(item.PhoneNumbers, content);
+ var sms_result = this.SendSms(item.PhoneNumbers, content);
//内容过长-分段发送
- if (!sms_result.IsSuccess && sms_result.Message== "isv.PARAM_LENGTH_LIMIT")
+ if (!sms_result.IsSuccess && sms_result.Message == "isv.PARAM_LENGTH_LIMIT")
{
//分段发送:以字数480长度分段
- var contentParts= this.SplitContent(content, 480);
+ var contentParts = this.SplitContent(content, 480);
foreach (var partContent in contentParts)
{
this.SendSms(item.PhoneNumbers, partContent);
@@ -266,30 +266,32 @@ namespace WMS.Web.Domain.Services
}
//任务明细:修改的
var tasksDetails = await _inStockTaskRepositories.GetDetailsList(update_taskDetailsIds.Distinct().ToList());
- if(tasksDetails!=null && tasksDetails.Count != 0)
+ if (tasksDetails != null && tasksDetails.Count != 0)
{
tasksDetails.ForEach(x => { x.IsHasSend = true; });
- var update_Result= await _inStockTaskRepositories.UpdateRange(tasksDetails);
+ var update_Result = await _inStockTaskRepositories.UpdateRange(tasksDetails);
if (!update_Result)
{
_logger.LogInformation("发送消息:失败-修改任务明细->:" + JsonConvert.SerializeObject(tasksDetails));
}
}
}
+ else
+ _logger.LogInformation("发送消息:暂无可发送的通知明细");
}
return Result.ReSuccess();
}
catch (Exception ex)
{
- return Result.ReFailure("发送失败:"+ex.Message,50006);
+ return Result.ReFailure("发送失败:" + ex.Message, 50006);
}
-
+
}
// 将消息分割成多个部分
- public List SplitContent(string content, int maxLength)
+ public List SplitContent(string content, int maxLength)
{
List parts = new List();