Commit 021becdd authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents bbb86a66 f3279cea
......@@ -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,
}
}
......@@ -5087,11 +5087,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, int PostId = 0, int leaveStatus = 0)
public List<int> GetMyUnderlingUserIdList(UserInfo userInfo, int DeptId = 0, int PostId = 0, int leaveStatus = 0, string userName ="")
{
List<int> UserIdList = new List<int>();
#region 我的直属下级
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, DirectSupervisor = userInfo.Id, Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, DirectSupervisor = userInfo.Id, Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
if (emList.Any())
{
foreach (var item in emList)
......@@ -5105,7 +5105,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, IsLeave = 1, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)), Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)), Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
if (em1List.Any())
{
......@@ -5128,7 +5128,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, IsLeave = 1, QIds = ManagerIds, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, QIds = ManagerIds, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
......@@ -5145,7 +5145,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<int> GetMyAllDownlineUserIdList(UserInfo userInfo, int DeptId = 0, int PostId = 0, int leaveStatus = 0)
public List<int> GetMyAllDownlineUserIdList(UserInfo userInfo, int DeptId = 0, int PostId = 0, int leaveStatus = 0, string userName ="")
{
List<int> UserIdList = new List<int>() { userInfo.Id };
#region 我的所有下级(部门层级所有人+直属人)
......@@ -5166,7 +5166,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
}
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, QDeptIds = string.Join(",", DeptIdList.Distinct()), Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, QDeptIds = string.Join(",", DeptIdList.Distinct()), Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = em1List.Where(x => x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
......@@ -5178,7 +5178,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, IsLeave = 1, QIds = ManagerIds, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, QIds = ManagerIds, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
......@@ -5187,7 +5187,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
}
UserIdList = UserIdList.Distinct().ToList();
//查询这些人的直属人
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, DirectSupervisorIds = string.Join(",", UserIdList), Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, DirectSupervisorIds = string.Join(",", UserIdList), Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
if (emList.Any())
{
foreach (var item in emList)
......@@ -5199,7 +5199,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
else
{
//非部门负责人 直接查直属
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, DirectSupervisor = userInfo.Id, Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, EmployeeName = userName, IsLeave = 1, DirectSupervisor = userInfo.Id, Dept_Id = DeptId, Post_Id = PostId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
if (emList.Any())
{
foreach (var item in emList)
......@@ -7553,7 +7553,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
/// <param name="userInfo"></param>
/// <param name="IsAdmin"></param>
/// <returns></returns>
public object GetOKRGRDateDistributionDetail_V2(int pageIndex, int pageSize, out long count, int periodId, int type, int orderBy, int orderByNum, int rangeType, string departId, int postId, int leaveStatus, UserInfo userInfo, bool IsAdmin = false)
public object GetOKRGRDateDistributionDetail_V2(int pageIndex, int pageSize, out long count, int periodId, string userName, int type, int orderBy, int orderByNum, int rangeType, string departId, int postId, int leaveStatus, UserInfo userInfo, bool IsAdmin = false)
{
count = 0;
var userIdList = new List<int>();
......@@ -7562,17 +7562,17 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
if (rangeType == 1)
{
//查询该用户下所有的下级用户
userIdList = GetMyAllDownlineUserIdList(userInfo, 0, postId, leaveStatus);
userIdList = GetMyAllDownlineUserIdList(userInfo, 0, postId, leaveStatus, userName);
}
else
{
//首先查询用户的所有直属下级
userIdList = GetMyUnderlingUserIdList(userInfo, 0, postId, leaveStatus);
userIdList = GetMyUnderlingUserIdList(userInfo, 0, postId, leaveStatus, userName);
}
}
else
{
var accountList = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, DeptIds = departId, Post_Id = postId, LeaveStatus = leaveStatus, IsSelectLevelNor = 1 });
var accountList = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, AccountName = userName, DeptIds = departId, Post_Id = postId, LeaveStatus = leaveStatus, IsSelectLevelNor = 1 });
userIdList = accountList.Select(x => x.Id).ToList();
}
string userIds = string.Join(",", userIdList.Distinct());
......@@ -8041,26 +8041,45 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{
Id = Num,
Days = SDays,
TotalNum,
PeopleNum = TotalNum - Number,
Type = Common.Enum.OKR.MatterTypeEnum.NotFilled,
TypeName = Common.Enum.OKR.MatterTypeEnum.NotFilled.ToName()
TypeName = Common.Enum.OKR.MatterTypeEnum.NotFilled.ToName(),
SelectType = 1,
});
Num++;
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.NotUpdated).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.NotAlign).Any() && (SValue == 0 || (SValue > 0 && SDays >= SValue)))
{
//查询未更新
int Number = oKR_ObjectiveRepository.GetNotUpdatedList(userInfo.Group_Id, periodId, userIds);
//查询未对齐
int Number = oKR_ObjectiveRepository.GetAlignPeopleNum(userInfo.Group_Id, periodId, userIds);
RList.Add(new
{
Id = Num,
Days = EDays,
PeopleNum = Number,
Type = Common.Enum.OKR.MatterTypeEnum.NotUpdated,
TypeName = Common.Enum.OKR.MatterTypeEnum.NotUpdated.ToName()
Days = SDays,
TotalNum,
PeopleNum = TotalNum - Number,
Type = Common.Enum.OKR.MatterTypeEnum.NotAlign,
TypeName = Common.Enum.OKR.MatterTypeEnum.NotAlign.ToName(),
SelectType = 2,
});
Num++;
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.NotUpdated).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
{
//查询未更新
//int Number = oKR_ObjectiveRepository.GetNotUpdatedList(userInfo.Group_Id, periodId, userIds);
//RList.Add(new
//{
// Id = Num,
// Days = EDays,
// PeopleNum = Number,
// Type = Common.Enum.OKR.MatterTypeEnum.NotUpdated,
// TypeName = Common.Enum.OKR.MatterTypeEnum.NotUpdated.ToName(),
// SelectType = 3,
//});
//Num++;
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.NotScore).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
{
//查询未打分
......@@ -8069,9 +8088,11 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{
Id = Num,
Days = EDays,
TotalNum,
PeopleNum = Number,
Type = Common.Enum.OKR.MatterTypeEnum.NotScore,
TypeName = Common.Enum.OKR.MatterTypeEnum.NotScore.ToName()
TypeName = Common.Enum.OKR.MatterTypeEnum.NotScore.ToName(),
SelectType = 4,
});
Num++;
}
......@@ -8080,7 +8101,188 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
else
{
//管理端 主查询对齐率这些
int lastPeriodId = 0;
if (periodId > 0)
{
//查询上一个周期id
var model = oKR_PeriodRepository.GetEntity(periodId);
if (model != null && model.IsNormal == 1)
{
lastPeriodId = oKR_PeriodRepository.GetLastPeriodId(model.Id, model.IsYear, userInfo.Group_Id);
}
}
if (lastPeriodId > 0)
{
var accountList = accountRepository.GetAccountListExtRepository(new RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, DeptIds = departId, Post_Id = postId, LeaveStatus = leaveStatus, IsSelectLevelNor = 1 });
var userIdList = accountList.Select(x => x.Id).Distinct().ToList();
if (userIdList.Any())
{
int TotalPeopleNum = userIdList.Count();
string userIds = string.Join(",", userIdList);
List<RB_OKR_Objective_ViewModel> NRList = new List<RB_OKR_Objective_ViewModel>();
List<RB_OKR_Objective_ViewModel> LastRList = new List<RB_OKR_Objective_ViewModel>();
string OKRMatterValue = Common.Config.OKRMatterValue;
int EValue = 0;
if (!string.IsNullOrEmpty(OKRMatterValue))
{
var matterArr = OKRMatterValue.Split(',');
EValue = Convert.ToInt32(matterArr[2]);
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.Write).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
{
NRList = new List<RB_OKR_Objective_ViewModel>();
LastRList = new List<RB_OKR_Objective_ViewModel>();
//查询填写
NRList = oKR_ObjectiveRepository.GetWritePageList(1, 100000, out long count, userInfo.Group_Id, periodId, userIds, 1);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetWritePageList(1, 100000, out count, userInfo.Group_Id, lastPeriodId, userIds, 1);
}
#region 计算概率
int PeopleNum = NRList.Count();
int OKPNum = NRList.Where(x => x.Status == 1).Count();
decimal nowRate = 0;
if (PeopleNum > 0)
{
nowRate = Math.Round(Convert.ToDecimal(OKPNum) / PeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
int lPeopleNum = LastRList.Count();
decimal lastRate = 0;
if (lPeopleNum > 0)
{
lastRate = Math.Round(Convert.ToDecimal(LastRList.Where(x => x.Status == 1).Count()) / lPeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
//只查询同比下降的
decimal UpRate = 0;
if (nowRate < lastRate)
{
if (nowRate == 0)
{
UpRate = 100;
}
else
{
UpRate = Math.Round((lastRate - nowRate) / lastRate, 3, MidpointRounding.AwayFromZero) * 100;
}
RList.Add(new
{
Id = Num,
Days = EDays,
TotalNum = PeopleNum,
PeopleNum = OKPNum,
UpRate,
Type = Common.Enum.OKR.MatterTypeEnum.Write,
TypeName = Common.Enum.OKR.MatterTypeEnum.Write.ToName(),
SelectType = 1,
});
Num++;
}
#endregion
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.Align).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
{
NRList = new List<RB_OKR_Objective_ViewModel>();
LastRList = new List<RB_OKR_Objective_ViewModel>();
//查询对齐
NRList = oKR_ObjectiveRepository.GetAlignPageList(1, 100000, out long count, userInfo.Group_Id, periodId, userIds, 1);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetAlignPageList(1, 100000, out count, userInfo.Group_Id, lastPeriodId, userIds, 1);
}
#region 计算概率
int PeopleNum = NRList.Count();
int OKPNum = NRList.Where(x => x.Status == 1).Count();
decimal nowRate = 0;
if (PeopleNum > 0)
{
nowRate = Math.Round(Convert.ToDecimal(OKPNum) / PeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
int lPeopleNum = LastRList.Count();
decimal lastRate = 0;
if (lPeopleNum > 0)
{
lastRate = Math.Round(Convert.ToDecimal(LastRList.Where(x => x.Status == 1).Count()) / lPeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
//只查询同比下降的
decimal UpRate = 0;
if (nowRate < lastRate)
{
if (nowRate == 0)
{
UpRate = 100;
}
else
{
UpRate = Math.Round((lastRate - nowRate) / lastRate, 3, MidpointRounding.AwayFromZero) * 100;
}
RList.Add(new
{
Id = Num,
Days = EDays,
TotalNum = PeopleNum,
PeopleNum = OKPNum,
UpRate,
Type = Common.Enum.OKR.MatterTypeEnum.Align,
TypeName = Common.Enum.OKR.MatterTypeEnum.Align.ToName(),
SelectType = 2,
});
Num++;
}
#endregion
}
if (!list.Where(x => x.Type == Common.Enum.OKR.MatterTypeEnum.Score).Any() && (EValue == 0 || (EValue > 0 && EDays <= EValue)))
{
NRList = new List<RB_OKR_Objective_ViewModel>();
LastRList = new List<RB_OKR_Objective_ViewModel>();
//查询打分
NRList = oKR_ObjectiveRepository.GetScorePageList(1, 100000,out long count, userInfo.Group_Id, periodId, userIds, 1);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetScorePageList(1, 100000, out count, userInfo.Group_Id, lastPeriodId, userIds, 1);
}
#region 计算概率
int PeopleNum = NRList.Count();
int OKPNum = NRList.Where(x => x.Status == 1).Count();
decimal nowRate = 0;
if (PeopleNum > 0)
{
nowRate = Math.Round(Convert.ToDecimal(OKPNum) / PeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
int lPeopleNum = LastRList.Count();
decimal lastRate = 0;
if (lPeopleNum > 0)
{
lastRate = Math.Round(Convert.ToDecimal(LastRList.Where(x => x.Status == 1).Count()) / lPeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
//只查询同比下降的
decimal UpRate = 0;
if (nowRate < lastRate)
{
if (nowRate == 0)
{
UpRate = 100;
}
else
{
UpRate = Math.Round((lastRate - nowRate) / lastRate, 3, MidpointRounding.AwayFromZero) * 100;
}
RList.Add(new
{
Id = Num,
Days = EDays,
TotalNum = PeopleNum,
PeopleNum = OKPNum,
UpRate,
Type = Common.Enum.OKR.MatterTypeEnum.Score,
TypeName = Common.Enum.OKR.MatterTypeEnum.Score.ToName(),
SelectType = 4,
});
Num++;
}
#endregion
}
}
}
}
return RList;
......@@ -8222,19 +8424,477 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{
TotalPeopleNum = TotalNum,
WriteNum,
WriteRate = Math.Round(Convert.ToDecimal(WriteNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
WriteRate = (Math.Round(Convert.ToDecimal(WriteNum) / TotalNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0"),
AlignNum,
AlignRate = Math.Round(Convert.ToDecimal(AlignNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
AlignRate = (Math.Round(Convert.ToDecimal(AlignNum) / TotalNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0"),
ScoreNum,
ScoreRate = Math.Round(Convert.ToDecimal(ScoreNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
ScoreRate = (Math.Round(Convert.ToDecimal(ScoreNum) / TotalNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0"),
UpdateNum,
UpdateRate = Math.Round(Convert.ToDecimal(UpdateNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
TWriteRate = BranchTNum > 0 ? Math.Round(Convert.ToDecimal(TWriteNum) / BranchTNum, 2, MidpointRounding.AwayFromZero) : 0,
TAlignRate = BranchTNum > 0 ? Math.Round(Convert.ToDecimal(TAlignNum) / BranchTNum, 2, MidpointRounding.AwayFromZero) : 0,
TScoreRate = BranchTNum > 0 ? Math.Round(Convert.ToDecimal(TScoreNum) / BranchTNum, 2, MidpointRounding.AwayFromZero) : 0,
TUpdateRate = BranchTNum > 0 ? Math.Round(Convert.ToDecimal(TUpdateNum) / BranchTNum, 2, MidpointRounding.AwayFromZero) : 0
UpdateRate = (Math.Round(Convert.ToDecimal(UpdateNum) / TotalNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0"),
TWriteRate = BranchTNum > 0 ? (Math.Round(Convert.ToDecimal(TWriteNum) / BranchTNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0") : "0.0",
TAlignRate = BranchTNum > 0 ? (Math.Round(Convert.ToDecimal(TAlignNum) / BranchTNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0") : "0.0",
TScoreRate = BranchTNum > 0 ? (Math.Round(Convert.ToDecimal(TScoreNum) / BranchTNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0") : "0.0",
TUpdateRate = BranchTNum > 0 ? (Math.Round(Convert.ToDecimal(TUpdateNum) / BranchTNum, 3, MidpointRounding.AwayFromZero) * 100).ToString("#0.0") : "0.0"
};
}
/// <summary>
/// 获取概率明细分页列表 - 人员
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="periodId"></param>
/// <param name="type"></param>
/// <param name="rangeType"></param>
/// <param name="departId"></param>
/// <param name="postId"></param>
/// <param name="leaveStatus"></param>
/// <param name="userInfo"></param>
/// <param name="IsAdmin"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRProbabilityPageListForEmp(int pageIndex, int pageSize, out long count, int periodId,int orderBy, int type, string userName, int rangeType, string departId, int postId, int leaveStatus, UserInfo userInfo, bool IsAdmin)
{
count = 0;
List<RB_OKR_Objective_ViewModel> Rlist = new List<RB_OKR_Objective_ViewModel>();
var userIdList = new List<int>();
if (IsAdmin == false)
{
if (rangeType == 1)
{
//查询该用户下所有的下级用户
userIdList = GetMyAllDownlineUserIdList(userInfo, 0, postId, leaveStatus);
}
else
{
//首先查询用户的所有直属下级
userIdList = GetMyUnderlingUserIdList(userInfo, 0, postId, leaveStatus);
}
}
else
{
var accountList = accountRepository.GetAccountListExtRepository(new Model.ViewModel.User.RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, AccountName = userName, DeptIds = departId, Post_Id = postId, LeaveStatus = leaveStatus, IsSelectLevelNor = 1 });
userIdList = accountList.Select(x => x.Id).ToList();
}
if (userIdList.Any())
{
userIdList = userIdList.Distinct().ToList();
string userIds = string.Join(",", userIdList);
if (type == (int)Common.Enum.OKR.MatterTypeEnum.NotFilled)
{
//查询填写
Rlist = oKR_ObjectiveRepository.GetWritePageList(pageIndex, pageSize, out count, userInfo.Group_Id, periodId, userIds, orderBy);
}
else if (type == (int)Common.Enum.OKR.MatterTypeEnum.NotAlign)
{
//查询对齐
Rlist = oKR_ObjectiveRepository.GetAlignPageList(pageIndex, pageSize, out count, userInfo.Group_Id, periodId, userIds, orderBy);
}
else if (type == (int)Common.Enum.OKR.MatterTypeEnum.NotUpdated)
{
//查询更新
string dateStr = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
Rlist = oKR_ObjectiveRepository.GetUpdatePageList(pageIndex, pageSize, out count, userInfo.Group_Id, periodId, userIds, dateStr, orderBy);
}
if (type == (int)Common.Enum.OKR.MatterTypeEnum.NotScore)
{
//查询打分
Rlist = oKR_ObjectiveRepository.GetScorePageList(pageIndex, pageSize, out count, userInfo.Group_Id, periodId, userIds, orderBy);
}
}
return Rlist;
}
/// <summary>
/// 获取概率明细分页列表 - 部门
/// </summary>
/// <param name="periodId"></param>
/// <param name="selectType"></param>
/// <param name="departId"></param>
/// <param name="postId"></param>
/// <param name="leaveStatus"></param>
/// <param name="userInfo"></param>
/// <param name="IsAdmin"></param>
/// <returns></returns>
public object GetOKRProbabilityPageListForDept(int periodId, int selectType, string departId, int postId, int leaveStatus, UserInfo userInfo, bool IsAdmin)
{
int lastPeriodId = 0;
if (periodId > 0) {
//查询上一个周期id
var model = oKR_PeriodRepository.GetEntity(periodId);
if (model != null && model.IsNormal == 1) {
lastPeriodId = oKR_PeriodRepository.GetLastPeriodId(model.Id, model.IsYear, userInfo.Group_Id);
}
}
List<object> Rlist = new List<object>();
if (IsAdmin == false)
{
var xjdlist = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
List<int> DeptIdList = new List<int>();
foreach (var item in xjdlist)
{
//查询出所有的部门
string DeptIds = departmentRepository.GetCurrentAndChildDepartmentIdsRepository(item.DeptId);
if (!string.IsNullOrEmpty(DeptIds))
{
DeptIdList.AddRange(JsonHelper.DeserializeObject<List<int>>("[" + DeptIds + "]"));
}
}
string DeptIdStr = string.Join(",", DeptIdList.Distinct());
//上级部门下所有子部门的负责人
var d2list = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = DeptIdStr });
string ManagerIds = string.Join(",", d2list.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
List<Model.ViewModel.User.Employee_ViewModel> ManagerList = new List<Model.ViewModel.User.Employee_ViewModel>();
if (!string.IsNullOrEmpty(ManagerIds))
{
ManagerList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, QIds = ManagerIds, Post_Id = postId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
}
List<RB_OKR_Objective_ViewModel> RList = new List<RB_OKR_Objective_ViewModel>();
List<RB_OKR_Objective_ViewModel> LastRList = new List<RB_OKR_Objective_ViewModel>();
GetProbabilityListData(periodId, selectType, userInfo, lastPeriodId, DeptIdStr, ref RList, ref LastRList);
//返回部门树形结构
foreach (var item in xjdlist)
{
List<Employee_ViewModel> ManagerList1 = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(item.ManagerIds))
{
List<int> ManagerIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ManagerIds + "]");
ManagerList1 = ManagerList.Where(x => ManagerIdList.Contains(x.Id)).ToList();
}
int PeopleNum = 0, Type = 1;
decimal nowRate = 0, lastRate = 0, UpRate = 0;
GetProbabilityDeptRate(RList, LastRList, item, selectType, out PeopleNum, out nowRate, out lastRate, out Type, out UpRate);
Rlist.Add(new
{
item.DeptId,
item.DeptName,
ManagerList = ManagerList1.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon
}),
PeopleNum,
NowRate = nowRate,
LastRate = lastRate,
Type,
UpRate,
ChildList = GetChildProbabilityDept(item, selectType, d2list, ManagerList, RList, LastRList)
});
}
}
else
{
//只查询自己部门
var dlist = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, DeptId = userInfo.DeptId });
string DeptIdStr = userInfo.DeptId.ToString();
string ManagerIds = string.Join(",", dlist.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
List<Employee_ViewModel> ManagerList = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(ManagerIds))
{
ManagerList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, QIds = ManagerIds, Post_Id = postId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
}
List<RB_OKR_Objective_ViewModel> RList = new List<RB_OKR_Objective_ViewModel>();
List<RB_OKR_Objective_ViewModel> LastRList = new List<RB_OKR_Objective_ViewModel>();
GetProbabilityListData(periodId, selectType, userInfo, lastPeriodId, DeptIdStr, ref RList, ref LastRList);
//返回部门树形结构
foreach (var item in dlist)
{
List<Model.ViewModel.User.Employee_ViewModel> ManagerList1 = new List<Model.ViewModel.User.Employee_ViewModel>();
if (!string.IsNullOrEmpty(item.ManagerIds))
{
List<int> ManagerIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ManagerIds + "]");
ManagerList1 = ManagerList.Where(x => ManagerIdList.Contains(x.Id)).ToList();
}
int PeopleNum = 0, Type = 1;
decimal nowRate = 0, lastRate = 0, UpRate = 0;
GetProbabilityDeptRate(RList, LastRList, item, selectType, out PeopleNum, out nowRate, out lastRate, out Type, out UpRate);
Rlist.Add(new
{
item.DeptId,
item.DeptName,
ManagerList = ManagerList1.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon
}),
PeopleNum,
NowRate = nowRate,
LastRate = lastRate,
Type,
UpRate,
ChildList = GetChildProbabilityDept(item, selectType, dlist, ManagerList, RList, LastRList)
});
}
}
}
else
{
if (!string.IsNullOrEmpty(departId))
{
var dlist = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = departId });
string DeptIdStr = departId.ToString();
string ManagerIds = string.Join(",", dlist.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
List<Employee_ViewModel> ManagerList = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(ManagerIds))
{
ManagerList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, QIds = ManagerIds, Post_Id = postId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
}
List<RB_OKR_Objective_ViewModel> RList = new List<RB_OKR_Objective_ViewModel>();
List<RB_OKR_Objective_ViewModel> LastRList = new List<RB_OKR_Objective_ViewModel>();
GetProbabilityListData(periodId, selectType, userInfo, lastPeriodId, DeptIdStr, ref RList, ref LastRList);
//返回部门树形结构
foreach (var item in dlist)
{
List<Model.ViewModel.User.Employee_ViewModel> ManagerList1 = new List<Model.ViewModel.User.Employee_ViewModel>();
if (!string.IsNullOrEmpty(item.ManagerIds))
{
List<int> ManagerIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ManagerIds + "]");
ManagerList1 = ManagerList.Where(x => ManagerIdList.Contains(x.Id)).ToList();
}
int PeopleNum = 0, Type = 1;
decimal nowRate = 0, lastRate = 0, UpRate = 0;
GetProbabilityDeptRate(RList, LastRList, item, selectType, out PeopleNum, out nowRate, out lastRate, out Type, out UpRate);
Rlist.Add(new
{
item.DeptId,
item.DeptName,
ManagerList = ManagerList1.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon
}),
PeopleNum,
NowRate = nowRate,
LastRate = lastRate,
Type,
UpRate,
ChildList = GetChildProbabilityDept(item, selectType, dlist, ManagerList, RList, LastRList)
});
}
}
else
{
//直接查询所有部门
var dlist = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { Group_Id = userInfo.Group_Id });
if (dlist.Any())
{
string DeptIdStr = string.Join(",", dlist.Select(x => x.DeptId));
//上级部门下所有子部门的负责人
string ManagerIds = string.Join(",", dlist.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
List<Model.ViewModel.User.Employee_ViewModel> ManagerList = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(ManagerIds))
{
ManagerList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = userInfo.Group_Id, IsLeave = 1, QIds = ManagerIds, Post_Id = postId, LeaveStatus = (Common.Enum.User.LeaveStatusEnum)leaveStatus });
}
List<RB_OKR_Objective_ViewModel> RList = new List<RB_OKR_Objective_ViewModel>();
List<RB_OKR_Objective_ViewModel> LastRList = new List<RB_OKR_Objective_ViewModel>();
GetProbabilityListData(periodId, selectType, userInfo, lastPeriodId, DeptIdStr, ref RList, ref LastRList);
//返回部门树形结构
var firstList = dlist.Where(x => x.ParentId == 0).ToList();
foreach (var item in firstList)
{
List<Model.ViewModel.User.Employee_ViewModel> ManagerList1 = new List<Model.ViewModel.User.Employee_ViewModel>();
if (!string.IsNullOrEmpty(item.ManagerIds))
{
List<int> ManagerIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ManagerIds + "]");
ManagerList1 = ManagerList.Where(x => ManagerIdList.Contains(x.Id)).ToList();
}
int PeopleNum = 0, Type = 1;
decimal nowRate = 0, lastRate = 0, UpRate = 0;
GetProbabilityDeptRate(RList, LastRList, item, selectType, out PeopleNum, out nowRate, out lastRate, out Type, out UpRate);
Rlist.Add(new
{
item.DeptId,
item.DeptName,
ManagerList = ManagerList1.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon
}),
PeopleNum,
NowRate = nowRate,
LastRate = lastRate,
Type,
UpRate,
ChildList = GetChildProbabilityDept(item, selectType, dlist, ManagerList, RList, LastRList)
});
}
}
}
}
return Rlist;
}
/// <summary>
/// 获取概率明细树形子集列表
/// </summary>
/// <param name="item"></param>
/// <param name="d2list"></param>
/// <param name="managerList"></param>
/// <param name="rList"></param>
/// <returns></returns>
private object GetChildProbabilityDept(RB_Department_ViewModel model, int selectType, List<RB_Department_ViewModel> d2list, List<Employee_ViewModel> ManagerList, List<RB_OKR_Objective_ViewModel> RList, List<RB_OKR_Objective_ViewModel> LastRList)
{
List<object> Rlist = new List<object>();
var clist = d2list.Where(x => x.ParentId == model.DeptId).ToList();
foreach (var item in clist)
{
List<Employee_ViewModel> ManagerList1 = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(item.ManagerIds))
{
List<int> ManagerIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ManagerIds + "]");
ManagerList1 = ManagerList.Where(x => ManagerIdList.Contains(x.Id)).ToList();
}
int PeopleNum = 0, Type = 1;
decimal nowRate = 0, lastRate = 0, UpRate = 0;
GetProbabilityDeptRate(RList, LastRList, item, selectType, out PeopleNum, out nowRate, out lastRate, out Type, out UpRate);
Rlist.Add(new
{
item.DeptId,
item.DeptName,
ManagerList = ManagerList1.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon
}),
PeopleNum,
NowRate = nowRate,
LastRate = lastRate,
Type,
UpRate,
ChildList = GetChildProbabilityDept(item, selectType, d2list, ManagerList, RList, LastRList)
});
}
return Rlist;
}
/// <summary>
/// 获取概率数据
/// </summary>
/// <param name="periodId"></param>
/// <param name="selectType"></param>
/// <param name="userInfo"></param>
/// <param name="lastPeriodId"></param>
/// <param name="DeptIdStr"></param>
/// <param name="RList"></param>
/// <param name="LastRList"></param>
private void GetProbabilityListData(int periodId, int selectType, UserInfo userInfo, int lastPeriodId, string DeptIdStr, ref List<RB_OKR_Objective_ViewModel> RList, ref List<RB_OKR_Objective_ViewModel> LastRList)
{
if (selectType == (int)Common.Enum.OKR.MatterTypeEnum.NotFilled)
{
//查询填写
RList = oKR_ObjectiveRepository.GetWriteList(userInfo.Group_Id, periodId, DeptIdStr);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetWriteList(userInfo.Group_Id, lastPeriodId, DeptIdStr);
}
}
else if (selectType == (int)Common.Enum.OKR.MatterTypeEnum.NotAlign)
{
//查询对齐
RList = oKR_ObjectiveRepository.GetAlignList(userInfo.Group_Id, periodId, DeptIdStr);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetAlignList(userInfo.Group_Id, lastPeriodId, DeptIdStr);
}
}
else if (selectType == (int)Common.Enum.OKR.MatterTypeEnum.NotUpdated)
{
//查询更新
string dateStr = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
RList = oKR_ObjectiveRepository.GetUpdateList(userInfo.Group_Id, periodId, DeptIdStr, dateStr);
}
if (selectType == (int)Common.Enum.OKR.MatterTypeEnum.NotScore)
{
//查询打分
RList = oKR_ObjectiveRepository.GetScoreList(userInfo.Group_Id, periodId, DeptIdStr);
if (lastPeriodId > 0)
{
LastRList = oKR_ObjectiveRepository.GetScoreList(userInfo.Group_Id, lastPeriodId, DeptIdStr);
}
}
}
/// <summary>
/// 获取概率
/// </summary>
/// <param name="RList"></param>
/// <param name="LastRList"></param>
/// <param name="item"></param>
/// <param name="PeopleNum"></param>
/// <param name="nowRate"></param>
/// <param name="lastRate"></param>
/// <param name="Type"></param>
/// <param name="UpRate"></param>
private static void GetProbabilityDeptRate(List<RB_OKR_Objective_ViewModel> RList, List<RB_OKR_Objective_ViewModel> LastRList, RB_Department_ViewModel item, int selectType, out int PeopleNum, out decimal nowRate, out decimal lastRate, out int Type, out decimal UpRate)
{
var nowList = RList.Where(x => x.RB_Department_Id == item.DeptId).ToList();
PeopleNum = nowList.Count();
nowRate = 0;
if (PeopleNum > 0)
{
nowRate = Math.Round(Convert.ToDecimal(nowList.Where(x => x.Status == 1).Count()) / PeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
var lastList = LastRList.Where(x => x.RB_Department_Id == item.DeptId).ToList();
int lPeopleNum = lastList.Count();
lastRate = 0;
if (lPeopleNum > 0)
{
lastRate = Math.Round(Convert.ToDecimal(lastList.Where(x => x.Status == 1).Count()) / lPeopleNum, 3, MidpointRounding.AwayFromZero) * 100;
}
Type = 1;
UpRate = 0;
if (selectType == 3)
{
Type = 0;
}
else
{
if (nowRate > lastRate)
{
if (lastRate == 0)
{
UpRate = 100;
}
else
{
UpRate = Math.Round((nowRate - lastRate) / lastRate, 3, MidpointRounding.AwayFromZero) * 100;
}
}
else if (nowRate < lastRate)
{
Type = 2;
if (nowRate == 0)
{
UpRate = 100;
}
else
{
UpRate = Math.Round((lastRate - nowRate) / lastRate, 3, MidpointRounding.AwayFromZero) * 100;
}
}
else
{
Type = 0;
}
}
}
#endregion
#region 春姐 统计
......
......@@ -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);
......@@ -2154,6 +2155,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