作者 tangxvhui

调整逻辑 ,编辑综合评估

... ... @@ -93,19 +93,19 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
//保存填写值
for _, v := range itemValueList {
v.Id = 0
err = itemValueRepo.Save(v)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
//保存填写值
err = evaluationRepo.Save(summaryEvaluation)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation, itemValueList)
if err != nil {
return nil, err
}
... ...
... ... @@ -131,7 +131,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation, itemValueList)
if err != nil {
return nil, err
}
... ... @@ -152,6 +152,7 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
transactionContext application.TransactionContext,
evaluationData *domain.SummaryEvaluation,
evaluationValue []*domain.SummaryEvaluationValue,
) error {
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -160,7 +161,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
"cycleId": evaluationData.CycleId,
"limit": 1000,
"limit": 500,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -172,9 +173,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
break
}
}
if !allCompleted {
return nil
}
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationSuper)},
... ... @@ -184,6 +182,30 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
noSuper := (len(evaluationList) == 0)
_, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": evaluationData.CycleId,
"limit": 1,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !allCompleted {
//仅同步评估内容到考核结果
if noSuper && len(evaluationFinishList) > 0 {
//不存在上级评估
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
if err != nil {
return err
}
}
return nil
}
nowTime := time.Now()
updatedId := []int{}
// 变更上级评估的开始时间
... ... @@ -203,31 +225,29 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(
if len(evaluationList) == 0 {
//没有上级评估
//直接进入考核结果阶段
_, evaluationFinishList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": evaluationData.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationFinish)},
"cycleId": evaluationData.CycleId,
"limit": 1,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationFinishList) > 0 {
if evaluationFinishList[0].BeginTime.After(nowTime) {
evaluationFinishList[0].BeginTime = nowTime
}
evaluationFinishList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationFinishList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
//添加确认绩效成绩提醒短信提醒
err = notify.AddNotifyConfirmEvaluationScore(evaluationFinishList[0])
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error())
}
}
}
if noSuper && len(evaluationFinishList) > 0 {
//不存在上级评估
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinishList[0], evaluationValue)
if err != nil {
return err
}
} else if len(evaluationList) == 0 && len(evaluationFinishList) > 0 {
err = evaluationRepo.Save(evaluationFinishList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
}
return nil
}
... ...
... ... @@ -121,7 +121,6 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
// 变更360评估/人资评估/的开始时间 或者变更上级评估的开始时间
// evaluationData 综合自评
// evaluationValue 自评的填写内容
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
transactionContext application.TransactionContext,
evaluationData *domain.SummaryEvaluation,
... ... @@ -173,11 +172,14 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
}
var evaluationFinish *domain.SummaryEvaluation
noSuper := true
//查找综合评估结果
for _, v := range evaluationList {
if v.Types == domain.EvaluationFinish {
evaluationFinish = v
break
}
if v.Types == domain.EvaluationSuper {
noSuper = false
}
}
if len(targetEvaluation) == 0 {
... ... @@ -190,10 +192,6 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
evaluationFinish.BeginTime = nowTime
}
evaluationFinish.Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationFinish)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
//添加确认绩效成绩提醒短信提醒
err = notify.AddNotifyConfirmEvaluationScore(evaluationFinish)
if err != nil {
... ... @@ -202,5 +200,44 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
}
}
if noSuper && evaluationFinish != nil {
//没有上级评估 同步数据到考核结果
//提取非360,hrbp 的评估项
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationData.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
updateValue := []*domain.SummaryEvaluationValue{}
for _, val := range itemList {
if val.EvaluatorId != 0 {
continue
}
for _, val2 := range evaluationValue {
if val.Id == val2.EvaluationItemId {
updateValue = append(updateValue, val2)
break
}
}
}
//同步数据
err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
if err != nil {
return err
}
} else if len(targetEvaluation) == 0 && evaluationFinish != nil {
err = evaluationRepo.Save(evaluationFinish)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
}
return nil
}
... ...
... ... @@ -15,7 +15,6 @@ import (
"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/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
)
type SummaryEvaluationService struct {
... ... @@ -1448,12 +1447,11 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi
for i := range itemList {
result.ResetTotalRating(itemList[i])
}
//存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分
if result.TotalScore == "0" || result.TotalScore == "" {
if err := result.EvaluationTotalScore(itemValues); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//重新计算总分
if err := result.EvaluationTotalScore(itemValues); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result.CheckResult = domain.EvaluationCheckCompleted
if err := evaluationRepo.Save(result); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...