作者 tangxvhui

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

@@ -111,7 +111,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -111,7 +111,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
111 111
112 var cntAll360 int 112 var cntAll360 int
113 var cntUncompleted360 int 113 var cntUncompleted360 int
114 - //查找360评估,统计未完成 114 + //查找360评估,统计全部
115 cntAll360, _, err = evaluationRepo.Find(map[string]interface{}{ 115 cntAll360, _, err = evaluationRepo.Find(map[string]interface{}{
116 "types": int(domain.Evaluation360), 116 "types": int(domain.Evaluation360),
117 "executorId": param.UserId, 117 "executorId": param.UserId,
@@ -140,7 +140,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -140,7 +140,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
140 var cntAllSuper int 140 var cntAllSuper int
141 var cntUncompletedSuper int 141 var cntUncompletedSuper int
142 142
143 - //查询需要执行上级评估,统计未完成 143 + //查询需要执行上级评估,全部的
144 cntAllSuper, _, err = evaluationRepo.Find(map[string]interface{}{ 144 cntAllSuper, _, err = evaluationRepo.Find(map[string]interface{}{
145 "types": int(domain.EvaluationSuper), 145 "types": int(domain.EvaluationSuper),
146 "executorId": param.UserId, 146 "executorId": param.UserId,
@@ -169,7 +169,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -169,7 +169,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
169 var cntAllHrbp int 169 var cntAllHrbp int
170 var cntUncompletedHrbp int 170 var cntUncompletedHrbp int
171 171
172 - //查询需要执行人资评估,统计未完成 172 + //查询需要执行人资评估,全部的
173 cntAllHrbp, _, err = evaluationRepo.Find(map[string]interface{}{ 173 cntAllHrbp, _, err = evaluationRepo.Find(map[string]interface{}{
174 "types": int(domain.EvaluationHrbp), 174 "types": int(domain.EvaluationHrbp),
175 "limit": 1, 175 "limit": 1,
@@ -555,14 +555,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -555,14 +555,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
555 } 555 }
556 } 556 }
557 if !param.IsTemporary { 557 if !param.IsTemporary {
558 - if evaluationData.Status == domain.EvaluationUncompleted {  
559 - err = srv.AfterCompletedEvaluationSelf(transactionContext, evaluationData)  
560 - if err != nil {  
561 - return nil, err  
562 - }  
563 - }  
564 evaluationData.Status = domain.EvaluationCompleted 558 evaluationData.Status = domain.EvaluationCompleted
565 -  
566 } 559 }
567 err = evaluationRepo.Save(evaluationData) 560 err = evaluationRepo.Save(evaluationData)
568 if err != nil { 561 if err != nil {
@@ -571,6 +564,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -571,6 +564,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
571 if err := transactionContext.CommitTransaction(); err != nil { 564 if err := transactionContext.CommitTransaction(); err != nil {
572 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 565 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
573 } 566 }
  567 + if !param.IsTemporary {
  568 + err = srv.AfterCompletedEvaluationSelf(evaluationData)
  569 + if err != nil {
  570 + return nil, err
  571 + }
  572 + }
  573 +
574 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) 574 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
575 return map[string][]adapter.EvaluationItemAdapter{ 575 return map[string][]adapter.EvaluationItemAdapter{
576 "EvaluationItems": itemValueAdapter, 576 "EvaluationItems": itemValueAdapter,
@@ -580,7 +580,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu @@ -580,7 +580,17 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
580 // 员工提交自评内容后, 580 // 员工提交自评内容后,
581 // 员工作为被评估人, 581 // 员工作为被评估人,
582 // 变更360评估/人资评估/的开始时间 582 // 变更360评估/人资评估/的开始时间
583 -func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error { 583 +func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.SummaryEvaluation) error {
  584 + transactionContext, err := factory.CreateTransactionContext(nil)
  585 + if err != nil {
  586 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  587 + }
  588 + if err := transactionContext.StartTransaction(); err != nil {
  589 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  590 + }
  591 + defer func() {
  592 + _ = transactionContext.RollbackTransaction()
  593 + }()
584 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 594 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
585 "transactionContext": transactionContext, 595 "transactionContext": transactionContext,
586 }) 596 })
@@ -593,20 +603,37 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionCon @@ -593,20 +603,37 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(transactionCon
593 if err != nil { 603 if err != nil {
594 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 604 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
595 } 605 }
  606 + nowTime := time.Now()
596 // 变更360评估/人资评估/上级评估的开始时间 607 // 变更360评估/人资评估/上级评估的开始时间
597 for _, v := range evaluationList { 608 for _, v := range evaluationList {
598 - v.BeginTime = time.Now() 609 + if v.BeginTime.After(nowTime) {
  610 + v.BeginTime = nowTime
  611 + }
599 err = evaluationRepo.Save(v) 612 err = evaluationRepo.Save(v)
600 if err != nil { 613 if err != nil {
601 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 614 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
602 } 615 }
603 } 616 }
  617 + if err := transactionContext.CommitTransaction(); err != nil {
  618 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  619 + }
604 return nil 620 return nil
605 } 621 }
606 622
607 // 被评估员工的人资评估 或者 360 评估, 623 // 被评估员工的人资评估 或者 360 评估,
608 // 变更上级评估的开始时间 624 // 变更上级评估的开始时间
609 -func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transactionContext application.TransactionContext, param *domain.SummaryEvaluation) error { 625 +func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *domain.SummaryEvaluation) error {
  626 + transactionContext, err := factory.CreateTransactionContext(nil)
  627 + if err != nil {
  628 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  629 + }
  630 + if err := transactionContext.StartTransaction(); err != nil {
  631 + return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  632 + }
  633 + defer func() {
  634 + _ = transactionContext.RollbackTransaction()
  635 + }()
  636 +
610 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 637 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
611 "transactionContext": transactionContext, 638 "transactionContext": transactionContext,
612 }) 639 })
@@ -638,14 +665,20 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transaction @@ -638,14 +665,20 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(transaction
638 if err != nil { 665 if err != nil {
639 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 666 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
640 } 667 }
  668 + nowTime := time.Now()
641 // 变更上级评估的开始时间 669 // 变更上级评估的开始时间
642 for _, v := range evaluationList { 670 for _, v := range evaluationList {
643 - v.BeginTime = time.Now() 671 + if v.BeginTime.After(nowTime) {
  672 + v.BeginTime = nowTime
  673 + }
644 err = evaluationRepo.Save(v) 674 err = evaluationRepo.Save(v)
645 if err != nil { 675 if err != nil {
646 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 676 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
647 } 677 }
648 } 678 }
  679 + if err := transactionContext.CommitTransaction(); err != nil {
  680 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  681 + }
649 return nil 682 return nil
650 } 683 }
651 684
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
5 "strings" 6 "strings"
6 "time" 7 "time"
7 8
@@ -134,7 +135,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu @@ -134,7 +135,7 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu
134 } 135 }
135 } 136 }
136 rowMap["id"] = v.Id 137 rowMap["id"] = v.Id
137 - rowMap["targetUserId"] = v.TargetUser.UserId 138 + rowMap["targetUserId"] = strconv.Itoa(v.TargetUser.UserId)
138 rowMap["targetUserName"] = v.TargetUser.UserName 139 rowMap["targetUserName"] = v.TargetUser.UserName
139 rowMap["statusVal"] = statusVal 140 rowMap["statusVal"] = statusVal
140 rowMap["relation"] = "项目组员" 141 rowMap["relation"] = "项目组员"
@@ -390,12 +391,6 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua @@ -390,12 +391,6 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
390 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 391 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
391 } 392 }
392 if !param.IsTemporary { 393 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 - }  
399 //变更评估状态为已填写 394 //变更评估状态为已填写
400 summaryEvaluation.Status = domain.EvaluationCompleted 395 summaryEvaluation.Status = domain.EvaluationCompleted
401 } 396 }
@@ -416,6 +411,14 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua @@ -416,6 +411,14 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
416 if err := transactionContext.CommitTransaction(); err != nil { 411 if err := transactionContext.CommitTransaction(); err != nil {
417 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 412 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
418 } 413 }
  414 +
  415 + if !param.IsTemporary {
  416 + err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
  417 + if err != nil {
  418 + return nil, err
  419 + }
  420 + }
  421 +
