Commit 63284792 authored by liudong1993's avatar liudong1993

okr 用户最后更新进度记录

parent 569949cd
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.OKR
{
/// <summary>
/// okr进度更新记录实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_OKR_UpdateProgress
{
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 周期id
/// </summary>
public int PeriodId { get; set; }
/// <summary>
/// 用户id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 最后更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 集团id
/// </summary>
public int Group_Id { get; set; }
}
}
...@@ -106,6 +106,10 @@ namespace Edu.Module.OKR ...@@ -106,6 +106,10 @@ namespace Edu.Module.OKR
/// 关注事项 /// 关注事项
/// </summary> /// </summary>
private readonly RB_OKR_MatterRepository oKR_MatterRepository = new RB_OKR_MatterRepository(); private readonly RB_OKR_MatterRepository oKR_MatterRepository = new RB_OKR_MatterRepository();
/// <summary>
/// 用户最后更新进度时间
/// </summary>
private readonly RB_OKR_UpdateProgressRepository oKR_UpdateProgressRepository = new RB_OKR_UpdateProgressRepository();
#region 基础配置 #region 基础配置
...@@ -3763,6 +3767,9 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3763,6 +3767,9 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres); bool flag = oKR_ObjectiveRepository.Update(keyValues, wheres);
if (flag) if (flag)
{ {
if (type == 1 || type == 2) {
Task.Run(() => RecordUpdateProgress(0, objectiveId, userInfo.Group_Id, userInfo.Id));
}
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog() changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{ {
Id = 0, Id = 0,
...@@ -3845,6 +3852,8 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3845,6 +3852,8 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
} }
}; };
oKR_ObjectiveRepository.Update(keyValues1, wheres1); oKR_ObjectiveRepository.Update(keyValues1, wheres1);
//记录最后更新进度时间
Task.Run(() => RecordUpdateProgress(0, kmodel.ObjectiveId, userInfo.Group_Id, userInfo.Id));
} }
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog() changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{ {
...@@ -3931,6 +3940,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3931,6 +3940,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
SourceId = 0 SourceId = 0
}); });
} }
Task.Run(() => RecordUpdateProgress(0, keyResultId, userInfo.Group_Id, userInfo.Id));
return ApiResult.Success("", new return ApiResult.Success("", new
{ {
TProgress = (int)TProgress, TProgress = (int)TProgress,
...@@ -3990,6 +4000,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -3990,6 +4000,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
SourceId = 0 SourceId = 0
}); });
} }
Task.Run(() => RecordUpdateProgress(0, model.ObjectiveId, userInfo.Group_Id, userInfo.Id));
return ApiResult.Success("", new return ApiResult.Success("", new
{ {
TProgress = (int)TProgress, TProgress = (int)TProgress,
...@@ -4004,6 +4015,48 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -4004,6 +4015,48 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
return ApiResult.Failed(); return ApiResult.Failed();
} }
/// <summary>
/// 记录最后更新进度时间
/// </summary>
/// <param name="v"></param>
/// <param name="keyResultId"></param>
/// <param name="group_Id"></param>
/// <param name="id"></param>
private void RecordUpdateProgress(int periodId, int objectiveId, int group_Id, int userId)
{
if (periodId == 0 && objectiveId > 0) {
var model = oKR_ObjectiveRepository.GetEntity(objectiveId);
periodId = model?.PeriodId ?? 0;
}
if (periodId == 0) { return; }
var list = oKR_UpdateProgressRepository.GetList(new Model.Entity.OKR.RB_OKR_UpdateProgress() { Group_Id = group_Id, PeriodId = periodId, UserId = userId });
if (list.Any())
{
var model = list.FirstOrDefault();
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(Model.Entity.OKR.RB_OKR_UpdateProgress.UpdateTime),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(Model.Entity.OKR.RB_OKR_UpdateProgress.Id),
FiledValue=model.Id,
OperatorEnum=OperatorEnum.Equal
}
};
oKR_UpdateProgressRepository.Update(keyValues, wheres);
}
else {
oKR_UpdateProgressRepository.Insert(new Model.Entity.OKR.RB_OKR_UpdateProgress()
{
Id = 0,
Group_Id = group_Id,
PeriodId = periodId,
UserId = userId,
UpdateTime = DateTime.Now
});
}
}
/// <summary> /// <summary>
/// 设置结果权重 /// 设置结果权重
/// </summary> /// </summary>
...@@ -7235,15 +7288,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7235,15 +7288,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
int StartV = Group[i]; int StartV = Group[i];
int EndV = -1; int EndV = -1;
ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV).Count(); ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV).Count();
if (ONum > 0) ObjectiveNum.Add(new
{ {
ObjectiveNum.Add(new Start = StartV,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
else else
{ {
...@@ -7257,15 +7307,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7257,15 +7307,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{ {
ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV && x.ObjectiveNum <= EndV).Count(); ONum = objectiveNumList.Where(x => x.ObjectiveNum >= StartV && x.ObjectiveNum <= EndV).Count();
} }
if (ONum > 0) ObjectiveNum.Add(new
{ {
ObjectiveNum.Add(new Start = StartV,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
} }
...@@ -7299,15 +7346,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7299,15 +7346,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
int StartV = Progress[i]; int StartV = Progress[i];
int EndV = -1; int EndV = -1;
ONum = olist.Where(x => x.Progress >= StartV).Count(); ONum = olist.Where(x => x.Progress >= StartV).Count();
if (ONum > 0) ObjectiveProgress.Add(new
{ {
ObjectiveProgress.Add(new Start = StartV > 0 ? (StartV - 1) : StartV,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
else else
{ {
...@@ -7321,15 +7365,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7321,15 +7365,12 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{ {
ONum = olist.Where(x => x.Progress >= StartV && x.Progress <= EndV).Count(); ONum = olist.Where(x => x.Progress >= StartV && x.Progress <= EndV).Count();
} }
if (ONum > 0) ObjectiveProgress.Add(new
{ {
ObjectiveProgress.Add(new Start = StartV > 0 ? (StartV - 1) : StartV,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
} }
...@@ -7344,15 +7385,13 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7344,15 +7385,13 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
decimal StartV = Convert.ToDecimal(Score[i]); decimal StartV = Convert.ToDecimal(Score[i]);
int EndV = -1; int EndV = -1;
ONum = olist.Where(x => x.Score >= StartV).Count(); ONum = olist.Where(x => x.Score >= StartV).Count();
if (ONum > 0) double StartV1 = Convert.ToDouble(StartV > 0 ? (StartV - Convert.ToDecimal(0.01)) : StartV);
ObjectiveScore.Add(new
{ {
ObjectiveScore.Add(new Start = StartV1,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
else else
{ {
...@@ -7366,15 +7405,13 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru ...@@ -7366,15 +7405,13 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{ {
ONum = olist.Where(x => x.Score >= StartV && x.Score <= EndV).Count(); ONum = olist.Where(x => x.Score >= StartV && x.Score <= EndV).Count();
} }
if (ONum > 0) double StartV1 = Convert.ToDouble(StartV > 0 ? (StartV - Convert.ToDecimal(0.01)) : StartV);
ObjectiveScore.Add(new
{ {
ObjectiveScore.Add(new Start = StartV1,
{ End = EndV,
Start = StartV, Number = ONum
End = EndV, });
Number = ONum
});
}
} }
} }
......
using Edu.Common.Enum;
using Edu.Model.Entity.OKR;
using Edu.Model.ViewModel.OKR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.OKR
{
/// <summary>
/// OKR进度更新记录仓储层
/// </summary>
public class RB_OKR_UpdateProgressRepository : BaseRepository<RB_OKR_UpdateProgress>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_OKR_UpdateProgress> GetList(RB_OKR_UpdateProgress demodel)
{
string where = $@" 1=1 ";
if (demodel.Group_Id > 0)
{
where += $@" and {nameof(RB_OKR_UpdateProgress.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.PeriodId > 0)
{
where += $@" and {nameof(RB_OKR_UpdateProgress.PeriodId)} ={demodel.PeriodId}";
}
if (demodel.UserId > 0)
{
where += $@" and {nameof(RB_OKR_UpdateProgress.UserId)} ={demodel.UserId}";
}
string sql = $@" select * from RB_OKR_UpdateProgress where {where} order by Id desc";
return Get<RB_OKR_UpdateProgress>(sql).ToList();
}
}
}
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