Commit d36429b6 authored by liudong1993's avatar liudong1993

OKR提醒

parent d216690f
...@@ -212,6 +212,17 @@ namespace Edu.Education.Helper ...@@ -212,6 +212,17 @@ namespace Edu.Education.Helper
{ {
LogHelper.Write(ex, "CreateOKRPeriod"); LogHelper.Write(ex, "CreateOKRPeriod");
} }
try
{
LogHelper.Write("开始提醒....");
//OKRPeriodModule oKRPeriodModule = new OKRPeriodModule();
//oKRPeriodModule.SendOKRRemid();
}
catch (Exception ex)
{
LogHelper.Write(ex, "SendOKRRemid");
}
return null; return null;
} }
} }
......
...@@ -4336,7 +4336,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -4336,7 +4336,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
CreateBy = userInfo.Id, CreateBy = userInfo.Id,
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id, Group_Id = userInfo.Group_Id,
LogContent = "修改OKR目标关键结果进度【" + model.Id + "】", LogContent = "修改OKR目标关键结果【" + model.Id + "】进度为【" + progress + "】",
School_Id = userInfo.School_Id, School_Id = userInfo.School_Id,
SourceId = 0 SourceId = 0
}); });
...@@ -4394,7 +4394,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -4394,7 +4394,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
CreateBy = userInfo.Id, CreateBy = userInfo.Id,
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id, Group_Id = userInfo.Group_Id,
LogContent = "修改OKR目标关键结果进度【" + model.Id + "】", LogContent = "修改OKR目标关键结果【" + model.Id + "】进度为【" + progress + "】",
School_Id = userInfo.School_Id, School_Id = userInfo.School_Id,
SourceId = 0 SourceId = 0
}); });
...@@ -4546,7 +4546,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -4546,7 +4546,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
CreateBy = userInfo.Id, CreateBy = userInfo.Id,
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id, Group_Id = userInfo.Group_Id,
LogContent = "修改OKR关键结果得分【" + keyResultId + "】", LogContent = "修改OKR关键结果【" + keyResultId + "】得分为【" + score + "】",
School_Id = userInfo.School_Id, School_Id = userInfo.School_Id,
SourceId = 0 SourceId = 0
}); });
...@@ -5912,6 +5912,161 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -5912,6 +5912,161 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
#endregion #endregion
#region 提醒通知
/// <summary>
/// 发送提醒通知
/// </summary>
/// <param name="GroupId"></param>
/// <returns></returns>
public bool SendOKRRemid() {
var rlist = oKR_RemindRepository.GetList(new RB_OKR_Remind_ViewModel() { Enable = 1 });
if (rlist.Any()) {
var groupIdList = rlist.Select(x => x.Group_Id).Distinct().ToList();
foreach (var GroupId in groupIdList)
{
try
{
//获取当前周期
var currentModel = oKR_PeriodRepository.GetList(new RB_OKR_Period_ViewModel() { Group_Id = GroupId, IsCurrent = 1, IsNormal = 1, IsYear = 2 }).FirstOrDefault();
if (currentModel == null) { return false; }
var r1Model = rlist.Where(x => x.Type == 1).FirstOrDefault();
var r2Model = rlist.Where(x => x.Type == 2).FirstOrDefault();
var r3Model = rlist.Where(x => x.Type == 3).FirstOrDefault();
var r4Model = rlist.Where(x => x.Type == 4).FirstOrDefault();
if (r1Model != null && !string.IsNullOrEmpty(r1Model.Days))
{
int Days = (DateTime.Now - currentModel.StartDate).Days + 1;
if (("," + r1Model.Days + ",").Contains("," + Days + ","))
{
//查询该员工未填写OKR / 未提交审核OKR
var nlist = accountRepository.GetOKRUserNotObjectiveList(GroupId);
foreach (var item in nlist)
{
//发送通知 看通知接口 是否支持定时发送
}
}
}
if (r2Model != null && !string.IsNullOrEmpty(r2Model.Days))
{
int Days = (currentModel.EndDate - DateTime.Now).Days + 1;
if (("," + r2Model.Days + ",").Contains("," + Days + ","))
{
//查询员工有未打分的目标
var nlist = accountRepository.GetOKRUserNotScoreList(GroupId);
foreach (var item in nlist)
{
//发送通知
}
}
}
if (r3Model != null && !string.IsNullOrEmpty(r3Model.Days))
{
int Days = (DateTime.Now - currentModel.StartDate).Days + 1;
if (("," + r1Model.Days + ",").Contains("," + Days + ","))
{
//查询该员工未填写OKR / 未提交审核OKR
var nlist = accountRepository.GetOKRUserNotObjectiveList(GroupId);
foreach (var item in nlist)
{
//查找其上级
var amodel = accountRepository.GetEntity(item.EmployeeId);
if (amodel.DirectSupervisor > 0)
{
//有直属上级 直接给直属上级推
}
else
{
//看其是否是部门主管
var dlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = item.RB_Group_id, ManagerIds = item.EmployeeId.ToString() });
if (dlist.Any())
{
//是部门主管 查找其上级部门负责人
foreach (var qitem in dlist)
{
var dmodel = departmentRepository.GetEntity(qitem.ParentId);
if (!string.IsNullOrEmpty(dmodel.ManagerIds))
{
//给上级部门负责人推送
}
}
}
else
{
//查询其当前部门负责人
var dmodel = departmentRepository.GetEntity(item.RB_Department_Id);
if (!string.IsNullOrEmpty(dmodel.ManagerIds))
{
//给部门负责人推送
}
}
}
}
}
}
if (r4Model != null && !string.IsNullOrEmpty(r4Model.Days))
{
int Days = (currentModel.EndDate - DateTime.Now).Days + 1;
if (("," + r2Model.Days + ",").Contains("," + Days + ","))
{
//查询员工有未打分的目标
var nlist = accountRepository.GetOKRUserNotScoreList(GroupId);
foreach (var item in nlist)
{
//查找其上级
var amodel = accountRepository.GetEntity(item.EmployeeId);
if (amodel.DirectSupervisor > 0)
{
//有直属上级 直接给直属上级推
}
else
{
//看其是否是部门主管
var dlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = item.RB_Group_id, ManagerIds = item.EmployeeId.ToString() });
if (dlist.Any())
{
//是部门主管 查找其上级部门负责人
foreach (var qitem in dlist)
{
var dmodel = departmentRepository.GetEntity(qitem.ParentId);
if (!string.IsNullOrEmpty(dmodel.ManagerIds))
{
//给上级部门负责人推送
}
}
}
else
{
//查询其当前部门负责人
var dmodel = departmentRepository.GetEntity(item.RB_Department_Id);
if (!string.IsNullOrEmpty(dmodel.ManagerIds))
{
//给部门负责人推送
}
}
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "SendOKRRemid【" + GroupId + "】");
}
}
}
return true;
}
#endregion
#region 统计模块 #region 统计模块
/// <summary> /// <summary>
......
...@@ -54,6 +54,10 @@ namespace Edu.Repository.OKR ...@@ -54,6 +54,10 @@ namespace Edu.Repository.OKR
{ {
where += $@" and {nameof(RB_OKR_Remind_ViewModel.Type)} ={demodel.Type}"; where += $@" and {nameof(RB_OKR_Remind_ViewModel.Type)} ={demodel.Type}";
} }
if (demodel.Enable > 0)
{
where += $@" and {nameof(RB_OKR_Remind_ViewModel.Enable)} ={demodel.Enable}";
}
string sql = $@" select * from RB_OKR_Remind where {where} order by Id desc"; string sql = $@" select * from RB_OKR_Remind where {where} order by Id desc";
return Get<RB_OKR_Remind_ViewModel>(sql).ToList(); return Get<RB_OKR_Remind_ViewModel>(sql).ToList();
......
...@@ -442,5 +442,30 @@ WHERE 1=1 ...@@ -442,5 +442,30 @@ WHERE 1=1
} }
return Get<RB_Account_ViewModel>(builder.ToString(), parameters).ToList(); return Get<RB_Account_ViewModel>(builder.ToString(), parameters).ToList();
} }
/// <summary>
/// 获取OKR未填写目标的用户
/// </summary>
/// <param name="GroupId"></param>
/// <returns></returns>
public List<RB_Employee_Extend> GetOKRUserNotObjectiveList(int GroupId) {
string sql = $@"SELECT e.* FROM rb_employee e
LEFT JOIN rb_okr_objective o on e.EmployeeId = o.CreateBy AND o.`Status` in(1,2)
WHERE e.RB_Group_id ={GroupId} AND e.IsLeave =0 AND o.Id is null";
return Get<RB_Employee_Extend>(sql).ToList();
}
/// <summary>
/// 获取OKR未打分目标的用户
/// </summary>
/// <param name="GroupId"></param>
/// <returns></returns>
public List<RB_Employee_Extend> GetOKRUserNotScoreList(int GroupId)
{
string sql = $@"SELECT e.* FROM rb_employee e
LEFT JOIN rb_okr_objective o on e.EmployeeId = o.CreateBy AND o.`Status` =2
WHERE e.RB_Group_id ={GroupId} AND e.IsLeave =0 AND o.Score =0 GROUP BY e.EmployeeId";
return Get<RB_Employee_Extend>(sql).ToList();
}
} }
} }
\ No newline at end of file
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