...
|
...
|
@@ -1484,6 +1484,11 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi |
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
// 评估项ID(除考核结果和上级)
|
|
|
var evaluationIds = make([]int, 0)
|
...
|
...
|
@@ -1501,28 +1506,25 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi |
|
|
}
|
|
|
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues)
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for i := range itemValues {
|
|
|
err = itemValueRepo.Save(itemValues[i])
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
for i := range itemValues {
|
|
|
if err := itemValueRepo.Save(itemValues[i]); err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
err = result.EvaluationTotalScore(itemValues)
|
|
|
if err != nil {
|
|
|
if err := result.EvaluationTotalScore(itemValues); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
result.CheckResult = domain.EvaluationCheckCompleted
|
|
|
err = evaluationRepo.Save(result)
|
|
|
if err != nil {
|
|
|
if err := evaluationRepo.Save(result); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
@@ -1531,121 +1533,18 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//// 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估 ->自评)
|
|
|
//func (srv *SummaryEvaluationService) getEvaluationResult(list []*domain.SummaryEvaluation) (*domain.SummaryEvaluation, []*domain.SummaryEvaluation) {
|
|
|
// var finish *domain.SummaryEvaluation // 绩效考核结果项(已完成确认)
|
|
|
// var result *domain.SummaryEvaluation // 绩效考核结果项
|
|
|
// var super *domain.SummaryEvaluation // 上级评估
|
|
|
// var self *domain.SummaryEvaluation // 我的自评
|
|
|
// var hr360 = make([]*domain.SummaryEvaluation, 0) // 评估项
|
|
|
//
|
|
|
// for i := range list {
|
|
|
// it := list[i]
|
|
|
//
|
|
|
// if it.Types == domain.EvaluationFinish {
|
|
|
// result = it
|
|
|
// if it.CheckResult == domain.EvaluationCheckCompleted { // 绩效结果已确认
|
|
|
// finish = it
|
|
|
// break
|
|
|
// }
|
|
|
// } else if it.Types == domain.EvaluationSuper {
|
|
|
// super = it
|
|
|
// } else if it.Types == domain.EvaluationSelf {
|
|
|
// self = it
|
|
|
// } else if it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp {
|
|
|
// hr360 = append(hr360, it)
|
|
|
// }
|
|
|
// }
|
|
|
// if finish != nil {
|
|
|
// return result, []*domain.SummaryEvaluation{finish}
|
|
|
// }
|
|
|
//
|
|
|
// if super != nil {
|
|
|
// return result, []*domain.SummaryEvaluation{super}
|
|
|
// }
|
|
|
//
|
|
|
// if len(hr360) > 0 {
|
|
|
// return result, hr360
|
|
|
// }
|
|
|
//
|
|
|
// if self != nil {
|
|
|
// return result, []*domain.SummaryEvaluation{self}
|
|
|
// }
|
|
|
//
|
|
|
// return result, []*domain.SummaryEvaluation{}
|
|
|
//}
|
|
|
|
|
|
//func (srv *SummaryEvaluationService) findSummaryEvaluationByType(
|
|
|
// repo domain.SummaryEvaluationRepository,
|
|
|
// param *command.QueryEvaluation,
|
|
|
// eType domain.EvaluationType) ([]*domain.SummaryEvaluation, error) {
|
|
|
// p := map[string]interface{}{
|
|
|
// "companyId": param.CompanyId,
|
|
|
// "cycleId": param.CycleId,
|
|
|
// "targetUserId": param.TargetUserId,
|
|
|
// }
|
|
|
// if eType == domain.EvaluationFinish || eType == domain.EvaluationSuper || eType == domain.EvaluationSelf {
|
|
|
// p["types"] = eType
|
|
|
// p["limit"] = 1
|
|
|
// } else if eType == domain.Evaluation360 || eType == domain.EvaluationHrbp {
|
|
|
// p["typesList"] = []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)}
|
|
|
// }
|
|
|
// _, list, err := repo.Find(p)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// return list, nil
|
|
|
//}
|
|
|
|
|
|
//func (srv *SummaryEvaluationService) findEvaluationItemValue(
|
|
|
// repo domain.SummaryEvaluationRepository,
|
|
|
// valueRepo domain.SummaryEvaluationValueRepository,
|
|
|
// param *command.QueryEvaluation) (domain.EvaluationType, []*domain.SummaryEvaluationValue, error) {
|
|
|
// var eType = domain.EvaluationSuper
|
|
|
// list, err := srv.findSummaryEvaluationByType(repo, param, eType)
|
|
|
// if err != nil {
|
|
|
// return eType, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if len(list) == 0 {
|
|
|
// eType = domain.Evaluation360
|
|
|
// list, err = srv.findSummaryEvaluationByType(repo, param, eType)
|
|
|
// if err != nil {
|
|
|
// return eType, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if len(list) == 0 {
|
|
|
// eType = domain.EvaluationSelf
|
|
|
// list, err = srv.findSummaryEvaluationByType(repo, param, eType)
|
|
|
// if err != nil {
|
|
|
// return eType, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if len(list) == 0 {
|
|
|
// return eType, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
|
|
|
// }
|
|
|
//
|
|
|
// evaluationIds := make([]int, 0)
|
|
|
// for _, v := range list {
|
|
|
// evaluationIds = append(evaluationIds, v.Id)
|
|
|
// }
|
|
|
// // 获取已填写的评估内容
|
|
|
// _, itemValues, err := valueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
// if err != nil {
|
|
|
// return eType, nil, err
|
|
|
// }
|
|
|
// return eType, itemValues, nil
|
|
|
//}
|
|
|
//
|
|
|
|
|
|
// 处理优先级
|
|
|
func (srv *SummaryEvaluationService) updateItemValuePriority(
|
|
|
result *domain.SummaryEvaluation,
|
|
|
itemList []*domain.EvaluationItemUsed,
|
|
|
itemValues []*domain.SummaryEvaluationValue) ([]*domain.SummaryEvaluationValue, error) {
|
|
|
itemValues []*domain.SummaryEvaluationValue,
|
|
|
superior bool) ([]*domain.SummaryEvaluationValue, error) {
|
|
|
|
|
|
tempSelf := map[int]*domain.SummaryEvaluationValue{}
|
|
|
temp360 := map[int]*domain.SummaryEvaluationValue{}
|
|
|
tempHRBP := map[int]*domain.SummaryEvaluationValue{}
|
|
|
tempSuperior := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
|
|
for i := range itemValues {
|
|
|
it := itemValues[i]
|
|
|
if it.Types == domain.EvaluationSelf {
|
...
|
...
|
@@ -1654,6 +1553,8 @@ func (srv *SummaryEvaluationService) updateItemValuePriority( |
|
|
temp360[it.EvaluationItemId] = it
|
|
|
} else if it.Types == domain.EvaluationHrbp {
|
|
|
tempHRBP[it.EvaluationItemId] = it
|
|
|
} else if it.Types == domain.EvaluationSuper {
|
|
|
tempSuperior[it.EvaluationItemId] = it
|
|
|
}
|
|
|
}
|
|
|
nowTime := time.Now()
|
...
|
...
|
@@ -1664,24 +1565,31 @@ func (srv *SummaryEvaluationService) updateItemValuePriority( |
|
|
var tempValue domain.SummaryEvaluationValue
|
|
|
tempValue.SetBlankValue(result, it)
|
|
|
|
|
|
if it.EvaluatorId == 0 {
|
|
|
if v, ok := tempSelf[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationSelf
|
|
|
} else if it.EvaluatorId == -1 {
|
|
|
if v, ok := tempHRBP[it.Id]; ok {
|
|
|
if superior /* 上级数据 */ {
|
|
|
if v, ok := tempSuperior[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationHrbp
|
|
|
} else if it.EvaluatorId > 0 {
|
|
|
if v, ok := temp360[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
tempValue.Types = domain.EvaluationSuper
|
|
|
} else /* 其它数据 */ {
|
|
|
if it.EvaluatorId == 0 {
|
|
|
if v, ok := tempSelf[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationSelf
|
|
|
} else if it.EvaluatorId == -1 {
|
|
|
if v, ok := tempHRBP[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.EvaluationHrbp
|
|
|
} else if it.EvaluatorId > 0 {
|
|
|
if v, ok := temp360[it.Id]; ok {
|
|
|
tempValue = *v
|
|
|
}
|
|
|
tempValue.Types = domain.Evaluation360
|
|
|
}
|
|
|
tempValue.Types = domain.Evaluation360
|
|
|
}
|
|
|
|
|
|
// 清理ID
|
|
|
// ID置空
|
|
|
tempValue.Id = 0
|
|
|
tempValue.CreatedAt = nowTime
|
|
|
tempValue.UpdatedAt = nowTime
|
...
|
...
|
@@ -1771,7 +1679,7 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command |
|
|
}
|
|
|
|
|
|
// 更新填写值
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues)
|
|
|
itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|