Commit bedb3d58 authored by liudong1993's avatar liudong1993

概率查询

parent 3369f378
......@@ -8187,18 +8187,53 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
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 });
userIdList = accountList.Select(x => x.Id).ToList();
}
userIdList = userIdList.Distinct().ToList();
int TotalNum = userIdList.Count();
string userIds = string.Join(",", userIdList);
//填写率查询
//int WriteNum = oKR_ObjectiveRepository.GetOKRProbabilityForWrite(userInfo.Group_Id, periodId, userIds);
//对齐率查询
//打分率查询
//最近7天更新率
return "";
int BranchTNum = accountRepository.GetAccountTotalNum(new RB_Account_ViewModel() { Group_Id = userInfo.Group_Id, IsSelectLevelNor = 1 });
int TWriteNum = 0, TAlignNum = 0, TScoreNum = 0, TUpdateNum = 0;
if (BranchTNum > 0)
{
//填写人数查询
TWriteNum = oKR_ObjectiveRepository.GetNotFilledList(userInfo.Group_Id, periodId, "");
//对齐率查询
TAlignNum = oKR_ObjectiveRepository.GetAlignPeopleNum(userInfo.Group_Id, periodId, "");
//打分率查询
TScoreNum = oKR_ObjectiveRepository.GetNotScoreList(userInfo.Group_Id, periodId, "", 2);
//最近7天更新率
string dateStr = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
TUpdateNum = oKR_ObjectiveRepository.GetRecently7DayPeopleNum(userInfo.Group_Id, periodId, "", dateStr);
}
int TotalNum = 0, WriteNum = 0, AlignNum = 0, ScoreNum = 0, UpdateNum = 0;
if (userIdList.Any())
{
userIdList = userIdList.Distinct().ToList();
TotalNum = userIdList.Count();
string userIds = string.Join(",", userIdList);
//填写人数查询
WriteNum = oKR_ObjectiveRepository.GetNotFilledList(userInfo.Group_Id, periodId, userIds);
//对齐率查询
AlignNum = oKR_ObjectiveRepository.GetAlignPeopleNum(userInfo.Group_Id, periodId, userIds);
//打分率查询
ScoreNum = oKR_ObjectiveRepository.GetNotScoreList(userInfo.Group_Id, periodId, userIds, 2);
//最近7天更新率
string dateStr = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
UpdateNum = oKR_ObjectiveRepository.GetRecently7DayPeopleNum(userInfo.Group_Id, periodId, userIds, dateStr);
}
return new
{
TotalPeopleNum = TotalNum,
WriteNum,
WriteRate = Math.Round(Convert.ToDecimal(WriteNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
AlignNum,
AlignRate = Math.Round(Convert.ToDecimal(AlignNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
ScoreNum,
ScoreRate = Math.Round(Convert.ToDecimal(ScoreNum) / TotalNum, 2, MidpointRounding.AwayFromZero),
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
};
}
#endregion
......
......@@ -723,7 +723,7 @@ where e.RB_Group_id ={group_Id} and e.IsLeave =0 and e.RB_Department_Id in ({dep
public int GetNotFilledList(int groupId,int periodId, string userIds)
{
string sql = $@"SELECT COUNT(0) FROM(
SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 and PeriodId={periodId} and CreateBy in({userIds}) GROUP BY CreateBy
SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 and PeriodId={periodId} {(!string.IsNullOrEmpty(userIds)? "and CreateBy in("+ userIds + ")":"")} GROUP BY CreateBy
)t ";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
......@@ -752,10 +752,10 @@ SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 an
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public int GetNotScoreList(int groupId, int periodId, string userIds)
public int GetNotScoreList(int groupId, int periodId, string userIds, int type = 1)
{
string sql = $@"SELECT COUNT(0) FROM(
SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 and Score =0 and PeriodId={periodId} and CreateBy in({userIds}) GROUP BY CreateBy
SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 {(type==1? "and Score =0" : "and Score >0")} and PeriodId={periodId} {(!string.IsNullOrEmpty(userIds) ? "and CreateBy in(" + userIds + ")" : "")} GROUP BY CreateBy
)t ";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
......@@ -824,6 +824,45 @@ 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();
}
#endregion
#region 概率查询
/// <summary>
/// 对齐人数
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public int GetAlignPeopleNum(int group_Id, int periodId, string userIds)
{
string sql = $@"SELECT COUNT(0) FROM(
SELECT o.CreateBy FROM rb_okr_objective o
INNER JOIN rb_okr_objectiverelation re on re.ObjectiveId = o.Id
WHERE o.Group_Id={group_Id} and o.Status <>5 and o.PeriodId={periodId} {(!string.IsNullOrEmpty(userIds) ? "and o.CreateBy in(" + userIds + ")" : "")} GROUP BY o.CreateBy
)t;";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
/// <summary>
/// 最近7天更新进度人数
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public int GetRecently7DayPeopleNum(int group_Id, int periodId, string userIds,string date)
{
string sql = $@"SELECT COUNT(0) FROM(
SELECT UserId FROM rb_okr_updateprogress WHERE Group_Id={group_Id} and PeriodId={periodId} and UpdateTime >= '{date}' {(!string.IsNullOrEmpty(userIds) ? "and UserId in(" + userIds + ")" : "")} GROUP BY UserId
)t;";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
#endregion
}
}
......@@ -141,15 +141,15 @@ WHERE 1=1
}
if (query.Post_Id>0)
{
where2.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Post_Id), query.Post_Id);
where.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);
where.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Dept_Id), query.Dept_Id);
}
if (!string.IsNullOrEmpty(query.DeptIds))
{
where2.AppendFormat(" AND B.{0} in({1}) ", nameof(RB_Account_ViewModel.Dept_Id), query.DeptIds);
where.AppendFormat(" AND B.{0} in({1}) ", nameof(RB_Account_ViewModel.Dept_Id), query.DeptIds);
}
if (query.LeaveStatus > 0)
{
......@@ -189,6 +189,85 @@ WHERE 1=1 {1}
return list;
}
/// <summary>
/// 获取账户总数量
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public int GetAccountTotalNum(RB_Account_ViewModel query)
{
StringBuilder where = new StringBuilder();
if (query != null)
{
if (query.Group_Id > 0)
{
where.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrWhiteSpace(query.Account))
{
where.AppendFormat(" AND A.{0}='{1}' ", nameof(RB_Account_ViewModel.Account), query.Account.Trim());
}
if (query.AccountType > 0)
{
where.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.AccountType), (int)query.AccountType);
}
if (query.Id > 0)
{
where.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.Id), query.Id);
}
if (query.AccountId > 0)
{
where.AppendFormat(" AND A.{0}={1} ", nameof(RB_Account_ViewModel.AccountId), query.AccountId);
}
if (!string.IsNullOrEmpty(query.OpenId))
{
where.AppendFormat(" AND A.{0}='{1}' ", nameof(RB_Account_ViewModel.OpenId), query.OpenId);
}
if (query.Post_Id > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Post_Id), query.Post_Id);
}
if (query.Dept_Id > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(RB_Account_ViewModel.Dept_Id), query.Dept_Id);
}
if (!string.IsNullOrEmpty(query.DeptIds))
{
where.AppendFormat(" AND B.{0} in({1}) ", nameof(RB_Account_ViewModel.Dept_Id), query.DeptIds);
}
if (query.LeaveStatus > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(Employee_ViewModel.LeaveStatus), query.LeaveStatus);
}
if (query.IsSelectLevelNor == 1)
{
where.AppendFormat(" AND B.{0} <>4 ", nameof(Employee_ViewModel.LeaveStatus));
}
}
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT count(0)
FROM
(
SELECT A.*,IFNULL(B.MName,'') AS AccountName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id
FROM rb_account AS A INNER JOIN rb_manager AS B ON A.AccountId=B.MId AND A.AccountType=1
WHERE 1=1 {0}
UNION ALL
SELECT A.*,IFNULL(B.TeacherName,'') AS AccountName,B.TeacherIcon AS UserIcon,B.Dept_Id,B.Post_Id
FROM rb_account AS A INNER JOIN rb_teacher AS B ON A.AccountId=B.TId AND A.AccountType=2
WHERE 1=1 {0}
UNION ALL
SELECT A.*,IFNULL(B.AssistName,'') AS AccountName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id
FROM rb_account AS A INNER JOIN rb_assist AS B ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0}
) AS t
", where.ToString());
var obj = ExecuteScalar(builder.ToString());
return obj != null ? (int)obj : 0;
}
/// <summary>
/// 获取员工列表【管理者、讲师、助教】
......
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