|
@@ -155,15 +155,6 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
@@ -155,15 +155,6 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
155
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "不能提交临时数据")
|
155
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "不能提交临时数据")
|
156
|
}
|
156
|
}
|
157
|
|
157
|
|
158
|
- lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
159
|
- err := lock.Lock()
|
|
|
160
|
- if err != nil {
|
|
|
161
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
162
|
- }
|
|
|
163
|
- defer func() {
|
|
|
164
|
- lock.UnLock()
|
|
|
165
|
- }()
|
|
|
166
|
-
|
|
|
167
|
transactionContext, err := factory.StartTransaction()
|
158
|
transactionContext, err := factory.StartTransaction()
|
168
|
if err != nil {
|
159
|
if err != nil {
|
169
|
return nil, err
|
160
|
return nil, err
|
|
@@ -195,6 +186,16 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
@@ -195,6 +186,16 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
195
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核类型错误")
|
186
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核类型错误")
|
196
|
}
|
187
|
}
|
197
|
|
188
|
|
|
|
189
|
+ // 按照被评估人id ,加锁
|
|
|
190
|
+ lock := xredis.NewLockSummaryEvaluation(result.TargetUser.UserId)
|
|
|
191
|
+ err = lock.Lock()
|
|
|
192
|
+ if err != nil {
|
|
|
193
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
194
|
+ }
|
|
|
195
|
+ defer func() {
|
|
|
196
|
+ lock.UnLock()
|
|
|
197
|
+ }()
|
|
|
198
|
+
|
198
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
199
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
199
|
if err != nil {
|
200
|
if err != nil {
|
200
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
201
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -222,6 +223,55 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
@@ -222,6 +223,55 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
222
|
if err != nil {
|
223
|
if err != nil {
|
223
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
224
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
224
|
}
|
225
|
}
|
|
|
226
|
+
|
|
|
227
|
+ // 需要同步提交分数到上级去
|
|
|
228
|
+ if len(itemValueList) > 0 {
|
|
|
229
|
+ superValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)})
|
|
|
230
|
+ if err != nil {
|
|
|
231
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
232
|
+ }
|
|
|
233
|
+
|
|
|
234
|
+ // 上级评估存在(有上级考核类型时,不管分数有没有填写都算,没填写当作零)
|
|
|
235
|
+ if len(evaluationList) > 0 {
|
|
|
236
|
+ super := evaluationList[0]
|
|
|
237
|
+ super.Status = domain.EvaluationCompleted
|
|
|
238
|
+ err = evaluationRepo.Save(super)
|
|
|
239
|
+ if err != nil {
|
|
|
240
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
241
|
+ }
|
|
|
242
|
+
|
|
|
243
|
+ // 上级评估条目对应分数值
|
|
|
244
|
+ superMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
245
|
+ for i := range superValues {
|
|
|
246
|
+ it := superValues[i]
|
|
|
247
|
+ superMap[it.EvaluationItemId] = it
|
|
|
248
|
+ }
|
|
|
249
|
+ newList := make([]*domain.SummaryEvaluationValue, 0)
|
|
|
250
|
+ for i := range itemValueList {
|
|
|
251
|
+ it := itemValueList[i]
|
|
|
252
|
+ v, ok := superMap[it.EvaluationItemId]
|
|
|
253
|
+ if !ok {
|
|
|
254
|
+ v = &domain.SummaryEvaluationValue{}
|
|
|
255
|
+ v.SummaryEvaluationId = super.Id
|
|
|
256
|
+ v.Id = 0
|
|
|
257
|
+ v.EvaluationItemId = it.EvaluationItemId
|
|
|
258
|
+ }
|
|
|
259
|
+ v.Value = it.Value
|
|
|
260
|
+ v.Score = it.Score
|
|
|
261
|
+ v.Remark = it.Remark
|
|
|
262
|
+ v.Weight = it.Weight
|
|
|
263
|
+ v.Rating = it.Rating
|
|
|
264
|
+ newList = append(newList, v)
|
|
|
265
|
+ }
|
|
|
266
|
+ for _, v := range newList {
|
|
|
267
|
+ err = itemValueRepo.Save(v) // 保存填写值
|
|
|
268
|
+ if err != nil {
|
|
|
269
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
270
|
+ }
|
|
|
271
|
+ }
|
|
|
272
|
+ }
|
|
|
273
|
+ }
|
|
|
274
|
+
|
225
|
if err := transactionContext.CommitTransaction(); err != nil {
|
275
|
if err := transactionContext.CommitTransaction(); err != nil {
|
226
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
276
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
227
|
}
|
277
|
}
|