...
|
...
|
@@ -155,15 +155,6 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "不能提交临时数据")
|
|
|
}
|
|
|
|
|
|
lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
err := lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
|
|
|
transactionContext, err := factory.StartTransaction()
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -195,6 +186,16 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核类型错误")
|
|
|
}
|
|
|
|
|
|
// 按照被评估人id ,加锁
|
|
|
lock := xredis.NewLockSummaryEvaluation(result.TargetUser.UserId)
|
|
|
err = lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
|
|
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -222,6 +223,55 @@ func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEva |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 需要同步提交分数到上级去
|
|
|
if len(itemValueList) > 0 {
|
|
|
superValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 上级评估存在(有上级考核类型时,不管分数有没有填写都算,没填写当作零)
|
|
|
if len(evaluationList) > 0 {
|
|
|
super := evaluationList[0]
|
|
|
super.Status = domain.EvaluationCompleted
|
|
|
err = evaluationRepo.Save(super)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 上级评估条目对应分数值
|
|
|
superMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
for i := range superValues {
|
|
|
it := superValues[i]
|
|
|
superMap[it.EvaluationItemId] = it
|
|
|
}
|
|
|
newList := make([]*domain.SummaryEvaluationValue, 0)
|
|
|
for i := range itemValueList {
|
|
|
it := itemValueList[i]
|
|
|
v, ok := superMap[it.EvaluationItemId]
|
|
|
if !ok {
|
|
|
v = &domain.SummaryEvaluationValue{}
|
|
|
v.SummaryEvaluationId = super.Id
|
|
|
v.Id = 0
|
|
|
v.EvaluationItemId = it.EvaluationItemId
|
|
|
}
|
|
|
v.Value = it.Value
|
|
|
v.Score = it.Score
|
|
|
v.Remark = it.Remark
|
|
|
v.Weight = it.Weight
|
|
|
v.Rating = it.Rating
|
|
|
newList = append(newList, v)
|
|
|
}
|
|
|
for _, v := range newList {
|
|
|
err = itemValueRepo.Save(v) // 保存填写值
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|