419 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) 422 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
420 return map[string][]adapter.EvaluationItemAdapter{ 423 return map[string][]adapter.EvaluationItemAdapter{
421 "evaluationItems": itemValueAdapter, 424 "evaluationItems": itemValueAdapter,
@@ -763,12 +766,6 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -763,12 +766,6 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
763 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 766 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
764 } 767 }
765 if !param.IsTemporary { 768 if !param.IsTemporary {
766 - if summaryEvaluation.Status == domain.EvaluationUncompleted {  
767 - err = srv.AfterCompletedEvaluation360Hrbp(transactionContext, summaryEvaluation)  
768 - if err != nil {  
769 - return nil, err  
770 - }  
771 - }  
772 //变更评估状态为已填写 769 //变更评估状态为已填写
773 summaryEvaluation.Status = domain.EvaluationCompleted 770 summaryEvaluation.Status = domain.EvaluationCompleted
774 } 771 }
@@ -799,6 +796,13 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -799,6 +796,13 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
799 if err := transactionContext.CommitTransaction(); err != nil { 796 if err := transactionContext.CommitTransaction(); err != nil {
800 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 797 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
801 } 798 }
  799 +
  800 + if !param.IsTemporary {
  801 + err = srv.AfterCompletedEvaluation360Hrbp(summaryEvaluation)
  802 + if err != nil {
  803 + return nil, err
  804 + }
  805 + }
802 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) 806 itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
803 return map[string][]adapter.EvaluationItemAdapter{ 807 return map[string][]adapter.EvaluationItemAdapter{
804 "evaluationItems": itemValueAdapter, 808 "evaluationItems": itemValueAdapter,