Commit 16d3a83d authored by 罗超's avatar 罗超

新增业务单据推送

parent 3eeb0325
using Edu.Common.Enum.System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace Edu.Common.Plugin
{
/// <summary>
/// 企业微信推送
/// </summary>
public class PushWorkChatHelper
{
/// <summary>
/// 推送企业消息
/// </summary>
/// <param name="content">内容</param>
/// <param name="receiveid">接收人(全部:@all,多个:“LuoChao|HuangDaSha”,单个:“LuoChao”)</param>
/// <param name="title">标题</param>
/// <param name="workmsgType">类型,默认为markdown,还支持news,如果要拓展其他类型,需要到System里面拓展</param>
/// <param name="JumpUrl">跳转地址</param>
public static void PushToWorkChat(string content,string receiveid,string title,string workmsgType= "markdown",string JumpUrl="")
{
Common.Message.PushMessageModel modelWork = new Common.Message.PushMessageModel()
{
CategoryId = PushMessageCategoryEnum.SalePeople,
Content = content,
CoverImg = "",
CreateByName = "系统",
JumpUrl = "",
WorkMsgType = workmsgType,
SendTime = DateTime.Now,
SendType = 0,
Title = title,
Platform = 5,
ReceiveId = receiveid
};
Common.Message.MessageHelper.SendMessage(modelWork);
}
}
}
using Edu.AOP.CustomerAttribute; using Edu.AOP.CustomerAttribute;
using Edu.Cache.User; using Edu.Cache.User;
using Edu.Common;
using Edu.Common.Enum.EduTask; using Edu.Common.Enum.EduTask;
using Edu.Common.Enum.User; using Edu.Common.Enum.User;
using Edu.Common.Plugin; using Edu.Common.Plugin;
...@@ -19,6 +20,7 @@ using Edu.Repository.User; ...@@ -19,6 +20,7 @@ using Edu.Repository.User;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web;
using VT.FW.DB; using VT.FW.DB;
namespace Edu.Module.EduTask namespace Edu.Module.EduTask
...@@ -97,6 +99,11 @@ namespace Edu.Module.EduTask ...@@ -97,6 +99,11 @@ namespace Edu.Module.EduTask
/// </summary> /// </summary>
private readonly RB_Class_TimeRepository class_TimeRepository = new RB_Class_TimeRepository(); private readonly RB_Class_TimeRepository class_TimeRepository = new RB_Class_TimeRepository();
/// <summary>
/// 用户仓储层
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary> /// <summary>
/// 获取教务单据分页列表 /// 获取教务单据分页列表
...@@ -682,6 +689,23 @@ namespace Edu.Module.EduTask ...@@ -682,6 +689,23 @@ namespace Edu.Module.EduTask
if (!string.IsNullOrEmpty(auditModel.RecipientIds)) if (!string.IsNullOrEmpty(auditModel.RecipientIds))
{ {
newRecipientIds = ((!string.IsNullOrEmpty(receipt.RecipientIds) ? receipt.RecipientIds : "") + "," + auditModel.RecipientIds).TrimStart(',').TrimEnd(','); newRecipientIds = ((!string.IsNullOrEmpty(receipt.RecipientIds) ? receipt.RecipientIds : "") + "," + auditModel.RecipientIds).TrimStart(',').TrimEnd(',');
#region 抄送通知
var notifyUsers = accountRepository.GetAccountListExtRepository(new RB_Account_ViewModel() {
QIds= newRecipientIds
});
if (notifyUsers != null && notifyUsers.Count() > 0)
{
notifyUsers.ForEach(x=> {
if (!string.IsNullOrEmpty(x.WorkUserId))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=3&id={receipt.Id}");
var content = $"<font color='info'>抄送通知</font> 你收到了一张{EnumHelper.ToName(receipt.ReceiptType)}单据抄送\n>**概要信息** \n>抄 送 人:<font color='comment'>{user.AccountName}</font>\n>单据编号:<font color='comment'>{receipt.Id}</font>\n>创 建 人:<font color='comment'>{UserReidsCache.GetUserLoginInfo(receipt.CreateBy).AccountName}</font>\n>申请时间:<font color='comment'>{receipt.CreateTime.ToString("MM-dd HH:mm")}</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={x.Id}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content,x.WorkUserId,"抄送通知");
}
});
}
#endregion
} }
//获取审核记录 //获取审核记录
var aurList = education_RecordRepository.GetEducationRecordListRepository(new RB_Education_Record_ViewModel() var aurList = education_RecordRepository.GetEducationRecordListRepository(new RB_Education_Record_ViewModel()
...@@ -733,6 +757,19 @@ namespace Edu.Module.EduTask ...@@ -733,6 +757,19 @@ namespace Edu.Module.EduTask
#region 更新审核记录表状态 #region 更新审核记录表状态
flag = UpdateEduRecordModule(WFRrocessStatus.AuditNotThrough, auditModel.Description, user.Id, amodel.Id); flag = UpdateEduRecordModule(WFRrocessStatus.AuditNotThrough, auditModel.Description, user.Id, amodel.Id);
if (flag) {
#region 驳回通知
var notifyUsers = accountRepository.GetWorkUserIdRepository(receipt.Id);
if (!string.IsNullOrEmpty(notifyUsers))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=0&id={receipt.Id}");
var content = $"`业务单据驳回` 你有一张业务单据被驳回\n>**概要信息** \n>审 批 人:<font color='warning'>{user.AccountName}</font>\n>单据信息:<font color='comment'>{EnumHelper.ToName(receipt.ReceiptType)}单据 ({receipt.Id})</font>\n>驳回时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>驳回理由:<font color='comment'>{auditModel.Description}</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={receipt.CreateBy}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, notifyUsers, "业务单据驳回通知");
}
#endregion
}
#endregion #endregion
#region 更新审核关联表状态 #region 更新审核关联表状态
...@@ -756,6 +793,8 @@ namespace Edu.Module.EduTask ...@@ -756,6 +793,8 @@ namespace Edu.Module.EduTask
}; };
flag = education_ReceiptRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Receipt_ViewModel.Id), receipt.Id)); flag = education_ReceiptRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Receipt_ViewModel.Id), receipt.Id));
flag = UpdateOtherModule(receipt, auditModel); flag = UpdateOtherModule(receipt, auditModel);
} }
//审核通过 //审核通过
else else
...@@ -912,6 +951,15 @@ namespace Edu.Module.EduTask ...@@ -912,6 +951,15 @@ namespace Edu.Module.EduTask
{nameof(RB_Education_Receipt_ViewModel.VerifyStatus),(int)EduTaskRrocessStatus.AuditThrough} {nameof(RB_Education_Receipt_ViewModel.VerifyStatus),(int)EduTaskRrocessStatus.AuditThrough}
}; };
flag = education_ReceiptRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Receipt_ViewModel.Id), receipt.Id)); flag = education_ReceiptRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Receipt_ViewModel.Id), receipt.Id));
#region 完成通知
var notifyUsers = accountRepository.GetWorkUserIdRepository(receipt.Id);
if (!string.IsNullOrEmpty(notifyUsers))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=0&id={receipt.Id}");
var content = $"<font color='info'>审核完成通知</font> 你有一张业务单据已审核完成\n>**概要信息** \n>审 批 人:<font color='warning'>{user.AccountName}</font>\n>单据信息:<font color='comment'>{EnumHelper.ToName(receipt.ReceiptType)}单据 ({receipt.Id})</font>\n>驳回时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>审批备注:<font color='info'>已完成</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={receipt.CreateBy}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, notifyUsers, "业务单据驳回通知");
}
#endregion
} }
//同时创建下一步审核 复制审核人到审核关联表 创建审核记录表 //同时创建下一步审核 复制审核人到审核关联表 创建审核记录表
else else
...@@ -1066,6 +1114,17 @@ namespace Edu.Module.EduTask ...@@ -1066,6 +1114,17 @@ namespace Edu.Module.EduTask
return false; return false;
} }
} }
#region 通过通知
var notifyUsers = accountRepository.GetWorkUserIdRepository(receipt.Id);
if (!string.IsNullOrEmpty(notifyUsers))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=0&id={receipt.Id}");
var content = $"<font color='info'>审核通知</font> 你有一张业务单据被通过\n>**概要信息** \n>审 批 人:<font color='warning'>{user.AccountName}</font>\n>单据信息:<font color='comment'>{EnumHelper.ToName(receipt.ReceiptType)}单据 ({receipt.Id})</font>\n>驳回时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>审批备注:<font color='warning'>进行中</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={receipt.CreateBy}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, notifyUsers, "业务单据驳回通知");
}
#endregion
Dictionary<string, object> fileds = new Dictionary<string, object>() Dictionary<string, object> fileds = new Dictionary<string, object>()
{ {
{nameof(RB_Education_Receipt_ViewModel.VerifyStatus),(int)EduTaskRrocessStatus.AuditIng} {nameof(RB_Education_Receipt_ViewModel.VerifyStatus),(int)EduTaskRrocessStatus.AuditIng}
...@@ -1300,6 +1359,24 @@ namespace Edu.Module.EduTask ...@@ -1300,6 +1359,24 @@ namespace Edu.Module.EduTask
} }
} }
InsertBatcheAuditRecord(empList, receiptModel.Id, auditRelevance); InsertBatcheAuditRecord(empList, receiptModel.Id, auditRelevance);
#region 下一步审批通知
var notifyUsers = accountRepository.GetAccountListExtRepository(new RB_Account_ViewModel()
{
QIds = string.Join(",", empList)
});
if (notifyUsers != null && notifyUsers.Count() > 0)
{
notifyUsers.ForEach(x =>
{
if (!string.IsNullOrEmpty(x.WorkUserId))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=1&id={receiptModel.Id}");
var content = $"待审通知 你有一张业务单据等待审核\n>**概要信息** \n>单据信息:<font color='comment'>{EnumHelper.ToName(receiptModel.ReceiptType)}单据 ({receiptModel.Id})</font>\n>创 建 人:<font color='comment'>{UserReidsCache.GetUserLoginInfo(receiptModel.CreateBy).AccountName}</font>\n>创建时间:<font color='comment'>{receiptModel.CreateTime.ToString("MM-dd HH-mm")}</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={x.Id}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, x.WorkUserId, "业务单据待审通知");
}
});
}
#endregion
} }
} }
return true; return true;
......
...@@ -12,6 +12,9 @@ using Edu.Repository.User; ...@@ -12,6 +12,9 @@ using Edu.Repository.User;
using Edu.Repository.Course; using Edu.Repository.Course;
using Edu.Repository.Grade; using Edu.Repository.Grade;
using Edu.Repository.Sell; using Edu.Repository.Sell;
using System.Web;
using Edu.Common.Plugin;
using Edu.Common;
namespace Edu.Repository.EduTask namespace Edu.Repository.EduTask
{ {
...@@ -410,12 +413,31 @@ WHERE 1=1 ...@@ -410,12 +413,31 @@ WHERE 1=1
recordModel.Id = 0; recordModel.Id = 0;
recordModel.AuditEmId = tItem; recordModel.AuditEmId = tItem;
flag = student_BackRecordRepository.Insert(recordModel) > 0; flag = student_BackRecordRepository.Insert(recordModel) > 0;
#region 审核通知
var account = new RB_AccountRepository().GetEmployeeInfo(tItem);
if (account!=null && !string.IsNullOrEmpty(account.WorkUserId))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=1&id={model.Id}");
var content = $"待审通知 你有一张业务单据等待审核\n>**概要信息** \n>单据信息:<font color='comment'>{EnumHelper.ToName(model.ReceiptType)}单据 ({model.Id})</font>\n>创 建 人:<font color='comment'>{account.EmployeeName}</font>\n>创建时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={tItem}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, account.WorkUserId, "业务单据待审通知");
}
#endregion
} }
} }
else else
{ {
recordModel.AuditEmId = subItem.UserId; recordModel.AuditEmId = subItem.UserId;
flag = student_BackRecordRepository.Insert(recordModel) > 0; flag = student_BackRecordRepository.Insert(recordModel) > 0;
#region 审核通知
var account = new RB_AccountRepository().GetEmployeeInfo(subItem.UserId);
if (account != null && !string.IsNullOrEmpty(account.WorkUserId))
{
var recipientPath = HttpUtility.UrlEncode($"/teacher/change-class-manager?tab=1&id={model.Id}");
var content = $"待审通知 你有一张业务单据等待审核\n>**概要信息** \n>单据信息:<font color='comment'>{EnumHelper.ToName(model.ReceiptType)}单据 ({model.Id})</font>\n>创 建 人:<font color='comment'>{account.EmployeeName}</font>\n>创建时间:<font color='comment'>{DateTime.Now.ToString("MM-dd HH-mm")}</font>\n>请点击:[查看详情]({Config.ErpUrl}/autologin?loginId={subItem.UserId}&target={recipientPath}";
PushWorkChatHelper.PushToWorkChat(content, account.WorkUserId, "业务单据待审通知");
}
#endregion
} }
} }
} }
......
...@@ -640,7 +640,7 @@ WHERE e.RB_Group_id ={GroupId} AND e.IsLeave =0 AND o.Score =0 GROUP BY e.Employ ...@@ -640,7 +640,7 @@ WHERE e.RB_Group_id ={GroupId} AND e.IsLeave =0 AND o.Score =0 GROUP BY e.Employ
var result = ExecuteScalar(sql, null); var result = ExecuteScalar(sql, null);
return !result.Equals(null)&&Convert.IsDBNull(result) ? string.Empty : result.ToString(); return result==null ? string.Empty : result.ToString();
} }
/// <summary> /// <summary>
......
...@@ -146,6 +146,9 @@ namespace Edu.WebApi.Controllers.EduTask ...@@ -146,6 +146,9 @@ namespace Edu.WebApi.Controllers.EduTask
SpecialNode = base.ParmJObj.GetInt("SpecialNode"), SpecialNode = base.ParmJObj.GetInt("SpecialNode"),
}; };
var flag = educationReceiptModule.AduitEducationReceiptModule(auditModel, base.UserInfo, out string message); var flag = educationReceiptModule.AduitEducationReceiptModule(auditModel, base.UserInfo, out string message);
return flag?ApiResult.Success():ApiResult.Failed(message: message); return flag?ApiResult.Success():ApiResult.Failed(message: message);
} }
......
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