Commit 89893eaa authored by liudong1993's avatar liudong1993

1 增加企业微信消息推送

parent 46ecb9ca
......@@ -339,5 +339,13 @@ namespace REBORN.Common
return ReadConfigKey("PushAppId");
}
}
/// <summary>
/// 教育地址
/// </summary>
public static string EduPropertyDomainURL
{
get { return ConfigurationManager.AppSettings["EduPropertyDomainURL"] ?? "http://zcedu.oytour.com/#"; }
}
}
}
\ No newline at end of file
......@@ -60,6 +60,7 @@ namespace Property.Common.Message
message.CreateByName,
message.MsgSign,
message.MsgTemplateCode,
message.WorkMsgType,
Status = 0,
CreateTime = DateTime.Now,
AppId = Config.PushAppId,
......
......@@ -30,10 +30,10 @@ namespace Property.Common.Message
/// </summary>
public PushMessageCategoryEnum CategoryId { get; set; }
/// <summary>
/// 推送平台[1-手机端,2-Web端,3-短信,4-邮件]
/// </summary>
public int Platform { get; set; }
/// <summary>
/// 推送平台[1-手机端,2-Web端,3-短信,4-邮件, 5-企业微信]
/// </summary>
public int Platform { get; set; }
/// <summary>
/// 推送类型(0-立即推送,1-指定时间推送)
......@@ -55,10 +55,15 @@ namespace Property.Common.Message
/// </summary>
public string JumpUrl { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 企业微信消息类型
/// </summary>
public string WorkMsgType { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 短信模板代码
......
......@@ -91,5 +91,11 @@ namespace Property.Model.Entity
/// </summary>
public int ActivationStatus { get; set; }
/// <summary>
/// 用户企业微信ID
/// TODO 新增用户时添加此字段,使用用户手机号
/// </summary>
public string WorkUserId { get; set; }
}
}
......@@ -2229,6 +2229,43 @@ namespace Property.Module.FixedAssets
Common.Message.MessageHelper.SendMessage(SendList);
}
/// <summary>
/// 推送企业微信
/// </summary>
/// <param name="type">消息所属分类</param>
/// <param name="content">内容</param>
/// <param name="account">账户</param>
public void PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum type, string content, string title, List<EmAccoutIdModel> account, string jumpUrl)
{
#region 审批完成企业微信通知
List<Common.Message.PushMessageModel> SendList = new List<Common.Message.PushMessageModel>();
account.ForEach(x =>
{
var to = employeeRepository.GetUserWorkId(x.EmployeeId);
if (!string.IsNullOrEmpty(to))
{
var userContent = $"{content}请 点 击:[查看详情]({Config.EduPropertyDomainURL}/autologinqy?loginId={x.EmployeeId}&target={jumpUrl})";
Common.Message.PushMessageModel modelPubWork = new Common.Message.PushMessageModel()
{
CategoryId = type,
Content = userContent,
CoverImg = string.Empty,
CreateByName = x.EmAccount,
JumpUrl = string.Empty,
WorkMsgType = "markdown",
SendTime = DateTime.Now,
SendType = 0,
Title = title,
Platform = 5,
ReceiveId = to
};
SendList.Add(modelPubWork);
}
});
Common.Message.MessageHelper.SendMessage(SendList);
#endregion
}
/// <summary>
/// 获取审批日志
/// </summary>
......@@ -3998,6 +4035,10 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, demodel.Id, "您有待审核的请购信息", "请购审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.BuyingRequisition);
//推送企业微信
string markdownContent = $"`请购审核通知\n>**概要信息** \n>请购标题:{demodel.Name}\n>请购类型:{(demodel.Type == 1 ? "资产" : "耗材")}\n>申 请 人:<font color='warning'>{userInfo.emName}</font>\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/PurchaseRequisitionDetail?Id={demodel.Id}&backto=PurchaseRequisitionExamine&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.BuyingRequisition, markdownContent, "请购审核通知", sendAccount, JumpUrl);
}
}
}
......@@ -4074,6 +4115,10 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, Id, "您有待审核的请购信息", "请购审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.BuyingRequisition);
//推送企业微信
string markdownContent = $"`请购审核通知\n>**概要信息** \n>请购标题:{demodel.Name}\n>请购类型:{(demodel.Type == 1 ? "资产" : "耗材")}\n>申 请 人:<font color='warning'>{userInfo.emName}</font>\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/PurchaseRequisitionDetail?Id={demodel.Id}&backto=PurchaseRequisitionExamine&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.BuyingRequisition, markdownContent, "请购审核通知", sendAccount, JumpUrl);
}
}
}
......@@ -5087,6 +5132,11 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, StockInId, "您有待审核的资产采购入库信息", "入库审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit);
//推送企业微信
string markdownContent = $"`您有待审核的资产采购入库信息\n>**概要信息** \n>入库编号:{BMStr}\n>入库类型:资产\n>入库时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>入库备注:<font color='comment'>{demodel.Remark}</font>\n>入库人员:{userInfo.emName}\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/PropertrukuDetails?Id={StockInId}&backto=receiptApproval&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit, markdownContent, "入库审核通知", sendAccount, JumpUrl);
}
}
......@@ -5480,6 +5530,11 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, demodel.Id, "您有待审核的资产入库信息", "资产入库审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit);
//推送企业微信
string markdownContent = $"`您有待审核的资产采购入库信息\n>**概要信息** \n>入库编号:{oldModel.StockInNum}\n>入库类型:资产\n>入库时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>入库备注:<font color='comment'>{demodel.Remark}</font>\n>入库人员:{userInfo.emName}\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/PropertrukuDetails?Id={oldModel.Id}&backto=receiptApproval&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit, markdownContent, "资产入库审核通知", sendAccount, JumpUrl);
}
#endregion
}
......
......@@ -4856,6 +4856,11 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, Id, "您有待审核的耗材采购入库信息", "入库审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.SuppliesStokcInAudit);
//推送企业微信
string markdownContent = $"`您有待审核的耗材采购入库信息\n>**概要信息** \n>入库编号:{BMStr}\n>入库类型:耗材\n>入库时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>入库备注:<font color='comment'>{demodel.Remark}</font>\n>入库人员:{userInfo.emName}\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/rukuNewDetails?Id={Id}&backto=receiptApproval&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit, markdownContent, "入库审核通知", sendAccount, JumpUrl);
}
}
#region 更新采购单入库状态
......@@ -4938,6 +4943,43 @@ namespace Property.Module.FixedAssets
Common.Message.MessageHelper.SendMessage(SendList);
}
/// <summary>
/// 推送企业微信
/// </summary>
/// <param name="type">消息所属分类</param>
/// <param name="content">内容</param>
/// <param name="account">账户</param>
public void PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum type, string content, string title, List<EmAccoutIdModel> account, string jumpUrl)
{
#region 审批完成企业微信通知
List<Common.Message.PushMessageModel> SendList = new List<Common.Message.PushMessageModel>();
account.ForEach(x =>
{
var to = employeeRepository.GetUserWorkId(x.EmployeeId);
if (!string.IsNullOrEmpty(to))
{
var userContent = $"{content}请 点 击:[查看详情]({Config.EduPropertyDomainURL}/autologinqy?loginId={x.EmployeeId}&target={jumpUrl})";
Common.Message.PushMessageModel modelPubWork = new Common.Message.PushMessageModel()
{
CategoryId = type,
Content = userContent,
CoverImg = string.Empty,
CreateByName = x.EmAccount,
JumpUrl = string.Empty,
WorkMsgType = "markdown",
SendTime = DateTime.Now,
SendType = 0,
Title = title,
Platform = 5,
ReceiveId = to
};
SendList.Add(modelPubWork);
}
});
Common.Message.MessageHelper.SendMessage(SendList);
#endregion
}
/// <summary>
/// 获取流程模板
/// </summary>
......@@ -5098,6 +5140,11 @@ namespace Property.Module.FixedAssets
if (sendAccount.Any())
{
PushAuditMessage(sendAccount, demodel.Id, "您有待审核的耗材入库信息", "耗材入库审核通知", userInfo.EmployeeId, Common.Models.PushMessageCategoryEnum.SuppliesStokcInAudit);
//推送企业微信
string markdownContent = $"`您有待审核的耗材采购入库信息\n>**概要信息** \n>入库编号:{oldModel.StockInNum}\n>入库类型:耗材\n>入库时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>入库备注:<font color='comment'>{demodel.Remark}</font>\n>入库人员:{userInfo.emName}\n>";
string JumpUrl = System.Web.HttpUtility.UrlEncode($"/rukuNewDetails?Id={oldModel.Id}&backto=receiptApproval&showTable=1&compType=shenpi");
PushWeChatWorkAuditMsg(Common.Models.PushMessageCategoryEnum.PropertyStokcInAudit, markdownContent, "耗材入库审核通知", sendAccount, JumpUrl);
}
#endregion
}
......
......@@ -558,5 +558,18 @@ WHERE 1=1
}
return Get<RB_Account_ViewModel>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取指定人员的企业微信ID
/// </summary>
/// <param name="id">教师编号</param>
/// <returns></returns>
public string GetUserWorkId(int id)
{
string sql = $"select {nameof(RB_Account_ViewModel.WorkUserId)} from {nameof(RB_Account)} where {nameof(RB_Account_ViewModel.Id)}={id}";
var result = ExecuteScalar(sql, null);
return result == null ? string.Empty : result.ToString();
}
}
}
\ No newline at end of file
......@@ -144,5 +144,87 @@ namespace Property.WebApi.Controllers.Login
return ApiResult.Success(data: obj);
}
}
/// <summary>
/// 企业微信自动登录
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult UserLoginQY(object requestMsg) {
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
JObject jobj = JObject.Parse(requestParm.msg.ToString());
int loginId = jobj.GetInt("LoginId", 0);
var model = accountModule.GetAccountListExtModule(new RB_Account_ViewModel()
{
Id = loginId
})?.FirstOrDefault();
if (model == null)
{
return ApiResult.Failed(message: $"未找到【{ loginId }】用户!");
}
else
{
if (model.Status == DateStateEnum.Delete)
{
return ApiResult.Failed(message: $"此账号【{ loginId }】已禁用,如需使用请联系管理员!");
}
if (model.LeaveStatus == 4)
{
return ApiResult.Failed(message: $"此账号【{ loginId }】已离职,无法登陆!");
}
var treeList = menuModule.GetPostMenuTreeModule(new RB_Menu_ViewModel()
{
MenuType = 1
}, out List<RB_Menu_ViewModel> userCenterList, postIds: model.Post_Id.ToString());
TokenUserInfo userInfo = new TokenUserInfo { uid = model.Id.ToString(), requestFrom = ApiRequestFromEnum.ERP };
string token = "";
#region JWT
IDateTimeProvider provider = new UtcDateTimeProvider();
var now = provider.GetNow().AddMinutes(-1);
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); // or use JwtValidator.UnixEpoch
var secondsSinceEpoch = Math.Round((now - unixEpoch).TotalSeconds);
var payload = new Dictionary<string, object>
{
{"iat",secondsSinceEpoch },
{"exp",secondsSinceEpoch+Config.JwtExpirTime},
{"edu_userInfo",userInfo }
};
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new JsonNetSerializer();
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
string secret = Config.JwtSecretKey;
token = encoder.Encode(payload, secret);
#endregion
UserInfo obj = new UserInfo
{
GroupName = model.GroupName,
GroupPic = model.GroupLogo,
Domain = "zc",
BranchName = model.SchoolName,
DepartName = model.DeptName,
PostName = model.PostName,
emName = model.AccountName,
EmployeeId = model.Id,
RB_Group_id = model.Group_Id,
RB_Branch_id = model.School_Id,
RB_Post_Id = model.Post_Id,
RB_Department_Id = model.Dept_Id,
token = token,
FileDomain = Config.GetOssFileUrl,
Icon = model.UserIcon
};
CacheManager.User.UserReidsCache.UserInfoSet(UserModuleCacheKeyConfig.USER_Login_Info + model.Id, obj, Config.JwtExpirTime);
obj.UserMenu = treeList;
return ApiResult.Success(data: obj);
}
}
}
}
......@@ -2,9 +2,9 @@
"ConnectionStrings": {
"DefaultConnection": "server=192.168.20.214;port=3306;user id=reborn;password=Reborn@2018;database=reborn_user;CharSet=utf8; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"PropertyConnection": "server=192.168.20.214;port=3306;user id=reborn;password=Reborn@2018;database=test_property;CharSet=utf8; Convert Zero Datetime=true; ",
"PropertyConnection": "server=192.168.20.214;port=3306;user id=reborn;password=Reborn@2018;database=property;CharSet=utf8; Convert Zero Datetime=true; ",
"PropertyConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.20.214;port=3306;user id=reborn;password=Reborn@2018;database=test_reborn_finance;CharSet=utf8; Convert Zero Datetime=true; ",
"FinanceConnection": "server=192.168.20.214;port=3306;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient",
"LogConnection": "server=192.168.2.214;port=3306;user id=reborn;password=Reborn@2018;database=reborn_log;CharSet=utf8; Convert Zero Datetime=true; ",
"LogConnectionPName": "MySql.Data.MySqlClient",
......@@ -32,7 +32,7 @@
"ImSecret": "66000451fb72",
"FinanceKey": "FinanceMallInsertToERPViitto2020",
"OutCurrencyId": 1,
"PaymentFinanceApi": "http://192.168.20.9:8083/api/Mall/InsertFinanceBatchForMallOut",
"PaymentFinanceApi": "http://192.168.20.6:8083/api/Mall/InsertFinanceBatchForMallOut",
"ExpendDirector": 1756, //财务支出创建人
"ExpendBranchId": 49, //财务支出创建人公司
"ExpendDepartment": 331,
......@@ -52,5 +52,6 @@
},
//消息推送AppId
"PushAppId": "JiaHeJiaoYu",
"EduPropertyDomainURL": "http://zcedu.oytour.com/#",
"accessSiteStr": "http://testzcys.oytour.com,http://testzc2erp.oytour.com,http://testzc3erp.oytour.com"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment