Commit f50aa0c3 authored by liudong1993's avatar liudong1993

OKR数据分布

parent c1a76b8a
......@@ -24,6 +24,16 @@ namespace Edu.Model.ViewModel.OKR
/// </summary>
public int ObjectiveId { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum { get; set; }
/// <summary>
/// 目标创建人
/// </summary>
public string CreateByIds { get; set; }
/// <summary>
/// 父级id
/// </summary>
......@@ -87,6 +97,16 @@ namespace Edu.Model.ViewModel.OKR
/// </summary>
public string EmPhoto { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DeptName { get; set; }
/// <summary>
/// 岗位
/// </summary>
public string PostName { get; set; }
/// <summary>
/// 分数名称
/// </summary>
......
......@@ -18,6 +18,11 @@ namespace Edu.Model.ViewModel.User
/// </summary>
public string GroupName { get; set; }
/// <summary>
/// 查询账户正常 1是
/// </summary>
public int IsSelectLevelNor { get; set; }
/// <summary>
/// 学校名称
/// </summary>
......
......@@ -5285,11 +5285,11 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<int> GetMyUnderlingUserIdList(UserInfo userInfo, int DeptId = 0)
public List<int> GetMyUnderlingUserIdList(UserInfo userInfo, int DeptId = 0, int PostId = 0)
{
List<int> UserIdList = new List<int>();
#region 我的直属下级
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id, Dept_Id = DeptId });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id, Dept_Id = DeptId, Post_Id = PostId });
if (emList.Any())
{
foreach (var item in emList)
......@@ -5303,7 +5303,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
if (xjdlist.Any())
{
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)), Post_Id = PostId });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
if (em1List.Any())
{
......@@ -5326,7 +5326,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
string ManagerIds = string.Join(",", d2list.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
if (!string.IsNullOrEmpty(ManagerIds))
{
em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QIds = ManagerIds });
em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QIds = ManagerIds, Post_Id = PostId });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
......@@ -7159,6 +7159,239 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
}
#endregion
#region 数据分布
/// <summary>
/// 获取个人数据分布
/// </summary>
/// <param name="periodId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetOKRGRDateDistribution(int periodId, UserInfo userInfo, bool IsAdmin = false)
{
var userIdList = new List<int>();
if (IsAdmin == false)
{
//首先查询用户的所有直属下级
userIdList = GetMyUnderlingUserIdList(userInfo);
}
else {
var accountList = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, IsSelectLevelNor = 1 });
userIdList = accountList.Select(x => x.Id).ToList();
}
//直接查询所有的objective
var olist = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = periodId, CreateByIds = string.Join(",", userIdList), Status = 2 });
//查询出每个人的objective的数量
var objectiveNumList = new List<RB_OKR_Objective_ViewModel>();
foreach (var item in userIdList) {
objectiveNumList.Add(new RB_OKR_Objective_ViewModel()
{
CreateBy = item,
ObjectiveNum = olist.Where(x => x.CreateBy == item).Count()
});
}
List<object> ObjectiveNum = new List<object>();
List<int> Group = new List<int>() { 0, 1, 3, 6, 9 };
for (var i = 0; i < Group.Count(); i++)
{
int ONum = 0;
if (i == Group.Count() - 1)
{
int StartV = Group[i];
int EndV = -1;
ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV).Count();
if (ONum > 0)
{
ObjectiveNum.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
else
{
int StartV = Group[i];
int EndV = Group[i + 1] - 1;
if (StartV == 0)
{
ONum = objectiveNumList.Where(x => x.ObjectiveNum == 0).Count();
}
else
{
ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV && x.ObjectiveNum <= EndV).Count();
}
if (ONum > 0)
{
ObjectiveNum.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
}
//查询目标状态
List<object> ObjectiveState = new List<object>();
var ProgressStateList = EnumHelper.EnumToList(typeof(Common.Enum.OKR.ProgressStateEnum));
foreach (var item in ProgressStateList)
{
ObjectiveState.Add(new
{
ProgressState = item.Id,
item.Name,
Number = olist.Where(x => x.ProgressState == (Common.Enum.OKR.ProgressStateEnum)item.Id).Count()
});
}
//查询目标进度
List<object> ObjectiveProgress = new List<object>();
List<int> Progress = new List<int>() { 0, 1, 31, 61, 91 };
for (var i = 0; i < Progress.Count(); i++)
{
int ONum = 0;
if (i == Progress.Count() - 1)
{
int StartV = Progress[i];
int EndV = -1;
ONum = olist.Where(x => x.Progress >= StartV).Count();
if (ONum > 0)
{
ObjectiveProgress.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
else
{
int StartV = Progress[i];
int EndV = Progress[i + 1] - 1;
if (StartV == 0)
{
ONum = olist.Where(x => x.Progress == 0).Count();
}
else
{
ONum = olist.Where(x => x.Progress >= StartV && x.Progress <= EndV).Count();
}
if (ONum > 0)
{
ObjectiveProgress.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
}
//查询目标分数
List<object> ObjectiveScore = new List<object>();
List<double> Score = new List<double>() { 0, 0.01, 0.31, 0.61, 0.91 };
for (var i = 0; i < Score.Count(); i++)
{
int ONum = 0;
if (i == Score.Count() - 1)
{
decimal StartV = Convert.ToDecimal(Score[i]);
int EndV = -1;
ONum = olist.Where(x => x.Score >= StartV).Count();
if (ONum > 0)
{
ObjectiveScore.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
else
{
decimal StartV = Convert.ToDecimal(Score[i]);
decimal EndV = Convert.ToDecimal(Score[i + 1] - 0.01);
if (StartV == 0)
{
ONum = olist.Where(x => x.Score == 0).Count();
}
else
{
ONum = olist.Where(x => x.Score >= StartV && x.Score <= EndV).Count();
}
if (ONum > 0)
{
ObjectiveScore.Add(new
{
Start = StartV,
End = EndV,
Number = ONum
});
}
}
}
return new
{
ObjectiveNum,
ObjectiveState,
ObjectiveProgress,
ObjectiveScore
};
}
/// <summary>
/// 获取个人数据分布明细
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="periodId"></param>
/// <param name="type"></param>
/// <param name="startValue"></param>
/// <param name="endValue"></param>
/// <param name="orderBy"></param>
/// <param name="userInfo"></param>
/// <param name="IsAdmin"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRGRDateDistributionDetail(int pageIndex, int pageSize, out long count, int periodId, int type, int startValue, int endValue, int orderBy, UserInfo userInfo, bool IsAdmin = false)
{
count = 0;
var userIdList = new List<int>();
if (IsAdmin == false)
{
//首先查询用户的所有直属下级
userIdList = GetMyUnderlingUserIdList(userInfo);
}
string userIds = string.Join(",", userIdList);
List<RB_OKR_Objective_ViewModel> RList = new List<RB_OKR_Objective_ViewModel>();
switch (type)
{
case 1: //数量
RList = oKR_ObjectiveRepository.GetObjectiveNumPageList(pageIndex, pageSize, out count, periodId, startValue, endValue, orderBy, userIds, userInfo.Group_Id);
break;
case 2: //状态
RList = oKR_ObjectiveRepository.GetObjectiveStatePageList(pageIndex, pageSize, out count, periodId, startValue, orderBy, userIds, userInfo.Group_Id);
break;
case 3: //进度
RList = oKR_ObjectiveRepository.GetObjectiveProgressPageList(pageIndex, pageSize, out count, periodId, startValue, endValue, orderBy, userIds, userInfo.Group_Id);
break;
case 4: //打分
RList = oKR_ObjectiveRepository.GetObjectiveScorePageList(pageIndex, pageSize, out count, periodId, startValue, endValue, orderBy, userIds, userInfo.Group_Id);
break;
}
return RList;
}
#endregion
#region 春姐 统计
/// <summary>
/// 获取个人维度打分以及目标量
/// </summary>
......@@ -7299,6 +7532,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{
return oKR_ObjectiveRepository.GetAllEmployeeOKRPList(query);
}
#endregion
}
}
......@@ -83,6 +83,10 @@ namespace Edu.Repository.OKR
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (!string.IsNullOrEmpty(demodel.CreateByIds))
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} in({demodel.CreateByIds})";
}
if (demodel.Status > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Status)} ={demodel.Status}";
......@@ -92,6 +96,64 @@ namespace Edu.Repository.OKR
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取objective数量 统计
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetObjectiveNumList(RB_OKR_Objective_ViewModel demodel)
{
string where = $@" 1=1 and Status =2";
if (demodel.Group_Id > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.PeriodId > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if (demodel.CreateBy > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (!string.IsNullOrEmpty(demodel.CreateByIds))
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} in({demodel.CreateByIds})";
}
string sql = $@" select CreateBy,Count(0) as ObjectiveNum from RB_OKR_Objective where {where} group by CreateBy";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取objective状态 统计
/// </summary>
/// <param name="rB_OKR_Objective_ViewModel"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetObjectiveStateList(RB_OKR_Objective_ViewModel demodel)
{
string where = $@" 1=1 and Status =2";
if (demodel.Group_Id > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.PeriodId > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if (demodel.CreateBy > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (!string.IsNullOrEmpty(demodel.CreateByIds))
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.CreateBy)} in({demodel.CreateByIds})";
}
string sql = $@" select ProgressState,CreateBy,Count(0) as ObjectiveNum from RB_OKR_Objective where {where} group by ProgressState,CreateBy";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取父级列表
/// </summary>
......@@ -435,5 +497,60 @@ WHERE 1=1 {5}
var list = Get<OKRPersonalDimension>( sql, parameters).ToList();
return list;
}
#region 数据分布明细
public List<RB_OKR_Objective_ViewModel> GetObjectiveNumPageList(int pageIndex, int pageSize, out long count, int periodId, int startValue, int endValue, int orderBy, string userIds, int group_Id)
{
string sql = $@"
select * from(
select e.EmployeeId AS CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,SUM(CASE WHEN o.Id is null THEN 0 ELSE 1 END) as ObjectiveNum
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy AND o.PeriodId ={periodId} AND o.Status =2
where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ? "and e.EmployeeId in (" + userIds + ")" : "")} group by e.EmployeeId
)t where t.ObjectiveNum >={startValue} {(endValue >= 0 ? "and t.ObjectiveNum <=" + endValue : "")} order by t.ObjectiveNum {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveStatePageList(int pageIndex, int pageSize, out long count, int periodId, int startValue, int orderBy, string userIds, int group_Id)
{
string sql = $@"
select * from(
select o.CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,count(0) as ObjectiveNum
from RB_OKR_Objective o
LEFT JOIN rb_employee e on e.EmployeeId = o.CreateBy
where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.ProgressState ={startValue} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ? "and o.CreateBy in (" + userIds + ")" : "")} group by o.CreateBy
)t order by t.ObjectiveNum {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveProgressPageList(int pageIndex, int pageSize, out long count, int periodId, int startValue, int endValue, int orderBy, string userIds, int group_Id)
{
string sql = $@"
select * from(
select o.CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,count(0) as ObjectiveNum
from RB_OKR_Objective o
LEFT JOIN rb_employee e on e.EmployeeId = o.CreateBy
where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Progress >={startValue} {(endValue >= 0 ? "and o.Progress <=" + endValue : "")} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ? "and o.CreateBy in (" + userIds + ")" : "")} group by o.CreateBy
)t order by t.ObjectiveNum {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveScorePageList(int pageIndex, int pageSize, out long count, int periodId, int startValue, int endValue, int orderBy, string userIds, int group_Id)
{
string sql = $@"
select * from(
select o.CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,count(0) as ObjectiveNum
from RB_OKR_Objective o
LEFT JOIN rb_employee e on e.EmployeeId = o.CreateBy
where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Score >={startValue} {(endValue >= 0 ? "and o.Score <=" + endValue : "")} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ? "and o.CreateBy in (" + userIds + ")" : "")} group by o.CreateBy
)t order by t.ObjectiveNum {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
#endregion
}
}
......@@ -142,6 +142,10 @@ WHERE 1=1
{
where2.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.Post_Id), query.Post_Id);
}
if (query.IsSelectLevelNor == 1)
{
where.AppendFormat(" AND B.{0} <>4 ", nameof(Employee_ViewModel.LeaveStatus));
}
}
StringBuilder builder = new StringBuilder();
......
......@@ -1774,6 +1774,58 @@ namespace Edu.WebApi.Controllers.OKR
}
}
/// <summary>
/// 获取个人端数据分布
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRGRDateDistribution()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);//周期id
int IsAdmin = parms.GetInt("IsAdmin", 2);//是否管理端查询 1是 2否
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
var obj = okrPeriodModule.GetOKRGRDateDistribution(PeriodId, userInfo, IsAdmin == 1 ? true : false);
return ApiResult.Success("", obj);
}
/// <summary>
/// 获取个人端数据分布明细
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRGRDateDistributionDetail() {
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 IsAdmin = parms.GetInt("IsAdmin", 2);//是否管理端查询 1是 2否
int Type = parms.GetInt("Type", 1);//1234 对应4项统计
int StartValue = parms.GetInt("StartValue", 0);//开始值
int EndValue = parms.GetInt("EndValue", 0);//结束值
int OrderBy = parms.GetInt("OrderBy", 2);// 1升序 2降序
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
var list = okrPeriodModule.GetOKRGRDateDistributionDetail(pageModel.PageIndex,pageModel.PageSize, out long count, PeriodId, Type, StartValue, EndValue, OrderBy, userInfo, IsAdmin == 1 ? true : false);
pageModel.Count = Convert.ToInt32(count);
pageModel.PageData = list.Select(x => new
{
x.CreateBy,
x.EmName,
x.EmPhoto,
x.DeptName,
x.PostName,
x.ObjectiveNum
});
return ApiResult.Success("", pageModel);
}
#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