Commit 01c759eb authored by liudong1993's avatar liudong1993

优化代码

parent 53663581
...@@ -1312,232 +1312,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -1312,232 +1312,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
foreach (var item in sdqlist) foreach (var item in sdqlist)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2; GetDQListLookPermission(userInfo, MyUnderlingList, pList, pkrList, item);
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
} }
foreach (var item in xdqlist) foreach (var item in xdqlist)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2; GetDQListLookPermission(userInfo, MyUnderlingList, pList, pkrList, item);
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
} }
foreach (var item in list) foreach (var item in list)
{ {
...@@ -1697,140 +1477,34 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -1697,140 +1477,34 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
/// <summary> /// <summary>
/// 获取他人的目标列表 /// 获取目标/结果的对应用户权限
/// </summary> /// </summary>
/// <param name="periodId"></param>
/// <param name="userId"></param>
/// <param name="userInfo"></param> /// <param name="userInfo"></param>
/// <returns></returns> /// <param name="MyUnderlingList"></param>
public object GetOKROthersObjectiveList(int PeriodId, int userId, UserInfo userInfo) /// <param name="pList"></param>
/// <param name="pkrList"></param>
/// <param name="item"></param>
private static void GetDQListLookPermission(UserInfo userInfo, List<int> MyUnderlingList, List<RB_OKR_Permission_ViewModel> pList, List<RB_OKR_Permission_ViewModel> pkrList, RB_OKR_Objective_ViewModel item)
{ {
List<int> MyUnderlingList = GetMyUnderlingUserIdList(userInfo); item.IsLock = 2;
if (!MyUnderlingList.Contains(userId)) item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{ {
var pplist = oKR_PeriodPermissionRepository.GetList(new Model.Entity.OKR.RB_OKR_PeriodPermission() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userId }); item.IsLock = 1;
//查询是否有权限 if (!MyUnderlingList.Contains(item.CreateBy))
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = PeriodId, CreateBy = userId });
if (zpList.Any())
{ {
var NotLookList = zpList.Where(x => x.State == 2).ToList(); var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = zpList.Where(x => x.State == 1).ToList(); var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any()) if (NotLookList.Any())
{ {
//有不可看的 //有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{ {
return new item.IsNotLook = 1;
{
Status = 2,
Msg = "没有权限查询"
};
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{ {
return new item.IsNotLook = 1;
{
Status = 2,
Msg = "没有权限查询"
};
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
}
if (LookList.Any() && pplist.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
}
}
else
{
if (pplist.Any())
{
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
}
}
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userId, Status = 2 });
if (list.Any())
{
string objectiveIds = string.Join(",", list.Select(x => x.Id));
//查询向上对齐
var sdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ObjectiveIds = objectiveIds });
//查询向下对齐
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ParentIds = objectiveIds });
string jObjectiveIds = objectiveIds;
if (sdqlist.Any())
{
jObjectiveIds += "," + string.Join(",", sdqlist.Select(x => x.Id));
}
if (xdqlist.Any())
{
jObjectiveIds += "," + string.Join(",", xdqlist.Select(x => x.Id));
}
//查询结果列表
var krList = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveIds = jObjectiveIds });
//查询是否有权限
var pList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 2, ObjectiveIds = jObjectiveIds });
var pkrList = new List<RB_OKR_Permission_ViewModel>();
if (krList.Any())
{
string krIds = string.Join(",", krList.Select(x => x.Id));
pkrList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 3, ObjectiveIds = krIds });
}
string scoreRuleIds = string.Join(",", list.Where(x => x.ScoreRuleId > 0).Select(x => x.ScoreRuleId));
var ScoreRuleList = new List<RB_OKR_ScoreDetail_ViewModel>();
if (!string.IsNullOrEmpty(scoreRuleIds))
{
ScoreRuleList = oKR_ScoreDetailRepository.GetList(new RB_OKR_ScoreDetail_ViewModel() { ScoreIds = scoreRuleIds });
}
foreach (var item in sdqlist)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{ {
...@@ -1873,7 +1547,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -1873,7 +1547,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
if (pkrList.Where(x => x.TargetId == qitem.Id).Any()) if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{ {
qitem.IsLock = 1; qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id) if (!MyUnderlingList.Contains(item.CreateBy))
{ {
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList(); var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList(); var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
...@@ -1924,37 +1598,55 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -1924,37 +1598,55 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
} }
} }
foreach (var item in xdqlist)
/// <summary>
/// 获取他人的目标列表
/// </summary>
/// <param name="periodId"></param>
/// <param name="userId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetOKROthersObjectiveList(int PeriodId, int userId, UserInfo userInfo)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); List<int> MyUnderlingList = GetMyUnderlingUserIdList(userInfo);
item.IsLock = 2; if (!MyUnderlingList.Contains(userId))
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{ {
item.IsLock = 1; var pplist = oKR_PeriodPermissionRepository.GetList(new Model.Entity.OKR.RB_OKR_PeriodPermission() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userId });
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id) //查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = PeriodId, CreateBy = userId });
if (zpList.Any())
{ {
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList(); var NotLookList = zpList.Where(x => x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList(); var LookList = zpList.Where(x => x.State == 1).ToList();
if (NotLookList.Any()) if (NotLookList.Any())
{ {
//有不可看的 //有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{ {
item.IsNotLook = 1; return new
{
Status = 2,
Msg = "没有权限查询"
};
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{ {
item.IsNotLook = 1; return new
{
Status = 2,
Msg = "没有权限查询"
};
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any()) if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{ {
item.IsNotLook = 1; return new
{
Status = 2,
Msg = "没有权限查询"
};
} }
} }
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2) if (LookList.Any() && pplist.Any())
{
if (LookList.Any())
{ {
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any() if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any() || LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
...@@ -1964,198 +1656,79 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -1964,198 +1656,79 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
else else
{ {
item.IsNotLook = 1; return new
} {
} Status = 2,
Msg = "没有权限查询"
};
} }
} }
} }
else else
{ {
if (item.IsDefaultPermission == 2) if (pplist.Any())
{ {
item.IsLock = 1; return new
if (!MyUnderlingList.Contains(item.CreateBy))
{ {
item.IsNotLook = 1; Status = 2,
Msg = "没有权限查询"
};
} }
} }
} }
foreach (var qitem in item.KeyResultList) var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userId, Status = 2 });
{ if (list.Any())
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{ {
//有不可看的 string objectiveIds = string.Join(",", list.Select(x => x.Id));
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()) //查询向上对齐
var sdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ObjectiveIds = objectiveIds });
//查询向下对齐
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ParentIds = objectiveIds });
string jObjectiveIds = objectiveIds;
if (sdqlist.Any())
{ {
qitem.IsNotLook = 1; jObjectiveIds += "," + string.Join(",", sdqlist.Select(x => x.Id));
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()) if (xdqlist.Any())
{ {
qitem.IsNotLook = 1; jObjectiveIds += "," + string.Join(",", xdqlist.Select(x => x.Id));
} }
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
//查询结果列表
var krList = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveIds = jObjectiveIds });
//查询是否有权限
var pList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 2, ObjectiveIds = jObjectiveIds });
var pkrList = new List<RB_OKR_Permission_ViewModel>();
if (krList.Any())
{ {
qitem.IsNotLook = 1; string krIds = string.Join(",", krList.Select(x => x.Id));
} pkrList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 3, ObjectiveIds = krIds });
} }
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{ string scoreRuleIds = string.Join(",", list.Where(x => x.ScoreRuleId > 0).Select(x => x.ScoreRuleId));
if (LookList.Any()) var ScoreRuleList = new List<RB_OKR_ScoreDetail_ViewModel>();
{ if (!string.IsNullOrEmpty(scoreRuleIds))
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{ {
//OK ScoreRuleList = oKR_ScoreDetailRepository.GetList(new RB_OKR_ScoreDetail_ViewModel() { ScoreIds = scoreRuleIds });
} }
else
foreach (var item in sdqlist)
{ {
qitem.IsNotLook = 1; item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
} GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
}
}
}
} }
else foreach (var item in xdqlist)
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{ {
qitem.IsNotLook = 1; item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
} GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
}
}
}
} }
foreach (var item in list) foreach (var item in list)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2; GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
item.IsNotLook = 2; if (item.IsDefaultState == 1 && item.KeyResultList.Any())
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{ {
item.IsNotLook = 1; item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
if (item.IsDefaultState == 1 && item.KeyResultList.Any())
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
} }
#region 对齐列表 #region 对齐列表
...@@ -2408,6 +1981,165 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -2408,6 +1981,165 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
foreach (var item in sdqlist) foreach (var item in sdqlist)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
}
foreach (var item in xdqlist)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
}
foreach (var item in list)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
GetDQListLookPermission_V2(userInfo, MyUnderlingList, pList, pkrList, item);
if (item.IsDefaultState == 1 && item.KeyResultList.Any())
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
#region 对齐列表
var sdqclist = sdqlist.Where(x => x.ObjectiveId == item.Id).ToList();
List<int> EmIdList = sdqclist.Select(x => x.CreateBy).Distinct().ToList();
item.ParentList = new List<ObjectiveEmployeeModel>();
foreach (var qitem in EmIdList)
{
item.ParentList.Add(new ObjectiveEmployeeModel()
{
AccountId = qitem,
AccountName = sdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmName,
Icon = sdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmPhoto,
AlignList = sdqclist.Where(x => x.CreateBy == qitem).ToList()
});
}
var xdqclist = xdqlist.Where(x => x.ParentId == item.Id).ToList();
List<int> EmIdList2 = xdqclist.Select(x => x.CreateBy).Distinct().ToList();
item.ChildList = new List<ObjectiveEmployeeModel>();
foreach (var qitem in EmIdList2)
{
item.ChildList.Add(new ObjectiveEmployeeModel()
{
AccountId = qitem,
AccountName = xdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmName,
Icon = xdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmPhoto,
AlignList = xdqclist.Where(x => x.CreateBy == qitem).ToList()
});
}
#endregion
#region 分数显示
item.ScoreName = "";
item.ScoreColor = "";
if (item.ScoreRuleId > 0)
{
var scoreRuleModel = ScoreRuleList.Where(x => x.ScoreId == item.ScoreRuleId && x.ScoreMin <= item.Score && x.ScoreMax >= item.Score).FirstOrDefault();
item.ScoreName = scoreRuleModel?.Name ?? "";
item.ScoreColor = scoreRuleModel?.Color ?? "";
foreach (var qitem in item.KeyResultList)
{
var qscoreRuleModel = ScoreRuleList.Where(x => x.ScoreId == item.ScoreRuleId && x.ScoreMin <= qitem.Score && x.ScoreMax >= qitem.Score).FirstOrDefault();
qitem.ScoreName = qscoreRuleModel?.Name ?? "";
qitem.ScoreColor = qscoreRuleModel?.Color ?? "";
}
}
#endregion
}
}
var x = list.Where(x => x.IsNotLook == 2).FirstOrDefault();
if (x == null)
{
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
return new
{
x.Id,
x.Title,
x.Sort,
x.Progress,
x.Weight,
x.Score,
x.ProgressRemark,
x.IsDefaultState,
x.ProgressState,
ProgressStateName = x.ProgressState.ToName(),
x.Status,
x.IsLock,
x.IsNotLook,
x.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.Where(x => x.IsNotLook == 2).Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.Progress,
z.Weight,
z.Score,
z.ProgressState,
ProgressStateName = z.ProgressState.ToName(),
z.StartValue,
z.EndValue,
z.CurrentValue,
z.IsEasyMode,
z.IsLock,
z.IsNotLook,
z.ScoreName,
z.ScoreColor
}),
ParentList = x.ParentList.Select(y => new
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
{
q.Id,
Title = q.IsNotLook == 1 ? "" : q.Title,
q.Sort,
q.IsLock,
q.IsNotLook,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
Name = z.IsNotLook == 1 ? "" : z.Name,
z.Sort,
z.IsLock,
z.IsNotLook
}),
})
}),
ChildList = x.ChildList.Select(y => new
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
{
q.Id,
Title = q.IsNotLook == 1 ? "" : q.Title,
q.Sort,
q.IsLock,
q.IsNotLook,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
Name = z.IsNotLook == 1 ? "" : z.Name,
z.Sort,
z.IsLock,
z.IsNotLook
}),
})
}),
};
}
private static void GetDQListLookPermission_V2(UserInfo userInfo, List<int> MyUnderlingList, List<RB_OKR_Permission_ViewModel> pList, List<RB_OKR_Permission_ViewModel> pkrList, RB_OKR_Objective_ViewModel item)
{
item.IsLock = 2; item.IsLock = 2;
item.IsNotLook = 2; item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any()) if (pList.Where(x => x.TargetId == item.Id).Any())
...@@ -2456,7 +2188,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -2456,7 +2188,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
if (item.IsDefaultPermission == 2) if (item.IsDefaultPermission == 2)
{ {
item.IsLock = 1; item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy)) if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{ {
item.IsNotLook = 1; item.IsNotLook = 1;
} }
...@@ -2512,224 +2244,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -2512,224 +2244,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
if (qitem.IsDefaultPermission == 2) if (qitem.IsDefaultPermission == 2)
{ {
qitem.IsLock = 1; qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
}
foreach (var item in xdqlist)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
}
foreach (var item in list)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id) if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{ {
qitem.IsNotLook = 1; qitem.IsNotLook = 1;
} }
...@@ -2737,163 +2252,6 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -2737,163 +2252,6 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
} }
} }
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
if (item.IsDefaultState == 1 && item.KeyResultList.Any())
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
#region 对齐列表
var sdqclist = sdqlist.Where(x => x.ObjectiveId == item.Id).ToList();
List<int> EmIdList = sdqclist.Select(x => x.CreateBy).Distinct().ToList();
item.ParentList = new List<ObjectiveEmployeeModel>();
foreach (var qitem in EmIdList)
{
item.ParentList.Add(new ObjectiveEmployeeModel()
{
AccountId = qitem,
AccountName = sdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmName,
Icon = sdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmPhoto,
AlignList = sdqclist.Where(x => x.CreateBy == qitem).ToList()
});
}
var xdqclist = xdqlist.Where(x => x.ParentId == item.Id).ToList();
List<int> EmIdList2 = xdqclist.Select(x => x.CreateBy).Distinct().ToList();
item.ChildList = new List<ObjectiveEmployeeModel>();
foreach (var qitem in EmIdList2)
{
item.ChildList.Add(new ObjectiveEmployeeModel()
{
AccountId = qitem,
AccountName = xdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmName,
Icon = xdqclist.Where(x => x.CreateBy == qitem).FirstOrDefault().EmPhoto,
AlignList = xdqclist.Where(x => x.CreateBy == qitem).ToList()
});
}
#endregion
#region 分数显示
item.ScoreName = "";
item.ScoreColor = "";
if (item.ScoreRuleId > 0)
{
var scoreRuleModel = ScoreRuleList.Where(x => x.ScoreId == item.ScoreRuleId && x.ScoreMin <= item.Score && x.ScoreMax >= item.Score).FirstOrDefault();
item.ScoreName = scoreRuleModel?.Name ?? "";
item.ScoreColor = scoreRuleModel?.Color ?? "";
foreach (var qitem in item.KeyResultList)
{
var qscoreRuleModel = ScoreRuleList.Where(x => x.ScoreId == item.ScoreRuleId && x.ScoreMin <= qitem.Score && x.ScoreMax >= qitem.Score).FirstOrDefault();
qitem.ScoreName = qscoreRuleModel?.Name ?? "";
qitem.ScoreColor = qscoreRuleModel?.Color ?? "";
}
}
#endregion
}
}
var x = list.Where(x => x.IsNotLook == 2).FirstOrDefault();
if (x == null)
{
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
return new
{
x.Id,
x.Title,
x.Sort,
x.Progress,
x.Weight,
x.Score,
x.ProgressRemark,
x.IsDefaultState,
x.ProgressState,
ProgressStateName = x.ProgressState.ToName(),
x.Status,
x.IsLock,
x.IsNotLook,
x.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.Where(x => x.IsNotLook == 2).Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.Progress,
z.Weight,
z.Score,
z.ProgressState,
ProgressStateName = z.ProgressState.ToName(),
z.StartValue,
z.EndValue,
z.CurrentValue,
z.IsEasyMode,
z.IsLock,
z.IsNotLook,
z.ScoreName,
z.ScoreColor
}),
ParentList = x.ParentList.Select(y => new
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
{
q.Id,
Title = q.IsNotLook == 1 ? "" : q.Title,
q.Sort,
q.IsLock,
q.IsNotLook,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
Name = z.IsNotLook == 1 ? "" : z.Name,
z.Sort,
z.IsLock,
z.IsNotLook
}),
})
}),
ChildList = x.ChildList.Select(y => new
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
{
q.Id,
Title = q.IsNotLook == 1 ? "" : q.Title,
q.Sort,
q.IsLock,
q.IsNotLook,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
Name = z.IsNotLook == 1 ? "" : z.Name,
z.Sort,
z.IsLock,
z.IsNotLook
}),
})
}),
};
}
/// <summary> /// <summary>
/// 获取待我审核列表 /// 获取待我审核列表
...@@ -3172,152 +2530,42 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3172,152 +2530,42 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{ {
Status = 2, Status = 2,
Msg = "没有权限查询" Msg = "没有权限查询"
}; };
}
}
}
else {
if (pplist.Any()) {
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
}
}
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = periodId, CreateBy = userId, Status = 2 });
if (list.Any())
{
string objectiveIds = string.Join(",", list.Select(x => x.Id));
//查询结果列表
var krList = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveIds = objectiveIds });
//查询是否有权限
var pList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 2, ObjectiveIds = objectiveIds });
var pkrList = new List<RB_OKR_Permission_ViewModel>();
if (krList.Any())
{
string krIds = string.Join(",", krList.Select(x => x.Id));
pkrList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 3, ObjectiveIds = krIds });
}
#region 查询已对齐目标
//查询向上对齐
var sdqList = oKR_ObjectiveRelationRepository.GetList(new Model.Entity.OKR.RB_OKR_ObjectiveRelation() { ObjectiveId = objectiveId });
#endregion
foreach (var item in list)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy) && item.CreateBy != userInfo.Id)
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
} }
} }
} }
else else {
{ if (pplist.Any()) {
if (qitem.IsDefaultPermission == 2) return new
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{ {
qitem.IsNotLook = 1; Status = 2,
Msg = "没有权限查询"
};
} }
} }
} }
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = periodId, CreateBy = userId, Status = 2 });
if (list.Any())
{
string objectiveIds = string.Join(",", list.Select(x => x.Id));
//查询结果列表
var krList = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveIds = objectiveIds });
//查询是否有权限
var pList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 2, ObjectiveIds = objectiveIds });
var pkrList = new List<RB_OKR_Permission_ViewModel>();
if (krList.Any())
{
string krIds = string.Join(",", krList.Select(x => x.Id));
pkrList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 3, ObjectiveIds = krIds });
} }
#region 查询已对齐目标
//查询向上对齐
var sdqList = oKR_ObjectiveRelationRepository.GetList(new Model.Entity.OKR.RB_OKR_ObjectiveRelation() { ObjectiveId = objectiveId });
#endregion
foreach (var item in list)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
GetDQListLookPermission(userInfo, MyUnderlingList, pList, pkrList, item);
if (item.IsDefaultState == 1 && item.KeyResultList.Any()) if (item.IsDefaultState == 1 && item.KeyResultList.Any())
{ {
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState); item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
...@@ -3409,232 +2657,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3409,232 +2657,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
foreach (var item in sdqlist) foreach (var item in sdqlist)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2; GetDQListLookPermission(userInfo, MyUnderlingList, pList, pkrList, item);
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
} }
foreach (var item in xdqlist) foreach (var item in xdqlist)
{ {
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList(); item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2; GetDQListLookPermission(userInfo, MyUnderlingList, pList, pkrList, item);
item.IsNotLook = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pList.Where(x => x.TargetId == item.Id && x.State == 2).ToList();
var LookList = pList.Where(x => x.TargetId == item.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsNotLook = 1;
}
}
if (item.IsNotLook == 2 && item.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
item.IsNotLook = 1;
}
}
}
}
}
else
{
if (item.IsDefaultPermission == 2)
{
item.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
item.IsNotLook = 1;
}
}
}
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
var NotLookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.TargetId == qitem.Id && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
qitem.IsNotLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
qitem.IsNotLook = 1;
}
}
if (qitem.IsNotLook == 2 && qitem.IsDefaultPermission == 2)
{
if (LookList.Any())
{
if (LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any()
|| LookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
//OK
}
else
{
qitem.IsNotLook = 1;
}
}
}
}
}
else
{
if (qitem.IsDefaultPermission == 2)
{
qitem.IsLock = 1;
if (!MyUnderlingList.Contains(item.CreateBy))
{
qitem.IsNotLook = 1;
}
}
}
}
} }
foreach (var item in list) foreach (var item in list)
{ {
......
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