作者 tangxvhui

调整人资稽查 编辑逻辑

... ... @@ -74,6 +74,9 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
var evalutionHrbp *domain.SummaryEvaluation
// 360评估 SummaryEvaluation.Executor.UserId => SummaryEvaluation
evaluation360Map := map[int]*domain.SummaryEvaluation{}
// 考核结果
var evalutionFinish *domain.SummaryEvaluation
for _, val := range allEvaluationList {
switch val.Types {
case domain.Evaluation360:
... ... @@ -82,6 +85,8 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
evaluationSuper = val
case domain.EvaluationHrbp:
evalutionHrbp = val
case domain.EvaluationFinish:
evalutionFinish = val
}
}
// 填写值和填写项id的映射
... ... @@ -95,19 +100,13 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
newHrbpItemValueList := []*domain.SummaryEvaluationValue{}
//新的360评估填写值 SummaryEvaluation.Executor.UserId => []*domain.SummaryEvaluationValue
new360ItemValueList := map[int][]*domain.SummaryEvaluationValue{}
//新的评估考核结果
newFinishItemValueList := []*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)
newItemValue.HrCheck = param.ExecutorId
newSuperItemValueList = append(newSuperItemValueList, &newItemValue)
temp = newItemValue
}
//处理hrbp评的填写项,需要填写哪些
if evalutionHrbp != nil && val.EvaluatorId == -1 {
newItemValue := domain.SummaryEvaluationValue{}
newItemValue.SetBlankValue(evalutionHrbp, val)
... ... @@ -117,6 +116,7 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
newHrbpItemValueList = append(newHrbpItemValueList, &newItemValue)
temp = newItemValue
}
//处理360评的填写项,需要填写哪些
if val.EvaluatorId > 0 {
evaluation360, ok := evaluation360Map[val.EvaluatorId]
if ok {
... ... @@ -134,27 +134,28 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
temp = newItemValue
}
}
newItemValueList = append(newItemValueList, &temp)
}
// 处理上级评估
if evaluationSuper != nil {
evaluationSuper.EvaluationTotalScore(newSuperItemValueList)
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationSuper.Id)
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())
//处理上级评的填写项,需要填写哪些
if evaluationSuper != nil {
newItemValue := domain.SummaryEvaluationValue{}
newItemValue.SetBlankValue(evaluationSuper, val)
newItemValue.Remark = itemValueParam[val.Id].Remark
evaluationSuper.FillItemValue(val, &newItemValue, itemValueParam[val.Id].Value)
newItemValue.HrCheck = param.ExecutorId
newSuperItemValueList = append(newSuperItemValueList, &newItemValue)
temp = newItemValue
}
for _, val := range newSuperItemValueList {
err = itemValueRepo.Save(val)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//处理考核结果
if evalutionFinish != nil {
newItemValue := domain.SummaryEvaluationValue{}
newItemValue.SetBlankValue(evalutionFinish, val)
newItemValue.Remark = itemValueParam[val.Id].Remark
evalutionFinish.FillItemValue(val, &newItemValue, itemValueParam[val.Id].Value)
newItemValue.HrCheck = param.ExecutorId
newFinishItemValueList = append(newFinishItemValueList, &newItemValue)
}
newItemValueList = append(newItemValueList, &temp)
}
// 处理人资评估
if evalutionHrbp != nil {
evalutionHrbp.EvaluationTotalScore(newHrbpItemValueList)
... ... @@ -193,6 +194,44 @@ func (srv *SummaryEvaluationService) EditEvaluationByHrCheck(param *command.Edit
}
}
}
// 处理上级评估
if evaluationSuper != nil {
evaluationSuper.EvaluationTotalScore(newSuperItemValueList)
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationSuper.Id)
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 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
// 处理评估考核结果
if evalutionFinish != nil {
evalutionFinish.EvaluationTotalScore(newFinishItemValueList)
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evalutionFinish.Id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = evaluationRepo.Save(evalutionFinish)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, val := range newFinishItemValueList {
err = itemValueRepo.Save(val)
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())
}
... ...