作者 tangxvhui

更新评估的状态

... ... @@ -2,6 +2,7 @@ package service
import (
"fmt"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
... ... @@ -135,12 +136,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
}
//查找当前周期,我的考核结果
_, myEvaluationSuper, err := evaluationRepo.Find(map[string]interface{}{
_, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationSuper),
"limit": 1,
"targetUserId": param.UserId,
"cycleId": param.CycleId,
})
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -164,10 +166,10 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
}
menu1_2 := adapter.MenuListAdapter{
CycleId: param.CycleId,
NodeName: "查看综合自评",
NodeName: "查看我的成绩",
StatusName: "",
TargetUserId: param.UserId,
Types: "查看综合自评",
Types: "查看我的成绩",
}
if len(selfEvaluation) > 0 {
if selfEvaluation[0].Status == domain.EvaluationCompleted {
... ... @@ -477,9 +479,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
evaluationData.Status = domain.EvaluationCompleted
}
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
... ... @@ -487,6 +487,16 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if !param.IsTemporary {
if evaluationData.Status == domain.EvaluationUncompleted {
err = srv.AfterCompletedEvaluationSelf(transactionContext, evaluationData)
if err != nil {
return nil, err
}
}
evaluationData.Status = domain.EvaluationCompleted
}
err = evaluationRepo.Save(evaluationData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -500,6 +510,78 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
}, nil
}
// 员工提交自评内容后,
// 员工作为被评估人,
// 变更360评估/人资评估/上级评估的开始时间
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error {
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp), int(domain.EvaluationSuper)},
"cycleId": param.CycleId,
"limit": 1000,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 变更360评估/人资评估/上级评估的开始时间
for _, v := range evaluationList {
v.BeginTime = time.Now()
err = evaluationRepo.Save(v)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
return nil
}
// 被评估员工的人资评估 或者 360 评估,
// 变更上级评估的开始时间
func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error {
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, evaluation360HrbList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
"cycleId": param.CycleId,
"limit": 1000,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
allCompleted := true
for _, v := range evaluation360HrbList {
if v.Status == domain.EvaluationUncompleted {
allCompleted = false
break
}
}
if !allCompleted {
return nil
}
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationSuper)},
"cycleId": param.CycleId,
"limit": 1000,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 变更360评估/人资评估/上级评估的开始时间
for _, v := range evaluationList {
v.BeginTime = time.Now()
err = evaluationRepo.Save(v)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
return nil
}
// GetTargetUserCycleList
// 获取周期列表,被评估的周期列表
func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.QueryCycleList) (map[string]interface{}, error) {
... ...
... ... @@ -390,6 +390,12 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
if summaryEvaluation.Status == domain.EvaluationUncompleted {
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
if err != nil {
return nil, err
}
}
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
}
... ... @@ -756,6 +762,12 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
if summaryEvaluation.Status == domain.EvaluationUncompleted {
err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
if err != nil {
return nil, err
}
}
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
}
... ...