Commit 98e620f7 authored by liudong1993's avatar liudong1993

OKR调整

parent 71663e8b
......@@ -4154,8 +4154,9 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
/// <param name="progressState"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public string SetOKRMyObjectiveState(int objectiveId, int type, int progressState, UserInfo userInfo)
public string SetOKRMyObjectiveState(int objectiveId, int type, int progressState, out int outProgressState, UserInfo userInfo)
{
outProgressState = 0;
Dictionary<string, object> keyValues = new Dictionary<string, object>();
string LogContent = "";
if (type == 1)
......@@ -4164,6 +4165,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
keyValues.Add(nameof(RB_OKR_Objective_ViewModel.UpdateBy), userInfo.Id);
keyValues.Add(nameof(RB_OKR_Objective_ViewModel.UpdateTime), DateTime.Now);
LogContent = "修改OKR目标默认风险最高的 Key Result 状态【" + objectiveId + "】";
outProgressState = oKR_KeyResultRepository.GetKeyResultMaxProgressState(objectiveId);
}
else if (type == 2)
{
......@@ -4172,6 +4174,7 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
keyValues.Add(nameof(RB_OKR_Objective_ViewModel.UpdateBy), userInfo.Id);
keyValues.Add(nameof(RB_OKR_Objective_ViewModel.UpdateTime), DateTime.Now);
LogContent = "修改OKR目标自定义进度状态【" + objectiveId + "】";
outProgressState = progressState;
}
else if (type == 3)
{
......@@ -4467,9 +4470,10 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
bool flag = oKR_KeyResultRepository.Update(keyValues, wheres);
if (flag)
{
MaxModel.Weight -= (weight - model.Weight);
//更新最后一个KeyResult权重
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_OKR_KeyResult_ViewModel.Weight), MaxModel.Weight - (weight - model.Weight)}
{ nameof(RB_OKR_KeyResult_ViewModel.Weight), MaxModel.Weight}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
......@@ -4479,14 +4483,13 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
}
};
oKR_KeyResultRepository.Update(keyValues1, wheres1);
MaxModel.Weight -= (weight - model.Weight);
#region 更新目标进度+评分
//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);
decimal TScore = list.Sum(x => x.Score * x.Weight / 100);
decimal TScore = Convert.ToDecimal((int)(list.Sum(x => x.Score * x.Weight / 100) * 10)) / 10;
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_OKR_Objective_ViewModel.Progress),(int)TProgress},
{ nameof(RB_OKR_Objective_ViewModel.Score),(int)TScore}
{ nameof(RB_OKR_Objective_ViewModel.Score),TScore}
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){
......@@ -4512,8 +4515,8 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
return ApiResult.Success("", new
{
Weight = weight,
LastWeight = MaxModel.Weight - (weight - model.Weight),
TProgress,
LastWeight = MaxModel.Weight,
TProgress = (int)TProgress,
TScore
});
}
......@@ -4553,9 +4556,9 @@ and {ruleModel.Time} >='{dmodel.RuleSTime.Value.ToString("yyyy-MM-dd")}' and {ru
{
//更新目标的进度百分比
var list = oKR_KeyResultRepository.GetList(new RB_OKR_KeyResult_ViewModel() { Group_Id = userInfo.Group_Id, ObjectiveId = model.ObjectiveId });
decimal TScore = list.Sum(x => x.Score * x.Weight / 100);
decimal TScore = Convert.ToDecimal((int)(list.Sum(x => x.Score * x.Weight / 100) * 10)) / 10;
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_OKR_Objective_ViewModel.Score),(int)TScore}
{ nameof(RB_OKR_Objective_ViewModel.Score),TScore}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
......
......@@ -75,6 +75,18 @@ namespace Edu.Repository.OKR
return Get<RB_OKR_KeyResult_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取最大状态
/// </summary>
/// <param name="objectiveId"></param>
/// <returns></returns>
public int GetKeyResultMaxProgressState(int objectiveId)
{
string sql = $@"SELECT MAX(ProgressState) as ProgressState FROM rb_okr_keyresult WHERE Status =0 and ObjectiveId ={objectiveId}";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
/// <summary>
/// 获取最大sort
/// </summary>
......@@ -82,7 +94,7 @@ namespace Edu.Repository.OKR
/// <returns></returns>
public int GetKeyResultMaxSort(int objectiveId)
{
string sql = $@"SELECT MAX(Sort) Sort FROM rb_okr_keyresult WHERE ObjectiveId ={objectiveId}";
string sql = $@"SELECT MAX(Sort) Sort FROM rb_okr_keyresult WHERE Status =0 and ObjectiveId ={objectiveId}";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
......@@ -97,7 +109,7 @@ namespace Edu.Repository.OKR
/// <returns></returns>
public bool UpdateOtherSort(int objectiveId, int id, int startSort, int endSort)
{
string sql = $@"UPDATE rb_okr_keyresult SET Sort =Sort +1 WHERE ObjectiveId={objectiveId} AND Id <>{id} ";
string sql = $@"UPDATE rb_okr_keyresult SET Sort =Sort +1 WHERE Status =0 and ObjectiveId={objectiveId} AND Id <>{id} ";
if (startSort > 0)
{
sql += $@" AND Sort > {startSort} ";
......@@ -119,7 +131,7 @@ namespace Edu.Repository.OKR
/// <returns></returns>
public bool UpdateOtherSortDesc(int objectiveId, int id, int startSort, int endSort)
{
string sql = $@"UPDATE rb_okr_keyresult SET Sort =Sort -1 WHERE ObjectiveId={objectiveId} AND Id <>{id} ";
string sql = $@"UPDATE rb_okr_keyresult SET Sort =Sort -1 WHERE Status =0 and ObjectiveId={objectiveId} AND Id <>{id} ";
if (startSort > 0 && endSort > 0)
{
sql += $@" AND Sort > {startSort} and Sort <= {endSort}";
......
......@@ -577,11 +577,10 @@ namespace Edu.WebApi.Controllers.OKR
{
return ApiResult.ParamIsNull("请传递自定义状态");
}
string msg = okrPeriodModule.SetOKRMyObjectiveState(ObjectiveId, Type, ProgressState, userInfo);
string msg = okrPeriodModule.SetOKRMyObjectiveState(ObjectiveId, Type, ProgressState, out int OutProgressState, userInfo);
if (msg == "")
{
return ApiResult.Success();
return ApiResult.Success("", OutProgressState);
}
else
{
......
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