作者 tangxvhui

修正 完成周期评估后。 更新下一阶段的开始时间

... ... @@ -111,7 +111,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
var cntAll360 int
var cntUncompleted360 int
//查找360评估,统计未完成
//查找360评估,统计全部
cntAll360, _, err = evaluationRepo.Find(map[string]interface{}{
"types": int(domain.Evaluation360),
"executorId": param.UserId,
... ... @@ -140,7 +140,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
var cntAllSuper int
var cntUncompletedSuper int
//查询需要执行上级评估,统计未完成
//查询需要执行上级评估,全部的
cntAllSuper, _, err = evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationSuper),
"executorId": param.UserId,
... ... @@ -169,7 +169,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
var cntAllHrbp int
var cntUncompletedHrbp int
//查询需要执行人资评估,统计未完成
//查询需要执行人资评估,全部的
cntAllHrbp, _, err = evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationHrbp),
"limit": 1,
... ... @@ -555,14 +555,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
}
}
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 {
... ... @@ -571,6 +564,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluationSelf(evaluationData)
if err != nil {
return nil, err
}
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"EvaluationItems": itemValueAdapter,
... ... @@ -580,7 +580,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
// 员工提交自评内容后,
// 员工作为被评估人,
// 变更360评估/人资评估/的开始时间
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error {
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -593,20 +603,37 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionCon
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
nowTime := time.Now()
// 变更360评估/人资评估/上级评估的开始时间
for _, v := range evaluationList {
v.BeginTime = time.Now()
if v.BeginTime.After(nowTime) {
v.BeginTime = nowTime
}
err = evaluationRepo.Save(v)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); 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 {
func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *domain.SummaryEvaluation) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -638,14 +665,20 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transaction
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
nowTime := time.Now()
// 变更上级评估的开始时间
for _, v := range evaluationList {
v.BeginTime = time.Now()
if v.BeginTime.After(nowTime) {
v.BeginTime = nowTime
}
err = evaluationRepo.Save(v)
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"fmt"
"strconv"
"strings"
"time"
... ... @@ -134,7 +135,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu
}
}
rowMap["id"] = v.Id
rowMap["targetUserId"] = v.TargetUser.UserId
rowMap["targetUserId"] = strconv.Itoa(v.TargetUser.UserId)
rowMap["targetUserName"] = v.TargetUser.UserName
rowMap["statusVal"] = statusVal
rowMap["relation"] = "项目组员"
... ... @@ -390,12 +391,6 @@ 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
}
... ... @@ -416,6 +411,14 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
if err != nil {
return nil, err
}
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"evaluationItems": itemValueAdapter,
... ... @@ -763,12 +766,6 @@ 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
}
... ... @@ -799,6 +796,13 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
if err != nil {
return nil, err
}
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"evaluationItems": itemValueAdapter,
... ...