|
|
@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Interface;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
|
|
|
using LogicExtensions;
|
|
|
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Code.Method;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Code.Interface;
|
|
|
|
|
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Utils
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public class DingTalkGroupHelper : IDingTalkGroupHelper
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
|
|
|
|
private readonly ICodeThirdPartyService _codeThirdPartyService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DingTalkGroupHelper(IServiceProvider serviceProvider)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
|
|
|
_configService = serviceProvider.GetRequiredService<IConfigService>();
|
|
|
|
|
|
|
|
_codeThirdPartyService = serviceProvider.GetRequiredService<ICodeThirdPartyService>();
|
|
|
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 发送钉钉客服群组消息通知
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="code">钉钉群配置code</param>
|
|
|
|
|
|
|
|
/// <param name="title">标题</param>
|
|
|
|
|
|
|
|
/// <param name="content">内容</param>
|
|
|
|
|
|
|
|
public async Task SendDingTalkGroupMessage(string code, string title, string content)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dingdingCfg = db.Queryable<SysConfig>().Filter(null, true)
|
|
|
|
|
|
|
|
.Where(x => x.Code == code && x.TenantId == 1288018625843826688).First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var postdata = new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
text =
|
|
|
|
|
|
|
|
new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
content = $"【{title}】\r\n{content}\r\n----{dingdingCfg.Note}"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
msgtype = "text"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"准备发送钉钉消息:{postdata.ToJsonString()}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rtn = RequestHelper.Post(JsonConvert.SerializeObject(postdata), dingdingCfg.Value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"发送钉钉消息返回:{rtn}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 发送钉钉客服群组消息通知
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="code">钉钉群配置code</param>
|
|
|
|
|
|
|
|
/// <param name="title">标题</param>
|
|
|
|
|
|
|
|
/// <param name="content">内容</param>
|
|
|
|
|
|
|
|
/// <param name="atAll">@所有人</param>
|
|
|
|
|
|
|
|
/// <param name="atMobiles">@手机号数组</param>
|
|
|
|
|
|
|
|
/// <param name="atUserIds">@用户id数组</param>
|
|
|
|
|
|
|
|
public async Task SendDingTalkGroupMessage(string code, string title, string content, bool atAll, string[] atMobiles, string[] atUserIds)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dingdingCfg = db.Queryable<SysConfig>().Filter(null, true)
|
|
|
|
|
|
|
|
.Where(x => x.Code == code && x.TenantId == 1288018625843826688).First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var postdata = new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
text =
|
|
|
|
|
|
|
|
new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
content = $"【{title}】\r\n{content}\r\n----{dingdingCfg.Note}"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
msgtype = "text",
|
|
|
|
|
|
|
|
at = new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
isAtAll = atAll,
|
|
|
|
|
|
|
|
atMobiles = atMobiles,
|
|
|
|
|
|
|
|
atUserIds = atUserIds
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"准备发送钉钉消息:{postdata.ToJsonString()}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rtn = RequestHelper.Post(JsonConvert.SerializeObject(postdata), dingdingCfg.Value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"发送钉钉消息返回:{rtn}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface IDingTalkGroupHelper
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 发送钉钉客服群组消息通知
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="code">钉钉群配置code</param>
|
|
|
|
|
|
|
|
/// <param name="title">标题</param>
|
|
|
|
|
|
|
|
/// <param name="content">内容</param>
|
|
|
|
|
|
|
|
Task SendDingTalkGroupMessage(string code, string title, string content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 发送钉钉客服群组消息通知
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="code">钉钉群配置code</param>
|
|
|
|
|
|
|
|
/// <param name="title">标题</param>
|
|
|
|
|
|
|
|
/// <param name="content">内容</param>
|
|
|
|
|
|
|
|
/// <param name="atAll">@所有人</param>
|
|
|
|
|
|
|
|
/// <param name="atMobiles">@手机号数组</param>
|
|
|
|
|
|
|
|
/// <param name="atUserIds">@用户id数组</param>
|
|
|
|
|
|
|
|
Task SendDingTalkGroupMessage(string code, string title, string content, bool atAll, string[] atMobiles, string[] atUserIds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|