作者 tangxvhui

更新评估的状态

@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
7 "github.com/linmadan/egglib-go/utils/tool_funs" 8 "github.com/linmadan/egglib-go/utils/tool_funs"
@@ -135,12 +136,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -135,12 +136,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
135 } 136 }
136 137
137 //查找当前周期,我的考核结果 138 //查找当前周期,我的考核结果
138 - _, myEvaluationSuper, err := evaluationRepo.Find(map[string]interface{}{ 139 + _, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{
139 "types": int(domain.EvaluationSuper), 140 "types": int(domain.EvaluationSuper),
140 "limit": 1, 141 "limit": 1,
141 "targetUserId": param.UserId, 142 "targetUserId": param.UserId,
142 "cycleId": param.CycleId, 143 "cycleId": param.CycleId,
143 }) 144 })
  145 +
144 if err := transactionContext.CommitTransaction(); err != nil { 146 if err := transactionContext.CommitTransaction(); err != nil {
145 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 147 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
146 } 148 }
@@ -164,10 +166,10 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -164,10 +166,10 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
164 } 166 }
165 menu1_2 := adapter.MenuListAdapter{ 167 menu1_2 := adapter.MenuListAdapter{
166 CycleId: param.CycleId, 168 CycleId: param.CycleId,
167 - NodeName: "查看综合自评", 169 + NodeName: "查看我的成绩",
168 StatusName: "", 170 StatusName: "",
169 TargetUserId: param.UserId, 171 TargetUserId: param.UserId,
170 - Types: "查看综合自评", 172 + Types: "查看我的成绩",
171 } 173 }
172 if len(selfEvaluation) > 0 { 174 if len(selfEvaluation) > 0 {
173 if selfEvaluation[0].Status == domain.EvaluationCompleted { 175 if selfEvaluation[0].Status == domain.EvaluationCompleted {
@@ -477,9 +479,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -477,9 +479,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
477 if err != nil { 479 if err != nil {
478 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 480 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
479 } 481 }
480 - if !param.IsTemporary {  
481 - evaluationData.Status = domain.EvaluationCompleted  
482 - } 482 +
483 //保存填写值 483 //保存填写值
484 for _, v := range itemValueList { 484 for _, v := range itemValueList {
485 err = itemValueRepo.Save(v) 485 err = itemValueRepo.Save(v)
@@ -487,6 +487,16 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -487,6 +487,16 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
487 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 487 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
488 } 488 }
489 } 489 }
  490 + if !param.IsTemporary {
  491 + if evaluationData.Status == domain.EvaluationUncompleted {
  492 + err = srv.AfterCompletedEvaluationSelf(transactionContext, evaluationData)
  493 + if err != nil {
  494 + return nil, err
  495 + }
  496 + }
  497 + evaluationData.Status = domain.EvaluationCompleted
  498 +
  499 + }
490 err = evaluationRepo.Save(evaluationData) 500 err = evaluationRepo.Save(evaluationData)
491 if err != nil { 501 if err != nil {
492 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 502 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -500,6 +510,78 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -500,6 +510,78 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
500 }, nil 510 }, nil
501 } 511 }
502 512
  513 +// 员工提交自评内容后,
  514 +// 员工作为被评估人,
  515 +// 变更360评估/人资评估/上级评估的开始时间
  516 +func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error {
  517 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  518 + "transactionContext": transactionContext,
  519 + })
  520 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  521 + "targetUserId": param.TargetUser.UserId,
  522 + "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp), int(domain.EvaluationSuper)},
  523 + "cycleId": param.CycleId,
  524 + "limit": 1000,
  525 + })
  526 + if err != nil {
  527 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  528 + }
  529 + // 变更360评估/人资评估/上级评估的开始时间
  530 + for _, v := range evaluationList {
  531 + v.BeginTime = time.Now()
  532 + err = evaluationRepo.Save(v)
  533 + if err != nil {
  534 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  535 + }
  536 + }
  537 + return nil
  538 +}
  539 +
  540 +// 被评估员工的人资评估 或者 360 评估,
  541 +// 变更上级评估的开始时间
  542 +func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error {
  543 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  544 + "transactionContext": transactionContext,
  545 + })
  546 + _, evaluation360HrbList, err := evaluationRepo.Find(map[string]interface{}{
  547 + "targetUserId": param.TargetUser.UserId,
  548 + "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
  549 + "cycleId": param.CycleId,
  550 + "limit": 1000,
  551 + })
  552 + if err != nil {
  553 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  554 + }
  555 + allCompleted := true
  556 + for _, v := range evaluation360HrbList {
  557 + if v.Status == domain.EvaluationUncompleted {
  558 + allCompleted = false
  559 + break
  560 + }
  561 + }
  562 + if !allCompleted {
  563 + return nil
  564 + }
  565 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  566 + "targetUserId": param.TargetUser.UserId,
  567 + "typesList": []int{int(domain.EvaluationSuper)},
  568 + "cycleId": param.CycleId,
  569 + "limit": 1000,
  570 + })
  571 + if err != nil {
  572 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  573 + }
  574 + // 变更360评估/人资评估/上级评估的开始时间
  575 + for _, v := range evaluationList {
  576 + v.BeginTime = time.Now()
  577 + err = evaluationRepo.Save(v)
  578 + if err != nil {
  579 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  580 + }
  581 + }
  582 + return nil
  583 +}
  584 +
503 // GetTargetUserCycleList 585 // GetTargetUserCycleList
504 // 获取周期列表,被评估的周期列表 586 // 获取周期列表,被评估的周期列表
505 func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.QueryCycleList) (map[string]interface{}, error) { 587 func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.QueryCycleList) (map[string]interface{}, error) {
@@ -390,6 +390,12 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua @@ -390,6 +390,12 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
390 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 390 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
391 } 391 }
392 if !param.IsTemporary { 392 if !param.IsTemporary {
  393 + if summaryEvaluation.Status == domain.EvaluationUncompleted {
  394 + err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
  395 + if err != nil {
  396 + return nil, err
  397 + }
  398 + }
393 //变更评估状态为已填写 399 //变更评估状态为已填写
394 summaryEvaluation.Status = domain.EvaluationCompleted 400 summaryEvaluation.Status = domain.EvaluationCompleted
395 } 401 }
@@ -756,6 +762,12 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -756,6 +762,12 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
756 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 762 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
757 } 763 }
758 if !param.IsTemporary { 764 if !param.IsTemporary {
  765 + if summaryEvaluation.Status == domain.EvaluationUncompleted {
  766 + err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)
  767 + if err != nil {
  768 + return nil, err
  769 + }
  770 + }
759 //变更评估状态为已填写 771 //变更评估状态为已填写
760 summaryEvaluation.Status = domain.EvaluationCompleted 772 summaryEvaluation.Status = domain.EvaluationCompleted
761 } 773 }