Commit ca412231 authored by liudong1993's avatar liudong1993

OKR数据看板调整

parent 34d81ae3
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.OKR
{
/// <summary>
/// 事项类型枚举
/// </summary>
public enum MatterTypeEnum
{
/// <summary>
/// 未填写OKR
/// </summary>
[EnumField("未填写OKR")]
NotFilled = 1,
/// <summary>
/// 有OKR未更新进度
/// </summary>
[EnumField("有OKR未更新进度")]
NotUpdated = 2,
/// <summary>
/// 有OKR未打分
/// </summary>
[EnumField("有OKR未打分")]
NotScore = 3
}
}
...@@ -28,6 +28,26 @@ namespace Edu.Model.ViewModel.OKR ...@@ -28,6 +28,26 @@ namespace Edu.Model.ViewModel.OKR
/// 目标数量 /// 目标数量
/// </summary> /// </summary>
public int ObjectiveNum { get; set; } public int ObjectiveNum { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum1 { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum2 { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum3 { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum4 { get; set; }
/// <summary>
/// 目标数量
/// </summary>
public int ObjectiveNum5 { get; set; }
/// <summary> /// <summary>
/// 目标创建人 /// 目标创建人
...@@ -102,6 +122,11 @@ namespace Edu.Model.ViewModel.OKR ...@@ -102,6 +122,11 @@ namespace Edu.Model.ViewModel.OKR
/// </summary> /// </summary>
public string EmPhoto { get; set; } public string EmPhoto { get; set; }
/// <summary>
/// 部门id
/// </summary>
public int RB_Department_Id { get; set; }
/// <summary> /// <summary>
/// 部门名称 /// 部门名称
/// </summary> /// </summary>
......
...@@ -23,6 +23,11 @@ namespace Edu.Model.ViewModel.User ...@@ -23,6 +23,11 @@ namespace Edu.Model.ViewModel.User
/// </summary> /// </summary>
public int IsSelectLevelNor { get; set; } public int IsSelectLevelNor { get; set; }
/// <summary>
/// 离职状态
/// </summary>
public int LeaveStatus { get; set; }
/// <summary> /// <summary>
/// 学校名称 /// 学校名称
/// </summary> /// </summary>
......
This diff is collapsed.
...@@ -528,6 +528,24 @@ where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ...@@ -528,6 +528,24 @@ where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds)
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
} }
public List<RB_OKR_Objective_ViewModel> GetObjectiveNumListForDept(int periodId, string deptIds, int group_Id)
{
string sql = $@"
select t.RB_Department_Id,count(0) as ObjectiveNum,
sum(case when t.ObjectiveNum=0 then 1 else 0 end) as ObjectiveNum1,
sum(case when t.ObjectiveNum>0 and t.ObjectiveNum<=2 then 1 else 0 end) as ObjectiveNum2,
sum(case when t.ObjectiveNum>2 and t.ObjectiveNum<=5 then 1 else 0 end) as ObjectiveNum3,
sum(case when t.ObjectiveNum>5 then 1 else 0 end) as ObjectiveNum4
from(
select e.EmployeeId,e.RB_Department_Id,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 and e.RB_Department_Id in ({deptIds}) group by e.EmployeeId
)t group by t.RB_Department_Id
";
return Get<RB_OKR_Objective_ViewModel>(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) 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 = $@" string sql = $@"
...@@ -541,6 +559,36 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Pr ...@@ -541,6 +559,36 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Pr
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
} }
public List<RB_OKR_Objective_ViewModel> GetObjectiveStatePageList_V2(int pageIndex, int pageSize, out long count, int periodId, int orderBy, int orderByNum, 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.ProgressState = 1 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.ProgressState = 2 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.ProgressState = 3 then 1 else 0 end) as ObjectiveNum3
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} 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 order by t.ObjectiveNum{orderByNum} {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveStateListForDept( int periodId, string deptIds, int group_Id)
{
string sql = $@"
select e.RB_Department_Id,
sum(case when o.ProgressState = 1 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.ProgressState = 2 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.ProgressState = 3 then 1 else 0 end) as ObjectiveNum3
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2
where e.RB_Group_id ={group_Id} and e.IsLeave =0 and e.RB_Department_Id in ({deptIds}) group by e.RB_Department_Id
";
return Get<RB_OKR_Objective_ViewModel>(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) 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 = $@" string sql = $@"
...@@ -554,6 +602,40 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Pr ...@@ -554,6 +602,40 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Pr
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
} }
public List<RB_OKR_Objective_ViewModel> GetObjectiveProgressPageList_V2(int pageIndex, int pageSize, out long count, int periodId, int orderBy, int orderByNum, 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.Progress=0 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.Progress>0 and o.Progress <=30 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.Progress>30 and o.Progress <=60 then 1 else 0 end) as ObjectiveNum3,
sum(case when o.Progress>60 and o.Progress <=90 then 1 else 0 end) as ObjectiveNum4,
sum(case when o.Progress>90 then 1 else 0 end) as ObjectiveNum5
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} 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 order by t.ObjectiveNum{orderByNum} {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveProgressListForDept(int periodId, string deptIds, int group_Id)
{
string sql = $@"
select e.RB_Department_Id,
sum(case when o.Progress=0 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.Progress>0 and o.Progress <=30 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.Progress>30 and o.Progress <=60 then 1 else 0 end) as ObjectiveNum3,
sum(case when o.Progress>60 and o.Progress <=90 then 1 else 0 end) as ObjectiveNum4,
sum(case when o.Progress>90 then 1 else 0 end) as ObjectiveNum5
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2
where e.RB_Group_id ={group_Id} and e.IsLeave =0 and e.RB_Department_Id in ({deptIds}) group by e.RB_Department_Id
";
return Get<RB_OKR_Objective_ViewModel>(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) 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 = $@" string sql = $@"
...@@ -567,6 +649,40 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Sc ...@@ -567,6 +649,40 @@ where o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2 and o.Sc
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
} }
public List<RB_OKR_Objective_ViewModel> GetObjectiveScorePageList_V2(int pageIndex, int pageSize, out long count, int periodId, int orderBy, int orderByNum, 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.Score=0 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.Score>0 and o.Score<=0.3 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.Score>0.3 and o.Score<=0.6 then 1 else 0 end) as ObjectiveNum3,
sum(case when o.Score>0.6 and o.Score<=0.9 then 1 else 0 end) as ObjectiveNum4,
sum(case when o.Score>0.9 then 1 else 0 end) as ObjectiveNum5
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} 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 order by t.ObjectiveNum{orderByNum} {(orderBy == 1 ? " asc" : " desc")}
";
return GetPage<RB_OKR_Objective_ViewModel>(pageIndex, pageSize, out count, sql).ToList();
}
public List<RB_OKR_Objective_ViewModel> GetObjectiveScoreListForDept(int periodId, string deptIds, int group_Id)
{
string sql = $@"
select e.RB_Department_Id,
sum(case when o.Score=0 then 1 else 0 end) as ObjectiveNum1,
sum(case when o.Score>0 and o.Score<=0.3 then 1 else 0 end) as ObjectiveNum2,
sum(case when o.Score>0.3 and o.Score<=0.6 then 1 else 0 end) as ObjectiveNum3,
sum(case when o.Score>0.6 and o.Score<=0.9 then 1 else 0 end) as ObjectiveNum4,
sum(case when o.Score>0.9 then 1 else 0 end) as ObjectiveNum5
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy and o.Group_Id ={group_Id} and o.PeriodId ={periodId} AND o.Status =2
where e.RB_Group_id ={group_Id} and e.IsLeave =0 and e.RB_Department_Id in ({deptIds}) group by e.RB_Department_Id
";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
#endregion #endregion
} }
} }
...@@ -141,7 +141,15 @@ WHERE 1=1 ...@@ -141,7 +141,15 @@ WHERE 1=1
} }
if (query.Post_Id>0) if (query.Post_Id>0)
{ {
where2.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.Post_Id), query.Post_Id); where2.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Post_Id), query.Post_Id);
}
if (query.Dept_Id > 0)
{
where2.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Dept_Id), query.Dept_Id);
}
if (query.LeaveStatus > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(Employee_ViewModel.LeaveStatus), query.LeaveStatus);
} }
if (query.IsSelectLevelNor == 1) if (query.IsSelectLevelNor == 1)
{ {
......
...@@ -1885,6 +1885,138 @@ namespace Edu.WebApi.Controllers.OKR ...@@ -1885,6 +1885,138 @@ namespace Edu.WebApi.Controllers.OKR
#endregion #endregion
#region 数据看板-上面统计
/// <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否
int RangeType = parms.GetInt("RangeType", 1);//范围类型 非管理端查询 1所有下级 2直属下级
int DepartId = parms.GetInt("DepartId", 0);//部门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 obj = okrPeriodModule.GetOKRGRDateDistribution(PeriodId, RangeType, DepartId, PostId, LeaveStatus, 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降序
int RangeType = parms.GetInt("RangeType", 1);//范围类型 非管理端查询 1所有下级 2直属下级
int DepartId = parms.GetInt("DepartId", 0);//部门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.GetOKRGRDateDistributionDetail(pageModel.PageIndex, pageModel.PageSize, out long count, PeriodId, Type, StartValue, EndValue, OrderBy, RangeType, DepartId, PostId, LeaveStatus, 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);
}
/// <summary>
/// 获取个人端数据分布明细 - 员工
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRGRDateDistributionDetail_V2()
{
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 OrderBy = parms.GetInt("OrderBy", 2);// 1升序 2降序
int OrderByNum = parms.GetInt("OrderByNum", 1);// 以第几个排序
int RangeType = parms.GetInt("RangeType", 1);//范围类型 非管理端查询 1所有下级 2直属下级
int DepartId = parms.GetInt("DepartId", 0);//部门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;
}
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);
pageModel.Count = Convert.ToInt32(count);
pageModel.PageData = list;
return ApiResult.Success("", pageModel);
}
/// <summary>
/// 获取个人端数据分布明细 - 部门
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRGRDateDistributionForDepartment()
{
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否
int Type = parms.GetInt("Type", 1);//1234 对应4项统计
int OrderBy = parms.GetInt("OrderBy", 2);// 1升序 2降序
int OrderByNum = parms.GetInt("OrderByNum", 1);// 以第几个排序
int DepartId = parms.GetInt("DepartId", 0);//部门ID 管理端可用查询
int PostId = parms.GetInt("PostId", 0);//岗位ID
int LeaveStatus = parms.GetInt("LeaveStatus", 0);//在职状态
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
var list = okrPeriodModule.GetOKRGRDateDistributionForDepartment(PeriodId, Type, OrderBy, OrderByNum, DepartId, PostId, LeaveStatus, userInfo, IsAdmin == 1 ? true : false);
return ApiResult.Success("", list);
}
#endregion
#region 个人端数据看板 #region 个人端数据看板
/// <summary> /// <summary>
/// 获取个人维度 /// 获取个人维度
...@@ -1941,58 +2073,6 @@ namespace Edu.WebApi.Controllers.OKR ...@@ -1941,58 +2073,6 @@ 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 #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