...
|
...
|
@@ -2,6 +2,7 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
...
|
...
|
@@ -482,6 +483,15 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter |
|
|
}
|
|
|
|
|
|
func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) {
|
|
|
lock := xredis.NewLockProjectId(int(in.Id))
|
|
|
err := lock.Lock()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
lock.UnLock()
|
|
|
}()
|
|
|
|
|
|
transactionContext, err := factory.ValidateStartTransaction(in)
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -562,10 +572,14 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
tasks, err := taskRepository.Find(map[string]interface{}{"projectId": project.Id})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(tasks) == 0 {
|
|
|
now := time.Now().Local()
|
|
|
year, month, day := now.Date()
|
|
|
nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
|
|
|
|
|
|
for i := range project.Template.LinkNodes {
|
|
|
node := project.Template.LinkNodes[i]
|
|
|
task := &domain.NodeTask{
|
...
|
...
|
@@ -611,6 +625,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
|