Commit 634e13c9 authored by 吴春's avatar 吴春

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

parents b3d0d70a 12f112d2
......@@ -724,6 +724,412 @@ namespace Edu.Module.OKR
});
}
/// <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)
{
//查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, ObjectiveId = periodId, CreateBy = userId });
if (zpList.Any()) {
var NotLookList = zpList.Where(x => x.State == 2).ToList();
var LookList = zpList.Where(x => x.State == 1).ToList();
if (NotLookList.Any()) {
//有不可看的
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee && x.SourceId == userInfo.Id).Any()) {
return new
{
Status = 2,
Msg = "没有权限查询"
};
}
if (NotLookList.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Post && x.SourceId == userInfo.PostId).Any())
{
return new
{
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()) {
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 = "没有权限查询"
};
}
}
}
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = periodId, CreateBy = userId });
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 });
}
foreach (var item in krList)
{
item.IsLock = 2;
if (pkrList.Where(x => x.ObjectiveId == item.Id).Any())
{
var NotLookList = pkrList.Where(x => x.ObjectiveId == item.Id && x.State == 2).ToList();
var LookList = pkrList.Where(x => x.ObjectiveId == 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 (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.IsLock = 2;
if (pList.Where(x => x.ObjectiveId == item.Id).Any())
{
item.IsLock = 1;
}
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
}
}
return list.Select(x => 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.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.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.ScoreName,
z.ScoreColor
}),
ParentList = x.ParentList.Select(y => new
{
y.AccountId,
y.AccountName,
AlignList = y.AlignList.Select(q => new
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
ChildList = x.ChildList.Select(y => new
{
y.AccountId,
y.AccountName,
AlignList = y.AlignList.Select(q => new
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
});
}
/// <summary>
/// 获取我的单个目标
/// </summary>
/// <param name="objectiveId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetOKRMyObjectiveInfo(int objectiveId, UserInfo userInfo)
{
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, Id = objectiveId, CreateBy = userInfo.Id });
if (list.Any())
{
var mdoel = list.FirstOrDefault();
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 = mdoel.PeriodId, ObjectiveIds = objectiveIds });
//查询向下对齐
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = mdoel.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 krList)
{
item.IsLock = 2;
if (pkrList.Where(x => x.ObjectiveId == item.Id).Any())
{
item.IsLock = 1;
}
}
foreach (var item in sdqlist)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
if (pList.Where(x => x.ObjectiveId == item.Id).Any())
{
item.IsLock = 1;
}
}
foreach (var item in xdqlist)
{
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
item.IsLock = 2;
if (pList.Where(x => x.ObjectiveId == item.Id).Any())
{
item.IsLock = 1;
}
}
foreach (var item in list)
{
item.IsLock = 2;
if (pList.Where(x => x.ObjectiveId == item.Id).Any())
{
item.IsLock = 1;
}
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1)
{
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,
AlignList = sdqclist.Where(x => x.CreateBy == qitem).ToList()
});
}
var xdqclist = xdqlist.Where(x => x.ObjectiveId == 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,
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.FirstOrDefault();
if (x == null) { return null; }
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.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.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.ScoreName,
z.ScoreColor
}),
ParentList = x.ParentList.Select(y => new
{
y.AccountId,
y.AccountName,
AlignList = y.AlignList.Select(q => new
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
ChildList = x.ChildList.Select(y => new
{
y.AccountId,
y.AccountName,
AlignList = y.AlignList.Select(q => new
{
q.Id,
q.Title,
q.Sort,
q.IsLock,
KeyResultList = x.KeyResultList.Select(z => new
{
z.Id,
z.Name,
z.Sort,
z.IsLock
}),
})
}),
};
}
/// <summary>
/// 保存目标
/// </summary>
......
......@@ -59,6 +59,10 @@ namespace Edu.Repository.OKR
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Id > 0)
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Id)} ={demodel.Id}";
}
if (!string.IsNullOrEmpty(demodel.ObjectiveIds))
{
where += $@" and {nameof(RB_OKR_Objective_ViewModel.Id)} in({demodel.ObjectiveIds})";
......
......@@ -90,6 +90,10 @@ namespace Edu.Repository.OKR
{
where += $@" and {nameof(RB_OKR_Permission_ViewModel.State)} ={demodel.State}";
}
if (demodel.CreateBy > 0)
{
where += $@" and {nameof(RB_OKR_Permission_ViewModel.CreateBy)} ={demodel.CreateBy}";
}
string sql = $@" select * from RB_OKR_Permission where {where} order by Id desc";
return Get<RB_OKR_Permission_ViewModel>(sql).ToList();
......
......@@ -414,7 +414,15 @@ namespace Edu.WebApi.Controllers.OKR
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRMyObjectiveInfo() {
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int ObjectiveId = parms.GetInt("ObjectiveId", 0);
if (ObjectiveId <= 0)
{
return ApiResult.ParamIsNull("请传递目标id");
}
var obj = okrPeriodModule.GetOKRMyObjectiveInfo(ObjectiveId, userInfo);
return ApiResult.Success("", obj);
}
/// <summary>
......@@ -696,6 +704,41 @@ namespace Edu.WebApi.Controllers.OKR
}
//权限 添加对齐 审核 评论 左边人员列表 对齐视图 数据看板 (管理员版 对齐视图 数据看板)
#region 添加对齐
/// <summary>
/// 添加对齐
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKRMyObjectiveParent() {
return ApiResult.Success();
}
/// <summary>
/// 获取他人的目标列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKROthersObjectiveList()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
int UserId = parms.GetInt("UserId", 0);
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull("请传递周期id");
}
if (UserId <= 0)
{
return ApiResult.ParamIsNull("请传递用户id");
}
var list = okrPeriodModule.GetOKROthersObjectiveList(PeriodId, UserId, userInfo);
return ApiResult.Success("", list);
}
#endregion
#endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment