Commit d52d61a9 authored by liudong1993's avatar liudong1993

OKR概率统计

parent d635a653
......@@ -16,16 +16,54 @@ namespace Edu.Common.Enum.OKR
[EnumField("请提醒 Ta 们尽快填写,避免重点工作实施受到影响")]
NotFilled = 1,
/// <summary>
/// 未对齐OKR
/// </summary>
[EnumField("请提醒 Ta 们尽快对齐,避免重点工作实施受到影响")]
NotAlign = 2,
/// <summary>
/// 有OKR未更新进度
/// </summary>
[EnumField("请提醒 Ta 及时更新,对 OKR 结果进行复盘")]
NotUpdated = 2,
NotUpdated = 3,
/// <summary>
/// 有OKR未打分
/// </summary>
[EnumField("请提醒 Ta 及时打分,对 OKR 结果进行复盘")]
NotScore = 3
NotScore = 4,
/// <summary>
/// 填写率对比上周期下降
/// </summary>
[EnumField("请关注员工对 OKR 填写的重视程度")]
Write = 5,
/// <summary>
/// 对齐率对比上周期下降
/// </summary>
[EnumField("请关注员工对 OKR 对齐的重视程度")]
Align = 6,
/// <summary>
/// 更新率对比上周期下降
/// </summary>
[EnumField("请关注员工对 OKR 更新的重视程度")]
Update = 7,
/// <summary>
/// 打分率对比上周期下降
/// </summary>
[EnumField("请关注员工对 OKR 打分的重视程度")]
Score = 8,
/// <summary>
/// 有@他人的未对齐
/// </summary>
[EnumField("请提醒 Ta 们对齐 OKR, 避免重点工作实施受到影响")]
Others = 9,
/// <summary>
/// 有@我的未对齐
/// </summary>
[EnumField("请及时对齐 OKR, 避免重点工作实施受到影响")]
My = 10,
}
}
This diff is collapsed.
......@@ -824,6 +824,191 @@ WHERE e.RB_Group_id={groupId} and e.EmployeeId in({userIds}) and o.Status <>5 an
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取人员填写分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetWritePageList(int pageIndex, int pageSize, out long count, int groupId, int periodId, string userIds, int orderBy)
{
string sql = $@"
select * from(
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (SELECT o.CreateBy FROM rb_okr_objective o WHERE o.Group_Id ={groupId} and o.Status <>5 and o.PeriodId={periodId} and o.CreateBy in({userIds}) GROUP BY o.CreateBy) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.EmployeeId in({userIds})
)tt order by tt.Status {(orderBy == 1 ? "asc" : "desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取人员对齐分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetAlignPageList(int pageIndex, int pageSize, out long count, int groupId, int periodId, string userIds, int orderBy)
{
string sql = $@"
select * from(
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (
SELECT o.CreateBy FROM rb_okr_objective o
INNER JOIN rb_okr_objectiverelation re on re.ObjectiveId = o.Id
WHERE o.Group_Id={groupId} and o.Status <>5 and o.PeriodId={periodId} and o.CreateBy in({userIds}) GROUP BY o.CreateBy
) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.EmployeeId in({userIds})
)tt order by tt.Status {(orderBy == 1 ? "asc" : "desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取人员最近更新分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetUpdatePageList(int pageIndex, int pageSize, out long count, int groupId, int periodId, string userIds, string date, int orderBy)
{
string sql = $@"
select * from(
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,
CASE WHEN t.UserId IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (
SELECT UserId FROM rb_okr_updateprogress WHERE Group_Id={groupId} and PeriodId={periodId} and UpdateTime >= '{date}' and UserId in ({userIds}) GROUP BY UserId
) t ON e.EmployeeId = t.UserId
WHERE e.RB_Group_id={groupId} and e.EmployeeId in({userIds})
)tt order by tt.Status {(orderBy == 1 ? "asc" : "desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取人员未打分分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetScorePageList(int pageIndex, int pageSize, out long count, int groupId, int periodId, string userIds, int orderBy)
{
string sql = $@"
select * from(
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (SELECT o.CreateBy FROM rb_okr_objective o WHERE o.Group_Id ={groupId} and o.Status <>5 and o.PeriodId={periodId} and o.Score >0 and o.CreateBy in({userIds}) GROUP BY o.CreateBy) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.EmployeeId in({userIds})
)tt order by tt.Status {(orderBy == 1 ? "asc" : "desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取人员填写列表
/// </summary>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="deptIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetWriteList(int groupId, int periodId, string deptIds)
{
string sql = $@"
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,e.RB_Department_Id,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (SELECT o.CreateBy FROM rb_okr_objective o WHERE o.Group_Id ={groupId} and o.Status <>5 and o.PeriodId={periodId} GROUP BY o.CreateBy) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.RB_Department_Id in({deptIds})
";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取人员对齐分页列表
/// </summary>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="deptIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetAlignList(int groupId, int periodId, string deptIds)
{
string sql = $@"
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,e.RB_Department_Id,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (
SELECT o.CreateBy FROM rb_okr_objective o
INNER JOIN rb_okr_objectiverelation re on re.ObjectiveId = o.Id
WHERE o.Group_Id={groupId} and o.Status <>5 and o.PeriodId={periodId} GROUP BY o.CreateBy
) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.RB_Department_Id in({deptIds})
";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取人员最近更新分页列表
/// </summary>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetUpdateList(int groupId, int periodId, string deptIds, string date)
{
string sql = $@"
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,e.RB_Department_Id,
CASE WHEN t.UserId IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (
SELECT UserId FROM rb_okr_updateprogress WHERE Group_Id={groupId} and PeriodId={periodId} and UpdateTime >= '{date}' GROUP BY UserId
) t ON e.EmployeeId = t.UserId
WHERE e.RB_Group_id={groupId} and e.RB_Department_Id in({deptIds})
";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取人员未打分分页列表
/// </summary>
/// <param name="groupId"></param>
/// <param name="periodId"></param>
/// <param name="deptIds"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetScoreList(int groupId, int periodId, string deptIds)
{
string sql = $@"
SELECT e.EmployeeId as CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,e.RB_Department_Id,
CASE WHEN t.CreateBy IS NOT NULL THEN 1 ELSE 2 END AS Status FROM
rb_employee e
LEFT JOIN (SELECT o.CreateBy FROM rb_okr_objective o WHERE o.Group_Id ={groupId} and o.Status <>5 and o.PeriodId={periodId} and o.Score >0 GROUP BY o.CreateBy) t ON e.EmployeeId = t.CreateBy
WHERE e.RB_Group_id={groupId} and e.RB_Department_Id in({deptIds})
";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
#endregion
#region 概率查询
......
......@@ -82,5 +82,19 @@ namespace Edu.Repository.OKR
string sql = $" UPDATE rb_okr_period SET IsNormal =2 WHERE Group_Id={GroupId} AND IsNormal =1 AND IsYear =2";
return Execute(sql)> 0;
}
/// <summary>
/// 获取上一周期id
/// </summary>
/// <param name="id"></param>
/// <param name="isYear"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public int GetLastPeriodId(int id, int isYear, int group_Id)
{
string sql = $@"SELECT Id FROM rb_okr_period WHERE Id <{id} and IsNormal = 1 and IsYear = {isYear} and Group_Id ={group_Id} ORDER BY Id DESC LIMIT 1";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
}
}
using Edu.Common.Enum;
using Edu.Common.Enum.User;
using Edu.Model.ViewModel.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -135,6 +136,10 @@ WHERE 1=1
{
where.AppendFormat(" AND A.{0}='{1}' ", nameof(RB_Account_ViewModel.OpenId), query.OpenId);
}
if (!string.IsNullOrEmpty(query.AccountName))
{
where2.AppendFormat(" AND A.{0} like '%{1}%' ", nameof(RB_Account_ViewModel.AccountName), query.AccountName);
}
if (!string.IsNullOrEmpty(query.PostName))
{
where2.AppendFormat(" AND p.{0}='{1}' ", nameof(RB_Account_ViewModel.PostName), query.PostName);
......@@ -265,7 +270,7 @@ FROM
) AS t
", where.ToString());
var obj = ExecuteScalar(builder.ToString());
return obj != null ? (int)obj : 0;
return obj != null ? Convert.ToInt32(obj) : 0;
}
......
......@@ -2001,6 +2001,7 @@ namespace Edu.WebApi.Controllers.OKR
int PeriodId = parms.GetInt("PeriodId", 0);//周期id
int IsAdmin = parms.GetInt("IsAdmin", 2);//是否管理端查询 1是 2否
int Type = parms.GetInt("Type", 1);//1234 对应4项统计
string UserName = parms.GetStringValue("UserName");//用户名称
int OrderBy = parms.GetInt("OrderBy", 2);// 1升序 2降序
int OrderByNum = parms.GetInt("OrderByNum", 1);// 以第几个排序
int RangeType = parms.GetInt("RangeType", 1);//范围类型 非管理端查询 1所有下级 2直属下级
......@@ -2016,7 +2017,7 @@ namespace Edu.WebApi.Controllers.OKR
RangeType = 0;
}
OrderByNum = OrderByNum == 0 ? 1 : OrderByNum;
var list = okrPeriodModule.GetOKRGRDateDistributionDetail_V2(pageModel.PageIndex, pageModel.PageSize, out long count, PeriodId, Type, OrderBy, OrderByNum, RangeType, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
var list = okrPeriodModule.GetOKRGRDateDistributionDetail_V2(pageModel.PageIndex, pageModel.PageSize, out long count, PeriodId, UserName, Type, OrderBy, OrderByNum, RangeType, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
pageModel.Count = Convert.ToInt32(count);
pageModel.PageData = list;
return ApiResult.Success("", pageModel);
......@@ -2150,6 +2151,69 @@ namespace Edu.WebApi.Controllers.OKR
var obj = okrPeriodModule.GetOKRProbabilityInfo(PeriodId, RangeType, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
return ApiResult.Success("", obj);
}
/// <summary>
/// 获取概率明细 - 人员
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRProbabilityPageListForEmp() {
var userInfo = base.UserInfo;
var pageModel = JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);//周期id
int SelectType = parms.GetInt("SelectType", 0);//类型 1填写率 2对齐率 3更新率 4打分率
int OrderBy = parms.GetInt("OrderBy", 1);//排序 1已填写在前 2未填写在前
string UserName = parms.GetStringValue("UserName");//用户名称
int IsAdmin = parms.GetInt("IsAdmin", 2);//是否管理端查询 1是 2否
int RangeType = parms.GetInt("RangeType", 1);//范围类型 非管理端查询 1所有下级 2直属下级
string DepartId = parms.GetStringValue("DepartId");//部门ID 管理端可用查询
int PostId = parms.GetInt("PostId", 0);//岗位ID
int LeaveStatus = parms.GetInt("LeaveStatus", 0);//在职状态
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
if (IsAdmin == 1)
{
RangeType = 0;
}
var list = okrPeriodModule.GetOKRProbabilityPageListForEmp(pageModel.PageIndex, pageModel.PageSize, out long count, PeriodId, SelectType, OrderBy, UserName, RangeType, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
pageModel.Count = Convert.ToInt32(count);
pageModel.PageData = list.Select(x => new
{
EmpId = x.CreateBy,
x.EmName,
x.EmPhoto,
x.DeptName,
x.PostName,
x.Status
});
return ApiResult.Success("", pageModel);
}
/// <summary>
/// 获取概率明细 - 部门
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRProbabilityPageListForDept()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);//周期id
int SelectType = parms.GetInt("SelectType", 0);//类型 1填写率 2对齐率 3更新率 4打分率
int IsAdmin = parms.GetInt("IsAdmin", 2);//是否管理端查询 1是 2否
string DepartId = parms.GetStringValue("DepartId");//部门ID 管理端可用查询
int PostId = parms.GetInt("PostId", 0);//岗位ID
int LeaveStatus = parms.GetInt("LeaveStatus", 0);//在职状态
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
var list = okrPeriodModule.GetOKRProbabilityPageListForDept(PeriodId, SelectType, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
return ApiResult.Success("", list);
}
#endregion
......
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