Commit c12a315b authored by 吴春's avatar 吴春

提交代码

parent e43fea97
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.OKR
{
public class OKRPersonalDimension
{
/// <summary>
/// 员工id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 员工名称
/// </summary>
public string EmployeeName { get; set; }
/// <summary>
/// 员工头像
/// </summary>
public string UserIcon { get; set; }
/// <summary>
/// 员工部门
/// </summary>
public int Dept_Id { get; set; }
/// <summary>
/// 填写量
/// </summary>
public int ObjectiveNCount { get; set; }
/// <summary>
/// 对齐量
/// </summary>
public int OBjectiveRelation { get; set; }
/// <summary>
/// 打分量
/// </summary>
public decimal ScoreCount { get; set; }
/// <summary>
/// 类型 1-我的上级,2-我的下级,3-我的同级,4-我的关注
/// </summary>
public int Type { get; set; }
}
}
......@@ -132,7 +132,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_PeriodConfigRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -148,14 +149,17 @@ namespace Edu.Module.OKR
}
return flag ? "" : "失败了,请联系管理";
}
else {
else
{
//验证是否存在
var model = oKR_PeriodConfigRepository.GetList(new RB_OKR_PeriodConfig_ViewModel() { Group_Id = userInfo.Group_Id }).FirstOrDefault();
if (model != null) {
if (model != null)
{
return "已存在配置";
}
bool flag = oKR_PeriodConfigRepository.Insert(dmodel) > 0;
if (flag) {
if (flag)
{
//生成对应期数
oKR_PeriodRepository.Insert(new Model.Entity.OKR.RB_OKR_Period()
{
......@@ -172,7 +176,8 @@ namespace Edu.Module.OKR
UpdateBy = dmodel.UpdateBy,
UpdateTime = DateTime.Now
});
if (dmodel.YearOKR == 1) {
if (dmodel.YearOKR == 1)
{
//今年
oKR_PeriodRepository.Insert(new Model.Entity.OKR.RB_OKR_Period()
{
......@@ -231,9 +236,11 @@ namespace Edu.Module.OKR
public List<RB_OKR_Remind_ViewModel> GetOKRRemindList(int group_Id)
{
var list = oKR_RemindRepository.GetList(new RB_OKR_Remind_ViewModel() { Group_Id = group_Id });
for (var i = 1; i <= 4; i++) {
for (var i = 1; i <= 4; i++)
{
var model = list.Where(x => x.Type == i).FirstOrDefault();
if (model == null) {
if (model == null)
{
list.Add(new RB_OKR_Remind_ViewModel()
{
Days = "",
......@@ -274,7 +281,8 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错啦,请联系管理员";
}
else {
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_OKR_Remind_ViewModel.Days),dmodel.Days},
{ nameof(RB_OKR_Remind_ViewModel.Time),dmodel.Time},
......@@ -289,7 +297,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_RemindRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -320,7 +329,8 @@ namespace Edu.Module.OKR
{
return false;
}
else {
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_OKR_Remind_ViewModel.Enable),model.Enable == 1 ? 2 : 1}
};
......@@ -362,15 +372,17 @@ namespace Edu.Module.OKR
public List<RB_OKR_Score_ViewModel> GetOKRScoreConfigPageList(int pageIndex, int pageSize, out long count, RB_OKR_Score_ViewModel dmodel)
{
var list = oKR_ScoreRepository.GetPageList(pageIndex, pageSize, out count, dmodel);
if (list.Any()) {
if (list.Any())
{
string ids = string.Join(",", list.Select(x => x.Id));
var dlist = oKR_ScoreDetailRepository.GetList(new RB_OKR_ScoreDetail_ViewModel() { ScoreIds = ids });
foreach (var item in list) {
foreach (var item in list)
{
item.DetailList = dlist.Where(x => x.ScoreId == item.Id).ToList();
}
}
return list;
}
}
/// <summary>
/// 保存分数配置
......@@ -393,7 +405,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_ScoreRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
var list = oKR_ScoreDetailRepository.GetList(new RB_OKR_ScoreDetail_ViewModel() { ScoreId = dmodel.Id });
//删除后 再新增
oKR_ScoreDetailRepository.DeleteBatch(list);
......@@ -417,16 +430,18 @@ namespace Edu.Module.OKR
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = "修改OKR分数配置【"+dmodel.Id+"】",
LogContent = "修改OKR分数配置【" + dmodel.Id + "】",
School_Id = userInfo.School_Id,
SourceId = 0
});
}
return flag ? "" : "出错了,请联系管理员";
}
else {
else
{
int Id = oKR_ScoreRepository.Insert(dmodel);
if (Id > 0) {
if (Id > 0)
{
//增加明细
foreach (var item in dmodel.DetailList)
{
......@@ -448,14 +463,14 @@ namespace Edu.Module.OKR
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = "新增OKR分数配置【"+Id+"】",
LogContent = "新增OKR分数配置【" + Id + "】",
School_Id = userInfo.School_Id,
SourceId = 0
});
}
return Id > 0 ? "" : "出错了,请联系管理员";
}
}
}
/// <summary>
/// 设置分数配置状态
......@@ -526,7 +541,8 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错了,请联系管理员";
}
else {
else
{
return "类型不正确";
}
}
......@@ -545,7 +561,8 @@ namespace Edu.Module.OKR
foreach (var item in list)
{
item.IsCurrent = 2;
if (item.StartDate <= DateTime.Now && item.EndDate >= DateTime.Now) {
if (item.StartDate <= DateTime.Now && item.EndDate >= DateTime.Now)
{
item.IsCurrent = 1;
}
}
......@@ -561,7 +578,8 @@ namespace Edu.Module.OKR
public object GetOKRMyObjectiveList(int PeriodId, UserInfo userInfo)
{
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, CreateBy = userInfo.Id });
if (list.Any()) {
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 });
......@@ -620,7 +638,8 @@ namespace Edu.Module.OKR
item.IsLock = 1;
}
}
foreach (var item in list) {
foreach (var item in list)
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
......@@ -628,7 +647,8 @@ namespace Edu.Module.OKR
}
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
if (item.IsDefaultState == 1) {
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
......@@ -636,7 +656,8 @@ namespace Edu.Module.OKR
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) {
foreach (var qitem in EmIdList)
{
item.ParentList.Add(new ObjectiveEmployeeModel()
{
AccountId = qitem,
......@@ -1072,8 +1093,9 @@ namespace Edu.Module.OKR
#endregion
}
}
return new {
Status =1,
return new
{
Status = 1,
List = list.Where(x => x.IsLock == 2).Select(x => new
{
x.Id,
......@@ -1090,7 +1112,7 @@ namespace Edu.Module.OKR
x.IsLock,
x.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.Where(x=>x.IsLock == 2).Select(z => new
KeyResultList = x.KeyResultList.Where(x => x.IsLock == 2).Select(z => new
{
z.Id,
z.Name,
......@@ -1403,12 +1425,15 @@ namespace Edu.Module.OKR
{
//查询是否有权限
var zpList = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = 1, TargetId = periodId, CreateBy = userId });
if (zpList.Any()) {
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.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
{
Status = 2,
......@@ -1432,7 +1457,8 @@ namespace Edu.Module.OKR
};
}
}
if (LookList.Any()) {
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())
......@@ -1573,7 +1599,7 @@ namespace Edu.Module.OKR
x.Sort,
x.Progress,
x.ProgressState,
ProgressStateName = x.ProgressState.ToName(),
ProgressStateName = x.ProgressState.ToName(),
x.IsParent,
KeyResultList = x.KeyResultList.Where(x => x.IsLock == 2).Select(z => new
{
......@@ -1823,7 +1849,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -1840,7 +1867,8 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错了,请联系管理员";
}
else {
else
{
var configModel = oKR_PeriodConfigRepository.GetList(new RB_OKR_PeriodConfig_ViewModel() { Group_Id = userInfo.Group_Id }).FirstOrDefault();
if (configModel != null && configModel.DirectorAudit == 1)
......@@ -1874,7 +1902,8 @@ namespace Edu.Module.OKR
}
#endregion
}
else {
else
{
dmodel.Status = 2;
}
dmodel.Sort = oKR_ObjectiveRepository.GetObjectiveMaxSort(userInfo.Group_Id, dmodel.PeriodId, userInfo.Id) + 1;//获取 当前最大的
......@@ -1897,7 +1926,8 @@ namespace Edu.Module.OKR
dmodel.UpdateTime = DateTime.Now;
int Id = oKR_ObjectiveRepository.Insert(dmodel);
if (Id > 0) {
if (Id > 0)
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -1941,7 +1971,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_KeyResultRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -1958,27 +1989,31 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错了,请联系管理员";
}
else {
else
{
int Sort = oKR_KeyResultRepository.GetKeyResultMaxSort(objectiveId);
decimal Weight = 100;
decimal NowWeight = Weight;
bool IsUpdate = false;
var list = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveId = objectiveId });
if (list.Any()) {
if (list.Any())
{
if (list.Select(x => x.Weight).Distinct().Count() == 1)
{
//说明权重一致 平摊到每个结果里
Weight = Convert.ToDecimal((int)((Convert.ToDecimal(100) / (list.Count() + 1)) * 10)) / 10;
IsUpdate = true;
}
else if (list.Select(x => x.Weight).Distinct().Count() == 2) {
else if (list.Select(x => x.Weight).Distinct().Count() == 2)
{
if ((list.Max(x => x.Weight) - list.Min(x => x.Weight)) == (decimal)0.1)
{
//相差0.1 特殊情况 可以分摊
Weight = Convert.ToDecimal((int)((Convert.ToDecimal(100) / (list.Count() + 1)) * 10)) / 10;
IsUpdate = true;
}
else {
else
{
Weight = 0;
}
}
......@@ -2015,9 +2050,12 @@ namespace Edu.Module.OKR
UpdateTime = DateTime.Now,
Weight = NowWeight
});
if (Id > 0) {
if (IsUpdate) {
foreach (var item in list) {
if (Id > 0)
{
if (IsUpdate)
{
foreach (var item in list)
{
//修改每个结果的权重
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_OKR_KeyResult_ViewModel.Weight), Weight}
......@@ -2118,7 +2156,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//在这个范围里面的 Sort+1
oKR_ObjectiveRepository.UpdateOtherSort(objectModel1.PeriodId, objectModel1.CreateBy, objectModel1.Id, objectModel2.Sort, objectModel1.Sort);
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
......@@ -2321,7 +2360,8 @@ namespace Edu.Module.OKR
keyValues.Add(nameof(RB_OKR_Objective_ViewModel.UpdateTime), DateTime.Now);
LogContent = "删除OKR目标【" + objectiveId + "】";
}
else {
else
{
return "类型不正确";
}
List<WhereHelper> wheres = new List<WhereHelper>() {
......@@ -2332,7 +2372,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -2388,7 +2429,8 @@ namespace Edu.Module.OKR
keyValues.Add(nameof(RB_OKR_KeyResult_ViewModel.UpdateTime), DateTime.Now);
LogContent = "修改OKR目标关键结果进度为高级模式【" + keyResultId + "】";
}
else {
else
{
return "类型不正确";
}
List<WhereHelper> wheres = new List<WhereHelper>() {
......@@ -2430,7 +2472,8 @@ namespace Edu.Module.OKR
public ApiResult SgetOKRMyKeyResultProgress(int keyResultId, int type, int progress, decimal startValue, decimal endValue, decimal currentValue, UserInfo userInfo)
{
var model = oKR_KeyResultRepository.GetEntity(keyResultId);
if (model == null || model.Status == 1) {
if (model == null || model.Status == 1)
{
return ApiResult.Failed("关键结果不存在");
}
if (type == 1)
......@@ -2449,7 +2492,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_KeyResultRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//更新目标的进度百分比
var list = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveId = model.ObjectiveId });
decimal TProgress = list.Sum(x => x.Progress * x.Weight / 100);
......@@ -2478,7 +2522,7 @@ namespace Edu.Module.OKR
});
return ApiResult.Success("", new
{
TProgress =(int)TProgress,
TProgress = (int)TProgress,
CProgress = progress,
model.StartValue,
model.EndValue,
......@@ -2486,7 +2530,8 @@ namespace Edu.Module.OKR
});
}
}
else {
else
{
//根据当前值 求进度
progress = (int)(((currentValue - startValue) / (endValue - startValue)) * 100);
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -2555,22 +2600,27 @@ namespace Edu.Module.OKR
public ApiResult SgetOKRMyKeyResultWeight(int keyResultId, decimal weight, UserInfo userInfo)
{
var model = oKR_KeyResultRepository.GetEntity(keyResultId);
if (model == null || model.Status == 1) {
if (model == null || model.Status == 1)
{
return ApiResult.Failed("关键结果不存在");
}
if (model.Weight == weight) {
if (model.Weight == weight)
{
return ApiResult.Success();
}
var list = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveId = model.ObjectiveId });
if (list.Count() == 1) {
if (list.Count() == 1)
{
return ApiResult.Failed("只有一个结果,无法修改权重");
}
int MaxSort = list.Max(x => x.Sort);
var MaxModel = list.Where(x => x.Sort == MaxSort).FirstOrDefault();
if (model.Sort == MaxSort) {
if (model.Sort == MaxSort)
{
return ApiResult.Failed("最后一个KeyResult无法修改权重");
}
if (weight - model.Weight > MaxModel.Weight){
if (weight - model.Weight > MaxModel.Weight)
{
return ApiResult.Failed("总权重不能超过100%");
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -2584,7 +2634,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_KeyResultRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//更新最后一个KeyResult权重
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_OKR_KeyResult_ViewModel.Weight), MaxModel.Weight - (weight - model.Weight)}
......@@ -2605,7 +2656,7 @@ namespace Edu.Module.OKR
CreateBy = userInfo.Id,
CreateTime = DateTime.Now,
Group_Id = userInfo.Group_Id,
LogContent = "修改OKR关键结果权重【"+ keyResultId + "】",
LogContent = "修改OKR关键结果权重【" + keyResultId + "】",
School_Id = userInfo.School_Id,
SourceId = 0
});
......@@ -2629,10 +2680,12 @@ namespace Edu.Module.OKR
public ApiResult SgetOKRMyKeyResultScore(int keyResultId, decimal score, UserInfo userInfo)
{
var model = oKR_KeyResultRepository.GetEntity(keyResultId);
if (model == null || model.Status == 1){
if (model == null || model.Status == 1)
{
return ApiResult.Failed("关键结果不存在");
}
if (model.Score == score){
if (model.Score == score)
{
return ApiResult.Success();
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -2693,7 +2746,8 @@ namespace Edu.Module.OKR
public ApiResult SgetOKRMyKeyResultDel(int keyResultId, UserInfo userInfo)
{
var model = oKR_KeyResultRepository.GetEntity(keyResultId);
if (model == null || model.Status == 1){
if (model == null || model.Status == 1)
{
return ApiResult.Failed("关键结果不存在");
}
var list = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveId = model.ObjectiveId });
......@@ -2737,7 +2791,8 @@ namespace Edu.Module.OKR
oKR_ObjectiveRepository.Update(keyValues1, wheres1);
Weight = -1;
}
else {
else
{
#region 查询进度 分数
Progress = list.Where(x => x.Id != model.Id).Sum(x => x.Progress * x.Weight / 100);
Score = list.Where(x => x.Id != model.Id).Sum(x => x.Score * x.Weight / 100);
......@@ -2779,7 +2834,8 @@ namespace Edu.Module.OKR
}
decimal NowWeight = Weight + diff;
int MaxSort1 = list.Where(x => x.Id != model.Id).Max(x => x.Sort);
foreach (var item in list.Where(x => x.Id != model.Id)) {
foreach (var item in list.Where(x => x.Id != model.Id))
{
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_OKR_KeyResult_ViewModel.Weight), (diff > 0 && MaxSort1 == item.Sort ) ? Weight + diff : Weight}
};
......@@ -2832,7 +2888,7 @@ namespace Edu.Module.OKR
}
}
}
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
......@@ -2866,25 +2922,30 @@ namespace Edu.Module.OKR
public string SetOKRMyObjectiveParent(int objectiveId, int parentId, UserInfo userInfo)
{
var vlist = oKR_ObjectiveRelationRepository.GetList(new Model.Entity.OKR.RB_OKR_ObjectiveRelation() { ObjectiveId = objectiveId, ParentId = parentId });
if (vlist.Any()) {
if (vlist.Any())
{
return "已存在对齐,无法再次对齐";
}
var omodel = oKR_ObjectiveRepository.GetEntity(objectiveId);
var pmodel = oKR_ObjectiveRepository.GetEntity(parentId);
if (omodel == null) {
if (omodel == null)
{
return "目标不存在";
}
if (omodel.Status != 2)
{
return "未审核通过,无法对齐";
}
if (omodel.CreateBy != userInfo.Id) {
if (omodel.CreateBy != userInfo.Id)
{
return "不是自己目标,无法对齐";
}
if (pmodel == null) {
if (pmodel == null)
{
return "对齐目标不存在";
}
if (pmodel.Status != 2) {
if (pmodel.Status != 2)
{
return "未审核目标,无法对齐";
}
//验证是否会出现循环对齐 父级继续向上找, 当前向下找;看是否有交集
......@@ -2896,7 +2957,8 @@ namespace Edu.Module.OKR
ObjectiveId = objectiveId,
ParentId = parentId
});
if (Id > 0) {
if (Id > 0)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -2952,7 +3014,8 @@ namespace Edu.Module.OKR
});
return "";
}
else {
else
{
return "";
}
}
......@@ -2967,7 +3030,8 @@ namespace Edu.Module.OKR
public List<RB_OKR_Permission_ViewModel> GetOKRPermissionList(int targetId, int type, UserInfo userInfo)
{
var list = oKR_PermissionRepository.GetList(new RB_OKR_Permission_ViewModel() { Group_Id = userInfo.Group_Id, PermissionType = type, TargetId = targetId, CreateBy = userInfo.Id });
if (list.Any()) {
if (list.Any())
{
//人员 部门 岗位查询
string rids = string.Join(",", list.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Employee).Select(x => x.SourceId));
string bids = string.Join(",", list.Where(x => x.Type == Common.Enum.OKR.PermissionTypeEnum.Department).Select(x => x.SourceId));
......@@ -2978,15 +3042,18 @@ namespace Edu.Module.OKR
peopleList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { QIds = rids });
}
var departmentList = new List<Model.ViewModel.User.RB_Department_ViewModel>();
if (!string.IsNullOrEmpty(bids)) {
if (!string.IsNullOrEmpty(bids))
{
departmentList = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { QDeptIds = bids });
}
var postList = new List<Model.ViewModel.User.RB_Post_ViewModel>();
if (!string.IsNullOrEmpty(gids)) {
if (!string.IsNullOrEmpty(gids))
{
postRepository.GetPostListRepository(new Model.ViewModel.User.RB_Post_ViewModel() { QPostIds = gids });
}
foreach (var item in list) {
foreach (var item in list)
{
if (item.Type == Common.Enum.OKR.PermissionTypeEnum.Employee)
{
item.SourceName = peopleList.Where(x => x.Id == item.SourceId).FirstOrDefault()?.EmployeeName ?? "";
......@@ -2995,7 +3062,8 @@ namespace Edu.Module.OKR
{
item.SourceName = departmentList.Where(x => x.DeptId == item.SourceId).FirstOrDefault()?.DeptName ?? "";
}
else if (item.Type == Common.Enum.OKR.PermissionTypeEnum.Post) {
else if (item.Type == Common.Enum.OKR.PermissionTypeEnum.Post)
{
item.SourceName = postList.Where(x => x.PostId == item.SourceId).FirstOrDefault()?.PostName ?? "";
}
}
......@@ -3021,14 +3089,16 @@ namespace Edu.Module.OKR
if (list.Any())
{
//没有新增 多的删除
foreach (var item in list) {
foreach (var item in list)
{
var model = plist.Where(x => x.Type == item.Type && x.SourceId == item.SourceId).FirstOrDefault();
if (model == null)
{
//新增
oKR_PermissionRepository.Insert(item);
}
else if (model.State != item.State) {
else if (model.State != item.State)
{
//修改
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_OKR_Permission_ViewModel.State),item.State},
......@@ -3045,13 +3115,16 @@ namespace Edu.Module.OKR
oKR_PermissionRepository.Update(keyValues, wheres, trans);
}
}
foreach (var item in plist) {
if (!list.Where(x => x.Type == item.Type && x.SourceId == item.SourceId).Any()) {
foreach (var item in plist)
{
if (!list.Where(x => x.Type == item.Type && x.SourceId == item.SourceId).Any())
{
oKR_PermissionRepository.Delete(item, trans);
}
}
}
else {
else
{
//删除所有权限
oKR_PermissionRepository.DeleteBatch(plist, trans);
}
......@@ -3103,7 +3176,8 @@ namespace Edu.Module.OKR
UserIdList.Add(directModel.Id);
ParentIdList.Add(directModel.Id);
}
else {
else
{
//根据部门查询
string ManagerIds = "";
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
......@@ -3112,12 +3186,15 @@ namespace Edu.Module.OKR
var deptpModel = departmentRepository.GetEntity(deptModel.ParentId);
ManagerIds = deptpModel?.ManagerIds ?? "";
}
else {
else
{
ManagerIds = deptModel.ManagerIds;
}
if (!string.IsNullOrEmpty(ManagerIds)) {
if (!string.IsNullOrEmpty(ManagerIds))
{
var list = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { QIds = ManagerIds });
foreach (var item in list) {
foreach (var item in list)
{
ZSList.Add(new Model.ViewModel.User.Employee_ViewModel()
{
Id = item.Id,
......@@ -3136,7 +3213,8 @@ namespace Edu.Module.OKR
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id });
if (emList.Any())
{
foreach (var item in emList) {
foreach (var item in emList)
{
ChildList.Add(new Model.ViewModel.User.Employee_ViewModel()
{
Id = item.Id,
......@@ -3149,7 +3227,8 @@ namespace Edu.Module.OKR
//如果是部门主管 需要将部门下除自己其他人加入
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any()) {
if (xjdlist.Any())
{
//查询该部门下所有人
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();//排序 已存在的直接关系
......@@ -3184,7 +3263,8 @@ namespace Edu.Module.OKR
//查询部门负责人 负责的所有部门
var dlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = string.Join(",", ParentIdList) });
if (dlist.Any()) {
if (dlist.Any())
{
if (!("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
{
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", dlist.Select(x => x.DeptId)) });
......@@ -3200,7 +3280,8 @@ namespace Edu.Module.OKR
UserIdList.Add(item.Id);
}
}
else {
else
{
//表示自己也是部门负责人 上级所在部门下的所有部门的负责人
var d2list = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, QParentIds = string.Join(",", ZSList.Select(x => x.Dept_Id)) });
string ManagerIds = string.Join(",", d2list.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
......@@ -3262,7 +3343,8 @@ namespace Edu.Module.OKR
}
#endregion
//还差了个 是否有最新消息返回------------------------------------------------------
if (UserIdList.Any()) {
if (UserIdList.Any())
{
var list = oKR_UpdateNotificationRepository.GetList(new RB_OKR_UpdateNotification_ViewModel() { ReceiveId = userInfo.Id, UpdateByIds = string.Join(",", UserIdList), State = 2 });
var UserUpdateList = list.Select(x => x.UpdateBy).ToList();
ZSList.Where(x => UserUpdateList.Contains(x.Id)).ToList().ForEach(x =>
......@@ -3284,25 +3366,29 @@ namespace Edu.Module.OKR
}
return new
{
ParentList = ZSList.Select(x => new {
ParentList = ZSList.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon,
IsHaveUpdate = x.IsBirth
}),
ChildList = ChildList.Select(x => new {
ChildList = ChildList.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon,
IsHaveUpdate = x.IsBirth
}),
SiblingList = SiblingList.Select(x => new {
SiblingList = SiblingList.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon,
IsHaveUpdate = x.IsBirth
}),
AttentionList = AttentionList.Select(x => new {
AttentionList = AttentionList.Select(x => new
{
x.Id,
x.EmployeeName,
x.UserIcon,
......@@ -3406,7 +3492,8 @@ namespace Edu.Module.OKR
{
bool Attention = false;
var list = oKR_AttentionRepository.GetList(new RB_OKR_Attention_ViewModel() { Group_Id = userInfo.Group_Id, AccountId = userInfo.Id, AttentionId = userId });
if (list.Any()) {
if (list.Any())
{
Attention = true;
}
return ApiResult.Success("", Attention);
......@@ -3424,7 +3511,8 @@ namespace Edu.Module.OKR
var list = oKR_AttentionRepository.GetList(new RB_OKR_Attention_ViewModel() { Group_Id = userInfo.Group_Id, AccountId = userInfo.Id, AttentionId = userId });
if (type == 1)
{
if (list.Any()) {
if (list.Any())
{
return "已经关注,无法再次关注";
}
bool flag = oKR_AttentionRepository.Insert(new Model.Entity.OKR.RB_OKR_Attention()
......@@ -3440,7 +3528,8 @@ namespace Edu.Module.OKR
UpdateBy = userInfo.Id,
UpdateTime = DateTime.Now
}) > 0;
if (flag) {
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -3456,8 +3545,10 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错了,请联系管理员";
}
else {
if (!list.Any()) {
else
{
if (!list.Any())
{
return "尚未关注,无法取消关注";
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -3552,7 +3643,8 @@ namespace Edu.Module.OKR
}
};
bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -3618,7 +3710,8 @@ namespace Edu.Module.OKR
public string ClearMyEmployeeUpdateNotification(int userId, UserInfo userInfo)
{
var model = oKR_UpdateNotificationRepository.GetList(new RB_OKR_UpdateNotification_ViewModel() { Group_Id = userInfo.Group_Id, ReceiveId = userInfo.Id, UpdateBy = userId, State = 2 }).FirstOrDefault();
if (model == null) {
if (model == null)
{
return "";
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -3643,7 +3736,8 @@ namespace Edu.Module.OKR
/// <param name="periodId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool AddMyEmployeeUpdateNotification(int periodId, UserInfo userInfo) {
public bool AddMyEmployeeUpdateNotification(int periodId, UserInfo userInfo)
{
try
{
var deptModel = departmentRepository.GetEntity(userInfo.DeptId);
......@@ -3851,9 +3945,11 @@ namespace Edu.Module.OKR
/// <param name="objectiveId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool AddMyEmployeeUpdateNotification_V2(int objectiveId, UserInfo userInfo) {
public bool AddMyEmployeeUpdateNotification_V2(int objectiveId, UserInfo userInfo)
{
var model = oKR_ObjectiveRepository.GetEntity(objectiveId);
if (model != null) {
if (model != null)
{
return AddMyEmployeeUpdateNotification(model.PeriodId, userInfo);
}
return false;
......@@ -3865,7 +3961,8 @@ namespace Edu.Module.OKR
/// <param name="UserIdList"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public bool SetMyUserUpdateNotification(List<int> UserIdList, UserInfo userInfo) {
public bool SetMyUserUpdateNotification(List<int> UserIdList, UserInfo userInfo)
{
if (UserIdList.Any())
{
UserIdList = UserIdList.Distinct().ToList();
......@@ -3937,7 +4034,8 @@ 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()) {
if (xdqlist.Any())
{
//查询下对齐数量
var rlist = oKR_ObjectiveRelationRepository.GetChildAlignNum(string.Join(",", xdqlist.Select(x => x.Id)));
foreach (var item in xdqlist)
......@@ -4203,7 +4301,8 @@ namespace Edu.Module.OKR
item.ParentNum = rlist.Where(x => x.ObjectiveId == item.Id).FirstOrDefault()?.ParentId ?? 0;
}
}
else {
else
{
return new List<object>();
}
List<int> DQUserId = new List<int>();
......@@ -4336,7 +4435,8 @@ namespace Edu.Module.OKR
y.EmPhoto
});
}
else {
else
{
//查询向下对齐
var xdqlist = oKR_ObjectiveRepository.GetParentList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = PeriodId, ParentIds = objectiveId.ToString() });
if (xdqlist.Any())
......@@ -4348,14 +4448,15 @@ namespace Edu.Module.OKR
item.ChildNum = rlist.Where(x => x.ParentId == item.Id).FirstOrDefault()?.ObjectiveId ?? 0;
}
}
else {
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 });
......@@ -4544,5 +4645,246 @@ namespace Edu.Module.OKR
#endregion
/// <summary>
/// 获取个人维度打分以及目标量
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="id"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRPersonalAlignList(int group_Id, int periodId, string CreateBys)
{
return oKR_ObjectiveRepository.GetOKRPersonalAlignList(group_Id, periodId, CreateBys);
}
/// <summary>
/// 获取个人维度对齐量
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="id"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRPersonalRelationAlignList(int group_Id, int periodId, string CreateBys, int id)
{
return oKR_ObjectiveRepository.GetOKRPersonalRelationAlignList(group_Id, periodId, CreateBys, id);
}
/// <summary>
/// 获取左边人员列表
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<OKRPersonalDimension> GetOKRPersonalDimensionList(UserInfo userInfo)
{
var deptModel = departmentRepository.GetEntity(userInfo.DeptId);
List<int> UserIdList = new List<int>();
List<int> ParentIdList = new List<int>();
List<OKRPersonalDimension> allList = new List<OKRPersonalDimension>();
#region 我的直属上级
List<Model.ViewModel.User.Employee_ViewModel> ZSList = new List<Model.ViewModel.User.Employee_ViewModel>();
var accountModel = accountRepository.GetEntity(userInfo.Id);
if (accountModel.DirectSupervisor > 0)
{
var directModel = accountRepository.GetEmployeeInfo(accountModel.DirectSupervisor);
allList.Add(new OKRPersonalDimension()
{
Id = directModel.Id,
EmployeeName = directModel.EmployeeName,
UserIcon = directModel.UserIcon,
Dept_Id = directModel.Dept_Id,
Type = 1
});
UserIdList.Add(directModel.Id);
ParentIdList.Add(directModel.Id);
}
else
{
//根据部门查询
string ManagerIds = "";
if (("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
{
//说明自己是当前部门的主管 再查上级部门主管
var deptpModel = departmentRepository.GetEntity(deptModel.ParentId);
ManagerIds = deptpModel?.ManagerIds ?? "";
}
else
{
ManagerIds = deptModel.ManagerIds;
}
if (!string.IsNullOrEmpty(ManagerIds))
{
var list = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { QIds = ManagerIds });
foreach (var item in list)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 1
});
UserIdList.Add(item.Id);
ParentIdList.Add(item.Id);
}
}
}
#endregion
#region 我的直属下级
List<Model.ViewModel.User.Employee_ViewModel> ChildList = new List<Model.ViewModel.User.Employee_ViewModel>();
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id });
if (emList.Any())
{
foreach (var item in emList)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 2
});
UserIdList.Add(item.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, 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)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 2
});
UserIdList.Add(item.Id);
}
}
#endregion
#region 我的同级
List<Model.ViewModel.User.Employee_ViewModel> SiblingList = new List<Model.ViewModel.User.Employee_ViewModel>();
if (ParentIdList.Any())
{
var em2List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisorIds = string.Join(",", ParentIdList) });
em2List = em2List.Where(x => x.Id != userInfo.Id && !UserIdList.Contains(x.Id)).ToList();
foreach (var item in em2List)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
});
UserIdList.Add(item.Id);
}
//查询部门负责人 负责的所有部门
var dlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = string.Join(",", ParentIdList) });
if (dlist.Any())
{
if (!("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
{
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QDeptIds = string.Join(",", dlist.Select(x => x.DeptId)) });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
});
UserIdList.Add(item.Id);
}
}
else
{
//表示自己也是部门负责人 上级所在部门下的所有部门的负责人
var d2list = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, QParentIds = string.Join(",", ZSList.Select(x => x.Dept_Id)) });
string ManagerIds = string.Join(",", d2list.Where(x => !string.IsNullOrEmpty(x.ManagerIds)).Select(x => x.ManagerIds));
if (!string.IsNullOrEmpty(ManagerIds))
{
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, QIds = ManagerIds });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
});
UserIdList.Add(item.Id);
}
}
}
}
}
else
{
//继续查询同部门的 也算同级
if (!("," + deptModel.ManagerIds + ",").Contains("," + userInfo.Id + ","))
{
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, Dept_Id = userInfo.DeptId });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != userInfo.Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
allList.Add(new OKRPersonalDimension()
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
});
UserIdList.Add(item.Id);
}
}
}
#endregion
#region 我的关注
//List<Model.ViewModel.User.Employee_ViewModel> AttentionList = new List<Model.ViewModel.User.Employee_ViewModel>();
//var alist = oKR_AttentionRepository.GetList(new RB_OKR_Attention_ViewModel() { Group_Id = userInfo.Group_Id, AccountId = userInfo.Id });
//if (alist.Any())
//{
// string aids = string.Join(",", alist.Select(x => x.AttentionId));
// var em3List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { QIds = aids });
// foreach (var item in em3List)
// {
// allList.Add(new OKRPersonalDimension()
// {
// Id = item.Id,
// EmployeeName = item.EmployeeName,
// UserIcon = item.UserIcon,
// Dept_Id = item.Dept_Id,
// Type = 3
// });
// UserIdList.Add(item.Id);
// }
//}
#endregion
return allList;
}
}
}
......@@ -219,7 +219,8 @@ where {where} order by o.Sort asc";
{
sql += $@" AND Sort > {startSort} ";
}
if (endSort > 0) {
if (endSort > 0)
{
sql += $@" and Sort < {endSort} ";
}
return Execute(sql) > 0;
......@@ -272,5 +273,43 @@ LEFT JOIN RB_OKR_Objective o2 on re.ParentId = o2.Id
WHERE o1.Group_Id={group_Id} and o1.`Status` <>5 and o2.`Status` <>5 and o1.PeriodId ={periodId} and o1.CreateBy in ({id}) GROUP BY o2.CreateBy";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取个人维度打分以及目标量
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="id"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRPersonalAlignList(int group_Id, int periodId, string CreateBys)
{
string where = string.Empty;
if (!string.IsNullOrWhiteSpace(CreateBys))
{
where = $" and a.CreateBy in({CreateBys})";
}
string sql = $@"SELECT COUNT(*) as ChildNum,a.CreateBy ,SUM(Score) as Score from rb_okr_objective as a LEFT JOIN rb_okr_objectiverelation as b on a.Id=b.ObjectiveId
WHERE a.Group_Id={group_Id} and a.`Status` <>5 and a.PeriodId ={periodId} {where}
GROUP BY a.CreateBy";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取个人维度对齐量
/// </summary>
/// <param name="group_Id"></param>
/// <param name="periodId"></param>
/// <param name="id"></param>
/// <returns></returns>
public List<RB_OKR_Objective_ViewModel> GetOKRPersonalRelationAlignList(int group_Id, int periodId, string CreateBys,int id)
{
string sql = $@"SELECT COUNT(0) as ChildNum,o2.CreateBy FROM
rb_okr_objectiverelation or1
LEFT JOIN rb_okr_objective o1 on or1.ObjectiveId = o1.Id
LEFT JOIN rb_okr_objective o2 on or1.ParentId = o2.Id
WHERE o1.CreateBy in({CreateBys}) and o2.CreateBy ={id} and o1.`Status`=2 and o1.Group_Id={group_Id} and o1.PeriodId ={periodId} and o2.Group_Id={group_Id} and o2.PeriodId ={periodId} and o2.`Status`=2 group by o1.CreateBy ";
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
}
}
......@@ -414,7 +414,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRMyObjectiveInfo() {
public ApiResult GetOKRMyObjectiveInfo()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int ObjectiveId = parms.GetInt("ObjectiveId", 0);
......@@ -649,15 +650,18 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKRMyKeyResultWeight() {
public ApiResult SgetOKRMyKeyResultWeight()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int KeyResultId = parms.GetInt("KeyResultId", 0);
decimal Weight = parms.GetDecimal("Weight");
if (KeyResultId <= 0) {
if (KeyResultId <= 0)
{
return ApiResult.ParamIsNull("请传递结果Id");
}
if (Weight < 0 || Weight > 100) {
if (Weight < 0 || Weight > 100)
{
return ApiResult.ParamIsNull("权重值有误");
}
......@@ -669,7 +673,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKRMyKeyResultScore() {
public ApiResult SgetOKRMyKeyResultScore()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int KeyResultId = parms.GetInt("KeyResultId", 0);
......@@ -714,7 +719,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKRMyObjectiveParent() {
public ApiResult SgetOKRMyObjectiveParent()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int ObjectiveId = parms.GetInt("ObjectiveId", 0);
......@@ -737,7 +743,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -814,7 +821,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRPermissionList() {
public ApiResult GetOKRPermissionList()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int TargetId = parms.GetInt("TargetId", 0);
......@@ -843,7 +851,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKRPermissionInfo() {
public ApiResult SgetOKRPermissionInfo()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PermissionType = parms.GetInt("PermissionType", 0);
......@@ -857,7 +866,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.ParamIsNull("请传递目标值");
}
if (string.IsNullOrEmpty(List)) {
if (string.IsNullOrEmpty(List))
{
return ApiResult.ParamIsNull("请传递列表数据");
}
List<RB_OKR_Permission_ViewModel> dmodel = JsonHelper.DeserializeObject<List<RB_OKR_Permission_ViewModel>>(List);
......@@ -890,7 +900,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -904,7 +915,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRMyEmployeeList() {
public ApiResult GetOKRMyEmployeeList()
{
var userInfo = base.UserInfo;
var obj = okrPeriodModule.GetOKRMyEmployeeList(userInfo);
......@@ -921,7 +933,8 @@ namespace Edu.WebApi.Controllers.OKR
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
if (PeriodId <= 0) {
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
......@@ -989,11 +1002,13 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKREmployeeAttention() {
public ApiResult GetOKREmployeeAttention()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int UserId = parms.GetInt("UserId", 0);
if (UserId <= 0) {
if (UserId <= 0)
{
return ApiResult.ParamIsNull("请传递用户id");
}
......@@ -1005,7 +1020,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetOKREmployeeAttention() {
public ApiResult SgetOKREmployeeAttention()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int UserId = parms.GetInt("UserId", 0);
......@@ -1020,7 +1036,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -1051,7 +1068,7 @@ namespace Edu.WebApi.Controllers.OKR
return ApiResult.Failed("只能审核他人目标");
}
return okrPeriodModule.GetOKRObjectiveAuditList(PeriodId, UserId, userInfo);
return okrPeriodModule.GetOKRObjectiveAuditList(PeriodId, UserId, userInfo);
}
/// <summary>
......@@ -1074,13 +1091,14 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.ParamIsNull("请传递类型");
}
string msg = okrPeriodModule.SetOKRObjectiveAudit(ObjectiveId, Type, Remark, userInfo);
if (msg == "")
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -1120,11 +1138,13 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult ClearMyEmployeeUpdateNotification() {
public ApiResult ClearMyEmployeeUpdateNotification()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int UserId = parms.GetInt("UserId", 0);
if (UserId <= 0) {
if (UserId <= 0)
{
return ApiResult.ParamIsNull("请传递用户id");
}
......@@ -1133,7 +1153,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed(msg);
}
}
......@@ -1143,7 +1164,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SgetMyUserUpdateNotification() {
public ApiResult SgetMyUserUpdateNotification()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
string UserIds = parms.GetStringValue("UserIds");
......@@ -1178,7 +1200,8 @@ namespace Edu.WebApi.Controllers.OKR
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
if (PeriodId <= 0) {
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull("请传递周期id");
}
......@@ -1191,7 +1214,8 @@ namespace Edu.WebApi.Controllers.OKR
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRMyAlignViewNext() {
public ApiResult GetOKRMyAlignViewNext()
{
var userInfo = base.UserInfo;
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
......@@ -1201,7 +1225,8 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.ParamIsNull("请传递周期id");
}
if (ObjectiveId <= 0) {
if (ObjectiveId <= 0)
{
return ApiResult.ParamIsNull("请传递关联目标id");
}
......@@ -1234,10 +1259,12 @@ namespace Edu.WebApi.Controllers.OKR
PeriodId = base.ParmJObj.GetInt("PeriodId", 0),
AccountId = base.ParmJObj.GetInt("AccountId", 0)
};
if (query.PeriodId <= 0) {
if (query.PeriodId <= 0)
{
return ApiResult.ParamIsNull("请传递期数");
}
if (query.AccountId <= 0) {
if (query.AccountId <= 0)
{
return ApiResult.ParamIsNull("请传递用户id");
}
query.Group_Id = base.UserInfo.Group_Id;
......@@ -1256,7 +1283,7 @@ namespace Edu.WebApi.Controllers.OKR
item.CreateTimeStr = StringHelper.DateFormatToString(item.CreateTime);
}
pageModel.Count = rowsCount;
pageModel.PageData = list.Select(x => new { x.CreateByName,x.Id, x.CreateByIco, x.UpdateByName, x.Content, x.CreateTimeStr });
pageModel.PageData = list.Select(x => new { x.CreateByName, x.Id, x.CreateByIco, x.UpdateByName, x.Content, x.CreateTimeStr });
return ApiResult.Success(data: pageModel);
}
......@@ -1273,13 +1300,16 @@ namespace Edu.WebApi.Controllers.OKR
Content = base.ParmJObj.GetStringValue("Content"),
AccountId = base.ParmJObj.GetInt("AccountId", 0)
};
if (extModel.PeriodId <= 0) {
if (extModel.PeriodId <= 0)
{
return ApiResult.ParamIsNull("请传递周期id");
}
if (extModel.AccountId <= 0) {
if (extModel.AccountId <= 0)
{
return ApiResult.ParamIsNull("请传递用户id");
}
if (string.IsNullOrEmpty(extModel.Content)) {
if (string.IsNullOrEmpty(extModel.Content))
{
return ApiResult.ParamIsNull("请传递内容");
}
extModel.CreateBy = base.UserInfo.Id;
......@@ -1321,7 +1351,60 @@ namespace Edu.WebApi.Controllers.OKR
#endregion
#region 数据看板
#region 个人端数据看板
/// <summary>
/// 获取个人维度
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetOKRPersonalDimensionList()
{
var userInfo = base.UserInfo;
List<OKRPersonalDimension> allList = okrPeriodModule.GetOKRPersonalDimensionList(userInfo);
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
int PeriodId = parms.GetInt("PeriodId", 0);
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
if (allList == null || !allList.Any(x => x.Type == 2))
{
return ApiResult.Failed("您没有下级");
}
else
{
decimal objectiveRate = 0;
decimal objectiveRelationRate = 0;
decimal scoreRate = 0;
string createBys = string.Join(",", allList.Where(x => x.Type == 2).Select(x => x.Id));
var obj = okrPeriodModule.GetOKRPersonalAlignList(userInfo.Group_Id, PeriodId, createBys);
if (obj != null && obj.Any())
{
var objRelation = okrPeriodModule.GetOKRPersonalRelationAlignList(userInfo.Group_Id, PeriodId, createBys, userInfo.Id);
foreach (var item in allList.Where(x => x.Type == 2))
{
item.ObjectiveNCount = obj.Where(x => x.CreateBy == item.Id).Sum(x => x.ChildNum);
item.OBjectiveRelation = objRelation.Where(x => x.CreateBy == item.Id).Sum(x => x.ChildNum);
item.ScoreCount = obj.Where(x => x.CreateBy == item.Id).Sum(x => x.Score);
}
int allChildrenCount = allList.Where(x => x.Type == 2).Count();
objectiveRate = decimal.Round(obj.GroupBy(x => x.CreateBy).Count() / allChildrenCount, 2);
objectiveRelationRate = decimal.Round(objRelation.GroupBy(x => x.CreateBy).Count() / allChildrenCount, 2);
scoreRate = decimal.Round(obj.Where(x => x.Score > 0).GroupBy(x => x.CreateBy).Count() / allChildrenCount, 2);
}
var resutl = new
{
MyChildrenList = allList.Where(x => x.Type == 2),
objectiveRate,
objectiveRelationRate,
scoreRate
};
return ApiResult.Success("", resutl);
}
}
#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