Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
9031d6a1
Commit
9031d6a1
authored
Jan 04, 2021
by
吴春
Browse files
Options
Browse Files
Download
Plain Diff
解决冲突
parents
5b726456
dc4ef83f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
400 additions
and
114 deletions
+400
-114
OKRPeriodModule.cs
Edu.Module.OKR/OKRPeriodModule.cs
+400
-114
No files found.
Edu.Module.OKR/OKRPeriodModule.cs
View file @
9031d6a1
...
...
@@ -104,8 +104,7 @@ namespace Edu.Module.OKR
}
};
bool
flag
=
oKR_PeriodConfigRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
if
(
flag
)
{
//记录日志
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
...
...
@@ -121,17 +120,14 @@ 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
()
{
...
...
@@ -148,8 +144,7 @@ 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
()
{
...
...
@@ -208,11 +203,9 @@ 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
=
""
,
...
...
@@ -253,8 +246,7 @@ 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
},
...
...
@@ -269,8 +261,7 @@ namespace Edu.Module.OKR
}
};
bool
flag
=
oKR_RemindRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
if
(
flag
)
{
//记录日志
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
...
...
@@ -301,8 +292,7 @@ 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
}
};
...
...
@@ -344,17 +334,15 @@ 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>
/// 保存分数配置
...
...
@@ -377,8 +365,7 @@ 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
);
...
...
@@ -402,18 +389,16 @@ 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
)
{
...
...
@@ -435,14 +420,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>
/// 设置分数配置状态
...
...
@@ -513,8 +498,7 @@ namespace Edu.Module.OKR
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
else
{
return
"类型不正确"
;
}
}
...
...
@@ -533,8 +517,7 @@ 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
;
}
}
...
...
@@ -550,8 +533,7 @@ 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
});
...
...
@@ -610,8 +592,7 @@ 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
.
ObjectiveId
==
item
.
Id
).
Any
())
{
...
...
@@ -619,8 +600,7 @@ 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
);
}
...
...
@@ -628,8 +608,7 @@ 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
,
...
...
@@ -769,8 +748,7 @@ 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
,
...
...
@@ -785,8 +763,7 @@ namespace Edu.Module.OKR
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
else
{
dmodel
.
Status
=
4
;
dmodel
.
Sort
=
oKR_ObjectiveRepository
.
GetObjectiveMaxSort
(
userInfo
.
Group_Id
,
dmodel
.
PeriodId
,
userInfo
.
Id
)
+
1
;
//获取 当前最大的
dmodel
.
ScoreRuleId
=
0
;
//获取 是否有默认
...
...
@@ -809,8 +786,7 @@ 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
,
...
...
@@ -852,8 +828,7 @@ 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
,
...
...
@@ -868,22 +843,19 @@ namespace Edu.Module.OKR
}
return
flag
?
""
:
"出错了,请联系管理员"
;
}
else
{
else
{
int
Sort
=
oKR_KeyResultRepository
.
GetKeyResultMaxSort
(
objectiveId
);
int
Weight
=
100
;
decimal
Weight
=
100
;
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
=
100
/
(
list
.
Count
()
+
1
)
;
Weight
=
Convert
.
ToDecimal
((
int
)((
Convert
.
ToDecimal
(
100
)
/
(
list
.
Count
()
+
1
))
*
10
))
/
10
;
IsUpdate
=
true
;
}
else
{
else
{
Weight
=
0
;
}
}
...
...
@@ -909,15 +881,18 @@ namespace Edu.Module.OKR
UpdateTime
=
DateTime
.
Now
,
Weight
=
Weight
});
if
(
Id
>
0
)
{
if
(
IsUpdate
)
{
foreach
(
var
item
in
list
)
{
//修改每个结果的权重
if
(
Id
>
0
)
{
if
(
IsUpdate
)
{
decimal
diff
=
0
;
int
MaxSort
=
0
;
if
(
list
.
Count
()
*
Weight
!=
100
)
{
diff
=
100
-
list
.
Count
()
*
Weight
;
MaxSort
=
list
.
Max
(
x
=>
x
.
Sort
);
}
foreach
(
var
item
in
list
)
{
//修改每个结果的权重
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
Weight
}
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
(
diff
>
0
&&
MaxSort
==
item
.
Sort
)?
Weight
+
diff
:
Weight
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
...
...
@@ -1013,8 +988,7 @@ 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
()
...
...
@@ -1217,8 +1191,7 @@ 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
>()
{
...
...
@@ -1229,8 +1202,7 @@ 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
,
...
...
@@ -1286,8 +1258,7 @@ 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
>()
{
...
...
@@ -1328,69 +1299,384 @@ namespace Edu.Module.OKR
/// <returns></returns>
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
)
{
return
ApiResult
.
Failed
(
"关键结果不存在"
);
}
if
(
type
==
1
)
{
//根据进度 求高级的当前值
currentValue
=
Math
.
Round
((
model
.
EndValue
-
model
.
StartValue
)
*
progress
/
100
,
2
,
MidpointRounding
.
AwayFromZero
)
+
model
.
StartValue
;
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Progress
),
progress
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
CurrentValue
),
currentValue
},
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
keyResultId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
oKR_KeyResultRepository
.
Update
(
keyValues
,
wheres
);
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
);
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Objective_ViewModel
.
Progress
),(
int
)
TProgress
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Objective_ViewModel
.
Id
),
FiledValue
=
model
.
ObjectiveId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_ObjectiveRepository
.
Update
(
keyValues1
,
wheres1
);
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
Id
=
0
,
Type
=
1
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
"修改OKR目标关键结果进度【"
+
keyResultId
+
"】"
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
0
});
return
ApiResult
.
Success
(
""
,
new
{
TProgress
=(
int
)
TProgress
,
CProgress
=
progress
,
model
.
StartValue
,
model
.
EndValue
,
currentValue
});
}
}
else
{
//根据当前值 求进度
progress
=
(
int
)(((
currentValue
-
startValue
)
/
(
endValue
-
startValue
))
*
100
);
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Progress
),
progress
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
CurrentValue
),
currentValue
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
StartValue
),
startValue
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
EndValue
),
endValue
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
keyResultId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
oKR_KeyResultRepository
.
Update
(
keyValues
,
wheres
);
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
);
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Objective_ViewModel
.
Progress
),(
int
)
TProgress
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Objective_ViewModel
.
Id
),
FiledValue
=
model
.
ObjectiveId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_ObjectiveRepository
.
Update
(
keyValues1
,
wheres1
);
return
ApiResult
.
Success
();
}
#
endregion
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
Id
=
0
,
Type
=
1
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
"修改OKR目标关键结果进度【"
+
keyResultId
+
"】"
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
0
});
return
ApiResult
.
Success
(
""
,
new
{
TProgress
=
(
int
)
TProgress
,
CProgress
=
progress
,
model
.
StartValue
,
model
.
EndValue
,
currentValue
});
}
}
#
region
okr
任务评论
return
ApiResult
.
Failed
();
}
/// <summary>
///
获取评论分页列表
///
设置结果权重
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="demodel"></param>
/// <param name="keyResultId"></param>
/// <param name="weight"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
List
<
RB_OKR_Comment_ViewModel
>
GetCommentPageList
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
RB_OKR_Comment_ViewModel
demodel
)
public
ApiResult
SgetOKRMyKeyResultWeight
(
int
keyResultId
,
decimal
weight
,
UserInfo
userInfo
)
{
return
oKR_CommentRepository
.
GetPageList
(
pageIndex
,
pageSize
,
out
rowsCount
,
demodel
);
var
model
=
oKR_KeyResultRepository
.
GetEntity
(
keyResultId
);
if
(
model
==
null
||
model
.
Status
==
1
)
{
return
ApiResult
.
Failed
(
"关键结果不存在"
);
}
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
)
{
return
ApiResult
.
Failed
(
"只有一个结果,无法修改权重"
);
}
int
MaxSort
=
list
.
Max
(
x
=>
x
.
Sort
);
var
MaxModel
=
list
.
Where
(
x
=>
x
.
Sort
==
MaxSort
).
FirstOrDefault
();
if
(
model
.
Sort
==
MaxSort
)
{
return
ApiResult
.
Failed
(
"最后一个KeyResult无法修改权重"
);
}
if
(
weight
-
model
.
Weight
>
MaxModel
.
Weight
){
return
ApiResult
.
Failed
(
"总权重不能超过100%"
);
}
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
weight
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
keyResultId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
oKR_KeyResultRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新最后一个KeyResult权重
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
MaxModel
.
Weight
-
(
weight
-
model
.
Weight
)}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
MaxModel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_KeyResultRepository
.
Update
(
keyValues1
,
wheres1
);
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
Id
=
0
,
Type
=
1
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
"修改OKR关键结果权重【"
+
keyResultId
+
"】"
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
0
});
return
ApiResult
.
Success
(
""
,
new
{
Weight
=
weight
,
LastWeight
=
MaxModel
.
Weight
-
(
weight
-
model
.
Weight
)
});
}
return
ApiResult
.
Failed
();
}
/// <summary>
///
获取评论列表
///
设置结果分数
/// </summary>
/// <param name="demodel"></param>
/// <param name="keyResultId"></param>
/// <param name="score"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
List
<
RB_OKR_Comment_ViewModel
>
GetCommentList
(
RB_OKR_Comment_ViewModel
demodel
)
public
ApiResult
SgetOKRMyKeyResultScore
(
int
keyResultId
,
decimal
score
,
UserInfo
userInfo
)
{
return
oKR_CommentRepository
.
GetList
(
demodel
);
}
var
model
=
oKR_KeyResultRepository
.
GetEntity
(
keyResultId
);
if
(
model
==
null
||
model
.
Status
==
1
){
return
ApiResult
.
Failed
(
"关键结果不存在"
);
}
if
(
model
.
Score
==
score
){
return
ApiResult
.
Success
();
}
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Score
),
score
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
keyResultId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
oKR_KeyResultRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新目标的进度百分比
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
);
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Objective_ViewModel
.
Score
),(
int
)
TScore
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Objective_ViewModel
.
Id
),
FiledValue
=
model
.
ObjectiveId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_ObjectiveRepository
.
Update
(
keyValues1
,
wheres1
);
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
Id
=
0
,
Type
=
1
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
"修改OKR关键结果得分【"
+
keyResultId
+
"】"
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
0
});
return
ApiResult
.
Success
(
""
,
new
{
Score
=
score
,
TScore
});
}
return
ApiResult
.
Failed
();
}
/// <summary>
///
新增/修改ork评论
///
删除结果
/// </summary>
/// <param name="model"></param>
/// <param name="keyResultId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public
bool
SetOKRComment
(
RB_OKR_Comment_ViewModel
model
)
public
ApiResult
SgetOKRMyKeyResultDel
(
int
keyResultId
,
UserInfo
userInfo
)
{
if
(
model
.
Id
==
0
)
{
return
oKR_CommentRepository
.
Insert
(
model
)
>
0
;
var
model
=
oKR_KeyResultRepository
.
GetEntity
(
keyResultId
);
if
(
model
==
null
||
model
.
Status
==
1
)
{
return
ApiResult
.
Failed
(
"关键结果不存在"
)
;
}
else
var
list
=
oKR_KeyResultRepository
.
GetList
(
new
RB_OKR_KeyResult_ViewModel
()
{
Group_Id
=
userInfo
.
Group_Id
,
ObjectiveId
=
model
.
ObjectiveId
});
int
MaxSort
=
list
.
Max
(
x
=>
x
.
Sort
);
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Comment_ViewModel
.
State
),
model
.
State
},
{
nameof
(
RB_OKR_Comment_ViewModel
.
UpdateBy
),
model
.
UpdateBy
},
{
nameof
(
RB_OKR_Comment_ViewModel
.
UpdateTime
),
DateTime
.
Now
},
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Comment_ViewModel
.
Id
),
FiledValue
=
model
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Status
),
1
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
UpdateBy
),
userInfo
.
Id
},
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
UpdateTime
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
keyResultId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
oKR_KeyResultRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//删除 需要重新分配权重,目标进度,目标评分
decimal
Progress
=
0
;
decimal
Score
=
0
;
decimal
Weight
=
0
;
if
(
list
.
Count
()
==
1
)
{
//删完了,直接初始化 目标
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Objective_ViewModel
.
Progress
),
Progress
},
{
nameof
(
RB_OKR_Objective_ViewModel
.
Score
),
Score
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Objective_ViewModel
.
Id
),
FiledValue
=
model
.
ObjectiveId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_ObjectiveRepository
.
Update
(
keyValues1
,
wheres1
);
Weight
=
-
1
;
}
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
);
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_Objective_ViewModel
.
Progress
),(
int
)
Progress
},
{
nameof
(
RB_OKR_Objective_ViewModel
.
Score
),
Score
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_Objective_ViewModel
.
Id
),
FiledValue
=
model
.
ObjectiveId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_ObjectiveRepository
.
Update
(
keyValues1
,
wheres1
);
#
endregion
//删除的如果是最后一个 权重转移至倒数第二个
//删除的弱国不是最后一个 权重转移至最后一个
if
(
model
.
Sort
==
MaxSort
)
{
//查询倒数第二个
var
TwoModel
=
list
.
Where
(
x
=>
x
.
Sort
!=
MaxSort
).
OrderByDescending
(
x
=>
x
.
Sort
).
FirstOrDefault
();
Weight
=
TwoModel
.
Weight
+
model
.
Weight
;
Dictionary
<
string
,
object
>
keyValues2
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
Weight
}
};
List
<
WhereHelper
>
wheres2
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
TwoModel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_KeyResultRepository
.
Update
(
keyValues2
,
wheres2
);
}
};
return
oKR_CommentRepository
.
Update
(
keyValues
,
wheres
);
else
{
var
LastModel
=
list
.
Where
(
x
=>
x
.
Sort
==
MaxSort
).
FirstOrDefault
();
Weight
=
LastModel
.
Weight
+
model
.
Weight
;
Dictionary
<
string
,
object
>
keyValues2
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_OKR_KeyResult_ViewModel
.
Weight
),
Weight
}
};
List
<
WhereHelper
>
wheres2
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_OKR_KeyResult_ViewModel
.
Id
),
FiledValue
=
LastModel
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
oKR_KeyResultRepository
.
Update
(
keyValues2
,
wheres2
);
}
}
changeLogRepository
.
Insert
(
new
Model
.
Entity
.
Log
.
RB_User_ChangeLog
()
{
Id
=
0
,
Type
=
1
,
CreateBy
=
userInfo
.
Id
,
CreateTime
=
DateTime
.
Now
,
Group_Id
=
userInfo
.
Group_Id
,
LogContent
=
"删除OKR目标关键结果【"
+
keyResultId
+
"】"
,
School_Id
=
userInfo
.
School_Id
,
SourceId
=
0
});
return
ApiResult
.
Success
(
""
,
new
{
TProgress
=
Progress
,
TScore
=
Score
,
LastWeight
=
Weight
});
}
return
ApiResult
.
Failed
();
}
#
endregion
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment