Commit c4d58b1e authored by liudong1993's avatar liudong1993

我的对齐视图

parent 5e75b49c
......@@ -18,5 +18,10 @@ namespace Edu.Model.ViewModel.OKR
/// 来源名称
/// </summary>
public string SourceName { get; set; }
/// <summary>
/// 创建人ids
/// </summary>
public string CreateByIds { get; set; }
}
}
\ No newline at end of file
......@@ -1173,11 +1173,13 @@ namespace Edu.Module.OKR
}
}
//如果是部门主管 需要将部门下除自己其他人加入
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !emList.Select(y => y.Id).Contains(x.Id)).ToList();//排序 已存在的直接关系
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id)).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
UserIdList.Add(item.Id);
......@@ -3145,10 +3147,12 @@ namespace Edu.Module.OKR
}
}
//如果是部门主管 需要将部门下除自己其他人加入
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ",")) {
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any()) {
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !emList.Select(y => y.Id).Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
ChildList.Add(new Model.ViewModel.User.Employee_ViewModel()
......@@ -3327,11 +3331,13 @@ namespace Edu.Module.OKR
}
}
//如果是部门主管 需要将部门下除自己其他人加入
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !emList.Select(y => y.Id).Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !ChildIdList.Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
ChildIdList.Add(item.Id);
......@@ -3509,11 +3515,13 @@ namespace Edu.Module.OKR
}
}
//如果是部门主管 需要将部门下除自己其他人加入
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !emList.Select(y => y.Id).Contains(x.Id)).ToList();//排序 已存在的直接关系
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id)).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
UserIdList.Add(item.Id);
......@@ -3699,11 +3707,13 @@ namespace Edu.Module.OKR
}
}
//如果是部门主管 需要将部门下除自己其他人加入
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
//查询该部门下所有人
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !emList.Select(y => y.Id).Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
UserIdList.Add(item.Id);
......@@ -3910,7 +3920,7 @@ namespace Edu.Module.OKR
/// <returns></returns>
public object GetOKRMyAlignView(int PeriodId, UserInfo userInfo)
{
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userInfo.Id });
var list = oKR_ObjectiveRepository.GetListForEmName(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userInfo.Id });
if (list.Any())
{
string objectiveIds = string.Join(",", list.Select(x => x.Id));
......@@ -3929,72 +3939,194 @@ namespace Edu.Module.OKR
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ParentIds = objectiveIds });
if (xdqlist.Any()) {
//查询下对齐数量
var rlist = oKR_ObjectiveRelationRepository.GetParentAlignNum(string.Join(",", sdqlist.Select(x => x.Id)));
foreach (var item in sdqlist)
var rlist = oKR_ObjectiveRelationRepository.GetChildAlignNum(string.Join(",", xdqlist.Select(x => x.Id)));
foreach (var item in xdqlist)
{
item.ParentNum = rlist.Where(x => x.ObjectiveId == item.Id).FirstOrDefault()?.ParentId ?? 0;
item.ChildNum = rlist.Where(x => x.ParentId == item.Id).FirstOrDefault()?.ObjectiveId ?? 0;
}
}
List<int> DQUserId = new List<int>();
string jObjectiveIds = objectiveIds;
if (sdqlist.Any())
{
jObjectiveIds += "," + string.Join(",", sdqlist.Select(x => x.Id));
DQUserId.AddRange(sdqlist.Select(x => x.CreateBy));
}
if (xdqlist.Any())
{
jObjectiveIds += "," + string.Join(",", xdqlist.Select(x => x.Id));
DQUserId.AddRange(xdqlist.Select(x => x.CreateBy));
}
//查询结果列表
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())
//用户周期权限
List<RB_OKR_Objective_ViewModel> UserLookList = new List<RB_OKR_Objective_ViewModel>();
if (DQUserId.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 });
DQUserId = DQUserId.Distinct().ToList();
//查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = PeriodId, CreateByIds = string.Join(",", DQUserId) });
if (zpList.Any())
{
foreach (var UserId in DQUserId)
{
int IsLook = 2;
var NotLookList = zpList.Where(x => x.CreateBy == UserId && x.State == 2).ToList();
var LookList = zpList.Where(x => x.CreateBy == UserId && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
IsLook = 1;
}
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))
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
ScoreRuleList = oKR_ScoreDetailRepository.GetList(new RB_OKR_ScoreDetail_ViewModel() { ScoreIds = scoreRuleIds });
IsLook = 1;
}
foreach (var item in krList)
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsLock = 2;
if (pkrList.Where(x => x.TargetId == item.Id).Any())
IsLook = 1;
}
}
if (LookList.Any())
{
item.IsLock = 1;
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
{
IsLook = 1;
}
}
UserLookList.Add(new RB_OKR_Objective_ViewModel()
{
CreateBy = UserId,
IsLock = IsLook
});
}
}
}
foreach (var item in sdqlist)
{
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
if ((UserLookList.Where(x => x.CreateBy == item.CreateBy).FirstOrDefault()?.IsLock ?? 0) == 1)
{
item.IsLock = 1;
}
else
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
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.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsLock = 1;
}
}
if (item.IsLock == 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.IsLock = 1;
}
}
}
}
}
}
foreach (var item in xdqlist)
{
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
if ((UserLookList.Where(x => x.CreateBy == item.CreateBy).FirstOrDefault()?.IsLock ?? 0) == 1)
{
item.IsLock = 1;
}
else
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
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.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsLock = 1;
}
foreach (var item in list)
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
item.IsLock = 1;
}
}
if (item.IsLock == 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.IsLock = 1;
}
}
}
}
}
}
foreach (var item in list)
{
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
......@@ -4003,129 +4135,355 @@ namespace Edu.Module.OKR
}
#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()
item.ParentSingleList = sdqlist.Where(x => x.ObjectiveId == item.Id).ToList();
item.ChildSingleList = xdqlist.Where(x => x.ParentId == item.Id).ToList();
#endregion
}
}
return list.Select(x => new
{
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()
x.Id,
x.Title,
x.Sort,
x.Progress,
x.ProgressState,
ProgressStateName = x.ProgressState.ToName(),
x.Status,
x.EmName,
x.EmPhoto,
ParentList = x.ParentSingleList.Select(y => new
{
y.Id,
Title = y.IsLock == 1 ? "" : y.Title,
y.Sort,
y.Progress,
y.IsLock,
y.ProgressState,
ProgressStateName = y.ProgressState.ToName(),
y.ParentNum,
y.EmName,
y.EmPhoto
}),
ChildList = x.ChildSingleList.Select(y => new
{
y.Id,
Title = y.IsLock == 1 ? "" : y.Title,
y.Sort,
y.Progress,
y.IsLock,
y.ProgressState,
ProgressStateName = y.ProgressState.ToName(),
y.ChildNum,
y.EmName,
y.EmPhoto
}),
});
}
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)
/// <summary>
/// 获取我的对齐视图 再下一级
/// </summary>
/// <param name="periodId"></param>
/// <param name="objectiveId"></param>
/// <param name="type"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetOKRMyAlignViewNext(int PeriodId, int objectiveId, int type, UserInfo userInfo)
{
item.ChildList.Add(new ObjectiveEmployeeModel()
if (type == 1)
{
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()
//查询向上对齐
var sdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ObjectiveIds = objectiveId.ToString() });
if (sdqlist.Any())
{
//查询上对齐数量
var rlist = oKR_ObjectiveRelationRepository.GetParentAlignNum(string.Join(",", sdqlist.Select(x => x.Id)));
foreach (var item in sdqlist)
{
item.ParentNum = rlist.Where(x => x.ObjectiveId == item.Id).FirstOrDefault()?.ParentId ?? 0;
}
}
else {
return new List<object>();
}
List<int> DQUserId = new List<int>();
string jObjectiveIds = string.Join(",", sdqlist.Select(x => x.Id));
DQUserId.AddRange(sdqlist.Select(x => x.CreateBy));
//查询结果列表
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 });
//用户周期权限
List<RB_OKR_Objective_ViewModel> UserLookList = new List<RB_OKR_Objective_ViewModel>();
if (DQUserId.Any())
{
DQUserId = DQUserId.Distinct().ToList();
//查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = PeriodId, CreateByIds = string.Join(",", DQUserId) });
if (zpList.Any())
{
foreach (var UserId in DQUserId)
{
int IsLook = 2;
var NotLookList = zpList.Where(x => x.CreateBy == UserId && x.State == 2).ToList();
var LookList = zpList.Where(x => x.CreateBy == UserId && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
IsLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
IsLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
IsLook = 1;
}
}
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
{
IsLook = 1;
}
}
UserLookList.Add(new RB_OKR_Objective_ViewModel()
{
CreateBy = UserId,
IsLock = IsLook
});
}
#endregion
}
}
foreach (var item in sdqlist)
{
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
if ((UserLookList.Where(x => x.CreateBy == item.CreateBy).FirstOrDefault()?.IsLock ?? 0) == 1)
{
item.IsLock = 1;
}
else
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
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.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsLock = 1;
}
}
if (item.IsLock == 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.IsLock = 1;
}
}
}
}
}
}
#region 分数显示
item.ScoreName = "";
item.ScoreColor = "";
if (item.ScoreRuleId > 0)
return sdqlist.Select(y => new
{
y.Id,
Title = y.IsLock == 1 ? "" : y.Title,
y.Sort,
y.Progress,
y.IsLock,
y.ProgressState,
ProgressStateName = y.ProgressState.ToName(),
y.ParentNum,
y.EmName,
y.EmPhoto
});
}
else {
//查询向下对齐
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ParentIds = objectiveId.ToString() });
if (xdqlist.Any())
{
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 rlist = oKR_ObjectiveRelationRepository.GetChildAlignNum(string.Join(",", xdqlist.Select(x => x.Id)));
foreach (var item in xdqlist)
{
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 ?? "";
item.ChildNum = rlist.Where(x => x.ParentId == item.Id).FirstOrDefault()?.ObjectiveId ?? 0;
}
}
#endregion
else {
return new List<object>();
}
List<int> DQUserId = new List<int>();
string jObjectiveIds = string.Join(",", xdqlist.Select(x => x.Id));
DQUserId.AddRange(xdqlist.Select(x => x.CreateBy));
//查询结果列表
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 });
//用户周期权限
List<RB_OKR_Objective_ViewModel> UserLookList = new List<RB_OKR_Objective_ViewModel>();
if (DQUserId.Any())
{
DQUserId = DQUserId.Distinct().ToList();
//查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = PeriodId, CreateByIds = string.Join(",", DQUserId) });
if (zpList.Any())
{
foreach (var UserId in DQUserId)
{
int IsLook = 2;
var NotLookList = zpList.Where(x => x.CreateBy == UserId && x.State == 2).ToList();
var LookList = zpList.Where(x => x.CreateBy == UserId && x.State == 1).ToList();
if (NotLookList.Any())
{
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any())
{
IsLook = 1;
}
return list.Select(x => new
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
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.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.Select(z => new
IsLook = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
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.ScoreName,
z.ScoreColor
}),
ParentList = x.ParentList.Select(y => new
IsLook = 1;
}
}
if (LookList.Any())
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
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())
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
//OK
}
else
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
ChildList = x.ChildList.Select(y => new
IsLook = 1;
}
}
UserLookList.Add(new RB_OKR_Objective_ViewModel()
{
y.AccountId,
y.AccountName,
y.Icon,
AlignList = y.AlignList.Select(q => new
CreateBy = UserId,
IsLock = IsLook
});
}
}
}
foreach (var item in xdqlist)
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
if ((UserLookList.Where(x => x.CreateBy == item.CreateBy).FirstOrDefault()?.IsLock ?? 0) == 1)
{
item.IsLock = 1;
}
else
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
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.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
item.IsLock = 1;
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department && x.SourceId == userInfo.DeptId).Any())
{
item.IsLock = 1;
}
}
if (item.IsLock == 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.IsLock = 1;
}
}
}
}
}
}
return xdqlist.Select(y => new
{
y.Id,
Title = y.IsLock == 1 ? "" : y.Title,
y.Sort,
y.Progress,
y.IsLock,
y.ProgressState,
ProgressStateName = y.ProgressState.ToName(),
y.ChildNum,
y.EmName,
y.EmPhoto
});
}
}
#endregion
......
......@@ -45,5 +45,16 @@ namespace Edu.Repository.OKR
string sql = $@" select ObjectiveId,COUNT(0) AS ParentId from RB_OKR_ObjectiveRelation WHERE ObjectiveId in({ObjectiveIds}) GROUP BY ObjectiveId";
return Get<RB_OKR_ObjectiveRelation>(sql).ToList();
}
/// <summary>
/// 获取下对齐数量
/// </summary>
/// <param name="ObjectiveIds"></param>
/// <returns></returns>
public List<RB_OKR_ObjectiveRelation> GetChildAlignNum(string ObjectiveIds)
{
string sql = $@" select ParentId,COUNT(0) AS ObjectiveId from RB_OKR_ObjectiveRelation WHERE ParentId in({ObjectiveIds}) GROUP BY ParentId";
return Get<RB_OKR_ObjectiveRelation>(sql).ToList();
}
}
}
......@@ -127,18 +127,68 @@ namespace Edu.Repository.OKR
if (!string.IsNullOrEmpty(demodel.ObjectiveIds))
{
where += $@" and r.{nameof(RB_OKR_ObjectiveRelation.ObjectiveId)} in({demodel.ObjectiveIds})";
string sql = $@" select o.*,r.ObjectiveId,r.ParentId,e.EmName,e.EmPhoto from RB_OKR_Objective o
inner join rb_okr_objectiverelation r on o.Id = r.ParentId
left join rb_employee e on o.CreateBy = e.EmployeeId
where {where} order by o.Id desc";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
if (!string.IsNullOrEmpty(demodel.ParentIds))
{
where += $@" and r.{nameof(RB_OKR_ObjectiveRelation.ParentId)} in({demodel.ParentIds})";
}
string sql = $@" select o.*,r.ObjectiveId,r.ParentId,e.EmName,e.EmPhoto from RB_OKR_Objective o
inner join rb_okr_objectiverelation r on o.Id = r.ParentId
inner join rb_okr_objectiverelation r on o.Id = r.ObjectiveId
left join rb_employee e on o.CreateBy = e.EmployeeId
where {where} order by o.Id desc";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
return new List<RB_OKR_Objective_ViewModel>();
}
public List<RB_OKR_Objective_ViewModel> GetListForEmName(RB_OKR_Objective_ViewModel demodel)
{
string where = $@" 1=1 and o.Status <>5";
if (demodel.Group_Id > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Id > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.Id)} ={demodel.Id}";
}
if (!string.IsNullOrEmpty(demodel.ObjectiveIds))
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.Id)} in({demodel.ObjectiveIds})";
}
if (demodel.PeriodId > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if (!string.IsNullOrEmpty(demodel.Title))
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.Title)} like '%{demodel.Title}%'";
}
if (demodel.ProgressState > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.ProgressState)} ={(int)demodel.ProgressState}";
}
if (demodel.CreateBy > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (demodel.Status > 0)
{
where += $@" and o.{nameof(RB_OKR_Objective_ViewModel.Status)} ={demodel.Status}";
}
string sql = $@" select o.*,e.EmName,e.EmPhoto from RB_OKR_Objective o
left join rb_employee e on o.CreateBy = e.EmployeeId
where {where} order by o.Sort asc";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取最大的Sort
......
......@@ -94,6 +94,10 @@ namespace Edu.Repository.OKR
{
where += $@" and {nameof(RB_OKR_Permission_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
if (!string.IsNullOrEmpty(demodel.CreateByIds))
{
where += $@" and {nameof(RB_OKR_Permission_ViewModel.CreateBy)} in({demodel.CreateByIds})";
}
string sql = $@" select * from RB_OKR_Permission where {where} order by Id desc";
return Get<RB_OKR_Permission_ViewModel>(sql).ToList();
......
......@@ -1186,6 +1186,29 @@ namespace Edu.WebApi.Controllers.OKR
return ApiResult.Success("", obj);
}
/// <summary>
/// 获取我的对齐视图 再下一级
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRMyAlignViewNext() {
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
int ObjectiveId = parms.GetInt("ObjectiveId", 0);//目标id
int Type = parms.GetInt("Type", 1);//类型 1向上 2向下
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull("请传递周期id");
}
if (ObjectiveId <= 0) {
return ApiResult.ParamIsNull("请传递关联目标id");
}
var obj = okrPeriodModule.GetOKRMyAlignViewNext(PeriodId, ObjectiveId, Type, userInfo);
return ApiResult.Success("", obj);
}
#endregion
#region 后台管理
......
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