|
@@ -2,6 +2,7 @@ package service |
|
@@ -2,6 +2,7 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "time"
|
5
|
|
6
|
|
6
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
@@ -12,7 +13,7 @@ import ( |
|
@@ -12,7 +13,7 @@ import ( |
12
|
|
13
|
|
13
|
// 超管直接修改考核结果分数
|
14
|
// 超管直接修改考核结果分数
|
14
|
// 修改周期考核的分数
|
15
|
// 修改周期考核的分数
|
15
|
-func (srv *SummaryEvaluationService) ModifyFinishScoreV2(param *command.ModifyFinishScore) error {
|
16
|
+func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
|
16
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
17
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
17
|
if err != nil {
|
18
|
if err != nil {
|
18
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
19
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -60,22 +61,13 @@ func (srv *SummaryEvaluationService) ModifyFinishScoreV2(param *command.ModifyFi |
|
@@ -60,22 +61,13 @@ func (srv *SummaryEvaluationService) ModifyFinishScoreV2(param *command.ModifyFi |
60
|
|
61
|
|
61
|
if len(evaluationFinishValue) == 0 {
|
62
|
if len(evaluationFinishValue) == 0 {
|
62
|
saveNewValue = true
|
63
|
saveNewValue = true
|
63
|
-
|
|
|
64
|
- }
|
|
|
65
|
-
|
|
|
66
|
- if len(evaluationFinishValue) == 0 {
|
|
|
67
|
- //尝试获取目标人员的360评估、人资评估、自评的评估内容
|
|
|
68
|
- }
|
|
|
69
|
-
|
|
|
70
|
- scoreStr := fmt.Sprintf("%.2f", param.Score)
|
|
|
71
|
- evaluationFinishData.TotalScore = scoreStr
|
|
|
72
|
- evaluationFinishData.Status = domain.EvaluationCompleted
|
|
|
73
|
- err = evaluationRepo.Save(evaluationFinishData)
|
64
|
+ evaluationFinishValue, err = srv.buildSummaryFinishValue(transactionContext, evaluationFinishData)
|
74
|
if err != nil {
|
65
|
if err != nil {
|
75
|
- return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
|
66
|
+ return application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
67
|
+ }
|
76
|
}
|
68
|
}
|
77
|
-
|
|
|
78
|
if saveNewValue {
|
69
|
if saveNewValue {
|
|
|
70
|
+ // 重置评级汇总
|
79
|
for _, val := range evaluationFinishValue {
|
71
|
for _, val := range evaluationFinishValue {
|
80
|
err = evaluationValueRepo.Save(val)
|
72
|
err = evaluationValueRepo.Save(val)
|
81
|
if err != nil {
|
73
|
if err != nil {
|
|
@@ -83,6 +75,14 @@ func (srv *SummaryEvaluationService) ModifyFinishScoreV2(param *command.ModifyFi |
|
@@ -83,6 +75,14 @@ func (srv *SummaryEvaluationService) ModifyFinishScoreV2(param *command.ModifyFi |
83
|
}
|
75
|
}
|
84
|
}
|
76
|
}
|
85
|
}
|
77
|
}
|
|
|
78
|
+ scoreStr := fmt.Sprintf("%.2f", param.Score)
|
|
|
79
|
+ evaluationFinishData.TotalScore = scoreStr
|
|
|
80
|
+ evaluationFinishData.Status = domain.EvaluationCompleted
|
|
|
81
|
+ err = evaluationRepo.Save(evaluationFinishData)
|
|
|
82
|
+ if err != nil {
|
|
|
83
|
+ return application.ThrowError(application.BUSINESS_ERROR, "修改考核结果"+err.Error())
|
|
|
84
|
+ }
|
|
|
85
|
+
|
86
|
if err := transactionContext.CommitTransaction(); err != nil {
|
86
|
if err := transactionContext.CommitTransaction(); err != nil {
|
87
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
87
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
88
|
}
|
88
|
}
|
|
@@ -119,8 +119,9 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
|
@@ -119,8 +119,9 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
119
|
break
|
119
|
break
|
120
|
}
|
120
|
}
|
121
|
}
|
121
|
}
|
122
|
- //使用上级评估的评估内容
|
122
|
+
|
123
|
if evaluationData != nil {
|
123
|
if evaluationData != nil {
|
|
|
124
|
+ //使用上级评估的评估内容
|
124
|
_, itemValue, err := evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})
|
125
|
_, itemValue, err := evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})
|
125
|
if err != nil {
|
126
|
if err != nil {
|
126
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
127
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
@@ -141,9 +142,7 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
|
@@ -141,9 +142,7 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
141
|
}
|
142
|
}
|
142
|
evaluationFinishValue = append(evaluationFinishValue, newItemValue)
|
143
|
evaluationFinishValue = append(evaluationFinishValue, newItemValue)
|
143
|
}
|
144
|
}
|
144
|
- return evaluationFinishValue, nil
|
|
|
145
|
- }
|
|
|
146
|
-
|
145
|
+ } else {
|
147
|
//使用360评估、人资评估、自评 构建考核结果的评估项内容
|
146
|
//使用360评估、人资评估、自评 构建考核结果的评估项内容
|
148
|
var itemValueBack []*domain.SummaryEvaluationValue
|
147
|
var itemValueBack []*domain.SummaryEvaluationValue
|
149
|
var summaryEvaluationId []int
|
148
|
var summaryEvaluationId []int
|
|
@@ -172,9 +171,35 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
|
@@ -172,9 +171,35 @@ func (srv *SummaryEvaluationService) buildSummaryFinishValue(transactionContext |
172
|
tempHRBP[it.EvaluationItemId] = it
|
171
|
tempHRBP[it.EvaluationItemId] = it
|
173
|
}
|
172
|
}
|
174
|
}
|
173
|
}
|
|
|
174
|
+ nowTime := time.Now()
|
175
|
for _, val := range itemUsed {
|
175
|
for _, val := range itemUsed {
|
176
|
var newItemValue *domain.SummaryEvaluationValue
|
176
|
var newItemValue *domain.SummaryEvaluationValue
|
177
|
-
|
177
|
+ if val.EvaluatorId == 0 {
|
|
|
178
|
+ newItemValue = tempSelf[val.Id]
|
|
|
179
|
+ } else if val.EvaluatorId == -1 {
|
|
|
180
|
+ newItemValue = tempHRBP[val.Id]
|
|
|
181
|
+ } else {
|
|
|
182
|
+ newItemValue = temp360[val.Id]
|
|
|
183
|
+ }
|
|
|
184
|
+ if newItemValue == nil {
|
|
|
185
|
+ newItemValue = &domain.SummaryEvaluationValue{}
|
|
|
186
|
+ newItemValue.SetBlankValue(evaluationFinisih, val)
|
|
|
187
|
+ }
|
|
|
188
|
+ newItemValue.SummaryEvaluationId = 0
|
|
|
189
|
+ newItemValue.Id = 0
|
|
|
190
|
+ newItemValue.CreatedAt = nowTime
|
|
|
191
|
+ newItemValue.UpdatedAt = nowTime
|
|
|
192
|
+ evaluationFinishValue = append(evaluationFinishValue, newItemValue)
|
|
|
193
|
+ }
|
|
|
194
|
+ }
|
|
|
195
|
+ // 重置评级汇总
|
|
|
196
|
+ evaluationFinisih.TotalRating = nil
|
|
|
197
|
+ for i := range itemUsed {
|
|
|
198
|
+ evaluationFinisih.ResetTotalRating(itemUsed[i])
|
|
|
199
|
+ }
|
|
|
200
|
+ // 计算分数
|
|
|
201
|
+ if err := evaluationFinisih.EvaluationTotalScore(evaluationFinishValue); err != nil {
|
|
|
202
|
+ return evaluationFinishValue, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
178
|
}
|
203
|
}
|
179
|
return evaluationFinishValue, nil
|
204
|
return evaluationFinishValue, nil
|
180
|
} |
205
|
} |