|
@@ -2,6 +2,7 @@ package service |
|
@@ -2,6 +2,7 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
|
5
|
"strconv"
|
6
|
"strconv"
|
6
|
"strings"
|
7
|
"strings"
|
7
|
"time"
|
8
|
"time"
|
|
@@ -501,6 +502,15 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
|
@@ -501,6 +502,15 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
501
|
}
|
502
|
}
|
502
|
|
503
|
|
503
|
func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) {
|
504
|
func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) {
|
|
|
505
|
+ lock := xredis.NewLockProjectId(int(in.Id))
|
|
|
506
|
+ err := lock.Lock()
|
|
|
507
|
+ if err != nil {
|
|
|
508
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
509
|
+ }
|
|
|
510
|
+ defer func() {
|
|
|
511
|
+ lock.UnLock()
|
|
|
512
|
+ }()
|
|
|
513
|
+
|
504
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
514
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
505
|
if err != nil {
|
515
|
if err != nil {
|
506
|
return nil, err
|
516
|
return nil, err
|
|
@@ -736,6 +746,9 @@ func (rs *EvaluationProjectService) Resume(in *command.ActivateProjectCommand) ( |
|
@@ -736,6 +746,9 @@ func (rs *EvaluationProjectService) Resume(in *command.ActivateProjectCommand) ( |
736
|
if project.State == domain.ProjectStateEnable {
|
746
|
if project.State == domain.ProjectStateEnable {
|
737
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
|
747
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "项目已启动")
|
738
|
}
|
748
|
}
|
|
|
749
|
+ if project.State == domain.ProjectStatePause {
|
|
|
750
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "项目暂停中,先进行恢复")
|
|
|
751
|
+ }
|
739
|
|
752
|
|
740
|
// 周期内的所有项目,已启用的员工不能重复被评估
|
753
|
// 周期内的所有项目,已启用的员工不能重复被评估
|
741
|
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
|
754
|
_, projects, err := projectRepository.Find(map[string]interface{}{"companyId": project.CompanyId, "cycleId": project.CycleId}, "template")
|