Commit 497c327a authored by 吴春's avatar 吴春

提交代码

parent 502dfe7e
......@@ -11,6 +11,10 @@ namespace Edu.Model.ViewModel.OKR
/// </summary>
public int Id { get; set; }
/// <summary>
/// 员工名称
/// </summary>
public int AccountId { get; set; }
/// <summary>
/// 员工名称
......@@ -47,7 +51,11 @@ namespace Edu.Model.ViewModel.OKR
public int Type { get; set; }
public int PeriodId { get; set; }
public int School_Id { get; set; }
public int Group_Id { 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,10 +372,12 @@ 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();
}
}
......@@ -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,7 +463,7 @@ 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
});
......@@ -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())
{
List<int> MyUnderlingList = GetMyUnderlingUserIdList(userInfo);
string objectiveIds = string.Join(",", list.Select(x => x.Id));
......@@ -642,7 +660,8 @@ namespace Edu.Module.OKR
}
}
}
foreach (var qitem in item.KeyResultList) {
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
qitem.IsNotLook = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
......@@ -781,7 +800,8 @@ namespace Edu.Module.OKR
}
}
}
foreach (var item in list) {
foreach (var item in list)
{
item.IsLock = 2;
if (pList.Where(x => x.TargetId == item.Id).Any())
{
......@@ -789,14 +809,16 @@ namespace Edu.Module.OKR
}
//结果列表
item.KeyResultList = krList.Where(x => x.ObjectiveId == item.Id).ToList();
foreach (var qitem in item.KeyResultList) {
foreach (var qitem in item.KeyResultList)
{
qitem.IsLock = 2;
if (pkrList.Where(x => x.TargetId == qitem.Id).Any())
{
qitem.IsLock = 1;
}
}
if (item.IsDefaultState == 1) {
if (item.IsDefaultState == 1)
{
item.ProgressState = item.KeyResultList.Max(x => x.ProgressState);
}
......@@ -804,7 +826,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,
......@@ -1362,8 +1385,9 @@ namespace Edu.Module.OKR
#endregion
}
}
return new {
Status =1,
return new
{
Status = 1,
List = list.Where(x => x.IsNotLook == 2).Select(x => new
{
x.Id,
......@@ -1380,7 +1404,7 @@ namespace Edu.Module.OKR
x.IsNotLook,
x.ScoreName,
x.ScoreColor,
KeyResultList = x.KeyResultList.Where(x=>x.IsNotLook == 2).Select(z => new
KeyResultList = x.KeyResultList.Where(x => x.IsNotLook == 2).Select(z => new
{
z.Id,
z.Name,
......@@ -2857,7 +2881,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,
......@@ -2874,7 +2899,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)
......@@ -2919,7 +2945,8 @@ namespace Edu.Module.OKR
}
#endregion
}
else {
else
{
dmodel.Status = 2;
}
dmodel.Sort = oKR_ObjectiveRepository.GetObjectiveMaxSort(userInfo.Group_Id, dmodel.PeriodId, userInfo.Id) + 1;//获取 当前最大的
......@@ -2942,7 +2969,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,
......@@ -2986,7 +3014,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,
......@@ -3003,27 +3032,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;
}
}
......@@ -3060,9 +3093,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}
......@@ -3163,7 +3199,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()
......@@ -3366,7 +3403,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>() {
......@@ -3377,7 +3415,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,
......@@ -3433,7 +3472,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>() {
......@@ -3475,7 +3515,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)
......@@ -3494,7 +3535,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);
......@@ -3523,7 +3565,7 @@ namespace Edu.Module.OKR
});
return ApiResult.Success("", new
{
TProgress =(int)TProgress,
TProgress = (int)TProgress,
CProgress = progress,
model.StartValue,
model.EndValue,
......@@ -3531,7 +3573,8 @@ namespace Edu.Module.OKR
});
}
}
else {
else
{
//根据当前值 求进度
progress = (int)(((currentValue - startValue) / (endValue - startValue)) * 100);
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -3600,22 +3643,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>() {
......@@ -3629,7 +3677,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)}
......@@ -3650,7 +3699,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
});
......@@ -3674,10 +3723,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>() {
......@@ -3738,7 +3789,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 });
......@@ -3782,7 +3834,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);
......@@ -3824,7 +3877,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}
};
......@@ -3911,25 +3965,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 "已向该 Objective对齐,无法再次对齐";
}
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 "未审核目标,无法对齐";
}
//验证是否会出现循环对齐 父级继续向上找/当前向下找;看是否有交集
......@@ -3945,7 +4004,8 @@ namespace Edu.Module.OKR
ObjectiveId = objectiveId,
ParentId = parentId
});
if (Id > 0) {
if (Id > 0)
{
//记录日志
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
......@@ -4001,7 +4061,8 @@ namespace Edu.Module.OKR
});
return "";
}
else {
else
{
return "";
}
}
......@@ -4016,7 +4077,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));
......@@ -4027,15 +4089,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 ?? "";
......@@ -4044,7 +4109,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 ?? "";
}
}
......@@ -4070,14 +4136,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},
......@@ -4094,13 +4162,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);
}
......@@ -4154,7 +4225,8 @@ namespace Edu.Module.OKR
UserIdList.Add(directModel.Id);
ParentIdList.Add(directModel.Id);
}
else {
else
{
//根据部门查询
string ManagerIds = "";
sjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
......@@ -4175,13 +4247,16 @@ namespace Edu.Module.OKR
ManagerIds = ManagerIds[0..^1];
}
}
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,
......@@ -4200,7 +4275,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,
......@@ -4213,7 +4289,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();//排序 已存在的直接关系
......@@ -4278,7 +4355,8 @@ namespace Edu.Module.OKR
//查询部门负责人 负责的所1有部门
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())
{
//上级所在部门下 所有的普通成员
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();//排序 已存在的直接关系
......@@ -4315,7 +4393,8 @@ namespace Edu.Module.OKR
}
else
{
if (sjdlistSelect == false) {
if (sjdlistSelect == false)
{
sjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
}
//继续查询同部门的 也算同级
......@@ -4356,7 +4435,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 =>
......@@ -4378,25 +4458,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,
......@@ -4410,10 +4494,11 @@ namespace Edu.Module.OKR
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<int> GetMyUnderlingUserIdList(UserInfo userInfo) {
public List<int> GetMyUnderlingUserIdList(UserInfo userInfo, int DeptId = 0)
{
List<int> UserIdList = new List<int>();
#region 我的直属下级
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = userInfo.Group_Id, DirectSupervisor = userInfo.Id, Dept_Id = DeptId });
if (emList.Any())
{
foreach (var item in emList)
......@@ -4423,7 +4508,7 @@ namespace Edu.Module.OKR
}
//如果是部门主管 需要将部门下除自己其他人加入
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { DeptId = DeptId, Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
if (xjdlist.Any())
{
//查询该部门下所有人
......@@ -4534,7 +4619,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);
......@@ -4552,7 +4638,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()
......@@ -4568,7 +4655,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()
{
......@@ -4584,8 +4672,10 @@ namespace Edu.Module.OKR
}
return flag ? "" : "出错了,请联系管理员";
}
else {
if (!list.Any()) {
else
{
if (!list.Any())
{
return "尚未关注,无法取消关注";
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -4656,7 +4746,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()
{
......@@ -4722,7 +4813,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>() {
......@@ -4747,7 +4839,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);
......@@ -4966,9 +5059,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;
......@@ -4980,7 +5075,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();
......@@ -5054,7 +5150,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)
......@@ -5336,7 +5433,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>();
......@@ -5476,7 +5574,8 @@ namespace Edu.Module.OKR
y.EmPhoto
});
}
else {
else
{
List<int> MyUnderlingList = GetMyUnderlingUserIdList(userInfo);
//查询向下对齐
......@@ -5490,7 +5589,8 @@ namespace Edu.Module.OKR
item.ChildNum = rlist.Where(x => x.ParentId == item.Id).FirstOrDefault()?.ObjectiveId ?? 0;
}
}
else {
else
{
return new List<object>();
}
......@@ -5876,7 +5976,7 @@ namespace Edu.Module.OKR
/// <returns></returns>
public object GetOKRAdminLookObjectiveInfo(int objectiveId, UserInfo userInfo)
{
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, Id = objectiveId});
var list = oKR_ObjectiveRepository.GetList(new RB_OKR_Objective_ViewModel() { Group_Id = userInfo.Group_Id, Id = objectiveId });
if (list.Any())
{
var mdoel = list.FirstOrDefault();
......@@ -6138,72 +6238,20 @@ namespace Edu.Module.OKR
}
/// <summary>
/// 获取左边人员列表
/// 获取我的直属下级
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<OKRPersonalDimension> GetOKRPersonalDimensionList(UserInfo userInfo)
public List<OKRPersonalDimension> GetOKRPersonalDimensionList(int Group_Id,int Id, int DeptId = 0)
{
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 });
var emList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id =Group_Id, DirectSupervisor = Id, Dept_Id = DeptId });
if (emList.Any())
{
foreach (var item in emList)
......@@ -6221,75 +6269,44 @@ namespace Edu.Module.OKR
}
//如果是部门主管 需要将部门下除自己其他人加入
//查询部门负责人 负责的所有部门
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = userInfo.Group_Id, ManagerIds = userInfo.Id.ToString() });
var xjdlist = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { DeptId = DeptId, Group_Id = Group_Id, ManagerIds = 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)) });
var em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id =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)
if (em1List.Any())
{
allList.Add(new OKRPersonalDimension()
//查询全部负责人
string AllManagerIds = departmentRepository.GetAllDepartmentManagerIds(Group_Id);
List<int> AllDeptManageId = new List<int>();
if (!string.IsNullOrEmpty(AllManagerIds))
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 2
});
UserIdList.Add(item.Id);
}
AllDeptManageId = JsonHelper.DeserializeObject<List<int>>(AllManagerIds);
}
#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()
//对 em1List 排除负责人
foreach (var item in em1List.Where(x => !AllDeptManageId.Contains(x.Id)))
{
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
Type = 2
});
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)) });
//上级部门下所有子部门的负责人
var d2list = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel() { Group_Id = Group_Id, QParentIds = string.Join(",", xjdlist.Select(x => x.DeptId)) });
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();//排序 已存在的直接关系
em1List = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = Group_Id, QIds = ManagerIds });
em1List = em1List.Where(x => !UserIdList.Contains(x.Id) && x.Id != Id && x.DirectSupervisor == 0).ToList();//排序 已存在的直接关系
foreach (var item in em1List)
{
allList.Add(new OKRPersonalDimension()
......@@ -6298,59 +6315,31 @@ namespace Edu.Module.OKR
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
Type = 2
});
UserIdList.Add(item.Id);
}
}
}
#endregion
return allList;
}
}
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()
/// <summary>
/// 获取员工okr列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<OKRPersonalDimension> GetAllEmployeeOKRPPageRepository(int pageIndex, int pageSize, out long rowsCount, OKRPersonalDimension query)
{
Id = item.Id,
EmployeeName = item.EmployeeName,
UserIcon = item.UserIcon,
Dept_Id = item.Dept_Id,
Type = 3
});
UserIdList.Add(item.Id);
}
return oKR_ObjectiveRepository.GetAllEmployeeOKRPPageRepository(pageIndex, pageSize,out rowsCount, query);
}
}
#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;
}
}
}
......@@ -311,5 +311,108 @@ WHERE o1.CreateBy in({CreateBys}) and o2.CreateBy ={id} and o1.`Status`=2 and
return Get<RB_OKR_Objective_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取员工查询SQL
/// </summary>
/// <param name="query"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public string GetEmployeeSqlReposiroty(OKRPersonalDimension query, DynamicParameters parameters)
{
StringBuilder where = new StringBuilder();
StringBuilder where2 = new StringBuilder();
StringBuilder wheremanager = new StringBuilder();
StringBuilder whereteacher = new StringBuilder();
StringBuilder whereassist = new StringBuilder();
if (query != null)
{
if (query.Group_Id > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(OKRPersonalDimension.Group_Id), query.Group_Id);
}
if (query.School_Id > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(OKRPersonalDimension.School_Id), query.School_Id);
}
if (query.Dept_Id > 0)
{
where.AppendFormat(" AND B.{0}={1} ", nameof(OKRPersonalDimension.Dept_Id), query.Dept_Id);
}
//if (!string.IsNullOrEmpty(query.StartEntryTime))
//{
// where.AppendFormat(" AND b.{0}>='{1}' ", nameof(Employee_ViewModel.EntryTime), query.StartEntryTime);
//}
//if (!string.IsNullOrEmpty(query.EndEntryTime))
//{
// where.AppendFormat(" AND b.{0}<='{1} 23:59:59' ", nameof(Employee_ViewModel.EntryTime), query.EndEntryTime);
//}
}
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.Id as AccountId,A.Account,orro.ObjectiveNCount,orro.Score,A.Group_Id,A.School_Id,A.EmployeeName,A.UserIcon,A.LeaveStatus,A.AccountType
,IFNULL(G.GroupName,'') AS GroupName,IFNULL(s.SName,'') AS SchoolName
,IFNULL(d.DeptId,0) AS Dept_Id,IFNULL(d.DeptName,'') AS DeptName
FROM
(
SELECT A.Id,A.Account,A.`Password`, 1 as AccountType,B.MId as AccountId
,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,A.`Status`,A.AnnualLeaveDay,A.DirectSupervisor
,b.School_Id,IFNULL(B.MName,'') AS EmployeeName,B.MHead AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.MTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
FROM rb_manager AS B LEFT JOIN rb_account AS A ON A.AccountId=B.MId AND A.AccountType=1
WHERE 1=1 {0} {1}
UNION ALL
SELECT A.Id,A.Account,A.`Password`, 2 as AccountType,B.TId as AccountId
,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,A.`Status`,A.AnnualLeaveDay,A.DirectSupervisor
,b.School_Id,IFNULL(B.TeacherName,'') AS EmployeeName,B.TeacherIcon AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.TeacherTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
FROM rb_teacher AS B LEFT JOIN rb_account AS A ON A.AccountId=B.TId AND A.AccountType=2
WHERE 1=1 {0} {2}
UNION ALL
SELECT A.Id,A.Account,A.`Password`, 3 as AccountType,B.AId as AccountId
,A.CreateBy,A.CreateTime,A.UpdateBy,A.UpdateTime,A.Group_Id,A.`Status`,A.AnnualLeaveDay,A.DirectSupervisor
,b.School_Id,IFNULL(B.AssistName,'') AS EmployeeName,B.AssistIcon AS UserIcon,B.Dept_Id,B.Post_Id,B.IDCard
,B.Sex,B.Education,B.EntryTime,B.Address,B.BirthDate
,B.LeaveStatus,B.LeaveTime,B.AssistTel AS EmployeeTel,IFNULL(B.Email,'') AS Email
FROM rb_assist AS B LEFT JOIN rb_account AS A ON A.AccountId=B.AId AND A.AccountType=3
WHERE 1=1 {0} {3}
) AS A LEFT JOIN rb_group AS g ON A.Group_Id=g.GId
LEFT JOIN rb_school AS s ON A.School_Id=s.SId
LEFT JOIN rb_department AS d ON A.Dept_Id=d.DeptId
LEFT JOIN (SELECT a.CreateBy,COUNT(*) as ObjectiveNCount,SUM(Score) as Score from rb_okr_objective as a LEFT JOIN rb_okr_objectiverelation as b on a.Id=b.ObjectiveId GROUP BY a.CreateBy) as
orro on orro.CreateBy=a.Id
WHERE 1=1 {4}
", where.ToString(), wheremanager.ToString(), whereteacher.ToString(), whereassist.ToString(), where2.ToString());
return builder.ToString();
}
/// <summary>
/// 获取员工okr列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<OKRPersonalDimension> GetAllEmployeeOKRPPageRepository(int pageIndex, int pageSize, out long rowsCount, OKRPersonalDimension query)
{
DynamicParameters parameters = new DynamicParameters();
string sql = GetEmployeeSqlReposiroty(query, parameters);
var list = GetPage<OKRPersonalDimension>(pageIndex, pageSize, out rowsCount, sql, parameters).ToList();
return list;
}
}
}
......@@ -1450,15 +1450,16 @@ namespace Edu.WebApi.Controllers.OKR
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);
int DeptId = parms.GetInt("DeptId", 0);
if (PeriodId <= 0)
{
return ApiResult.ParamIsNull();
}
List<OKRPersonalDimension> allList = okrPeriodModule.GetOKRPersonalDimensionList(userInfo.Group_Id,userInfo.Id, DeptId);
if (allList == null || !allList.Any(x => x.Type == 2))
{
return ApiResult.Failed("您没有下级");
......@@ -1498,5 +1499,34 @@ namespace Edu.WebApi.Controllers.OKR
#endregion
#region 管理端数据看板
/// <summary>
/// 获取评论分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAllEmployeeOKRPPageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new OKRPersonalDimension()
{
School_Id = base.ParmJObj.GetInt("School_Id"),
PeriodId = base.ParmJObj.GetInt("PeriodId", 0)
};
query.Group_Id = base.UserInfo.Group_Id;
var list = okrPeriodModule.GetAllEmployeeOKRPPageRepository(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
foreach (var item in list)
{
var objRelation = okrPeriodModule.GetOKRPersonalRelationAlignList(base.UserInfo.Group_Id, query.PeriodId, item.AccountId.ToString(), item.AccountId);
}
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
#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