作者 郑周

1. 统一更新编辑后的值

... ... @@ -390,60 +390,20 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
summaryEvaluation.TotalRating = nil //清空评级数量统计
for i, v := range itemList {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(summaryEvaluation, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = itemList[i]
//重置计数
summaryEvaluation.ResetTotalRating(v)
}
for _, v := range itemValueList {
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
mValue.Id = v.Id
}
}
//nowTime := time.Now()
for _, v := range param.EvaluationItems {
updatedData, ok := evaluationValueMap[v.EvaluationItemId]
if !ok {
continue
}
if it, ok := evaluationItemMap[v.EvaluationItemId]; ok {
err = updatedData.FillValue(it, v.Value, v.Remark)
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
//updatedData.UpdatedAt = nowTime
//updatedData.Value = v.Value
//updatedData.Remark = v.Remark
////计算得分
//err = updatedData.SummaryEvaluationScore()
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
}
evaluationValueList := make([]*domain.SummaryEvaluationValue, 0)
for _, v := range evaluationValueMap {
summaryEvaluation.Status = domain.EvaluationCompleted
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationValueList = append(evaluationValueList, v)
}
//计算总得分
err = summaryEvaluation.EvaluationTotalScore(evaluationValueList)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//summaryEvaluation.UpdatedAt = nowTime
//保存填写值
err = evaluationRepo.Save(summaryEvaluation)
if err != nil {
... ... @@ -452,7 +412,7 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"evaluationItems": itemValueAdapter,
}, nil
... ... @@ -745,57 +705,18 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
summaryEvaluation.TotalRating = nil //清空评级数量统计
for i, v := range itemList {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(summaryEvaluation, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = itemList[i]
//重置计数
summaryEvaluation.ResetTotalRating(v)
}
for _, v := range itemValueList {
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
mValue.Id = v.Id
}
}
//nowTime := time.Now()
for _, v := range param.EvaluationItems {
updatedData, ok := evaluationValueMap[v.EvaluationItemId]
if !ok {
continue
}
if it, ok := evaluationItemMap[v.EvaluationItemId]; ok {
err = updatedData.FillValue(it, v.Value, v.Remark)
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
//updatedData.UpdatedAt = nowTime
//updatedData.Value = v.Value
//updatedData.Remark = v.Remark
////计算得分
//err = updatedData.SummaryEvaluationScore()
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
}
evaluationValueList := make([]*domain.SummaryEvaluationValue, 0)
for _, v := range evaluationValueMap {
summaryEvaluation.Status = domain.EvaluationCompleted
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationValueList = append(evaluationValueList, v)
}
//计算总得分
err = summaryEvaluation.EvaluationTotalScore(evaluationValueList)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 针对HRBP类型,更新最后一次操作的HRBP人
... ... @@ -807,8 +728,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
summaryEvaluation.Executor.Account = user.Account
summaryEvaluation.Executor.UserName = user.Name
summaryEvaluation.Executor.CompanyName = "" // 暂时无用
//summaryEvaluation.UpdatedAt = nowTime
summaryEvaluation.Status = domain.EvaluationCompleted
//保存填写值
err = evaluationRepo.Save(summaryEvaluation)
... ... @@ -818,7 +738,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"evaluationItems": itemValueAdapter,
}, nil
... ...