作者 郑周

1. 超管提交分数,同步到上级分数中去

... ... @@ -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())
}
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
"strconv"
"strings"
"time"
... ... @@ -760,6 +761,15 @@ func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFini
if result.Types != domain.EvaluationFinish {
return nil
}
// 按照被评估人id ,加锁
lock := xredis.NewLockSummaryEvaluation(result.TargetUser.UserId)
err = lock.Lock()
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
}
defer func() {
lock.UnLock()
}()
// 获取考核结果评分
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
... ...