作者 tangxvhui

调整 人资稽查编辑逻辑

... ... @@ -3,6 +3,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
... ... @@ -81,13 +82,17 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
newHrbpItemValueList := []*domain.SummaryEvaluationValue{}
//新的360评估填写值 SummaryEvaluation.Executor.UserId => []*domain.SummaryEvaluationValue
new360ItemValueList := map[int][]*domain.SummaryEvaluationValue{}
newItemValueList := []*domain.SummaryEvaluationValue{}
for _, val := range itemUsedList {
temp := domain.SummaryEvaluationValue{}
if evaluationSuper != nil {
newItemValue := domain.SummaryEvaluationValue{}
newItemValue.SetBlankValue(evaluationSuper, val)
newItemValue.Remark = itemValueParam[val.Id].Remark
evaluationSuper.FillItemValue(val, &newItemValue, itemValueParam[val.Id].Value)
newSuperItemValueList = append(newSuperItemValueList, &newItemValue)
temp = newItemValue
}
if evalutionHrbp != nil && val.EvaluatorId == -1 {
newItemValue := domain.SummaryEvaluationValue{}
... ... @@ -95,6 +100,7 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
newItemValue.Remark = itemValueParam[val.Id].Remark
evalutionHrbp.FillItemValue(val, &newItemValue, itemValueParam[val.Id].Value)
newHrbpItemValueList = append(newHrbpItemValueList, &newItemValue)
temp = newItemValue
}
if val.EvaluatorId > 0 {
evaluation360, ok := evaluation360Map[val.EvaluatorId]
... ... @@ -109,8 +115,10 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
evaluation360.FillItemValue(val, &newItemValue, itemValueParam[val.Id].Value)
itemValue360List = append(itemValue360List, &newItemValue)
new360ItemValueList[evaluation360.Executor.UserId] = itemValue360List
temp = newItemValue
}
}
newItemValueList = append(newItemValueList, &temp)
}
// 处理上级评估
if evaluationSuper != nil {
... ... @@ -120,6 +128,10 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = evaluationRepo.Save(evaluationSuper)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, val := range newSuperItemValueList {
err = itemValueRepo.Save(val)
if err != nil {
... ... @@ -135,6 +147,10 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = evaluationRepo.Save(evalutionHrbp)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, val := range newHrbpItemValueList {
err = itemValueRepo.Save(val)
if err != nil {
... ... @@ -150,6 +166,10 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = evaluationRepo.Save(val)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, val := range new360ItemValueList[key] {
err = itemValueRepo.Save(val)
if err != nil {
... ... @@ -160,6 +180,8 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
itemValueAdapter := srv.buildSummaryItemValue(itemUsedList, newItemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"EvaluationItems": itemValueAdapter,
}, nil
}
... ...